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

wjp wjp at usecode.org
Wed Dec 23 22:02:13 CET 2015


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

Summary:
8ca14d1d64 LAB: Initial code
b396135a4d LAB: Fix compilation
11a7ffaabe LAB: Started rendering pipeline
bbddd32d38 LAB: Further rendering pipeline fixes
dfa0a1ef0b LAB: Implement openFile(), first gfx output!
0dbcb7160c LAB: Added input
78b46fb026 LAB: fix input processing
bff3cc390f LAB: Fix game palette
62ceb496a9 LAB: Cleanup
3a8cafa41e LAB: Kill storage.h
abded17657 LAB: Simplify stddefines.h
6ab5edf762 LAB: Further cleanup
471dbaa758 LAB: Started objectifying LargeSets
cb8f843296 LAB: Objectify LabSets
90f0a8650f LAB: Fix line endings
7baabb22c1 LAB: Cleanup
fefb78457e LAB: Cleanup
58182bd77a LAB: Cleanup
85ea7da24e LAB: Improved detection
7ee90c693f LAB: Cleanup
01e290e4c3 LAB: Added detection for lowres DOS version
60388893a9 LAB: propagate gamePlatform()
60d4f0a069 LAB: Initial support for lowres mode
c624799498 LAB: Cleanup
fdb4f3edf8 LAB: Cleanup
b8da3f2bc2 LAB: Final fix for game variant detection
500bb493f6 LAB: Fix regression
9a116c57e1 LAB: Use OSystem for mouse drawing
80e00c1f54 LAB: Fix regression
f9d90934f6 LAB: Fix signed/unsigned comparison warnings
28bbcf5641 LAB: Add missing const qualifiers
d70819fa67 LAB: Silence false positives about uninitialized variables
7f80a4ff63 LAB: Change the "action" parameter of doActionRule to lowercase
4f185f7dd6 LAB: Further fixes to signed/unsigned comparisons and bool assignments
f9b4b43e90 LAB: Remove multiple mouse coordinate variables
7ddbc55251 LAB: Remove unused mouse reset call
35751e0f12 LAB: Implement getCurMemLabFile()
31ef4866a7 LAB: Implement generateSaveFileName()
ccb3390f09 LAB: Disable startup warning about hi/low res mode
6af7abeab2 LAB: Remove unused variable
0a71969018 LAB: Rewrite the save/load system
6648689590 LAB: Remove the unused Cords struct
95461c9161 LAB: Remove the journalCleanUp() wrapper
5bc37fd878 LAB: Fix loading of saved games
d25d74ef20 LAB: Remove leftover debug code
7e0545cf6d LAB: Remove unused byte swap code
2cd1c0d3ff LAB: Clean up some DOS-specific code
af35398ad0 LAB: Initial sound implementation
530aa5926b LAB: Remove dead code
6ff7c480af LAB: Remove superfluous void function parameters
ca819e0b86 LAB: Rename playMusic() to playSoundEffect()
1c77b2daf8 LAB: Implement correct duration calculation for the DOS version music
6006a00836 LAB: The audio data in the DOS version is unsigned
9264f4964e LAB: Remove the unused setMode()/getMode() functions
d949375e70 LAB: Remove unused variables
465f5f0c09 LAB: Simplify mouse handling code
a83c50cf66 LAB: Remove duplicate swap code and some unused defines
83e58fe452 LAB: Rename waiteffect -> waitForEffect
22b82d7729 LAB: Initial music implementation
6842ffbe90 LAB: Further clean up of the music and sound effect code
16df4305f4 LAB: Allow skipping the credits in the intro sequence
219811feaa LAB: Add support for the Wyrmkeep Windows trial version
4cf271054a LAB: Bugfix for freeMusic()
cc0baf48ed LAB: Check for engine quit events
650819cfec LAB: Simplify allocRoom()
8ebb53948d LAB: Remove superfluous white space
f017cb624e LAB: Use CamelCase, and simplify mouseHandler()
884b80f215 LAB: Remove unused variables, some cleanup
79ed1e1f05 LAB: Get rid of numtostr(), and simplify most uses of sizeOfFile()
047df0b0e8 LAB: Simplify usage of createButton()
e35307ccba LAB: Simplify initLabText()
e031359d99 LAB: Use the correct splash screen file for the DOS version
9a12f6be3f LAB: Simplify translateFileName()
4f0c63c0f8 LAB: Merge the VGAScale and setCurClose functions
5ae4d3bf9e LAB: Initial code to simplify translateFileName() and the save menu
27683945e6 LAB: Simplify timeDiff()
21e360b9b1 LAB: Remove dead/superfluous code, and remove the newCheckMusic() wrapper
a4bad804f6 LAB: Get rid of sizeOfFile(), some cleanup
77f4a10901 LAB: Remove dead code
b1eb345f80 LAB: Move some static variables to the top. Some cleanup
da0ee48ab9 LAB: Remove the fillUpMusic() and checkMusic() wrappers. Some cleanup
75882daa49 LAB: Simplify decrypt()
df3200ef0c LAB: Simplify readViews()
524d30ee16 LAB: Cleanup
eae0773b41 LAB: Move more static variables to the top
8bf15cbe4b LAB: Replace more calls to checkMusic()
c3bb54989c LAB: Cleanup
c8b2745f7a LAB: Replace some more calls to checkMusic(). Some cleanup
cb4b86cdb8 LAB: Replace more uses of checkMusic(). Some cleanup
e9f161b3aa LAB: Clean up readSound(), readMusic() and longDrawMessage()
db969dc938 LAB: Move more static variables to the top
f085a3187e LAB: Remove several usages of skip(). Remove dead code
d0171440df LAB: Move checkRoomMusic to the Music class. Some cleanup
76b66de8b6 LAB: Remove dead code
454c02f321 LAB: Get rid of some uses of readBlock()
afa9475d2a LAB: Some cleanup
69694b6b45 LAB: Check if a sound effect is active before attempting to stop it
98e9eff2d1 LAB: Remove superfluous references to g_music, some cleanup
f1351dcd9e LAB: Remove dead code
edf92fc680 LAB: Revert accidental change
c67852d940 LAB: Initial implementation of the Resource class
d565b10384 LAB: Move the font loading code into the Resource class
01dffc75a1 LAB: Move static text loading to the Resource class
92bb4a522a LAB: Replace readRoomData() and readInventory()
9cd640a6ef LAB: Bugfixes to the Resource class
72f7fbe82b LAB: Bugfixes to the Resource class
77608bfc66 LAB: Move more room reading functions to the Resource class
b033b7e539 LAB: Simplify readInitialConditions()
9676165436 LAB: Remove unused code for the demo version
93b2e413fd LAB: Change the scene rule list to use a Common::List
5cc3d3b682 LAB: Remove superfluous image buffers
1bdf07c7ac LAB: Remove unused code
a6805e884d LAB: Rewrite readSound() to use Common::File
f014218aca LAB: Remove dead code
12f4a71c73 LAB: Simplify getViewData, get rid of ViewDataPtr and ActionPtr
95d91d81e5 LAB: Fix whitespace
09a7232daa LAB: Use Common::File to load map data
1feb0e4c2c LAB: Rename monpage -> monitorPage
ebff05e7e7 LAB: Simplify the file reading code for the movement control panel
ad29493fa7 LAB: Fix compilation
647b0355c9 LAB: Cleanup
3160bb0bc3 LAB: Fix warning
d4e0c23ed3 LAB: Simplify code
36684eb1ba LAB: get rid of timing.h
fd8215454c LAB: Objectify intro code
158f623db8 LAB: Rename IntuiMessage struct members
c187a3bda9 LAB: Add intro.h
f56f2effb4 LAB: Started vga code refactoring
06c2e60cf0 LAB: Further renaming of vga code
4b65faaa63 LAB: More renames in vga.cpp
93e3ba9edd LAB: Put vga.cpp into LabEngine class
b76a624c9a LAB: Fix several cppcheck errors
ff2def7da1 LAB: Check all the 'for' loops, reduce the scope of variable accordingly
c485d9e8a6 LAB: Some rework related to the mouse code
8d70f33efe LAB: Rename RoomData members
d96484d81c LAB: Move mouse code in separate class, move some functions to LabEngine. (WIP)
18fc6fd102 LAB: Add some feedback when a file isn't found
db773d92b7 LAB: Remove useless redirections
0c84355f4a LAB: Move IsHiRes to main engine class
771e558d90 LAB: Move the global variable g_resource to the main engine class
05f54b7fe0 LAB: Make _music a member of LabEngine instead of a global
d0c6c73036 LAB: Rename _music, delete it in engine destructor
6cee2eb2be LAB: Move RoomNum to main engine class
11df8b5cf7 LAB: Make consistent the type of pen number
17678103db LAB: Move Music declaration to a separate header file
6395095b83 LAB: Move crumb variables to main class
d45d46c2cb LAB: Rename music source file
4a90aba77a LAB: Get rid of a goto
8dbdc70de4 LAB: Fix stopDiffEnd. This fixes the intro (between others)
6d4b71e2ce LAB: Renames in vga.cpp
fa8d319e31 LAB: More renames
29fc7a56c1 LAB: Fix warning
06b8eb856e LAB: C++'ify vga.cpp
51d04a8187 LAB: Remove leftover debug code
24684fe321 LAB: Move getText to the Resource class
0fbf62f7f0 LAB: Plug several font-related memory leaks. Some cleanup
f817c1de2e LAB: Get rid of stddefines
377bed8db0 LAB: Some renaming in Room Markers
609fd323d3 LAB: Remove some dead code
611df0c0dc LAB: Some renaming in allocroom, remove useless code and variables
3f33ad277d LAB: More renames
27c204976e LAB: Cleanup
83d88cab80 LAB: Some renaming, get rid of copytwo()
d656aa4859 LAB: Introduce the Anim class (WIP)
148d64eceb LAB: Put Image into a separate class. Leaks memory for now
7651ac7388 LAB: Get rid of readdiff.cpp
2fb0250e0c LAB: Renaming of Anim
53d92be11f LAB: remove the use of g_lab in Anim
66bf888558 LAB: Rework and renaming in the Event class
6b24481358 LAB: Move functions related to keyboard events to Event
d2dbf19244 LAB: Fix module.mk after readdiff.cpp removal
9ac98357bd LAB: Get rid of g_lab in Intro
1d13083b29 LAB: Clean up includes in Intro
8fa64824a2 LAB: Some renaming, move a couple of variables to game engine
88ede5d2d5 LAB: Rename Image class members
17d6e5e860 LAB: Moved bltBitMap to Image class
ab2519f57b LAB: Get rid of machine.cpp
adbb0ce0c5 LAB: Renamed mouse.* to eventman.*
69bdfae235 LAB: Plug memory leak
38ed7f930f LAB: Renames and moved static variables to class
44e098b06d LAB: More renames
a8b6003751 LAB: Merged in allocroom.cpp
d1e8e6dfbd LAB: Fix bug during initialization
5c246e4189 LAB: Remove leftover after rebase/merge
646c29d5a3 LAB: Renames and moved vars to classes
c67a9e867c LAB: More renames
4424463f06 LAB: Moved CPtr to engine class
3b40199ab6 LAB: Move doActions() to LabEngine class
f76f0d957a LAB: Merge room views into an array
23b70db958 LAB: Cleanup of palette code
1913a61f30 LAB: Some renaming and cleanup
f7fe91c8d2 LAB: Function reordering
914bd26295 LAB: Cleanup of roomCords()
359eda3b97 LAB: openDataFile can also be used without checking for a file header
8f4d9c9c05 LAB: Image accepts a Common::File now
4d46c1e820 LAB: Merge getCurMemLabFile() into allocFile()
ca52b2624e LAB: The size parameter of newOpen() is no longer used
58e6627f19 LAB: Remove superfluous image variables
58e16e2cd7 LAB: More renames and C++'ify
c320e6d0ae LAB: Move inventory to LabEngine class
c6041a41a3 LAB: More renames
021cb4c526 LAB: Rename roomCords to roomCoords
d50e9f3541 LAB: Remove dead code
b7faa0bccf LAB: Fix bug in getText()
c399536a07 LAB: Small cleanup in from_crumbs()
733fbe4c62 LAB: Start working on a separate DisplayMan class
f7321fa278 LAB: Make more functions member of LabEngine class
d376fd8dd0 LAB: Get rid of g_lab in several LabEngine and DisplayMan functions
a182a6af1a LAB: Rewrite picture handling and get rid of the memory manager
eb0a52e7fb LAB: Remove some superfluous initialization code
9ba30835a2 LAB: Refactor the remaining functions in labfile.cpp
3ac02c1196 LAB: Simplify file handling code
6eb9c084be LAB: Remove dead code
dddd07cc87 LAB: Remove unused code
6f3644f377 LAB: Fix a regression in roomCoords()
ea6d4579e2 LAB: Merge all of the different image drawing functions
c42973604c LAB: Split the tile puzzle related functions into a separate file
ab1d9771d2 LAB: Some cleanup of the monitor code
525db01913 LAB: Simplify several calls to flowText() and rectFill()
61d89cb744 LAB: Small cleanup in drawMap()
d9d2383d93 LAB: Use the windows keyboard mapping for the other versions
ef99d82d13 LAB: Move more functions to DisplayMan
fa966938c8 LAB: Remove vga.cpp
f48cf343c2 LAB: Move doNotes and doWestPaper to LabEngine, remove some useless defines
438e7a24f5 LAB: Get rid of some global variables
785772e86f LAB: Move fade functions to DisplayMan, some renaming
a9dc3a9302 LAB: Remove some useless uses of g_lab
b3269dc80d LAB: Move readMusic to the Music class
803dbcee90 LAB: Move _rooms to LabEngine, some renaming
62c4acc6b3 LAB: Change the gadget lists to use Common::List
2611b62d5e LAB: Rename parse types
0f41d8894c LAB: Simplify usage of the DIFF file buffer
2eb430dcff LAB: Simplify the calling code of playSoundEffect()
d264621832 LAB: Fix compilation
895d29c1ae LAB: Some more renaming, remove useless variables
5636181b78 LAB: Move text functions to DisplayMan, some renaming
f3a24ff593 LAB: Some refactoring, remove dead code and a useless return value
87201cfed2 LAB: Rename and clean up some of the scene transition code
9cc30c3c6d LAB: Clean up processArrow()
75c9d0b585 LAB: Fix spelling
1e11090edc LAB: Remove useless return
4f1a8f9fa4 LAB: Merge the uniffMemory() code into unDiff()
5ccc0fd7c6 LAB: Clean up checkGadgetHit() a bit
6bba608fc0 LAB: Get rid of _numHidden
156ad539ff LAB: Move readSound() into the Music class
0e886461d0 LAB: Replace some uses of malloc() with new
b6397c0af7 LAB: Use the correct bitmap buffer in the Anim class
320e658cb1 LAB: Get rid of the intermediate display bitmap pointer
5bc48cbbdd LAB: Move utility functions to a separate class
743b492ac7 LAB: Add safeguards in unDiff()
8059277928 LAB: remove some useless forward references and includes
6aff1b450d LAB: Move scene transition functions into a separate file
dcefb696ed LAB: Remove more extern variables
fb86132314 LAB: Fix some coding style in tilepuzzle
2d21f51c34 LAB: Some cleanup of the transition code
daf0655754 LAB: Use SWAP<> to simplify the transition code
00d61638ac LAB: Merge parsetypes.h and parsefun.h into processroom.h
73eb0d2f28 LAB: Revert incorrect change
6b9264d9da LAB: Refactoring the vgaUnscale code and the way it's used
9cc70b6f03 LAB: Some more refactoring and renaming
3a1ee64761 LAB: Review spacing
ae056a767b LAB: Use doxygen format for function comments
21fc36bfad LAB: Get rid of _isBM
2d0fab7f4c LAB: Use // for comments
0b2bf45a09 LAB: Simplify the gadget enabling/disabling code
6230fcbeb9 LAB: Simplify the journal and map gadget handling
c4ca8223b7 LAB: Plug a memory leak in freeButtonList()
4340295fbf LAB: Rename floor defines
ff6dfee221 LAB: Initialize the game interface correctly after saving/loading
c9ca5a0dd0 LAB: Remove unused return values
90e221a570 LAB: Plug a memory leak
53de3143f6 LAB: Cleanup doGoForward()
151e27f4b1 LAB: Fix regression in setCurClose(). Fixes closeups
d2a540ea55 LAB: Rename graphics.* to dispman.*
eccb852749 LAB: Removed unnecessary includes
d8e01fe23a LAB: Reduce header dependency from music.h
8e9798a0bc LAB: Reduce header intra-dependency. Reduced image.h dependency
d2cf293e4a LAB: More intra-header dependency reduction
a53045626d LAB: Moved direction defines to lab.h
bb80b6d46b LAB: Rename labfun.h to savegame.h
b1585b2c62 LAB: Reduced header dependency: savegame.h
5fad5cece3 LAB: Reduced header dependency: labsets.h, utils.h
9a9b752c0e LAB: More header dependency redux
66f2935a22 LAB: Reduced header dependency: dispman.h, eventman.h
9015cf72a3 LAB: Reduced header dependency: interface.h
cf020db741 LAB: Converted DisplayMan::_dispBitMap to a pointer.
9af853b6ab LAB: Reduced last reducable header: anim.h
c062dee369 LAB: Optimized dependency on common headers
e5f753749f LAB: Reduced dependency on processroom.h. Yay!
c1fc1687fc LAB: Code naming standards
23bbd70aac LAB: Reduced variables scope
f137e1af15 LAB: Use a local buffer for moving tiles in the tile puzzle
23f73c3244 LAB: Fix regression when scrolling tiles
c42629674b LAB: Code naming, reduced variable scope
0af299d3c7 LAB: Move saveRestoreGame() to saveload.cpp
199fa254f9 LAB: Rename CloseDataPtr pointers, some refactoring
72c08cfc8c LAB: Move mapScale functions to the utility class
1e9ee6ef4a LAB: Some refactoring and renaming in map.cpp
2d90f8a08d LAB: Move map function to LabEngine class, some renaming
4a9286ef27 LAB: Move getWord to DisplayMan
8e88d31025 LAB: Move processroom functions to LabEngine
b586f76f94 LAB: Review struct definitions in processroom
e7a0e05301 LAB: Merge playDiff() into readDiff()
f59ceebad9 LAB: Move readBlock to the utility class
67b3960968 LAB: Remove some useless use of g_lab
9c94d140db LAB: Simplify bitmap flags
165c0b3b49 LAB: More vars renaming
9f7ad4b5f2 LAB: Fix crash when closing the map
aa7ec3654d LAB: Refactor readPictToMem()
e0d546a4eb LAB: Remove extra whitespace
b77f726469 LAB: Reduce some variable scopes, some renaming
8f5c91ee07 LAB: Move all the tile puzzle related functionality into its own class
46a25b93ab LAB: Rewrite some code using switch statements
7d4e71d29e LAB: Change the map floor showing code, when changing floors
4fb53ad170 LAB: Some renames, simplified saveGame() and loadGame()
0c0b2da235 LAB: Move some defines which are only used in the tile puzzle
7bb45a8eaa LAB: Move timing functions to the utility class
f47d41930f LAB: Review LabEngine definition, make private a lot of members
a01f068969 LAB: Merge transitions in dispman
1b0a7db0b6 LAB: Get rid of getTime(), readBlock() and getRandom()
452c20ab8a LAB: Get rid of the rest of the custom time delay functions
cd85e5dd34 LAB: Remove unneeded static
aad3b063b3 LAB: The mouse cursor data is constant
aef304a83b LAB: Some renaming and refactoring in special.cpp
ac346869f7 LAB: Remove a useless use of g_lab
6668b76edc LAB: Remove some more useless g_lab
47368c157e LAB: Review Music declaration, some refactoring and renaming
7efd471a92 LAB: check header define names, rename a parameter of processMonitor()
c837e67070 LAB: Move interface functions to EventMan
7c1401264c LAB: Remove interface.h, get rid of a lot of useless defines
577b60d785 LAB: Move getMsg to the event manager
0dcfd74b84 LAB: Simplify fromCrumbs()
ff43ec7e86 LAB: Now that timing works correctly, disable some annoying delays
ceb5ef18e5 LAB: Get rid of a superfluous global variable
40b16afcab LAB: Get rid of _unstoppableSoundEffect
dffaffdd09 LAB: Simplify calls to initMusic()
231dda2ba9 LAB: Fix regression in animation code in looping animations
c883769adc LAB: Move the LAB2 teaser screen in a separate function
1524e20ef1 LAB: Simplify the room doors array
2332fb617c LAB: Rename gadget to button
f0e345a1a2 LAB: Make some functions and variables private in eventMan
e994c90d9b LAB: Simplify the crumb wait time code
2e09975086 LAB: Simplify the LabEngine destructor
99e09b2ca2 LAB: Merge the different X image maps
2b91bf2f34 LAB: Some renaming in EventMan
ad54a75b85 LAB: Add _vm to Image class
974740d307 LAB: Some renaming in LabEngine
a784e2bd5c LAB: Finally get rid of g_lab
5d240e3493 LAB; Fix a couple of typos in game description
aa718e4c84 LAB: Variable rename
79eec20361 LAB: Reduced variable scope. Renames
a7d5ae6b4b LAB: Converted ifs into switch()
ee73e5ca15 LAB: Simplified code
abb3e233bf LAB: More code simplification
5848a20af2 LAB: Turned another chain of ifs into a switch statement
1120958dac LAB: Removed useless condition
cbf4c876e5 LAB: Turned another if chain into switch
21e6f40301 LAB: Fix a regression related to random number generation, some renaming
1d027704e0 LAB: Fix mouse cursor after save/load
167d9c48a3 LAB: Reduced scope of a few more variables
acaece288f LAB: More variable scope redux
52d0243eff LAB: Fix the coding style of a some if/else statements
e0de03463e LAB: Use strlen to compute text length instead of a difference between start and end address. Some refactoring.
69294eccb0 LAB: Some renaming in DisplayMan
521652e436 LAB: Move some code from fromCrumbs() into separate functions
b661f2f8e6 LAB: Use enums for the interface buttons
2cfac1c4b0 LAB: Fix compilation
e71f28d0ba LAB: Reorder mouse position check in processMonitor in order to avoid duplicate checks
f791d690b2 LAB: Use Common::Rect in a couple of position checks to make it a bit more readable
75d1a3a22a LAB: Fix freePict as pointed by eriktorbjorn
fbff6313b5 LAB: Initialize a variable. This should fix a Valgrind warning.
6193626f7c LAB: Fix two deletes
b42ed683b8 LAB: Fix the style of some if/else statements
3f1bb66959 LAB: Fix memory leak
eab6682929 LAB: Add some checks to quit the game quickly when closing ScummVM
802a0d09dc LAB: Use Common::KEYCODE in several places
de6de51e8b LAB: More use of Common::KEYCODEs
dd06c83280 LAB: Make more use of kButton enum
9c7e372a21 LAB: make takeItem use Common::Point, some refactoring
83126e84ee LAB: Make the use of nullptr consistent through the engine
5ed11d721c LAB: Verify the appropriate use of parenthesis in if statements
eb6854e2c7 LAB: Add a short delay when changing screen so that the text is readable when changing screens
f932f39214 LAB: reduce a variable scope, remove useless code
005e077551 LAB: Some renames
5aef1367e2 LAB: Remove useless checks, and clean up the mouse processing code
09539d76ac LAB: Remove superfluous function
8b16ccbea1 LAB: Get rid of mouseButton()
605c2e553b LAB: Use common keycodes instead of direct keycode values
054a7a1e19 LAB: Use Common::Rect in functions related to flowText (WIP)
25509777aa LAB: Get rid of flowTextScaled
540173de36 LAB: constify 2 variables in drawMap
361aab82dc LAB: Fix regression in left click handling
fdf09a6385 LAB: Some simplification of the mouse handling code
b6bed0aed7 LAB: Simplify mouse button handling
318dc59382 LAB: Make setUpScreens() a bit easier to read
832d87e0bf LAB: Use Common::Point in IntuiMessage
bc25b6be55 LAB: Change the graphics and audio code to use Common::File directly
69680808d0 LAB: Remove unused variable
f452834f70 LAB: Remove unused variables in DIFFHeader and BitMap
b1fc785225 LAB: Use templates for the undiff functions
15889e6fd2 LAB: Make processMap a bit more readable by using Rects
12572a9c4b LAB: Merge enableButton() and disableButton()
0004488441 LAB: Simplify decIncInv() and move action handling out of fromCrumbs()
1c02487a00 LAB: Fix the intro of the DOS version
c5528a631d LAB: Handle some differences of the Amiga version
691d9e7e2e LAB: Fix memory leaks in savegame code
e94b18aec7 LAB: Correct engine name spelling. No functional change.
9048d08a05 LAB: Correct compiler warning in savegame code.
28bfce3de7 LAB: Correct variable shadows function compiler warning.
a7afc80e18 LAB: Avoid variable shadowing compiler warning.
b3b3c0cfd5 LAB: Remove parameters from processMainButton and performAction
5c360b4021 LAB: Remove dead code
70396e6fba LAB: Handle some differences in the intro of the Amiga version
4d5856a95e LAB: Handle the music encoding of the Amiga version
5c480485d4 LAB: Simplify the Amiga music flags
f1bb844e90 LAB: Fix a memory leak in the Image class
eb70efc900 LAB: Simplify decIncInv()
3e8eaa2c35 LAB: Use Common::String for strings, removing a ton of memory leaks
11d16bb34f LAB: Remove some leftover MSVC memory leak tester code
406710bac6 LAB: Plug a memory leak in the sound effects code
2a80c8066c LAB: Plug all the remaining resource-related memory leaks
567ed6a57a LAB: Formatting
df1376983d LAB: Simplify code related to _keyBuf handling
164b9d5a66 LAB: Use Common:KeyCode in keyPress() and getNextChar()
7f5826cfcb LAB: Fix check of ending animation, some renaming
3fcd3c1526 LAB: Avoid memory leaks with fonts
1d9e3cd561 LAB: Remove useless variable
2981ccc243 LAB: get rid of the last strcpy
d827faf156 LAB: Rename a parameter for consistency with other function definitions
a2097d2a2e LAB: Get rid of strcat by using Common::String
b9326e3850 LAB: Refactor some DispMan functions to use Common::String
ee4e67a731 LAB: Move and improve function comments to header in DispMan
28c74aed05 LAB: More work on the comments
eaa6f3bd01 LAB: Fix some GCC warnings
c6e5232fa3 LAB: Fix bug identified by eriktorbjorn
08a035f0e5 LAB: Fix loop in flooVisited
a4266d2109 LAB: Better handling of the Trial check in the puzzle
a41f9076c5 LAB: Fix malloc pointed by eriktorbjorn
a4d3bda5c1 LAB: Use an array of Common::Strings instead of bytes in Action
ae9c2fea51 LAB: Replace char* by Common::String in several functions
baa638fe2e LAB: Remove useless call to c_str
af8f87d55d LAB: Fix compilation for non-MSVC compilers
7e047b45b7 LAB: Fix a delete[] pointed out by eriktorbjorn
6981d750ea LAB: Fix a bug pointed out by wjp in getObject
feeaf09486 LAB: Use rectScale in two other places
cc039ef113 LAB: Fix crash in intro
4dfc428bac LAB: Some cleanup and refactoring
cff1f99b26 LAB: Set a default to the second parameter of readPict
2edd0c5142 LAB: Remove a couple of useless calls to c_Str()
b53735ba06 LAB: Constify some parameters
eba44d3094 LAB: Close _curBitmap before deleting it
2eeb027604 LAB: Revert previous commit as suggested by wjp
fa222f0ca8 LAB: Make string check more readable, remove a useless c_str()
9b6851c1a7 LAB: Safeguard: Set some variables to null pointer after deleting them
be1fd471be LAB: better fix of loadMapData, taking into account the other loops on _maps
6aad3aebd9 LAB: Move some more comments to header files
46f792d82d LAB: Delete some more variables in LabEngine destructor
10baf6b9a2 LAB: Finish moving function comments to header
137e12bf95 LAB: Fix regression in intro
df05be466e LAB: Fix readString when encrypted strings are stored with a wrong size and multiple \0
e88d09d2ec LAB: Fix delete in previous commit
26c48305b5 LAB: Add a couple of safeguards
02b606e375 LAB: Avoid to delete _screenImage->_imageData, which causes a crash
108cbce3b5 LAB: Remove useless assignments
503b633866 LAB: Remove useless casts and dead code
0823ebb36f LAB: Reduce the use of redirections in Resource
db99a31acc LAB: Fix stupid regression
f3db3ba305 LAB: Remove deletes from mainGameLoop
7380ddf400 LAB:  Change RuleList to a Common::List<Rule> as suggested by wjp
be4c436dca LAB: Move event update functions out of updateMusic
8c9d65b8cb LAB: Rename a member of Anim
8a3ff50d5c LAB: Remove _drawBitMap, make diffNextFrame a bit more readable
040fa45cf1 LAB: Fix header define for Anim
50a6cf12ef LAB: Add a safeguard on numChunks
966f82d82e LAB: Clarify a bit the use of header in Anim
f59ccf534c LAB: Get rid of the _doNotDrawMessage hack (from the original)
ced5b677f6 LAB: Add enums for action types, rule types ad rule actions
333d553716 LAB: Add a console, with two new commands (scene and scene_resources)
f7395ba0ab LAB: Rewrite the action message functionality (_doNotShowMessage)
c855cd46df LAB: Extend the scene_resources command and add the find_action command
07da047fa1 LAB: Fix the find_action command
9d53245f73 LAB: Get rid of _waitTillFinished
7a81e03b25 LAB: Prevent the Image destructor from deleting external scroll buffers
8de38a8d10 LAB: Greatly simplify doScrollBlack() using scrollDisplayY()
e8edff85f3 LAB: Synchronize function definition in Intro
34b59256fc LAB: Replace g_system by _system
2f1506edec LAB: Replace do..while by while statements in resource
c9049f2329 LAB: Remove left-over long size specifiers
9dae9eb811 LAB: Implement the scroll buffer of doScrollWipe() and doScrollBounce()
b3a19cf75e LAB: Show the correct number of parameters in find_action
29d85c8d50 LAB: Use int in for loops, instead of uint16
07aec19a06 LAB: Also mention Terra Nova Development in the engine copyright message
c66d5eca3a LAB: setAmigaPal() is always using 16 colors
60f7849c20 LAB: Improve the palette assignment in writeColorRegs()
5327b6f545 LAB: Use byte instead of char in overlayRect()
52c7fcbfe5 LAB: Rename overlayRect() to checkerboardEffect()
d30ee82cdb LAB: Use camelCase for a variable name
f9641a6d66 LAB: Show a more descriptive message when save/restore is aborted
ff93e55afd Merge pull request #636 from sev-/lab


Commit: 8ca14d1d642fce2617513fdc0c3223af2ab4e7e7
    https://github.com/scummvm/scummvm/commit/8ca14d1d642fce2617513fdc0c3223af2ab4e7e7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Initial code

Changed paths:
  A engines/lab/allocroom.cpp
  A engines/lab/audioi.cpp
  A engines/lab/configure.engine
  A engines/lab/detection.cpp
  A engines/lab/diff.h
  A engines/lab/engine.cpp
  A engines/lab/graphics.cpp
  A engines/lab/interface.cpp
  A engines/lab/interface.h
  A engines/lab/intro.cpp
  A engines/lab/lab.cpp
  A engines/lab/lab.h
  A engines/lab/labfile.cpp
  A engines/lab/labfun.h
  A engines/lab/labmusic.cpp
  A engines/lab/labsets.cpp
  A engines/lab/labtext.cpp
  A engines/lab/machine.cpp
  A engines/lab/map.cpp
  A engines/lab/modernsavegame.cpp
  A engines/lab/modernsavegame.h
  A engines/lab/module.mk
  A engines/lab/mouse.cpp
  A engines/lab/mouse.h
  A engines/lab/parsefun.h
  A engines/lab/parsetypes.h
  A engines/lab/processroom.cpp
  A engines/lab/readdiff.cpp
  A engines/lab/readparse.cpp
  A engines/lab/savegame.cpp
  A engines/lab/savegamepalmap.cpp
  A engines/lab/special.cpp
  A engines/lab/stddefines.h
  A engines/lab/storage.cpp
  A engines/lab/storage.h
  A engines/lab/text.cpp
  A engines/lab/text.h
  A engines/lab/timing.cpp
  A engines/lab/timing.h
  A engines/lab/undiff.cpp
  A engines/lab/vga.cpp
  A engines/lab/vga.h



diff --git a/engines/lab/allocroom.cpp b/engines/lab/allocroom.cpp
new file mode 100644
index 0000000..208d7ce
--- /dev/null
+++ b/engines/lab/allocroom.cpp
@@ -0,0 +1,221 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/storage.h"
+#include "lab/parsetypes.h"
+#include "lab/stddefines.h"
+
+namespace Lab {
+
+/* Have to make sure that ROOMBUFFERSIZE is bigger than the biggest piece of memory
+   that we need */
+#define ROOMBUFFERSIZE (2 * 20480L)
+#define EMPTYROOM      ((uint16) -1)
+#define MAXMARKERS     10
+
+extern RoomData *Rooms;
+extern uint16 ManyRooms;
+
+
+typedef struct {
+	uint16 RoomNum;
+	void *Start0, *End0, *Start1, *End1;
+} RoomMarker;
+
+
+
+static RoomMarker RoomMarkers[MAXMARKERS];
+static void *RoomBuffer = NULL;
+static uint16 CurMarker  = 0;
+static void *MemPlace = NULL, *NextMemPlace = NULL;
+static int32 MemLeftInBuffer = 0L;
+
+/*****************************************************************************/
+/* Allocates the memory for the room buffers.                                */
+/*****************************************************************************/
+bool initRoomBuffer(void) {
+	uint16 counter;
+
+	CurMarker = 0;
+
+	if (allocate((void **)&RoomBuffer, ROOMBUFFERSIZE)) {
+		MemPlace = RoomBuffer;
+		MemLeftInBuffer = ROOMBUFFERSIZE;
+
+		for (counter = 0; counter < MAXMARKERS; counter++)
+			RoomMarkers[counter].RoomNum = EMPTYROOM;
+
+		return true;
+	} else
+		return false;
+}
+
+
+
+
+/*****************************************************************************/
+/* Frees the memory for the room buffers.                                    */
+/*****************************************************************************/
+void freeRoomBuffer(void) {
+	if (RoomBuffer)
+		deallocate(RoomBuffer, ROOMBUFFERSIZE);
+}
+
+
+/*****************************************************************************/
+/* Frees a room's resources.                                                 */
+/*****************************************************************************/
+static void freeRoom(uint16 RMarker) {
+	uint16 RoomNum;
+
+	RoomNum = RoomMarkers[RMarker].RoomNum;
+
+	if (RoomNum != EMPTYROOM) {
+		Rooms[RoomNum].NorthView = NULL;
+		Rooms[RoomNum].SouthView = NULL;
+		Rooms[RoomNum].EastView  = NULL;
+		Rooms[RoomNum].WestView  = NULL;
+		Rooms[RoomNum].RuleList  = NULL;
+		Rooms[RoomNum].RoomMsg   = NULL;
+	}
+
+	RoomMarkers[RMarker].RoomNum = EMPTYROOM;
+	RoomMarkers[RMarker].Start0  = NULL;
+	RoomMarkers[RMarker].End0    = NULL;
+	RoomMarkers[RMarker].Start1  = NULL;
+	RoomMarkers[RMarker].End1    = NULL;
+}
+
+/*****************************************************************************/
+/* Gets a chunk of memory from the buffer.                                   */
+/*****************************************************************************/
+static void *getCurMem(uint16 Size) {
+	uint16 counter;
+	void *Ptr, *Start0, *Start1, *End0, *End1;
+
+	if (((int32) Size) > MemLeftInBuffer) {
+		MemPlace = RoomBuffer;
+		MemLeftInBuffer = ROOMBUFFERSIZE;
+		NextMemPlace = NULL;
+	}
+
+	Ptr = MemPlace;
+	MemPlace = (char *)MemPlace + Size;
+	MemLeftInBuffer -= Size;
+
+	if (MemPlace > NextMemPlace) {
+		NextMemPlace = NULL;
+
+		for (counter = 0; counter < MAXMARKERS; counter++) {
+			if (RoomMarkers[counter].RoomNum != EMPTYROOM) {
+				Start0 = RoomMarkers[counter].Start0;
+				Start1 = RoomMarkers[counter].Start1;
+				End0   = RoomMarkers[counter].End0;
+				End1   = RoomMarkers[counter].End1;
+
+				if (((Start0 >= Ptr) && (Start0 < MemPlace))  ||
+				        ((End0 >= Ptr) && (End0 < MemPlace))    ||
+				        ((Ptr >= Start0) && (Ptr <= End0))        ||
+
+				        ((Start1 >= Ptr) && (Start1 < MemPlace))  ||
+				        ((End1 >= Ptr) && (End1 < MemPlace))    ||
+				        ((Ptr >= Start1) && (Ptr <= End1))) {
+					freeRoom(counter);
+				} else {
+					if (Start0 >= MemPlace)
+						if ((NextMemPlace == NULL) || (Start0 < NextMemPlace))
+							NextMemPlace = Start0;
+
+					if (Start1 >= MemPlace)
+						if ((NextMemPlace == NULL) || (Start1 < NextMemPlace))
+							NextMemPlace = Start1;
+				}
+			}
+		}
+
+		if (NextMemPlace == NULL) {
+			NextMemPlace = RoomBuffer;
+			NextMemPlace = (char *)NextMemPlace + ROOMBUFFERSIZE;
+		}
+	}
+
+	return Ptr;
+}
+
+
+
+
+
+/*****************************************************************************/
+/* Grabs a chunk of memory from the room buffer, and manages it for a        */
+/* particular room.                                                          */
+/*****************************************************************************/
+void allocRoom(void **Ptr, uint16 Size, uint16 RoomNum) {
+	uint16 RMarker;
+	bool doit = true;
+
+	if (1 & Size)  /* Memory is required to be even aligned */
+		Size++;
+
+	RMarker = 0;
+
+	while ((RMarker < MAXMARKERS) && doit) {
+		if (RoomMarkers[RMarker].RoomNum == RoomNum)
+			doit = false;
+		else
+			RMarker++;
+	}
+
+	if (RMarker >= MAXMARKERS) {
+		RMarker = CurMarker;
+		CurMarker++;
+
+		if (CurMarker >= MAXMARKERS)
+			CurMarker = 0;
+
+		freeRoom(RMarker);
+		RoomMarkers[RMarker].RoomNum = RoomNum;
+	}
+
+	*Ptr = getCurMem(Size);
+
+	if (RoomMarkers[RMarker].Start0 == NULL) {
+		RoomMarkers[RMarker].Start0 = *Ptr;
+		RoomMarkers[RMarker].End0   = (void *)(((char *)(*Ptr)) + Size - 1);
+	} else if (*Ptr < RoomMarkers[RMarker].Start0) {
+		if (RoomMarkers[RMarker].Start1 == NULL)
+			RoomMarkers[RMarker].Start1 = *Ptr;
+
+		RoomMarkers[RMarker].End1 = (void *)(((char *)(*Ptr)) + Size - 1);
+	} else
+		RoomMarkers[RMarker].End0 = (void *)(((char *)(*Ptr)) + Size - 1);
+}
+
+} // End of namespace Lab
diff --git a/engines/lab/audioi.cpp b/engines/lab/audioi.cpp
new file mode 100644
index 0000000..44ba56e
--- /dev/null
+++ b/engines/lab/audioi.cpp
@@ -0,0 +1,461 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/stddefines.h"
+
+#include "lab/labfun.h"
+
+namespace Lab {
+
+#define PLAYBUFSIZE     65536L
+
+#if defined(DOSCODE)
+const char VERSION[] = "1.01";
+
+char *AudioI_DriverName = "a32sbdg.dll";
+#endif
+
+extern bool MusicOn;
+
+#if defined(DOSCODE)
+static HTIMER server;
+static HDRIVER hdriver;
+static char *drvr;
+static char *dll;
+static drvr_desc *desc;
+#endif
+//static sound_buff firstblock, tempblock;
+static int bufnum;
+#if defined(DOSCODE)
+static unsigned seg1;
+static unsigned seg2;
+static union REGS inregs, outregs;
+#endif
+
+
+bool EffectPlaying = false, ContMusic = false, DoMusic = false;
+static char *CurMusic, *startMusic;
+static uint32 StartMusicLen;
+
+
+#if defined(DOSCODE)
+static uint16 *mem, *head, *tail, counter;
+
+#pragma off (check_stack)
+void cdecl timer_callback(void) {
+
+	head = (uint16 *)(0x41A);
+	tail = (uint16 *)(0x41C);
+	mem  = (uint16 *)(0x400 + *head);
+
+	if (*tail > *head)
+		counter = (*tail - *head) >> 1;
+	else
+		counter = (*head - *tail) >> 1;
+
+	if (counter > 16)
+		counter = 16;
+
+	while (counter) {
+		if ((*mem == 0x2e03) || (*mem == 0x300) || (*mem == 0x0003)) {
+			*tail = *head;
+			return;
+		}
+
+		mem++;
+		counter--;
+	}
+}
+#endif
+
+void freeAudio(void) {
+	if (!DoMusic)
+		return;
+
+#if defined(DOSCODE)
+	AIL_release_timer_handle(server);
+
+	AIL_shutdown(NULL);
+#else
+	//SDLWrapAudio();
+#endif
+}
+
+
+
+bool initAudio(void) {
+	if (!DoMusic)
+		return true;
+
+#if 0
+#if defined(DOSCODE)
+
+	AudioI_DriverName = "a32sbdg.dll";
+
+	//
+	// Allocate two 16K buffers from real-mode (lower 1MB) memory
+	//
+	// *buf1, *buf2 -> protected-mode pointers to buffers (sel:0000)
+	// *seg1, *seg2 -> real-mode (physical) pointers to buffers (seg:0000)
+	//
+	// Note: DPMI calculations assume flat model near pointer offset 0 =
+	// segment 0, offset 0 (Rational DOS4GW).  The reason -- our simple
+	// file loader function can't use the far pointer formed by the selector
+	// returned by the DPMI call.
+
+	// Note that these examples do not implement out-of-memory error
+	// checking
+	//
+
+	inregs.x.eax = 0x100;
+	inregs.x.ebx = (16384 / 16);
+	int386(0x31, &inregs, &outregs);
+
+	seg1 = outregs.x.eax << 16;
+	buf1 = (char *)(outregs.x.eax * 16);
+
+	if (buf1 == NULL)
+		return false;
+
+	inregs.x.eax = 0x100;
+	inregs.x.ebx = (16384 / 16);
+	int386(0x31, &inregs, &outregs);
+
+	seg2 = outregs.x.eax << 16;
+	buf2 = (char *)(outregs.x.eax * 16);
+
+	if (buf2 == NULL)
+		return false;
+
+	//
+	// Load driver file
+	//
+
+	dll = FILE_read(AudioI_DriverName, NULL);
+
+	if (dll == NULL) {
+		return false;
+	}
+
+	drvr = DLL_load(dll, DLLMEM_ALLOC | DLLSRC_MEM, NULL);
+
+	if (drvr == NULL) {
+		return false;
+	}
+
+	free(dll);
+
+	//
+	// Initialize API before calling any Library functions
+	//
+
+	AIL_startup();
+
+	hdriver = AIL_register_driver(drvr);
+
+	if (hdriver == -1) {
+		AIL_shutdown(NULL);
+		return false;
+	}
+
+	//
+	// Get driver type and factory default I/O parameters; exit if
+	// driver is not capable of interpreting PCM sound data
+	//
+
+	desc = AIL_describe_driver(hdriver);
+
+	if (desc->drvr_type != DSP_DRVR) {
+		AIL_shutdown(NULL);
+		return false;
+	}
+
+	if (!AIL_detect_device(hdriver, desc->default_IO, desc->default_IRQ, desc->default_DMA, desc->default_DRQ)) {
+		desc->default_IRQ = 5;
+
+		if (!AIL_detect_device(hdriver, desc->default_IO, desc->default_IRQ, desc->default_DMA, desc->default_DRQ)) {
+			AIL_shutdown(NULL);
+			return false;
+		}
+	}
+
+	AIL_init_driver(hdriver, desc->default_IO, desc->default_IRQ, desc->default_DMA, desc->default_DRQ);
+
+	//
+	// Register a timer function; set up for 10-millisecond (100 Hz.)
+	// callback intervals
+	//
+
+	server = AIL_register_timer(timer_callback);
+
+	if (server != -1) {
+		AIL_set_timer_period(server, 20000L);
+		AIL_start_timer(server);
+	}
+
+#else
+	// we allocate extra mempory for 16-bit samples
+	buf1 = malloc(PLAYBUFSIZE);
+
+	if (buf1 == NULL)
+		return false;
+
+	buf2 = malloc(PLAYBUFSIZE);
+
+	if (buf2 == NULL)
+		return false;
+
+	if (!SDLInitAudio())
+		return false;
+
+#endif
+#endif
+
+	return true;
+}
+
+
+void initSampleRate(uint16 SampleSpeed) {
+	flushAudio();
+
+	if (SampleSpeed < 4000)
+		SampleSpeed = 4000;
+
+#if defined(DOSCODE)
+	firstblock.sample_rate = 256 - (1000000L / SampleSpeed);
+	firstblock.pack_type = 0 | 0x80;  // 8-bit mono sample
+#else
+	//firstblock.sample_rate = SampleSpeed;
+	//firstblock.pack_type = AUDIO_S16; // SOUND_MONO | SOUND_16BIT;  // 16-bit mono sample
+#endif
+}
+
+
+
+
+bool musicBufferEmpty(uint16 i) {
+#if defined(NEWCODE)
+	return (AIL_sound_buffer_status(hdriver, i) == DAC_DONE);
+#else
+	//return (SDLSoundBufferStatus(i) == DAC_DONE);
+	return true;
+#endif
+}
+
+
+
+void playMusicBlock(void *Ptr, uint32 Size, uint16 BufferNum, uint16 SampleSpeed) {
+#if defined(DOSCODE)
+	uint32 TempPtr;
+	uint32 seg;
+	char *buf;
+
+	TempPtr = ((uint32) Ptr) / 16L;
+
+	seg = TempPtr << 16;
+	buf = (char *)(TempPtr * 16);
+
+	if (SampleSpeed < 4000)
+		SampleSpeed = 4000;
+
+	firstblock.sample_rate = 256 - (1000000L / SampleSpeed);
+	firstblock.pack_type = 0 | 0x80;  // 8-bit mono sample
+
+	tempblock = firstblock;
+	tempblock.sel_data = buf;
+	tempblock.seg_data = seg;
+	tempblock.len      = Size;
+
+	AIL_register_sound_buffer(hdriver, BufferNum, &tempblock);
+	AIL_format_sound_buffer(hdriver, &tempblock);
+
+	AIL_start_digital_playback(hdriver);
+	AIL_set_digital_playback_volume(hdriver, 127);
+#else
+#if 0
+
+	if (SampleSpeed < 4000)
+		SampleSpeed = 4000;
+
+	firstblock.sample_rate = SampleSpeed;
+	firstblock.pack_type = SOUND_MONO | SOUND_16BIT;  // 16-bit mono sample
+
+	tempblock = firstblock;
+	tempblock.sel_data = Ptr;
+	tempblock.len      = Size;
+
+	SDLPlayBuffer(BufferNum, &tempblock);
+#endif
+#endif
+}
+
+
+void updateSoundBuffers(void) {
+	if (!DoMusic)
+		return;
+
+	if (!EffectPlaying)
+		return;
+
+#if defined(DOSCODE)
+
+	for (int i = 0; i < 2; i++) {
+		if ((AIL_sound_buffer_status(hdriver, i) == DAC_DONE) && firstblock.len) {
+			tempblock.len = min(16384L, firstblock.len);
+			firstblock.len -= tempblock.len;
+
+			if (!(bufnum ^= 1)) {
+				memcpy(buf1, CurMusic, (unsigned) tempblock.len);
+				tempblock.sel_data = buf1;
+				tempblock.seg_data = seg1;
+			} else {
+				memcpy(buf2, CurMusic, (unsigned) tempblock.len);
+				tempblock.sel_data = buf2;
+				tempblock.seg_data = seg2;
+			}
+
+			CurMusic += tempblock.len;
+
+			AIL_register_sound_buffer(hdriver, i, &tempblock);
+			AIL_format_sound_buffer(hdriver, &tempblock);
+
+			AIL_start_digital_playback(hdriver);
+			AIL_set_digital_playback_volume(hdriver, 127);
+		}
+	}
+
+	//
+	// Playback ends when no bytes are left in the source data and
+	// the status of both buffers equals DAC_DONE
+	//
+
+	if (!firstblock.len) {
+		if (ContMusic) {
+			CurMusic = startMusic;
+			firstblock.len = StartMusicLen;
+		} else if ((AIL_sound_buffer_status(hdriver, 0) == DAC_DONE) &&
+		           (AIL_sound_buffer_status(hdriver, 1) == DAC_DONE)) {
+			flushAudio();
+			EffectPlaying = false;
+		}
+	}
+
+#else
+#if 0
+
+	for (int i = 0; i < 2; i++) {
+		if ((SDLSoundBufferStatus(i) == DAC_DONE) && firstblock.len) {
+			// use extra memory for 16-bit samples
+			tempblock.len = min(PLAYBUFSIZE, firstblock.len);
+			firstblock.len -= tempblock.len;
+
+			if (!(bufnum ^= 1)) {
+				memcpy(buf1, CurMusic, (unsigned) tempblock.len);
+				tempblock.sel_data = buf1;
+			} else {
+				memcpy(buf2, CurMusic, (unsigned) tempblock.len);
+				tempblock.sel_data = buf2;
+			}
+
+			CurMusic += tempblock.len;
+
+			SDLPlayBuffer(i, &tempblock);
+		}
+	}
+
+	//
+	// Playback ends when no bytes are left in the source data and
+	// the status of both buffers equals DAC_DONE
+	//
+
+	if (!firstblock.len) {
+		if (ContMusic) {
+			CurMusic = startMusic;
+			firstblock.len = StartMusicLen;
+		} else if ((SDLSoundBufferStatus(0) == DAC_DONE) &&
+		           (SDLSoundBufferStatus(1) == DAC_DONE)) {
+			flushAudio();
+			EffectPlaying = false;
+		}
+	}
+
+#endif
+#endif
+}
+
+
+
+void flushAudio(void) {
+	if (!DoMusic)
+		return;
+
+#if defined(DOSCODE)
+	AIL_stop_digital_playback(hdriver);
+#else
+	//SDLStopPlayback();
+#endif
+	EffectPlaying = false;
+}
+
+
+
+
+void playMusic(uint16 SampleSpeed, uint16 Volume, uint32 Length, bool flush, void *Data) {
+	if (!DoMusic)
+		return;
+
+	g_music->pauseBackMusic();
+
+	if (flush)
+		flushAudio();
+
+	if (SampleSpeed < 4000)
+		SampleSpeed = 4000;
+
+#if defined(DOSCODE)
+	firstblock.sample_rate = 256 - (1000000L / SampleSpeed);
+	firstblock.pack_type = 0 | 0x80;  // 8-bit mono sample
+#else
+	//firstblock.sample_rate = SampleSpeed;
+	//firstblock.pack_type = SOUND_MONO | SOUND_16BIT;  // 16-bit mono sample
+#endif
+	//firstblock.len = Length;
+	bufnum = 0;
+
+	//tempblock = firstblock;
+	EffectPlaying = true;
+	CurMusic = (char *)Data;
+	startMusic = CurMusic;
+	StartMusicLen = Length;
+
+	updateSoundBuffers();
+}
+
+} // End of namespace Lab
diff --git a/engines/lab/configure.engine b/engines/lab/configure.engine
new file mode 100644
index 0000000..df154b4
--- /dev/null
+++ b/engines/lab/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 lab "Labirynth of Time" no
diff --git a/engines/lab/detection.cpp b/engines/lab/detection.cpp
new file mode 100644
index 0000000..f7632c7
--- /dev/null
+++ b/engines/lab/detection.cpp
@@ -0,0 +1,104 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+ /*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "engines/advancedDetector.h"
+#include "common/system.h"
+
+#include "base/plugins.h"
+
+#include "lab/lab.h"
+
+static const PlainGameDescriptor lab_setting[] = {
+	{ "lab", "Labyrith of Time Engine game" },
+	{ 0, 0 }
+};
+
+static const ADGameDescription labDescriptions[] = {
+	{
+		"lab",
+		"",
+		{
+			{ "doors",   0, "d77536010e7e5ae17ee066323ceb9585", 2537 },
+			{ "notes11", 0, "63e873f659f8f46f9809d16a2bf653c7", 3562 },
+			{ NULL, 0, NULL, 0 }
+		},
+		Common::EN_ANY,
+		Common::kPlatformDOS,
+		ADGF_NO_FLAGS,
+		GUIO0()
+	},
+	{
+		"lab",
+		"",
+		AD_ENTRY1s("doors", "7bf458df6ec30cc8ef4665e4d7c77f59", 2537),
+		Common::EN_ANY,
+		Common::kPlatformAmiga,
+		ADGF_NO_FLAGS,
+		GUIO0()
+	},
+	AD_TABLE_END_MARKER
+};
+
+static const char *const directoryGlobs[] = {
+        "fonts",
+		"game",
+        0
+};
+
+class LabMetaEngine : public AdvancedMetaEngine {
+public:
+	LabMetaEngine() : AdvancedMetaEngine(labDescriptions, sizeof(ADGameDescription), lab_setting) {
+		_singleid = "lab";
+
+		_maxScanDepth = 2;
+		_directoryGlobs = directoryGlobs;
+	}
+
+	virtual const char *getName() const {
+		return "Lab";
+	}
+
+	virtual const char *getOriginalCopyright() const {
+		return "Labytinth of Time (c) 2004 The Wyrmkeep Entertainment Co.";
+	}
+
+	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription * /* desc */) const {
+		// Instantiate Engine even if the game data is not found.
+		*engine = new Lab::LabEngine(syst);
+		return true;
+	}
+
+};
+
+#if PLUGIN_ENABLED_DYNAMIC(LAB)
+	REGISTER_PLUGIN_DYNAMIC(LAB, PLUGIN_TYPE_ENGINE, LabMetaEngine);
+#else
+	REGISTER_PLUGIN_STATIC(LAB, PLUGIN_TYPE_ENGINE, LabMetaEngine);
+#endif
diff --git a/engines/lab/diff.h b/engines/lab/diff.h
new file mode 100644
index 0000000..e46e320
--- /dev/null
+++ b/engines/lab/diff.h
@@ -0,0 +1,102 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#ifndef LAB_DIFF_H
+#define LAB_DIFF_H
+
+#include "lab/stddefines.h"
+
+namespace Lab {
+
+
+struct DIFFHeader {
+	uint16 Version, x, y;
+	char depth, fps;
+	uint32 BufferSize;
+	uint16 Machine;
+	uint32 Flags;
+};
+
+struct BitMap {
+	uint16 BytesPerRow, Rows;
+	byte Flags, Depth;
+	byte *Planes[16];
+};
+
+#if !defined(DOSCODE)
+#define BITMAPF_VIDEO (1<<7)
+#endif
+
+/* unDiff.c */
+
+void initOffsets(uint16 bytesperrow);
+
+bool unDIFFMemory(byte *Dest,       /* Where to Un-DIFF               */
+                  byte *diff,          /* The DIFFed code.               */
+                  uint16 HeaderSize,    /* Size of header (1, 2 or 4 bytes)
+                                                   (only supports 1 currently     */
+                  uint16 CopySize);     /* Size of minimum copy or skip.
+                                                   (1, 2 or 4 bytes)              */
+
+bool VUnDIFFMemory(byte *Dest, byte *diff, uint16 HeaderSize, uint16 CopySize, uint16 bytesperrow);
+
+void runLengthDecode(byte *Dest, byte *Source);
+
+void VRunLengthDecode(byte *Dest, byte *Source, uint16 bytesperrow);
+
+/* readDiff.c */
+
+void blackScreen();
+
+void blackAllScreen();
+
+void whiteScreen(void);
+
+bool readDiff(bool playonce);
+
+void diffNextFrame(void);
+
+void playCntMusic(void);
+
+void readSound(void);
+
+void stopDiff(void);
+
+void stopDiffEnd(void);
+
+void stopSound(void);
+
+void diffSetMusic(void);
+
+} // End of namespace Lab
+
+#endif /* LAB_DIFF_H */
+
+
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
new file mode 100644
index 0000000..b0b8614
--- /dev/null
+++ b/engines/lab/engine.cpp
@@ -0,0 +1,1834 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/stddefines.h"
+#include "lab/labfun.h"
+#include "lab/diff.h"
+#include "lab/vga.h"
+#include "lab/timing.h"
+#include "lab/text.h"
+#include "lab/storage.h"
+#include "lab/parsefun.h"
+#include "lab/interface.h"
+#include "lab/mouse.h"
+
+namespace Lab {
+
+const char *CurFileName = " ";
+
+bool LongWinInFront = false;
+
+struct TextFont *MsgFont;
+
+extern bool DoBlack, waiteffect, EffectPlaying, stopsound, DoNotDrawMessage, IsHiRes, nopalchange, DoMusic;
+
+/* Global parser data */
+
+extern RoomData *Rooms;
+extern InventoryData *Inventory;
+extern uint16 NumInv, RoomNum, ManyRooms, HighestCondition, Direction;
+extern LargeSet Conditions, RoomsFound;
+CloseDataPtr CPtr;
+
+#if !defined(DOSCODE)
+CrumbData BreadCrumbs[MAX_CRUMBS];
+uint16 NumCrumbs;
+bool DroppingCrumbs;
+bool FollowingCrumbs;
+bool FollowCrumbsFast;
+bool IsCrumbTurning;
+uint32 CrumbSecs, CrumbMicros;
+bool IsCrumbWaiting;
+
+int     followCrumbs();
+void    mayShowCrumbIndicator();
+void    mayShowCrumbIndicatorOff();
+#endif
+
+bool Alternate = false, ispal = false, noupdatediff = false, MainDisplay = true, QuitLab = false, DoNotReset = false;
+
+extern char *NewFileName;  /* When ProcessRoom.c decides to change the filename
+                              of the current picture. */
+
+extern char *LAMPONMSG, *TURNLEFT, *TURNRIGHT;
+extern char *GOFORWARDDIR, *NOPATH, *TAKEITEM, *USEONWHAT, *TAKEWHAT, *MOVEWHAT, *OPENWHAT, *CLOSEWHAT, *LOOKWHAT, *NOTHING, *USEMAP, *USEJOURNAL, *TURNLAMPON, *TURNLAMPOFF, *USEWHISKEY, *USEPITH, *USEHELMET;
+
+
+#define BIGBUFFERSIZE 850000L
+#define SMALLBUFFERSIZE 250000L
+
+static uint32 BUFFERSIZE = BIGBUFFERSIZE;
+
+
+/* LAB: Labyrinth specific code for the special puzzles */
+#define SPECIALLOCK         100
+#define SPECIALBRICK        101
+#define SPECIALBRICKNOMOUSE 102
+
+#define MAPNUM               28
+#define JOURNALNUM            9
+#define WESTPAPERNUM         18
+#define NOTESNUM             12
+#define WHISKEYNUM           25
+#define PITHHELMETNUM         7
+#define HELMETNUM             1
+
+#define LAMPNUM              27
+#define LAMPON              151
+
+#define BELTNUM               3
+#define BELTGLOW             70
+
+#define USEDHELMET          184
+
+#define QUARTERNUM           30
+
+
+#define MUSEUMMONITOR        71
+#define GRAMAPHONEMONITOR    72
+#define UNICYCLEMONITOR      73
+#define STATUEMONITOR        74
+#define TALISMANMONITOR      75
+#define LUTEMONITOR          76
+#define CLOCKMONITOR         77
+#define WINDOWMONITOR        78
+#define BELTMONITOR          79
+#define LIBRARYMONITOR       80
+#define TERMINALMONITOR      81
+#define LEVERSMONITOR        82
+
+
+#define CLOWNROOM           123
+#define DIMROOM              80
+
+
+
+static byte *MovePanelBuffer, *InvPanelBuffer;
+static uint32 MovePanelBufferSize, InvPanelBufferSize;
+static struct Image *MoveImages[20],
+#if defined(DOSCODE)
+		*InvImages[6];
+#else
+		*InvImages[10];
+#endif
+static struct Gadget *MoveGadgetList, *InvGadgetList;
+
+
+static char initcolors[] = { '\x00', '\x00', '\x00', '\x30',
+							 '\x30', '\x30', '\x10', '\x10',
+							 '\x10', '\x14', '\x14', '\x14',
+							 '\x20', '\x20', '\x20', '\x24',
+							 '\x24', '\x24', '\x2c', '\x2c',
+							 '\x2c', '\x08', '\x08', '\x08'};
+
+
+
+
+/******************************************************************************/
+/* Draws the control panel display.                                           */
+/******************************************************************************/
+void drawPanel(void) {
+	mouseHide();
+
+	setAPen(3);                 /* Clear Area */
+	rectFill(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319), VGAScaleY(199));
+
+	setAPen(0);                 /* First Line */
+	drawHLine(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319));
+	setAPen(5);                 /* Second Line */
+	drawHLine(0, VGAScaleY(149) + 1 + SVGACord(2), VGAScaleX(319));
+
+	/* Gadget Seperators */
+	setAPen(0);
+	drawHLine(0, VGAScaleY(170), VGAScaleX(319));     /* First black line to seperate buttons */
+
+	if (!Alternate) {
+		setAPen(4);
+		drawHLine(0, VGAScaleY(170) + 1, VGAScaleX(319)); /* The horizontal lines under the black one */
+		drawGadgetList(MoveGadgetList);
+	} else {
+#if defined(DOSCODE)
+		drawVLine(VGAScaleX(124), VGAScaleY(170) + 1, VGAScaleY(199)); /* Vertical Black lines */
+		drawVLine(VGAScaleX(194), VGAScaleY(170) + 1, VGAScaleY(199));
+#else
+		drawVLine(VGAScaleX(90), VGAScaleY(170) + 1, VGAScaleY(199));  /* Vertical Black lines */
+		drawVLine(VGAScaleX(160), VGAScaleY(170) + 1, VGAScaleY(199));
+		drawVLine(VGAScaleX(230), VGAScaleY(170) + 1, VGAScaleY(199));
+#endif
+
+		setAPen(4);
+		drawHLine(0, VGAScaleY(170) + 1, VGAScaleX(122));   /* The horizontal lines under the black one */
+		drawHLine(VGAScaleX(126), VGAScaleY(170) + 1, VGAScaleX(192));
+		drawHLine(VGAScaleX(196), VGAScaleY(170) + 1, VGAScaleX(319));
+
+		drawVLine(VGAScaleX(1), VGAScaleY(170) + 2, VGAScaleY(198)); /* The vertical high light lines */
+#if defined(DOSCODE)
+		drawVLine(VGAScaleX(126), VGAScaleY(170) + 2, VGAScaleY(198));
+		drawVLine(VGAScaleX(196), VGAScaleY(170) + 2, VGAScaleY(198));
+#else
+		drawVLine(VGAScaleX(92), VGAScaleY(170) + 2, VGAScaleY(198));
+		drawVLine(VGAScaleX(162), VGAScaleY(170) + 2, VGAScaleY(198));
+		drawVLine(VGAScaleX(232), VGAScaleY(170) + 2, VGAScaleY(198));
+#endif
+
+		drawGadgetList(InvGadgetList);
+	}
+
+	mouseShow();
+}
+
+
+extern bool LastMessageLong;
+
+static bool LastTooLong = false;
+
+
+
+
+/******************************************************************************/
+/* Draws the message for the room.                                            */
+/******************************************************************************/
+static void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr) {
+	char text[250], ManyText[8], *ManyPtr;
+
+	if (LastTooLong) {
+		LastTooLong = false;
+		return;
+	}
+
+	if (Alternate) {
+		if ((CurInv <= NumInv) && In(Conditions, CurInv) && Inventory[CurInv].BInvName) {
+			if ((CurInv == LAMPNUM) && In(Conditions, LAMPON))  /* LAB: Labyrith specific */
+				drawMessage(LAMPONMSG);
+			else if (Inventory[CurInv].Many > 1) {
+				ManyPtr = numtostr(ManyText, Inventory[CurInv].Many);
+				strcpy(text, Inventory[CurInv].name);
+				strcat(text, "  (");
+				strcat(text, ManyPtr);
+				strcat(text, ")");
+				drawMessage(text);
+			} else
+				drawMessage(Inventory[CurInv].name);
+		}
+	} else
+		drawDirection(cptr);
+
+	LastTooLong = LastMessageLong;
+}
+
+
+static uint16 OldMode;
+
+/******************************************************************************/
+/* Sets up the Labyrinth screens, and opens up the initial windows.           */
+/******************************************************************************/
+bool setUpScreens(void) {
+	uint16 counter;
+	byte *bufferstorage, **buffer = &bufferstorage;
+	struct Gadget *curgad;
+	uint16 y;
+
+	if (!createScreen(IsHiRes))
+		return false;
+
+	/* Loads in the graphics for the movement control panel */
+	MovePanelBufferSize = sizeOfFile("P:Control");
+
+	if (MovePanelBufferSize == 0L)
+		return false;
+
+	if (!allocate((void **) &MovePanelBuffer, MovePanelBufferSize))
+		return false;
+
+	Common::File *file = openPartial("P:Control");
+
+	if (!file)
+		return false;
+
+	file->read(MovePanelBuffer, MovePanelBufferSize);
+	file->close();
+
+	*buffer = MovePanelBuffer;
+
+	for (counter = 0; counter < 20; counter++)
+		readImage(buffer, &(MoveImages[counter]));
+
+	/* Creates the gadgets for the movement control panel */
+	y = VGAScaleY(173) - SVGACord(2);
+#if !defined(DOSCODE)
+	MoveGadgetList = createButton(VGAScaleX(1), y, 0, 't', MoveImages[0], MoveImages[1]);
+	curgad = MoveGadgetList;
+	curgad->NextGadget = createButton(VGAScaleX(33), y, 1, 'm', MoveImages[2], MoveImages[3]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(65), y, 2, 'o', MoveImages[4], MoveImages[5]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(97), y, 3, 'c', MoveImages[6], MoveImages[7]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(129), y, 4, 'l', MoveImages[8], MoveImages[9]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(161), y, 5, 'i', MoveImages[12], MoveImages[13]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(193), y, 6, VKEY_LTARROW, MoveImages[14], MoveImages[15]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(225), y, 7, VKEY_UPARROW, MoveImages[16], MoveImages[17]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(257), y, 8, VKEY_RTARROW, MoveImages[18], MoveImages[19]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(289), y, 9, 'p', MoveImages[10], MoveImages[11]);
+#else
+	MoveGadgetList = createButton(VGAScaleX(1), y, 0, MoveImages[0], MoveImages[1]);
+	curgad = MoveGadgetList;
+	curgad->NextGadget = createButton(VGAScaleX(33), y, 1, MoveImages[2], MoveImages[3]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(65), y, 2, MoveImages[4], MoveImages[5]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(97), y, 3, MoveImages[6], MoveImages[7]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(129), y, 4, MoveImages[8], MoveImages[9]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(161), y, 5, MoveImages[12], MoveImages[13]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(193), y, 6, MoveImages[14], MoveImages[15]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(225), y, 7, MoveImages[16], MoveImages[17]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(257), y, 8, MoveImages[18], MoveImages[19]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(289), y, 9, MoveImages[10], MoveImages[11]);
+#endif
+
+	InvPanelBufferSize = sizeOfFile("P:Inv");
+
+	if (InvPanelBufferSize == 0L)
+		return false;
+
+	if (!allocate((void **) &InvPanelBuffer, InvPanelBufferSize))
+		return false;
+
+	file = openPartial("P:Inv");
+
+	if (!file)
+		return false;
+
+	file->read(InvPanelBuffer, InvPanelBufferSize);
+	file->close();
+
+	*buffer = InvPanelBuffer;
+#if !defined(DOSCODE)
+
+	for (counter = 0; counter < 10; counter++)
+		readImage(buffer, &(InvImages[counter]));
+
+	InvGadgetList = createButton(VGAScaleX(24), y, 0, 'm', InvImages[0], InvImages[1]);
+	curgad = InvGadgetList;
+	curgad->NextGadget = createButton(VGAScaleX(56), y, 1, 'g', InvImages[2], InvImages[3]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(94), y, 2, 'u', InvImages[4], InvImages[5]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(126), y, 3, 'l', MoveImages[8], MoveImages[9]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(164), y, 4, VKEY_LTARROW, MoveImages[14], MoveImages[15]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(196), y, 5, VKEY_RTARROW, MoveImages[18], MoveImages[19]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(234), y, 6, 'b', InvImages[6], InvImages[7]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(266), y, 7, 'f', InvImages[8], InvImages[9]);
+	curgad = curgad->NextGadget;
+#else
+
+	for (counter = 0; counter < 6; counter++)
+		readImage(buffer, &(InvImages[counter]));
+
+	InvGadgetList = createButton(VGAScaleX(58), y, 0, InvImages[0], InvImages[1]);
+	curgad = InvGadgetList;
+	curgad->NextGadget = createButton(VGAScaleX(90), y, 1, InvImages[2], InvImages[3]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(128), y, 2, InvImages[4], InvImages[5]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(160), y, 3, MoveImages[8], MoveImages[9]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(198), y, 4, MoveImages[14], MoveImages[15]);
+	curgad = curgad->NextGadget;
+	curgad->NextGadget = createButton(VGAScaleX(230), y, 5, MoveImages[18], MoveImages[19]);
+	curgad = curgad->NextGadget;
+#endif
+
+	return true;
+}
+
+
+
+
+
+uint16 curmousex = 0, curmousey = 0;
+
+
+
+/******************************************************************************/
+/* Permanently flips the imagry of a gadget.                                  */
+/******************************************************************************/
+static void perFlipGadget(uint16 GadID) {
+	struct Image *Temp;
+	struct Gadget *TopGad;
+
+	TopGad = MoveGadgetList;
+
+	while (TopGad) {
+		if (TopGad->GadgetID == GadID) {
+			Temp = TopGad->Im;
+			TopGad->Im = TopGad->ImAlt;
+			TopGad->ImAlt = Temp;
+
+			if (!Alternate) {
+				mouseHide();
+				drawImage(TopGad->Im, TopGad->x, TopGad->y);
+				mouseShow();
+			}
+
+			return;
+		} else
+			TopGad = TopGad->NextGadget;
+	}
+}
+
+
+
+/******************************************************************************/
+/* Eats all the available messages.                                           */
+/******************************************************************************/
+void eatMessages(void) {
+	struct IntuiMessage *Msg;
+
+	do {
+		Msg = getMsg();
+
+		if (Msg) {
+			replyMsg((void *) Msg);
+		}
+	} while (Msg);
+
+	return;
+}
+
+
+
+
+
+static uint16 lastmusicroom = 1;
+
+
+/******************************************************************************/
+/* Checks the music that should be playing in a particular room.              */
+/******************************************************************************/
+static void checkRoomMusic(void) {
+	if ((lastmusicroom == RoomNum) || !g_music->_musicOn)
+		return;
+
+	if (RoomNum == CLOWNROOM)
+		g_music->changeMusic("Music:Laugh");
+	else if (RoomNum == DIMROOM)
+		g_music->changeMusic("Music:Rm81");
+	else if (!DoNotReset)
+		g_music->resetMusic();
+
+	lastmusicroom = RoomNum;
+}
+
+
+
+#if defined(DOSCODE)
+#define MONLTMARGIN     0
+#define MONRTMARGIN     319
+#define MONTOPMARGIN    0
+#define LUTERTMARGIN    124
+#else
+#define MONLTMARGIN     2
+#define MONRTMARGIN     317
+#define MONTOPMARGIN    2
+#define LUTERTMARGIN    128
+#endif
+
+/******************************************************************************/
+/* Checks whether the close up is one of the special case closeups.           */
+/******************************************************************************/
+static bool doCloseUp(CloseDataPtr cptr) {
+	if (cptr == NULL)
+		return false;
+
+	if ((cptr->CloseUpType == MUSEUMMONITOR) || (cptr->CloseUpType == LIBRARYMONITOR) ||
+	        (cptr->CloseUpType == WINDOWMONITOR))
+		doMonitor(cptr->GraphicName, cptr->Message, false, MONLTMARGIN, MONTOPMARGIN, MONRTMARGIN, 165);
+	else if (cptr->CloseUpType == GRAMAPHONEMONITOR)
+		doMonitor(cptr->GraphicName, cptr->Message, false, MONLTMARGIN, MONTOPMARGIN, 171, 165);
+	else if (cptr->CloseUpType == UNICYCLEMONITOR)
+		doMonitor(cptr->GraphicName, cptr->Message, false, 100, MONTOPMARGIN, MONRTMARGIN, 165);
+	else if (cptr->CloseUpType == STATUEMONITOR)
+		doMonitor(cptr->GraphicName, cptr->Message, false, 117, MONTOPMARGIN, MONRTMARGIN, 165);
+	else if (cptr->CloseUpType == TALISMANMONITOR)
+		doMonitor(cptr->GraphicName, cptr->Message, false, MONLTMARGIN, MONTOPMARGIN, 184, 165);
+	else if (cptr->CloseUpType == LUTEMONITOR)
+		doMonitor(cptr->GraphicName, cptr->Message, false, MONLTMARGIN, MONTOPMARGIN, LUTERTMARGIN, 165);
+	else if (cptr->CloseUpType == CLOCKMONITOR)
+		doMonitor(cptr->GraphicName, cptr->Message, false, MONLTMARGIN, MONTOPMARGIN, 206, 165);
+	else if (cptr->CloseUpType == TERMINALMONITOR)
+		doMonitor(cptr->GraphicName, cptr->Message, true, MONLTMARGIN, MONTOPMARGIN, MONRTMARGIN, 165);
+	else
+		return false;
+
+	CurFileName = " ";
+	drawPanel();
+
+	return true;
+}
+
+
+
+
+/******************************************************************************/
+/* Gets the current inventory name.                                           */
+/******************************************************************************/
+static const char *getInvName(uint16 CurInv) {
+	if (MainDisplay)
+		return Inventory[CurInv].BInvName;
+
+	if ((CurInv == LAMPNUM) && In(Conditions, LAMPON))
+		return "P:Mines/120";
+
+	else if ((CurInv == BELTNUM) && In(Conditions, BELTGLOW))
+		return "P:Future/BeltGlow";
+
+	else if (CurInv == WESTPAPERNUM) {
+		CurFileName = Inventory[CurInv].BInvName;
+		nopalchange = true;
+		readPict(CurFileName, false);
+		nopalchange = false;
+		doWestPaper();
+	}
+
+	else if (CurInv == NOTESNUM) {
+		CurFileName = Inventory[CurInv].BInvName;
+		nopalchange = true;
+		readPict(CurFileName, false);
+		nopalchange = false;
+		doNotes();
+	}
+
+	return Inventory[CurInv].BInvName;
+}
+
+
+
+
+static bool interfaceisoff = false;
+
+
+/******************************************************************************/
+/* Turns the interface off.                                                   */
+/******************************************************************************/
+static void interfaceOff(void) {
+	if (!interfaceisoff) {
+		attachGadgetList(NULL);
+		mouseHide();
+		interfaceisoff = true;
+	}
+}
+
+
+
+
+/******************************************************************************/
+/* Turns the interface on.                                                    */
+/******************************************************************************/
+static void interfaceOn(void) {
+	if (interfaceisoff) {
+		interfaceisoff = false;
+
+		mouseShow();
+	}
+
+	if (LongWinInFront)
+		attachGadgetList(NULL);
+	else if (Alternate)
+		attachGadgetList(InvGadgetList);
+	else
+		attachGadgetList(MoveGadgetList);
+}
+
+
+
+static const char *Test;
+
+
+/******************************************************************************/
+/* If the user hits the "Use" gadget; things that can get used on themselves. */
+/******************************************************************************/
+static bool doUse(uint16 CurInv) {
+
+	if (CurInv == MAPNUM) {                  /* LAB: Labyrinth specific */
+		drawMessage(USEMAP);
+		interfaceOff();
+		stopDiff();
+		CurFileName = " ";
+		CPtr = NULL;
+		doMap(RoomsFound, RoomNum);
+		VGASetPal(initcolors, 8);
+		drawMessage(NULL);
+		drawPanel();
+	}
+
+	else if (CurInv == JOURNALNUM) {         /* LAB: Labyrinth specific */
+		drawMessage(USEJOURNAL);
+		interfaceOff();
+		stopDiff();
+		CurFileName = " ";
+		CPtr = NULL;
+		doJournal(Conditions);
+		drawPanel();
+		drawMessage(NULL);
+	}
+
+	else if (CurInv == LAMPNUM) {            /* LAB: Labyrinth specific */
+		interfaceOff();
+
+		if (In(Conditions, LAMPON)) {
+			drawMessage(TURNLAMPOFF);
+			exclElement(Conditions, LAMPON);
+		} else {
+			drawMessage(TURNLAMPON);
+			inclElement(Conditions, LAMPON);
+		}
+
+		DoBlack = false;
+		waiteffect = true;
+		readPict("Music:Click", true);
+		waiteffect = false;
+
+		DoBlack = false;
+		Test = getInvName(CurInv);
+	}
+
+	else if (CurInv == BELTNUM) {                    /* LAB: Labyrinth specific */
+		if (!In(Conditions, BELTGLOW))
+			inclElement(Conditions, BELTGLOW);
+
+		DoBlack = false;
+		Test = getInvName(CurInv);
+	}
+
+	else if (CurInv == WHISKEYNUM) {                 /* LAB: Labyrinth specific */
+		inclElement(Conditions, USEDHELMET);
+		drawMessage(USEWHISKEY);
+	}
+
+	else if (CurInv == PITHHELMETNUM) {              /* LAB: Labyrinth specific */
+		inclElement(Conditions, USEDHELMET);
+		drawMessage(USEPITH);
+	}
+
+	else if (CurInv == HELMETNUM) {                  /* LAB: Labyrinth specific */
+		inclElement(Conditions, USEDHELMET);
+		drawMessage(USEHELMET);
+	}
+
+	else
+		return false;
+
+	return true;
+}
+
+
+
+
+/******************************************************************************/
+/* Decrements the current inventory number.                                   */
+/******************************************************************************/
+static void decIncInv(uint16 *CurInv, bool dec) {
+	interfaceOff();
+
+	if (dec)
+		(*CurInv)--;
+	else
+		(*CurInv)++;
+
+	while (*CurInv && (*CurInv <= NumInv)) {
+		if (In(Conditions, *CurInv) && Inventory[*CurInv].BInvName) {
+			Test = getInvName(*CurInv);
+			break;
+		}
+
+		if (dec)
+			(*CurInv)--;
+		else
+			(*CurInv)++;
+	}
+
+	if ((*CurInv == 0) || (*CurInv > NumInv)) {
+		if (dec)
+			*CurInv = NumInv;
+		else
+			*CurInv = 1;
+
+		while (*CurInv && (*CurInv <= NumInv)) {
+			if (In(Conditions, *CurInv) && Inventory[*CurInv].BInvName) {
+				Test = getInvName(*CurInv);
+				break;
+			}
+
+			if (dec)
+				(*CurInv)--;
+			else
+				(*CurInv)++;
+		}
+	}
+}
+
+
+#if defined(DOSCODE)
+static bool nosvgamem = false;
+static bool didintro = false;
+#else
+int didintro = false; // change to int do labw.c can access
+#endif
+static bool novesa = false, noaudio = false;
+
+
+void processEvents() {
+	warning("STUB: processEvents()");
+}
+
+/******************************************************************************/
+/* Processes user input events.                                               */
+/******************************************************************************/
+static void process(void) {
+	struct IntuiMessage *Msg;
+	uint32 Class;
+
+	uint16 Code, Qualifier, MouseX, MouseY, ActionMode = 4, CurInv = MAPNUM, /* Lab: Labyrinth specific initialization */
+	                                        LastInv = MAPNUM,     /* Lab: Labyrinth specific initialization */
+	                                        Old;
+
+	bool ForceDraw   = false, doit, GotMessage  = true;
+
+	uint16 OldRoomNum,
+#if !defined(DOSCODE)
+	       OldDirection,
+#endif
+	       GadID, NewDir;
+
+	CloseDataPtr OldCPtr, TempCPtr, HCPtr    = NULL;
+	ViewDataPtr VPtr;
+
+	VGASetPal(initcolors, 8);
+
+	CPtr    = NULL;
+	RoomNum = 1;
+	Direction = NORTH;
+
+	readRoomData("LAB:Doors");
+	readInventory("LAB:Inventor");
+
+	if (!createSet(&Conditions, HighestCondition + 1))
+		return;
+
+	if (!createSet(&RoomsFound, ManyRooms + 1))
+		return;
+
+	readInitialConditions(Conditions, "LAB:Conditio");
+
+	LongWinInFront = false;
+	drawPanel();
+
+	perFlipGadget(ActionMode);
+
+	/* Set up initial picture. */
+
+	while (1) {
+		processEvents();
+
+		if (GotMessage) {
+			if (QuitLab) {
+				stopDiff();
+				break;
+			}
+
+			g_music->restartBackMusic();
+
+			/* Sees what kind of close up we're in and does the appropriate stuff, if any. */
+			if (doCloseUp(CPtr)) {
+				CPtr = NULL;
+#if !defined(DOSCODE)
+				mayShowCrumbIndicator();
+				g_system->updateScreen();
+#endif
+			}
+
+			/* Sets the current picture properly on the screen */
+			if (MainDisplay)
+				Test = getPictName(&CPtr);
+
+			if (noupdatediff) {
+				inclElement(RoomsFound, RoomNum); /* Potentially entered another room */
+				ForceDraw = (strcmp(Test, CurFileName) != 0) || ForceDraw;
+
+				noupdatediff = false;
+				CurFileName = Test;
+			}
+
+			else if (strcmp(Test, CurFileName) != 0) {
+				interfaceOff();
+				inclElement(RoomsFound, RoomNum); /* Potentially entered another room */
+				CurFileName = Test;
+
+				if (CPtr) {
+					if ((CPtr->CloseUpType == SPECIALLOCK) && MainDisplay)  /* LAB: Labyrinth specific code */
+						showCombination(CurFileName);
+					else if (((CPtr->CloseUpType == SPECIALBRICK)  ||
+					          (CPtr->CloseUpType == SPECIALBRICKNOMOUSE)) &&
+					         MainDisplay) /* LAB: Labyrinth specific code */
+						showTile(CurFileName, (bool)(CPtr->CloseUpType == SPECIALBRICKNOMOUSE));
+					else
+						readPict(CurFileName, false);
+				} else
+					readPict(CurFileName, false);
+
+				drawRoomMessage(CurInv, CPtr);
+				ForceDraw = false;
+
+#if !defined(DOSCODE)
+				mayShowCrumbIndicator();
+				g_system->updateScreen();
+
+				if (!FollowingCrumbs)
+					eatMessages();
+
+#else
+				eatMessages();
+#endif
+			}
+
+			if (ForceDraw) {
+				drawRoomMessage(CurInv, CPtr);
+				ForceDraw = false;
+#if !defined(DOSCODE)
+				g_system->updateScreen();
+#endif
+			}
+		}
+
+		g_music->checkMusic();  /* Make sure we check the music at least after every message */
+		interfaceOn();
+		Msg = getMsg();
+
+		if (Msg == NULL) { /* Does music load and next animation frame when you've run out of messages */
+			GotMessage = false;
+			checkRoomMusic();
+			g_music->newCheckMusic();
+			diffNextFrame();
+#if !defined(DOSCODE)
+
+			if (FollowingCrumbs) {
+				int result = followCrumbs();
+
+				if (result != 0) {
+					int x = 0, y = 0;
+
+					warning("STUB: getMousePos()");
+					//SDL_GetMousePos(&x, &y);
+
+					Class     = GADGETUP;
+					Qualifier = 0;
+					MouseX    = x;
+					MouseY    = y;
+
+					if (result == VKEY_UPARROW) {
+						Code = GadID = 7;
+					} else if (result == VKEY_LTARROW) {
+						Code = GadID = 6;
+					} else if (result == VKEY_RTARROW) {
+						Code = GadID = 8;
+					}
+
+					GotMessage = true;
+					mayShowCrumbIndicator();
+					g_system->updateScreen();
+					goto from_crumbs;
+				}
+			}
+
+			mayShowCrumbIndicator();
+			g_system->updateScreen();
+#endif
+		} else {
+			GotMessage = true;
+
+			Class     = Msg->Class;
+			Code      = Msg->Code;
+			Qualifier = Msg->Qualifier;
+			MouseX    = Msg->MouseX;
+			MouseY    = Msg->MouseY;
+			GadID     = Msg->GadgetID;
+
+			replyMsg((void *) Msg);
+
+#if !defined(DOSCODE)
+			FollowingCrumbs = false;
+
+from_crumbs:
+#endif
+			DoBlack = false;
+
+			if ((Class == RAWKEY) && (!LongWinInFront)) {
+				if (Code == 13) { /* The return key */
+					Class     = MOUSEBUTTONS;
+					Qualifier = IEQUALIFIER_LEFTBUTTON;
+					mouseXY(&MouseX, &MouseY);
+				}
+
+#if !defined(DOSCODE)
+				else if (Code == 'b' || Code == 'B') {  /* Start bread crumbs */
+					BreadCrumbs[0].RoomNum = 0;
+					NumCrumbs = 0;
+					DroppingCrumbs = true;
+					mayShowCrumbIndicator();
+					g_system->updateScreen();
+				}
+
+				else if (Code == 'f' || Code == 'F' ||
+				         Code == 'r' || Code == 'R') {  /* Follow bread crumbs */
+					if (DroppingCrumbs) {
+						if (NumCrumbs > 0) {
+							FollowingCrumbs = true;
+							FollowCrumbsFast = (Code == 'r' || Code == 'R');
+							IsCrumbTurning = false;
+							IsCrumbWaiting = false;
+							getTime(&CrumbSecs, &CrumbMicros);
+
+							if (Alternate) {
+								eatMessages();
+								Alternate = false;
+								DoBlack = true;
+								DoNotDrawMessage = false;
+
+								MainDisplay = true;
+								interfaceOn(); /* Sets the correct gadget list */
+								drawPanel();
+								drawRoomMessage(CurInv, CPtr);
+								g_system->updateScreen();
+							}
+						} else {
+							BreadCrumbs[0].RoomNum = 0;
+							DroppingCrumbs = false;
+
+							// Need to hide indicator!!!!
+							mayShowCrumbIndicatorOff();
+							g_system->updateScreen();
+						}
+					}
+				}
+
+#endif
+
+				else if ((Code == 315) || (Code == 'x') || (Code == 'X')
+				         || (Code == 'q') || (Code == 'Q')) {  /* Quit? */
+					DoNotDrawMessage = false;
+					drawMessage("Do you want to quit? (Y/N)");
+					doit = false;
+					eatMessages();
+					interfaceOff();
+
+					while (1) {
+						g_music->checkMusic();  /* Make sure we check the music at least after every message */
+						Msg = getMsg();
+
+						if (Msg == NULL) { /* Does music load and next animation frame when you've run out of messages */
+							g_music->newCheckMusic();
+							diffNextFrame();
+						} else {
+							replyMsg((void *) Msg);    /* Can't do this in non-IBM versions */
+
+							if (Msg->Class == RAWKEY) {
+#if defined(DOSCODE)
+
+								if ((Msg->Code == 'Y') || (Msg->Code == 'y'))
+#else
+								if ((Msg->Code == 'Y') || (Msg->Code == 'y') || (Msg->Code == 'Q') || (Msg->Code == 'q'))
+#endif
+								{
+									doit = true;
+									break;
+								} else if (Msg->Code < 128) {
+									break;
+								}
+							} else if (Msg->Class == MOUSEBUTTONS) {
+								break;
+							}
+						}
+					}
+
+					if (doit) {
+						stopDiff();
+						break;
+					} else {
+						ForceDraw = true;
+						interfaceOn();
+					}
+				}
+
+#ifdef undef
+				else if (Code == 324) {
+					if (BUFFERSIZE >= BIGBUFFERSIZE) { /* F10 key to switch resolutions */
+						blackAllScreen();
+						setMode((char) OldMode);
+
+						Alternate = false;
+						MainDisplay = true;
+						attachGadgetList(NULL);
+						fillUpMusic(true);
+						g_system->delayMillis(750);
+
+						IsHiRes = !IsHiRes;
+
+						deallocate(MovePanelBuffer, MovePanelBufferSize);
+						deallocate(InvPanelBuffer, InvPanelBufferSize);
+						freeButtonList(MoveGadgetList);
+						freeButtonList(InvGadgetList);
+						MoveGadgetList = NULL;
+						InvGadgetList = NULL;
+
+						if (!setUpScreens()) {
+							IsHiRes = false;
+							setUpScreens();
+						}
+
+						blackAllScreen();
+						resetBuffer();
+						CPtr = NULL;
+						DoBlack = true;
+						CurFileName = " ";
+						closeFont(MsgFont);
+						openFont("P:AvanteG.12", &MsgFont);
+						/*
+						            mouseReset();
+						 */
+						initMouse();
+						drawPanel();
+						perFlipGadget(ActionMode);
+					} else
+						drawMessage("Not enough memory to change resolutions.");
+				}
+
+#endif
+
+				else if (Code == 9) { /* TAB key */
+					Class = DELTAMOVE;
+				}
+
+				else if (Code == 27) { /* ESC key */
+					CPtr = NULL;
+				}
+
+				eatMessages();
+			}
+
+			if (LongWinInFront) {
+				if ((Class == RAWKEY) ||
+				        ((Class == MOUSEBUTTONS) &&
+				         ((IEQUALIFIER_LEFTBUTTON & Qualifier) ||
+				          (IEQUALIFIER_RBUTTON & Qualifier)))) {
+					LongWinInFront = false;
+					DoNotDrawMessage = false;
+					drawPanel();
+					drawRoomMessage(CurInv, CPtr);
+#if !defined(DOSCODE)
+					g_system->updateScreen();
+#endif
+				}
+			}
+
+			else if ((Class == GADGETUP) && !Alternate) {
+				if (GadID <= 5) {
+					if ((ActionMode == 4) && (GadID == 4) && (CPtr != NULL)) {
+						doMainView(&CPtr);
+
+						DoBlack = true;
+						HCPtr = NULL;
+						CPtr = NULL;
+#if !defined(DOSCODE)
+						mayShowCrumbIndicator();
+						g_system->updateScreen();
+#endif
+					}
+
+					else if (GadID == 5) {
+						eatMessages();
+
+						Alternate = true;
+						DoBlack = true;
+						DoNotDrawMessage = false;
+						interfaceOn(); /* Sets the correct gadget list */
+
+						MainDisplay = false;
+
+						if (LastInv && In(Conditions, LastInv)) {
+							CurInv = LastInv;
+							Test = getInvName(CurInv);
+						} else
+							decIncInv(&CurInv, false);
+
+						drawPanel();
+						drawRoomMessage(CurInv, CPtr);
+#if !defined(DOSCODE)
+						mayShowCrumbIndicator();
+						g_system->updateScreen();
+#endif
+					} else {
+						Old        = ActionMode;
+						ActionMode = GadID;
+
+						if (Old < 5)
+							perFlipGadget(Old);
+
+						perFlipGadget(ActionMode);
+
+						if (GadID == 0)
+							drawMessage(TAKEWHAT);
+						else if (GadID == 1)
+							drawMessage(MOVEWHAT);
+						else if (GadID == 2)
+							drawMessage(OPENWHAT);
+						else if (GadID == 3)
+							drawMessage(CLOSEWHAT);
+						else if (GadID == 4)
+							drawMessage(LOOKWHAT);
+
+#if !defined(DOSCODE)
+						g_system->updateScreen();
+#endif
+					}
+				}
+
+				else if (GadID == 9) {
+					doUse(MAPNUM);
+#if !defined(DOSCODE)
+					mayShowCrumbIndicator();
+					g_system->updateScreen();
+#endif
+				}
+
+				else if (GadID >= 6) { /* Arrow Gadgets */
+					CPtr = NULL;
+					HCPtr = NULL;
+
+					if ((GadID == 6) || (GadID == 8)) {
+						if (GadID == 6)
+							drawMessage(TURNLEFT);
+						else
+							drawMessage(TURNRIGHT);
+
+						CurFileName = " ";
+#if !defined(DOSCODE)
+						OldDirection = Direction;
+#endif
+						NewDir = Direction;
+						processArrow(&NewDir, GadID - 6);
+						doTurn(Direction, NewDir, &CPtr);
+						DoBlack = true;
+						Direction = NewDir;
+						ForceDraw = true;
+#if !defined(DOSCODE)
+						mayShowCrumbIndicator();
+						g_system->updateScreen();
+#endif
+					} else if (GadID == 7) {
+						OldRoomNum = RoomNum;
+
+						if (doGoForward(&CPtr)) {
+							if (OldRoomNum == RoomNum)
+								DoBlack = true;
+						} else {
+							DoBlack = true;
+							processArrow(&Direction, GadID - 6);
+
+							if (OldRoomNum != RoomNum) {
+								drawMessage(GOFORWARDDIR);
+								inclElement(RoomsFound, RoomNum); /* Potentially entered a new room */
+								CurFileName = " ";
+								ForceDraw = true;
+							} else {
+								DoBlack = true;
+								drawMessage(NOPATH);
+							}
+						}
+
+#if defined(DEMODATA)
+						{
+							void writeDemoData();
+							writeDemoData();
+						}
+#endif
+
+#if !defined(DOSCODE)
+
+						if (FollowingCrumbs) {
+							if (IsCrumbTurning) {
+								if (Direction == OldDirection) {
+									FollowingCrumbs = false;
+								}
+							} else {
+								if (RoomNum == OldRoomNum) { // didn't get there?
+									FollowingCrumbs = false;
+								}
+							}
+						} else if (DroppingCrumbs && OldRoomNum != RoomNum) {
+							// If in surreal maze, turn off DroppingCrumbs.
+							// Note: These numbers were generated by parsing the
+							// "Maps" file, which is why they are hard-coded. Bleh!
+							if (RoomNum >= 245 && RoomNum <= 280) {
+								FollowingCrumbs = false;
+								DroppingCrumbs = false;
+								NumCrumbs = 0;
+								BreadCrumbs[0].RoomNum = 0;
+							} else {
+								bool intersect = false;
+								int i;
+
+								for (i = 0; i < NumCrumbs; i++) {
+									if (BreadCrumbs[i].RoomNum == RoomNum) {
+										NumCrumbs = i + 1;
+										BreadCrumbs[NumCrumbs].RoomNum = 0;
+										intersect = true;
+									}
+								}
+
+								if (!intersect) {
+									if (NumCrumbs == MAX_CRUMBS) {
+										NumCrumbs = MAX_CRUMBS - 1;
+										memcpy(&BreadCrumbs[0], &BreadCrumbs[1], NumCrumbs * sizeof BreadCrumbs[0]);
+									}
+
+									BreadCrumbs[NumCrumbs].RoomNum = RoomNum;
+									BreadCrumbs[NumCrumbs++].Direction = Direction;
+								}
+							}
+						}
+
+						mayShowCrumbIndicator();
+						g_system->updateScreen();
+#endif
+					}
+				}
+			}
+
+			else if ((Class == GADGETUP) && Alternate) {
+				DoBlack = true;
+
+				if (GadID == 0) {
+					eatMessages();
+					Alternate = false;
+					DoBlack = true;
+					DoNotDrawMessage = false;
+
+					MainDisplay = true;
+					interfaceOn(); /* Sets the correct gadget list */
+					drawPanel();
+					drawRoomMessage(CurInv, CPtr);
+#if !defined(DOSCODE)
+					g_system->updateScreen();
+#endif
+				}
+
+				GadID--;
+
+				if (GadID == 0) {
+					interfaceOff();
+					stopDiff();
+					CurFileName = " ";
+
+					doit = !saveRestoreGame();
+					CPtr = NULL;
+
+					MainDisplay = true;
+
+					CurInv = MAPNUM;
+					LastInv = MAPNUM;
+
+					Test = getInvName(CurInv);
+
+					drawPanel();
+
+					if (doit) {
+						drawMessage("Disk operation failed.");
+						VGASetPal(initcolors, 8);
+#if !defined(DOSCODE)
+						g_system->updateScreen();
+#endif
+						g_system->delayMillis(1000);
+					}
+
+#if !defined(DOSCODE)
+					else {
+						g_system->updateScreen();
+					}
+
+#endif
+				}
+
+				else if (GadID == 1) {
+					if (!doUse(CurInv)) {
+						Old        = ActionMode;
+						ActionMode = 5;  /* Use button */
+
+						if (Old < 5)
+							perFlipGadget(Old);
+
+						drawMessage(USEONWHAT);
+						MainDisplay = true;
+#if !defined(DOSCODE)
+						g_system->updateScreen();
+#endif
+					}
+				}
+
+				else if (GadID == 2) {
+					MainDisplay = !MainDisplay;
+
+					if ((CurInv == 0) || (CurInv > NumInv)) {
+						CurInv = 1;
+
+						while ((CurInv <= NumInv) && (!In(Conditions, CurInv)))
+							CurInv++;
+					}
+
+					if ((CurInv <= NumInv) && In(Conditions, CurInv) &&
+					        Inventory[CurInv].BInvName)
+						Test = getInvName(CurInv);
+
+#if !defined(DOSCODE)
+					g_system->updateScreen();
+#endif
+				}
+
+				else if (GadID == 3) { /* Left gadget */
+					decIncInv(&CurInv, true);
+					LastInv = CurInv;
+					DoNotDrawMessage = false;
+					drawRoomMessage(CurInv, CPtr);
+#if !defined(DOSCODE)
+					g_system->updateScreen();
+#endif
+				}
+
+				else if (GadID == 4) { /* Right gadget */
+					decIncInv(&CurInv, false);
+					LastInv = CurInv;
+					DoNotDrawMessage = false;
+					drawRoomMessage(CurInv, CPtr);
+#if !defined(DOSCODE)
+					g_system->updateScreen();
+#endif
+				}
+
+#if !defined(DOSCODE)
+				else if (GadID == 5) { /* bread crumbs */
+					BreadCrumbs[0].RoomNum = 0;
+					NumCrumbs = 0;
+					DroppingCrumbs = true;
+					mayShowCrumbIndicator();
+					g_system->updateScreen();
+				}
+
+				else if (GadID == 6) { /* follow crumbs */
+					if (DroppingCrumbs) {
+						if (NumCrumbs > 0) {
+							FollowingCrumbs = true;
+							FollowCrumbsFast = false;
+							IsCrumbTurning = false;
+							IsCrumbWaiting = false;
+							getTime(&CrumbSecs, &CrumbMicros);
+
+							eatMessages();
+							Alternate = false;
+							DoBlack = true;
+							DoNotDrawMessage = false;
+
+							MainDisplay = true;
+							interfaceOn(); /* Sets the correct gadget list */
+							drawPanel();
+							drawRoomMessage(CurInv, CPtr);
+							g_system->updateScreen();
+						} else {
+							BreadCrumbs[0].RoomNum = 0;
+							DroppingCrumbs = false;
+
+							// Need to hide indicator!!!!
+							mayShowCrumbIndicatorOff();
+							g_system->updateScreen();
+						}
+					}
+				}
+			}
+
+#endif
+
+			else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier) && MainDisplay) {
+				interfaceOff();
+				MainDisplay = true;
+
+				doit = false;
+
+				if (CPtr) {
+					if ((CPtr->CloseUpType == SPECIALLOCK) && MainDisplay) /* LAB: Labrinth specific code */
+						mouseCombination(Conditions, MouseX, MouseY);
+					else if ((CPtr->CloseUpType == SPECIALBRICK) && MainDisplay)
+						mouseTile(Conditions, MouseX, MouseY);
+					else
+						doit = true;
+				} else
+					doit = true;
+
+
+				if (doit) {
+					HCPtr = NULL;
+					eatMessages();
+
+					if (ActionMode == 0) { /* Take something. */
+						if (doActionRule(MouseX, MouseY, ActionMode, RoomNum, &CPtr))
+							CurFileName = NewFileName;
+						else if (takeItem(MouseX, MouseY, &CPtr))
+							drawMessage(TAKEITEM);
+						else if (doActionRule(MouseX, MouseY, TAKEDEF - 1, RoomNum, &CPtr))
+							CurFileName = NewFileName;
+						else if (doActionRule(MouseX, MouseY, TAKE - 1, 0, &CPtr))
+							CurFileName = NewFileName;
+						else if (MouseY < (VGAScaleY(149) + SVGACord(2)))
+							drawMessage(NOTHING);
+					}
+
+					else if ((ActionMode == 1) /* Manipulate an object */  ||
+					         (ActionMode == 2) /* Open up a "door" */      ||
+					         (ActionMode == 3)) { /* Close a "door" */
+						if (doActionRule(MouseX, MouseY, ActionMode, RoomNum, &CPtr))
+							CurFileName = NewFileName;
+						else if (!doActionRule(MouseX, MouseY, ActionMode, 0, &CPtr)) {
+							if (MouseY < (VGAScaleY(149) + SVGACord(2)))
+								drawMessage(NOTHING);
+						}
+					}
+
+					else if (ActionMode == 4) { /* Look at closeups */
+						TempCPtr = CPtr;
+						setCurClose(MouseX, MouseY, &TempCPtr);
+
+						if (CPtr == TempCPtr) {
+							if (MouseY < (VGAScaleY(149) + SVGACord(2)))
+								drawMessage(NOTHING);
+						} else if (TempCPtr->GraphicName) {
+							if (*(TempCPtr->GraphicName)) {
+								DoBlack = true;
+								CPtr = TempCPtr;
+							} else if (MouseY < (VGAScaleY(149) + SVGACord(2)))
+								drawMessage(NOTHING);
+						} else if (MouseY < (VGAScaleY(149) + SVGACord(2)))
+							drawMessage(NOTHING);
+					}
+
+					else if ((ActionMode == 5)  &&
+					         In(Conditions, CurInv)) { /* Use an item on something else */
+						if (doOperateRule(MouseX, MouseY, CurInv, &CPtr)) {
+							CurFileName = NewFileName;
+
+							if (!In(Conditions, CurInv))
+								decIncInv(&CurInv, false);
+						} else if (MouseY < (VGAScaleY(149) + SVGACord(2)))
+							drawMessage(NOTHING);
+					}
+				}
+
+#if !defined(DOSCODE)
+				mayShowCrumbIndicator();
+				g_system->updateScreen();
+#endif
+			}
+
+			else if (Class == DELTAMOVE) {
+				VPtr = getViewData(RoomNum, Direction);
+				OldCPtr = VPtr->closeUps;
+
+				if (HCPtr == NULL) {
+					TempCPtr = CPtr;
+					setCurClose(MouseX, MouseY, &TempCPtr);
+
+					if ((TempCPtr == NULL) || (TempCPtr == CPtr)) {
+						if (CPtr == NULL)
+							HCPtr = OldCPtr;
+						else
+							HCPtr = CPtr->SubCloseUps;
+					} else
+						HCPtr = TempCPtr->NextCloseUp;
+				} else
+					HCPtr = HCPtr->NextCloseUp;
+
+
+				if (HCPtr == NULL) {
+					if (CPtr == NULL)
+						HCPtr = OldCPtr;
+					else
+						HCPtr = CPtr->SubCloseUps;
+				}
+
+				if (HCPtr)
+					mouseMove(scaleX((HCPtr->x1 + HCPtr->x2) / 2), scaleY((HCPtr->y1 + HCPtr->y2) / 2));
+			}
+
+			else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) {
+				eatMessages();
+				Alternate = !Alternate;
+				DoBlack = true;
+				DoNotDrawMessage = false;
+				MainDisplay = true;
+				interfaceOn(); /* Sets the correct gadget list */
+
+				if (Alternate) {
+					if (LastInv && In(Conditions, LastInv))
+						CurInv = LastInv;
+					else
+						decIncInv(&CurInv, false);
+				}
+
+				drawPanel();
+				drawRoomMessage(CurInv, CPtr);
+#if !defined(DOSCODE)
+				mayShowCrumbIndicator();
+				g_system->updateScreen();
+#endif
+			}
+		}
+	}
+
+	if (Conditions)
+		deleteSet(Conditions);
+
+	if (RoomsFound)
+		deleteSet(RoomsFound);
+
+	if (Rooms)
+		deallocate(Rooms, (ManyRooms + 1) * sizeof(RoomData));
+
+	if (Inventory) {
+		for (Code = 1; Code <= NumInv; Code++) {
+			if (Inventory[Code].name)
+				deallocate(Inventory[Code].name, strlen(Inventory[Code].name) + 1);
+
+			if (Inventory[Code].BInvName)
+				deallocate(Inventory[Code].BInvName, strlen(Inventory[Code].BInvName) + 1);
+		}
+
+		deallocate(Inventory, (NumInv + 1) * sizeof(InventoryData));
+	}
+}
+
+
+/*
+   void mySignalHandler(int sig)
+   {
+   signal(sig, mySignalHandler);
+   }
+ */
+
+
+
+#if defined(DOSCODE)
+void (__interrupt __far *oldctrlc)(), (__interrupt __far *oldctrlcb)();
+
+uint16 iretdummy;
+void __interrupt __far myiret() {
+	iretdummy++;
+}
+#endif
+
+
+void inner_main() {
+	bool mem, dointro = false;
+	uint16 counter;
+
+	getMode(&OldMode);
+
+	IsHiRes = true;
+	DoMusic = true;
+	g_music->_turnMusicOn = true;
+	dointro = true;
+
+#if 0
+	for (counter = 1; counter < argc; counter++) {
+#if defined(DOSCODE)
+
+		if (((argv[counter])[0] == 'v') || ((argv[counter])[0] == 'V')) {
+			IsHiRes = false;
+		} else
+#endif
+			if (((argv[counter])[0] == 'q') || ((argv[counter])[0] == 'Q')) {
+				DoMusic = false;
+				g_music->_turnMusicOn = false;
+			}
+
+#ifdef _DEBUG
+			else if (((argv[counter])[0] == 'i') || ((argv[counter])[0] == 'I')) {
+				dointro = false;
+			}
+
+#endif
+			else if (((argv[counter])[0] == '/') && ((argv[counter])[1] == '?')) {
+				debug("\n\nPlayer Version 1.0.  Copyright (c) 1993 Terra Nova Development\n");
+				debug("Player v q\n");
+#ifdef _DEBUG
+				debug("    i : Skip intro (debug only).\n");
+#endif
+#if defined(DOSCODE)
+				debug("    v : Open up on a low res VGA display.\n");
+#endif
+				debug("    q : Start in quiet mode; no sound output.\n\n");
+				return;
+			}
+	}
+#endif
+
+	if (initBuffer(BUFFERSIZE, true)) {
+		mem = true;
+	} else {
+#if defined(DOSCODE)
+		BUFFERSIZE = SMALLBUFFERSIZE;
+		mem = initBuffer(BUFFERSIZE, true);
+		IsHiRes = false;
+		nosvgamem = true;
+#else
+		// unacceptable !!!!
+		warning("initBuffer() failed");
+		return;
+#endif
+	}
+
+	if (!initAudio()) {
+		noaudio = true;
+		DoMusic = false;
+		g_music->_turnMusicOn = false;
+		debug("Could not open Audio.");
+		g_system->delayMillis(500);
+	}
+
+	if (!setUpScreens()) {
+		IsHiRes = false;
+		novesa = true;
+		mem = mem && setUpScreens();
+	}
+
+	if (!initMouse()) {
+		setMode((char) OldMode);
+#if defined(DOSCODE)
+		_dos_setvect(0x23, oldctrlc);
+		_dos_setvect(0x1B, oldctrlcb);
+#endif
+		debug("\n\nMouse or mouse driver not installed!\n\n");
+		return;
+	}
+
+	mem = mem && initRoomBuffer() &&
+	      initLabText();
+
+	doDisks();
+
+	if (!dointro)
+		g_music->initMusic();
+
+	openFont("P:AvanteG.12", &MsgFont);
+
+	if (dointro && mem) {
+#if defined(DOSCODE)
+		didintro = true;
+#endif
+		introSequence();
+#if !defined(DOSCODE)
+		didintro = true;
+#endif
+	} else
+		DoBlack = true;
+
+	if (mem) {
+		mouseShow();
+		process();
+	} else
+		debug("\n\nNot enough memory to start game.\n\n");
+
+	if (QuitLab) { /* Won the game */
+		blackAllScreen();
+		readPict("P:End/L2In.1", true);
+
+		for (counter = 0; counter < 120; counter++) {
+			g_music->newCheckMusic();
+			waitTOF();
+		}
+
+		readPict("P:End/L2In.9", true);
+		readPict("P:End/Lost", true);
+
+#if defined(DOSCODE)
+		counter = 600;
+
+		while (counter) {
+			newCheckMusic();
+			diffNextFrame();
+			waitTOF();
+			counter--;
+		}
+
+#else
+
+		warning("STUB: waitForPress");
+		while (!1) { // 1 means ignore SDL_ProcessInput calls
+			g_music->newCheckMusic();
+			diffNextFrame();
+			waitTOF();
+		}
+
+		// If we weren't exiting, a call to a mythical SDL_StopWaitForPress() would be in order.
+#endif
+	}
+
+	closeFont(MsgFont);
+
+	freeLabText();
+	freeRoomBuffer();
+	freeBuffer();
+
+	g_music->freeMusic();
+	freeAudio();
+
+	mouseReset();
+	setMode((char) OldMode);
+
+#if defined(DOSCODE)
+	_dos_setvect(0x23, oldctrlc);
+	_dos_setvect(0x1B, oldctrlcb);
+#endif
+}
+
+#if !defined(DOSCODE)
+/*****************************************************************************/
+/* New code to allow quick(er) return navigation in game.                    */
+/*****************************************************************************/
+int followCrumbs() {
+	// NORTH, SOUTH, EAST, WEST
+	static int movement[4][4] = {
+		{ VKEY_UPARROW, VKEY_RTARROW, VKEY_RTARROW, VKEY_LTARROW }, { VKEY_RTARROW, VKEY_UPARROW, VKEY_LTARROW, VKEY_RTARROW }, { VKEY_LTARROW, VKEY_RTARROW, VKEY_UPARROW, VKEY_RTARROW }, { VKEY_RTARROW, VKEY_LTARROW, VKEY_RTARROW, VKEY_UPARROW }
+#if 0
+		{ -1, EAST, EAST, WEST }, { WEST, -1, EAST, WEST }, { NORTH, SOUTH, -1, SOUTH }, { NORTH, SOUTH, NORTH, -1 }
+#endif
+	};
+
+	int ExitDir;
+	int MoveDir;
+
+	if (IsCrumbWaiting) {
+		uint32 Secs;
+		uint32 Micros;
+
+		timeDiff(CrumbSecs, CrumbMicros, &Secs, &Micros);
+
+		if (Secs != 0 || Micros != 0)
+			return 0;
+
+		IsCrumbWaiting = false;
+	}
+
+	if (!IsCrumbTurning)
+		BreadCrumbs[NumCrumbs--].RoomNum = 0;
+
+	// Is the current crumb this room? If not, logic error.
+	if (RoomNum != BreadCrumbs[NumCrumbs].RoomNum) {
+		NumCrumbs = 0;
+		BreadCrumbs[0].RoomNum = 0;
+		DroppingCrumbs = false;
+		FollowingCrumbs = false;
+		return 0;
+	}
+
+	// which direction is last crumb
+	if (BreadCrumbs[NumCrumbs].Direction == EAST)
+		ExitDir = WEST;
+	else if (BreadCrumbs[NumCrumbs].Direction == WEST)
+		ExitDir = EAST;
+	else if (BreadCrumbs[NumCrumbs].Direction == NORTH)
+		ExitDir = SOUTH;
+	else
+		ExitDir = NORTH;
+
+	MoveDir = movement[Direction][ExitDir];
+
+	if (NumCrumbs == 0) {
+		IsCrumbTurning = false;
+		BreadCrumbs[0].RoomNum = 0;
+		DroppingCrumbs = false;
+		FollowingCrumbs = false;
+	} else {
+		int theDelay = (FollowCrumbsFast ? ONESECOND / 4 : ONESECOND);
+
+		IsCrumbTurning = (MoveDir != VKEY_UPARROW);
+		IsCrumbWaiting = true;
+
+		addCurTime(theDelay / ONESECOND, theDelay % ONESECOND, &CrumbSecs, &CrumbMicros);
+	}
+
+	return MoveDir;
+}
+
+byte dropCrumbs[] = { 0x00 };
+byte dropCrumbsOff[] = { 0x00 };
+
+struct Image DropCrumbsImage = { 24, 24, dropCrumbs };
+struct Image DropCrumbsOffImage = { 24, 24, dropCrumbsOff };
+
+void mayShowCrumbIndicator() {
+	if (DroppingCrumbs && MainDisplay) {
+		mouseHide();
+		drawMaskImage(&DropCrumbsImage, 612, 4);
+		mouseShow();
+	}
+}
+
+void mayShowCrumbIndicatorOff() {
+	if (MainDisplay) {
+		mouseHide();
+		drawMaskImage(&DropCrumbsOffImage, 612, 4);
+		mouseShow();
+	}
+}
+#endif
+
+} // End of namespace Lab
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
new file mode 100644
index 0000000..bcaed9c
--- /dev/null
+++ b/engines/lab/graphics.cpp
@@ -0,0 +1,902 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/stddefines.h"
+#include "lab/diff.h"
+#include "lab/parsetypes.h"
+#include "lab/labfun.h"
+#include "lab/parsefun.h"
+#include "lab/mouse.h"
+#include "lab/vga.h"
+#include "lab/text.h"
+
+namespace Lab {
+
+struct BitMap bit1, bit2, *DispBitMap = &bit1, *DrawBitMap = &bit1;
+
+
+extern struct BitMap RawDiffBM;
+extern char diffcmap[256 * 3], lastcmap[256 * 3];
+extern bool IsBM, NoFlip, nopalchange, ContMusic;
+
+extern int32 ReadSoFar;
+extern bool ReadIsDone, ReadIsError;
+extern bool DoBlack, EffectPlaying, stopsound;
+extern bool IsHiRes;
+extern struct TextFont *MsgFont;
+extern const char *CurFileName;
+
+
+
+
+
+/*---------------------------------------------------------------------------*/
+/*------ From readPict.c.  Reads in pictures and animations from disk. ------*/
+/*---------------------------------------------------------------------------*/
+
+
+extern uint32 VGAScreenWidth, VGAScreenHeight, VGAPages, VGABytesPerPage;
+
+/*****************************************************************************/
+/* Reads in a picture into the dest bitmap.                                  */
+/*****************************************************************************/
+bool readPict(const char *filename, bool PlayOnce) {
+	byte **file = NULL;
+#if defined(DOSCODE)
+	uint16 counter;
+#endif
+
+	stopDiff();
+
+	ReadSoFar  = 0L;
+	ReadIsDone = false;
+	ReadIsError = false;
+
+	file = g_music->newOpen(filename);
+
+	if (file == NULL) {
+		if ((filename[0] == 'p') || (filename[0] == 'P'))
+			blackScreen();
+
+		return false;
+	}
+
+	DispBitMap->BytesPerRow = VGAScreenWidth;
+	DispBitMap->Rows        = VGAScreenHeight;
+#if defined(DOSCODE)
+	DispBitMap->Flags       = 0;
+#else
+	DispBitMap->Flags       = BITMAPF_VIDEO;
+#endif
+	DispBitMap->Depth       = VGAPages;
+#if defined(DOSCODE)
+
+	for (counter = 0; counter < VGAPages; counter++)
+		DispBitMap->Planes[counter] = getVGABaseAddr();
+
+#else
+	// playDiff deals with resetting planes for the "video" display.
+#endif
+
+	readDiff(PlayOnce);
+
+#if !defined(DOSCODE)
+	ungetVGABaseAddr();
+#endif
+
+	return true;
+}
+
+
+
+
+/*****************************************************************************/
+/* Reads in a music file.  Ignores any graphics.                             */
+/*****************************************************************************/
+bool readMusic(const char *filename) {
+	byte **file = NULL;
+
+	file = g_music->newOpen(filename);
+
+	if (file == NULL) {
+		return false;
+	}
+
+	DoBlack = false;
+	readSound();
+
+	return true;
+}
+
+
+
+
+/*****************************************************************************/
+/* Reads in a picture into buffer memory.                                    */
+/*****************************************************************************/
+byte *readPictToMem(const char *filename, uint16 x, uint16 y) {
+	byte **file = NULL;
+	byte *Mem, *CurMem;
+#if defined(DOSCODE)
+	uint16 counter;
+#endif
+
+	stopDiff();
+
+	ReadSoFar  = 0L;
+	ReadIsDone = false;
+	ReadIsError = false;
+
+	allocFile((void **)&Mem, (int32) x * (int32) y, "Bitmap");
+	CurMem = Mem;
+
+	file = g_music->newOpen(filename);
+
+	if (file == NULL)
+		return NULL;
+
+	DispBitMap->BytesPerRow = x;
+	DispBitMap->Rows        = y;
+	DispBitMap->Flags       = 0;
+	DispBitMap->Depth       = VGAPages;
+#if defined(DOSCODE)
+
+	for (counter = 0; counter < VGAPages; counter++) {
+		DispBitMap->Planes[counter] = CurMem;
+		CurMem += VGABytesPerPage;
+	}
+
+#else
+	DispBitMap->Planes[0] = CurMem;
+	DispBitMap->Planes[1] = DispBitMap->Planes[0] + 0x10000;
+	DispBitMap->Planes[2] = DispBitMap->Planes[1] + 0x10000;
+	DispBitMap->Planes[3] = DispBitMap->Planes[2] + 0x10000;
+	DispBitMap->Planes[4] = DispBitMap->Planes[3] + 0x10000;
+#endif
+
+	readDiff(true);
+
+	return Mem;
+}
+
+
+
+
+/*---------------------------------------------------------------------------*/
+/*------------ Does all the text rendering to the message boxes. ------------*/
+/*---------------------------------------------------------------------------*/
+
+
+bool DoNotDrawMessage = false;
+
+extern bool LongWinInFront, Alternate;
+
+
+/*----- The flowText routines -----*/
+
+
+
+
+/******************************************************************************/
+/* Extracts the first word from a string.                                     */
+/******************************************************************************/
+static void getWord(char *WordBuffer, const char *MainBuffer, uint16 *WordWidth) {
+	uint16 width = 0;
+
+	while ((MainBuffer[width] != ' ') && MainBuffer[width] &&
+	        (MainBuffer[width] != '\n')) {
+		WordBuffer[width] = MainBuffer[width];
+		width++;
+	}
+
+	WordBuffer[width] = 0;
+
+	*WordWidth = width;
+}
+
+
+
+
+
+/******************************************************************************/
+/* Gets a line of text for flowText; makes sure that its length is less than  */
+/* or equal to the maximum width.                                             */
+/******************************************************************************/
+static void getLine(struct TextFont *tf, char *LineBuffer, const char **MainBuffer, uint16 LineWidth) {
+	uint16 CurWidth = 0, WordWidth;
+	char WordBuffer[100];
+	bool doit = true;
+
+	LineWidth += textLength(tf, " ", 1);
+
+	LineBuffer[0] = 0;
+
+	while ((*MainBuffer)[0] && doit) {
+		getWord(WordBuffer, *MainBuffer, &WordWidth);
+		strcat(WordBuffer, " ");
+
+		if ((CurWidth + textLength(tf, WordBuffer, WordWidth + 1)) <= LineWidth) {
+			strcat(LineBuffer, WordBuffer);
+			(*MainBuffer) += WordWidth;
+
+			if ((*MainBuffer)[0] == '\n')
+				doit = false;
+
+			if ((*MainBuffer)[0])
+				(*MainBuffer)++;
+
+			CurWidth = textLength(tf, LineBuffer, strlen(LineBuffer));
+		} else
+			doit = false;
+	}
+
+	/* NYI: Would add code here to break up words in case they were longer than a line */
+}
+
+
+
+
+/******************************************************************************/
+/* Dumps a chunk of text to an arbitrary box; flows it within that box and    */
+/* optionally centers it. Returns the number of characters that were          */
+/* processed.                                                                 */
+/*                                                                            */
+/* Note: Every individual word MUST be int16 enough to fit on a line, and     */
+/* each line less than 255 characters.                                        */
+/******************************************************************************/
+uint32 flowText(void *font,      /* the TextAttr pointer */
+                uint16 spacing,          /* How much vertical spacing between the lines */
+                uint16 pencolor,         /* pen number to use for text */
+                uint16 backpen,          /* the background color */
+                bool fillback,                /* Whether to fill the background */
+                bool centerh,                 /* Whether to center the text horizontally */
+                bool centerv,                 /* Whether to center the text vertically */
+                bool output,                  /* Whether to output any text */
+                uint16 x1,               /* Cords */
+                uint16 y1, uint16 x2, uint16 y2, const char *str) { /* The text itself */
+	struct TextFont *msgfont = (TextFont *)font;
+	char linebuffer[256];
+	const char *temp;
+	uint16 numlines, actlines, fontheight, width;
+	uint16 x, y;
+
+	if (fillback) {
+		setAPen(backpen);
+		rectFill(x1, y1, x2, y2);
+	}
+
+	if (str == NULL)
+		return 0L;
+
+	setAPen(pencolor);
+
+	fontheight = textHeight(msgfont) + spacing;
+	numlines   = (y2 - y1 + 1) / fontheight;
+	width      = x2 - x1 + 1;
+	y          = y1;
+
+	if (centerv && output) {
+		temp = str;
+		actlines = 0;
+
+		while (temp[0]) {
+			getLine(msgfont, linebuffer, &temp, width);
+			actlines++;
+		}
+
+		if (actlines <= numlines)
+			y += ((y2 - y1 + 1) - (actlines * fontheight)) / 2;
+	}
+
+	temp = str;
+
+	while (numlines && str[0]) {
+		getLine(msgfont, linebuffer, &str, width);
+
+		x = x1;
+
+		if (centerh)
+			x += (width - textLength(msgfont, linebuffer, strlen(linebuffer))) / 2;
+
+		if (output)
+			text(msgfont, x, y, pencolor, linebuffer, strlen(linebuffer));
+
+		numlines--;
+		y += fontheight;
+	}
+
+	return (str - temp);
+}
+
+
+extern uint32 VGABASEADDRESS, VGABytesPerPage;
+
+
+/******************************************************************************/
+/* Calls flowText, but flows it to memory.  Same restrictions as flowText.    */
+/******************************************************************************/
+uint32 flowTextToMem(struct Image *DestIm, void *font,     /* the TextAttr pointer */
+                     uint16 spacing,          /* How much vertical spacing between the lines */
+                     uint16 pencolor,         /* pen number to use for text */
+                     uint16 backpen,          /* the background color */
+                     bool fillback,                /* Whether to fill the background */
+                     bool centerh,                 /* Whether to center the text horizontally */
+                     bool centerv,                 /* Whether to center the text vertically */
+                     bool output,                  /* Whether to output any text */
+                     uint16 x1,               /* Cords */
+                     uint16 y1, uint16 x2, uint16 y2, const char *str) { /* The text itself */
+	uint32 res, vgabyte = VGABytesPerPage;
+
+	//VGABASEADDRESS = (uint32)(DestIm->ImageData);
+	VGABytesPerPage = (uint32) DestIm->Width * (int32) DestIm->Height;
+
+	res = flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str);
+
+	VGABytesPerPage = vgabyte;
+
+	return res;
+}
+
+
+
+
+/*----- The control panel stuff -----*/
+
+
+
+void createBox(uint16 y2) {
+	setAPen(7);                 /* Message box area */
+	rectFill(VGAScaleX(4), VGAScaleY(154), VGAScaleX(315), VGAScaleY(y2 - 2));
+
+	setAPen(0);                 /* Box around message area */
+	drawHLine(VGAScaleX(2), VGAScaleY(152), VGAScaleX(317));
+	drawVLine(VGAScaleX(317), VGAScaleY(152), VGAScaleY(y2));
+	drawHLine(VGAScaleX(2), VGAScaleY(y2), VGAScaleX(317));
+	drawVLine(VGAScaleX(2), VGAScaleY(152), VGAScaleY(y2));
+}
+
+
+
+
+int32 longcharsdrawn = 0L;
+bool LastMessageLong = false;
+
+void longDrawMessage(const char *str) {
+	char NewText[512];
+
+	if (str == NULL)
+		return;
+
+	attachGadgetList(NULL);
+	mouseHide();
+	strcpy(NewText, str);
+
+	if (!LongWinInFront) {
+		LongWinInFront = true;
+		setAPen(3);                 /* Clear Area */
+		rectFill(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319), VGAScaleY(199));
+	}
+
+	createBox(198);
+	longcharsdrawn = flowText(MsgFont, 0, 1, 7, false, true, true, true, VGAScaleX(6), VGAScaleY(155), VGAScaleX(313), VGAScaleY(195), str);
+	mouseShow();
+}
+
+
+
+
+/******************************************************************************/
+/* Draws a message to the message box.                                        */
+/******************************************************************************/
+void drawMessage(const char *str) {
+	if (DoNotDrawMessage) {
+		DoNotDrawMessage = false;
+		return;
+	}
+
+	if (str) {
+		if ((textLength(MsgFont, str, strlen(str)) > VGAScaleX(306))) {
+			longDrawMessage(str);
+			LastMessageLong = true;
+		} else {
+			if (LongWinInFront) {
+				LongWinInFront = false;
+				drawPanel();
+			}
+
+			mouseHide();
+			createBox(168);
+			text(MsgFont, VGAScaleX(7), VGAScaleY(155) + SVGACord(2), 1, str, strlen(str));
+			mouseShow();
+			LastMessageLong = false;
+		}
+	}
+}
+
+
+/*---------------------------------------------------------------------------*/
+/*--------------------------- All the wipe stuff. ---------------------------*/
+/*---------------------------------------------------------------------------*/
+
+
+
+#define TRANSWIPE      1
+#define SCROLLWIPE     2
+#define SCROLLBLACK    3
+#define SCROLLBOUNCE   4
+#define TRANSPORTER    5
+#define READFIRSTFRAME 6
+#define READNEXTFRAME  7
+
+
+
+
+/*****************************************************************************/
+/* Copies memory from one location to another 64 bytes at a time.            */
+/*****************************************************************************/
+void copyLong64(uint32 *Dest, uint32 *Source, uint32 Many64) {
+	while (Many64) {
+		*Dest = *Source;
+		Dest++;
+		Source++;
+		*Dest = *Source;
+		Dest++;
+		Source++;
+		*Dest = *Source;
+		Dest++;
+		Source++;
+		*Dest = *Source;
+		Dest++;
+		Source++;
+		*Dest = *Source;
+		Dest++;
+		Source++;
+		*Dest = *Source;
+		Dest++;
+		Source++;
+		*Dest = *Source;
+		Dest++;
+		Source++;
+		*Dest = *Source;
+		Dest++;
+		Source++;
+		*Dest = *Source;
+		Dest++;
+		Source++;
+		*Dest = *Source;
+		Dest++;
+		Source++;
+		*Dest = *Source;
+		Dest++;
+		Source++;
+		*Dest = *Source;
+		Dest++;
+		Source++;
+		*Dest = *Source;
+		Dest++;
+		Source++;
+		*Dest = *Source;
+		Dest++;
+		Source++;
+		*Dest = *Source;
+		Dest++;
+		Source++;
+		*Dest = *Source;
+		Dest++;
+		Source++;
+
+		Many64--;
+	}
+}
+
+
+
+
+/*****************************************************************************/
+/* Scrolls the display to black.                                             */
+/*****************************************************************************/
+static void doScrollBlack(void) {
+	byte *mem, *tempmem;
+	struct Image Im;
+	uint16 width, height, by, nheight, CurPage;
+	uint32 size, copysize;
+	uint32 *BaseAddr;
+
+	mouseHide();
+	width = VGAScaleX(320);
+	height = VGAScaleY(149) + SVGACord(2);
+
+	/*
+	   while (EffectPlaying)
+	   {
+	    g_music->updateMusic();
+	    waitTOF();
+	   }
+	 */
+
+	allocFile((void **) &mem, (int32) width * (int32) height, "Temp Mem");
+	/*
+	   mem = stealBufMem((int32) width * (int32) height);
+	 */
+	Im.Width = width;
+	Im.Height = height;
+	Im.ImageData = mem;
+	g_music->fillUpMusic(true);
+	readScreenImage(&Im, 0, 0);
+	g_music->fillUpMusic(true);
+
+	BaseAddr = (uint32 *) getVGABaseAddr();
+
+	by      = VGAScaleX(4);
+	nheight = height;
+
+	while (nheight) {
+		g_music->newCheckMusic();
+
+		if (!IsHiRes)
+			waitTOF();
+
+#if !defined(DOSCODE)
+		BaseAddr = (uint32 *) getVGABaseAddr();
+#endif
+
+		if (by > nheight)
+			by = nheight;
+
+		mem += by * width;
+		nheight -= by;
+		size = (int32) nheight * (int32) width;
+		CurPage = 0;
+		tempmem = mem;
+
+		while (size) {
+			if (size > VGABytesPerPage)
+				copysize = VGABytesPerPage;
+			else
+				copysize = size;
+
+			size -= copysize;
+
+			setPage(CurPage);
+			copyLong64(BaseAddr, (uint32 *) tempmem, copysize >> 6);
+			tempmem += copysize;
+			CurPage++;
+		}
+
+		setAPen(0);
+		rectFill(0, nheight, width - 1, nheight + by - 1);
+
+		g_system->updateScreen();
+
+		if (!IsHiRes) {
+			if (nheight <= (height / 8))
+				by = 1;
+			else if (nheight <= (height / 4))
+				by = 2;
+			else if (nheight <= (height / 2))
+				by = 3;
+		}
+	}
+
+	freeAllStolenMem();
+	mouseShow();
+
+#if !defined(DOSCODE)
+	ungetVGABaseAddr();
+#endif
+}
+
+
+
+
+extern struct BitMap RawDiffBM;
+extern DIFFHeader headerdata;
+
+
+
+
+static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem) {
+	uint32 size, OffSet, copysize;
+	uint16 CurPage;
+	uint32 *BaseAddr;
+
+	BaseAddr = (uint32 *) getVGABaseAddr();
+
+	size = (int32)(height - nheight) * (int32) width;
+	mem += startline * width;
+	CurPage = ((int32) nheight * (int32) width) / VGABytesPerPage;
+	OffSet = ((int32) nheight * (int32) width) - (CurPage * VGABytesPerPage);
+
+	while (size) {
+		if (size > (VGABytesPerPage - OffSet))
+			copysize = VGABytesPerPage - OffSet;
+		else
+			copysize = size;
+
+		size -= copysize;
+
+		setPage(CurPage);
+		copyLong64(BaseAddr + (OffSet >> 2), (uint32 *) mem, copysize >> 6);
+		mem += copysize;
+		CurPage++;
+		OffSet = 0;
+	}
+
+#if !defined(DOSCODE)
+	ungetVGABaseAddr();
+#endif
+}
+
+
+/*****************************************************************************/
+/* Scrolls the display to a new picture from a black screen.                 */
+/*****************************************************************************/
+static void doScrollWipe(char *filename) {
+	byte *mem;
+	uint16 width, height, by, nheight, startline = 0, onrow = 0;
+
+	mouseHide();
+	width = VGAScaleX(320);
+	height = VGAScaleY(149) + SVGACord(2);
+
+	while (EffectPlaying) {
+		g_music->newCheckMusic();
+		waitTOF();
+	}
+
+	IsBM = true;
+	readPict(filename, true);
+	VGASetPal(diffcmap, 256);
+	IsBM = false;
+	mem = RawDiffBM.Planes[0];
+
+	g_music->fillUpMusic(true);
+	by      = VGAScaleX(3);
+	nheight = height;
+
+	while (onrow < headerdata.y) {
+		g_music->newCheckMusic();
+
+		if ((by > nheight) && nheight)
+			by = nheight;
+
+		if ((startline + by) > (headerdata.y - height - 1))
+			break;
+
+		if (nheight)
+			nheight -= by;
+
+		copyPage(width, height, nheight, startline, mem);
+
+		g_system->updateScreen();
+
+		if (!nheight)
+			startline += by;
+
+		onrow += by;
+
+		if (nheight <= (height / 4))
+			by = VGAScaleX(5);
+		else if (nheight <= (height / 3))
+			by = VGAScaleX(4);
+		else if (nheight <= (height / 2))
+			by = VGAScaleX(3);
+	}
+
+	mouseShow();
+}
+
+
+
+
+/*****************************************************************************/
+/* Does the scroll bounce.  Assumes bitmap already in memory.                */
+/*****************************************************************************/
+static void doScrollBounce(void) {
+	byte *mem;
+	uint16 width, height, startline, counter,
+#if defined(DOSCODE)
+	       newby[5] = {5, 4, 3, 2, 1}, newby1[8] = {3, 3, 2, 2, 2, 1, 1, 1};
+#else
+	       newby[5] = {10, 8, 6, 4, 2}, newby1[8] = {6, 6, 4, 4, 4, 2, 2, 2};
+#endif
+
+	mouseHide();
+	width = VGAScaleX(320);
+	height = VGAScaleY(149) + SVGACord(2);
+	mem = RawDiffBM.Planes[0];
+
+	g_music->fillUpMusic(true);
+	startline = headerdata.y - height - 1;
+
+	for (counter = 0; counter < 5; counter++) {
+		g_music->newCheckMusic();
+		startline -= newby[counter];
+		copyPage(width, height, 0, startline, mem);
+
+		g_system->updateScreen();
+		waitTOF();
+	}
+
+	for (counter = 8; counter > 0; counter--) {
+		g_music->newCheckMusic();
+		startline += newby1[counter - 1];
+		copyPage(width, height, 0, startline, mem);
+
+		g_system->updateScreen();
+		waitTOF();
+
+	}
+
+	mouseShow();
+}
+
+
+
+/*****************************************************************************/
+/* Does the transporter wipe.                                                */
+/*****************************************************************************/
+static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
+	uint16 LastY, CurY, counter, linesdone = 0, lineslast;
+	struct Image ImSource, ImDest;
+
+	if (IsHiRes) {
+		lineslast = 3;
+		LastY = 358;
+	} else {
+		lineslast = 1;
+		LastY = 148;
+	}
+
+	for (counter = 0; counter < 2; counter++) {
+		CurY = counter * 2;
+
+		while (CurY < LastY) {
+			if (linesdone >= lineslast) {
+				g_music->updateMusic();
+				waitTOF();
+				linesdone = 0;
+			}
+
+			ghoastRect(0, 0, CurY, VGAScreenWidth - 1, CurY + 1);
+			CurY += 4;
+			linesdone++;
+		}
+	}
+
+	setAPen(0);
+
+	for (counter = 0; counter < 2; counter++) {
+		CurY = counter * 2;
+
+		while (CurY <= LastY) {
+			if (linesdone >= lineslast) {
+				g_music->updateMusic();
+				waitTOF();
+				linesdone = 0;
+			}
+
+			rectFill(0, CurY, VGAScreenWidth - 1, CurY + 1);
+			CurY += 4;
+			linesdone++;
+		}
+	}
+
+	if (filename == NULL)
+		CurFileName = getPictName(CPtr);
+	else if (filename[0] > ' ')
+		CurFileName = filename;
+	else
+		CurFileName = getPictName(CPtr);
+
+	byte *BitMapMem = readPictToMem(CurFileName, VGAScreenWidth, LastY + 5);
+	VGASetPal(diffcmap, 256);
+
+	if (BitMapMem) {
+		ImSource.Width = VGAScreenWidth;
+		ImSource.Height = LastY;
+		ImSource.ImageData = BitMapMem;
+
+		ImDest.Width = VGAScreenWidth;
+		ImDest.Height = VGAScreenHeight;
+		ImDest.ImageData = getVGABaseAddr();
+
+		for (counter = 0; counter < 2; counter++) {
+			CurY = counter * 2;
+
+			while (CurY < LastY) {
+				if (linesdone >= lineslast) {
+					g_music->updateMusic();
+					waitTOF();
+					linesdone = 0;
+				}
+
+#if !defined(DOSCODE)
+				ImDest.ImageData = getVGABaseAddr();
+#endif
+
+				bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, VGAScreenWidth, 2);
+				ghoastRect(0, 0, CurY, VGAScreenWidth - 1, CurY + 1);
+				CurY += 4;
+				linesdone++;
+			}
+		}
+
+		for (counter = 0; counter < 2; counter++) {
+			CurY = counter * 2;
+
+			while (CurY <= LastY) {
+				if (linesdone >= lineslast) {
+					g_music->updateMusic();
+					waitTOF();
+					linesdone = 0;
+				}
+
+#if !defined(DOSCODE)
+				ImDest.ImageData = getVGABaseAddr();
+#endif
+
+				if (CurY == LastY)
+					bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, VGAScreenWidth, 1);
+				else
+					bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, VGAScreenWidth, 2);
+
+				CurY += 4;
+				linesdone++;
+			}
+		}
+	}
+
+#if !defined(DOSCODE)
+	ungetVGABaseAddr();
+#endif
+}
+
+
+
+/*****************************************************************************/
+/* Does a certain number of pre-programmed wipes.                            */
+/*****************************************************************************/
+void doWipe(uint16 WipeType, CloseDataPtr *CPtr, char *filename) {
+	if ((WipeType == TRANSWIPE) || (WipeType == TRANSPORTER))
+		doTransWipe(CPtr, filename);
+	else if (WipeType == SCROLLWIPE)
+		doScrollWipe(filename);
+	else if (WipeType == SCROLLBLACK)
+		doScrollBlack();
+	else if (WipeType == SCROLLBOUNCE)
+		doScrollBounce();
+	else if (WipeType == READFIRSTFRAME)
+		readPict(filename, false);
+	else if (WipeType == READNEXTFRAME)
+		diffNextFrame();
+}
+
+} // End of namespace Lab
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
new file mode 100644
index 0000000..91111ae
--- /dev/null
+++ b/engines/lab/interface.cpp
@@ -0,0 +1,234 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/stddefines.h"
+#include "lab/interface.h"
+#include "lab/storage.h"
+#include "lab/timing.h"
+#include "lab/mouse.h"
+#include "lab/vga.h"
+#include "common/util.h"
+
+namespace Lab {
+
+extern bool IsHiRes;
+
+Common::KeyState _keyPressed;
+
+struct Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt) {
+	Gadget *gptr;
+
+	if (allocate((void **)&gptr, sizeof(struct Gadget))) {
+		gptr->x = x;
+		gptr->y = y;
+		gptr->GadgetID = id;
+#if !defined(DOSCODE)
+		gptr->KeyEquiv = key;
+#endif
+		gptr->Im = im;
+		gptr->ImAlt = imalt;
+		gptr->NextGadget = NULL;
+
+		return gptr;
+	} else
+		return NULL;
+}
+
+
+
+
+void freeButtonList(Gadget *gptrlist) {
+	struct Gadget *gptr, *next = gptrlist;
+
+	while (next) {
+		gptr = next;
+		next = next->NextGadget;
+
+		deallocate(gptr, sizeof(struct Gadget));
+	}
+}
+
+
+
+
+/*****************************************************************************/
+/* Draws a gadget list to the screen.                                        */
+/*****************************************************************************/
+void drawGadgetList(struct Gadget *gadlist) {
+	while (gadlist) {
+		drawImage(gadlist->Im, gadlist->x, gadlist->y);
+
+		if (GADGETOFF & gadlist->GadgetFlags)
+			ghoastGadget(gadlist, 1);
+
+		gadlist = gadlist->NextGadget;
+	}
+}
+
+
+/*****************************************************************************/
+/* Ghoasts a gadget, and makes it unavailable for using.                     */
+/*****************************************************************************/
+void ghoastGadget(struct Gadget *curgad, uint16 pencolor) {
+	ghoastRect(pencolor, curgad->x, curgad->y, curgad->x + curgad->Im->Width - 1, curgad->y + curgad->Im->Height - 1);
+	curgad->GadgetFlags |= GADGETOFF;
+}
+
+
+
+/*****************************************************************************/
+/* Unghoasts a gadget, and makes it available again.                         */
+/*****************************************************************************/
+void unGhoastGadget(struct Gadget *curgad) {
+	drawImage(curgad->Im, curgad->x, curgad->y);
+	curgad->GadgetFlags &= !(GADGETOFF);
+}
+
+
+/*****************************************************************************/
+/* Make a key press have the right case for a gadget KeyEquiv value.         */
+/*****************************************************************************/
+#if !defined(DOSCODE)
+uint16 makeGadgetKeyEquiv(uint16 key) {
+	if (Common::isAlnum(key))
+		key = tolower(key);
+
+	return key;
+}
+#endif
+
+/*****************************************************************************/
+/* Checks whether or not the cords fall within one of the gadgets in a list  */
+/* of gadgets.                                                               */
+/*****************************************************************************/
+static struct Gadget *checkNumGadgetHit(struct Gadget *gadlist, uint16 key) {
+#if !defined(DOSCODE)
+	uint16 gkey = key - '0';
+#else
+	key = key - '0';
+#endif
+
+	while (gadlist != NULL) {
+#if !defined(DOSCODE)
+
+		if ((gkey - 1 == gadlist->GadgetID || (gkey == 0 && gadlist->GadgetID == 9) ||
+		        (gadlist->KeyEquiv != 0 && makeGadgetKeyEquiv(key) == gadlist->KeyEquiv))
+		        && !(GADGETOFF & gadlist->GadgetFlags))
+#else
+		if ((((key - 1) == gadlist->GadgetID) || ((key == 0) && (gadlist->GadgetID == 9))) &&
+		        !(GADGETOFF & gadlist->GadgetFlags))
+#endif
+		{
+			mouseHide();
+			drawImage(gadlist->ImAlt, gadlist->x, gadlist->y);
+			mouseShow();
+			g_system->delayMillis(80);
+			mouseHide();
+			drawImage(gadlist->Im, gadlist->x, gadlist->y);
+			mouseShow();
+
+			return gadlist;
+		} else {
+			gadlist = gadlist->NextGadget;
+		}
+	}
+
+	return NULL;
+}
+
+
+
+/*****************************************************************************/
+/* Checks whether or not a key has been pressed.                             */
+/*****************************************************************************/
+static bool keyPress(uint16 *KeyCode) {
+	if (_keyPressed.keycode) {
+		*KeyCode = _keyPressed.keycode;
+		return true;
+	}
+
+	return false;
+}
+
+
+struct IntuiMessage IMessage;
+extern struct Gadget *ScreenGadgetList;
+
+struct IntuiMessage *getMsg(void) {
+	struct Gadget *curgad;
+	int Qualifiers;
+
+	updateMouse();
+#if !defined(DOSCODE)
+	Qualifiers = _keyPressed.flags;
+#endif
+
+	if ((curgad = mouseGadget()) != NULL) {
+		updateMouse();
+		IMessage.Class = GADGETUP;
+		IMessage.Code  = curgad->GadgetID;
+		IMessage.GadgetID = curgad->GadgetID;
+		IMessage.Qualifier = Qualifiers;
+		return &IMessage;
+	}
+
+	else if (mouseButton(&IMessage.MouseX, &IMessage.MouseY, true)) { /* Left Button */
+		IMessage.Qualifier = IEQUALIFIER_LEFTBUTTON | Qualifiers;
+		IMessage.Class = MOUSEBUTTONS;
+		return &IMessage;
+	}
+
+	else if (mouseButton(&IMessage.MouseX, &IMessage.MouseY, false)) { /* Right Button */
+		IMessage.Qualifier = IEQUALIFIER_RBUTTON | Qualifiers;
+		IMessage.Class = MOUSEBUTTONS;
+		return &IMessage;
+	}
+
+	else if (keyPress(&IMessage.Code)) { /* Keyboard key */
+		curgad = checkNumGadgetHit(ScreenGadgetList, IMessage.Code);
+
+		if (curgad) {
+			IMessage.Class = GADGETUP;
+			IMessage.Code  = curgad->GadgetID;
+			IMessage.GadgetID = curgad->GadgetID;
+		} else
+			IMessage.Class = RAWKEY;
+
+		IMessage.Qualifier = Qualifiers;
+		return &IMessage;
+	} else
+		return NULL;
+}
+
+void replyMsg(void *Msg) {
+	return;
+}
+
+} // End of namespace Lab
diff --git a/engines/lab/interface.h b/engines/lab/interface.h
new file mode 100644
index 0000000..cb0115d
--- /dev/null
+++ b/engines/lab/interface.h
@@ -0,0 +1,143 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/vga.h"
+#include "common/keyboard.h"
+
+#ifndef LAB_INTEFACE_H
+#define LAB_INTEFACE_H
+
+namespace Lab {
+
+struct IntuiMessage {
+	uint32 Class;
+	uint16 Code, Qualifier, MouseX, MouseY, GadgetID;
+	uint32 Seconds, Micros;
+};
+
+
+struct Gadget {
+	uint16 x, y, GadgetID;
+#if !defined(DOSCODE)
+	uint16 KeyEquiv; // if not zero, a key that activates gadget
+#endif
+	uint32 GadgetFlags;
+	struct Image *Im, *ImAlt;
+	struct Gadget *NextGadget;
+};
+
+extern Common::KeyState _keyPressed;
+
+/* Defines for the GadgetFlags portion */
+
+#define GADGETOFF 0x01
+
+
+
+/* Defines for the Class variable in IntuiMessage */
+#define SIZEVERIFY  0x00000001
+#define NEWSIZE     0x00000002
+#define REFRESHWINDOW   0x00000004
+#define MOUSEBUTTONS    0x00000008
+#define MOUSEMOVE   0x00000010
+#define GADGETDOWN  0x00000020
+#define GADGETUP    0x00000040
+#define REQSET      0x00000080
+#define MENUPICK    0x00000100
+#define CLOSEWINDOW 0x00000200
+#define RAWKEY      0x00000400
+#define REQVERIFY   0x00000800
+#define REQCLEAR    0x00001000
+#define MENUVERIFY  0x00002000
+#define NEWPREFS    0x00004000
+#define DISKINSERTED    0x00008000
+#define DISKREMOVED 0x00010000
+#define WBENCHMESSAGE   0x00020000  /*  System use only     */
+#define ACTIVEWINDOW    0x00040000
+#define INACTIVEWINDOW  0x00080000
+#define DELTAMOVE   0x00100000
+#define VANULLLAKEY  0x00200000
+
+
+/* Defines for the Qualifier variable in IntuiMessage */
+#define IEQUALIFIER_LSHIFT      0x0001
+#define IEQUALIFIER_RSHIFT      0x0002
+#define IEQUALIFIER_CAPSLOCK        0x0004
+#define IEQUALIFIER_CONTROL     0x0008
+#define IEQUALIFIER_LALT        0x0010
+#define IEQUALIFIER_RALT        0x0020
+#define IEQUALIFIER_LCOMMAND        0x0040
+#define IEQUALIFIER_RCOMMAND        0x0080
+#define IEQUALIFIER_NUMERICPAD      0x0100
+#define IEQUALIFIER_REPEAT      0x0200
+#define IEQUALIFIER_INTERRUPT       0x0400
+#define IEQUALIFIER_MULTIBROADCAST  0x0800
+#define IEQUALIFIER_MIDBUTTON       0x1000
+#define IEQUALIFIER_RBUTTON     0x2000
+#define IEQUALIFIER_LEFTBUTTON      0x4000
+
+#if !defined(DOSCODE)
+// these values come from the SDL virtual key table
+#define VKEY_UPARROW    273
+#define VKEY_DNARROW    274
+#define VKEY_RTARROW    275
+#define VKEY_LTARROW    276
+#endif
+
+
+/*---------------------------------------------------------------------------*/
+/*--------------------------- Function Prototypes ---------------------------*/
+/*---------------------------------------------------------------------------*/
+
+
+
+
+struct Gadget *createButton(uint16 x, uint16 y, uint16 id,
+#if !defined(DOSCODE)
+                            uint16 key,
+#endif
+                            struct Image *im, struct Image *imalt);
+
+void freeButtonList(void *gptrlist);
+
+void drawGadgetList(struct Gadget *gadlist);
+
+void ghoastGadget(struct Gadget *curgad, uint16 pencolor);
+
+void unGhoastGadget(struct Gadget *curgad);
+
+struct IntuiMessage *getMsg(void);
+
+void replyMsg(void *Msg);
+
+} // End of namespace Lab
+
+#endif /* LAB_INTEFACE_H */
+
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
new file mode 100644
index 0000000..ae822cb
--- /dev/null
+++ b/engines/lab/intro.cpp
@@ -0,0 +1,470 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/stddefines.h"
+#include "lab/labfun.h"
+#include "lab/timing.h"
+#include "lab/diff.h"
+#include "lab/text.h"
+#include "lab/interface.h"
+
+namespace Lab {
+
+static struct TextFont filler, *msgfont = &filler;
+
+extern bool nopalchange, noscreenchange, hidemouse, DoBlack, NoFlip, IsHiRes;
+
+extern char diffcmap[256 * 3];
+
+extern uint32 VGAScreenWidth, VGAScreenHeight;
+
+
+extern uint16 *FadePalette;
+
+static uint16 Palette[16] = {
+	0x0000, 0x0855, 0x0FF9, 0x0EE7, 0x0ED5, 0x0DB4, 0x0CA2, 0x0C91, 0x0B80, 0x0B80, 0x0B91, 0x0CA2, 0x0CB3, 0x0DC4, 0x0DD6, 0x0EE7
+};
+
+
+static bool QuitIntro = false, IntroDoBlack;
+extern int32 longcharsdrawn;
+
+
+
+/******************************************************************************/
+/* Goes thru, and responds to all the intuition messages currently in the     */
+/* the message port.                                                          */
+/******************************************************************************/
+void introEatMessages(void) {
+	struct IntuiMessage *Msg;
+
+	while (1) {
+		Msg = getMsg();
+
+		if (Msg == NULL)
+			return;
+		else {
+			if (((Msg->Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Msg->Qualifier)) ||
+			        ((Msg->Class == RAWKEY) && (Msg->Code == 27)))
+				QuitIntro = true;
+
+			replyMsg(Msg);
+		}
+	}
+}
+
+
+
+
+/*****************************************************************************/
+/* Reads in a picture.                                                       */
+/*****************************************************************************/
+static void doPictText(const char *Filename, bool isscreen) {
+	uint32 lastsecs = 0L, lastmicros = 0L, secs = 0L, micros = 0L;
+	struct IntuiMessage *Msg;
+	char filename[50] = "Lab:rooms/Intro/";
+	byte *curplace, **tfile;
+	bool DrawNextText = true, End = false, Begin = true;
+
+	int32 Class, Code, Drawn;
+	int16 Qualifier;
+	uint timedelay;
+
+	strcat(filename, Filename);
+
+	if (isscreen) {
+		g_music->fillUpMusic(true);
+		timedelay = 35;
+	} else {
+		g_music->newCheckMusic();
+		timedelay = 7;
+	}
+
+	if (QuitIntro)
+		return;
+
+	while (1) {
+		if (DrawNextText) {
+			if (Begin) {
+				Begin = false;
+
+				tfile = g_music->newOpen(filename);
+
+				if (!tfile)
+					return;
+
+				curplace = *tfile;
+			} else if (isscreen)
+				fade(false, 0);
+
+			if (isscreen) {
+				setAPen(7L);
+				rectFill(VGAScaleX(10), VGAScaleY(10), VGAScaleX(310), VGAScaleY(190));
+
+				Drawn = flowText(msgfont, (!IsHiRes) * -1, 5, 7, false, false, true, true, VGAScaleX(14), VGAScaleY(11), VGAScaleX(306), VGAScaleY(189), (char *)curplace);
+				fade(true, 0);
+			} else {
+				longDrawMessage((char *)curplace);
+				Drawn = longcharsdrawn;
+			}
+
+			curplace += Drawn;
+
+			End = (*curplace == 0);
+
+			DrawNextText = false;
+			introEatMessages();
+
+			if (QuitIntro) {
+				if (isscreen)
+					fade(false, 0);
+
+				return;
+			}
+
+			getTime(&lastsecs, &lastmicros);
+		}
+
+		Msg = getMsg();
+
+		if (Msg == NULL) {
+			g_music->newCheckMusic();
+			diffNextFrame();
+
+			getTime(&secs, &micros);
+			anyTimeDiff(lastsecs, lastmicros, secs, micros, &secs, &micros);
+
+			if (secs > timedelay) {
+				if (End) {
+					if (isscreen)
+						fade(false, 0);
+
+					return;
+				} else {
+					DrawNextText = true;
+				}
+			}
+
+			waitTOF();
+		} else {
+			Class     = Msg->Class;
+			Qualifier = Msg->Qualifier;
+			Code      = Msg->Code;
+			replyMsg(Msg);
+
+			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) ||
+			        ((Class == RAWKEY) && (Code == 27))) {
+				QuitIntro = true;
+
+				if (isscreen)
+					fade(false, 0);
+
+				return;
+			}
+
+			else if (Class == MOUSEBUTTONS) {
+				if (IEQUALIFIER_LEFTBUTTON & Qualifier) {
+					if (End) {
+						if (isscreen)
+							fade(false, 0);
+
+						return;
+					} else
+						DrawNextText = true;
+				}
+
+				introEatMessages();
+
+				if (QuitIntro) {
+					if (isscreen)
+						fade(false, 0);
+
+					return;
+				}
+			}
+
+			if (End) {
+				if (isscreen)
+					fade(false, 0);
+
+				return;
+			} else
+				DrawNextText = true;
+		}
+	}
+}
+
+
+
+
+
+/*****************************************************************************/
+/* Does a one second delay, but checks the music while doing it.             */
+/*****************************************************************************/
+void musicDelay(void) {
+	int16 counter;
+
+	g_music->newCheckMusic();
+
+	if (QuitIntro)
+		return;
+
+	for (counter = 0; counter < 20; counter++) {
+		g_music->newCheckMusic();
+		waitTOF();
+		waitTOF();
+		waitTOF();
+	}
+}
+
+
+
+static void NReadPict(const char *Filename, bool PlayOnce) {
+	char filename[20] = "P:Intro/";
+
+	g_music->newCheckMusic();
+
+	if (QuitIntro)
+		return;
+
+	strcat(filename, Filename);
+
+	DoBlack = IntroDoBlack;
+	stopDiffEnd();
+	readPict(filename, PlayOnce);
+}
+
+
+//#define ALL_LOGOS
+
+/*****************************************************************************/
+/* Does the introduction sequence for Labyrinth.                             */
+/*****************************************************************************/
+void introSequence(void) {
+	uint16 counter, counter1;
+
+	DoBlack = true;
+
+#if defined(DOSCODE)
+	readPict("p:Intro/EA0", true);
+	readPict("p:Intro/EA1", true);
+	readPict("p:Intro/EA2", true);
+	readPict("p:Intro/EA3", true);
+#elif defined(ALL_LOGOS) || defined(NDEBUG)
+	readPict("p:Intro/WYRMKEEP", true);
+	microDelay(4, 0, NULL);
+#endif
+	blackAllScreen();
+
+	g_music->initMusic();
+
+	nopalchange = true;
+	noscreenchange = true;
+	readPict("p:Intro/TNDcycle2.pic", true);
+	nopalchange = false;
+	noscreenchange = false;
+
+	FadePalette = Palette;
+#if defined(ALL_LOGOS) || defined(NDEBUG)
+
+	for (counter = 0; counter < 16; counter++) {
+		Palette[counter] = ((diffcmap[counter * 3] >> 2) << 8) +
+		                   ((diffcmap[counter * 3 + 1] >> 2) << 4) +
+		                   (diffcmap[counter * 3 + 2] >> 2);
+	}
+
+	newCheckMusic();
+	fade(true, 0);
+
+	for (int times = 0; times < 150; times++) {
+		newCheckMusic();
+		uint16 temp = Palette[2];
+
+		for (counter = 2; counter < 15; counter++)
+			Palette[counter] = Palette[counter + 1];
+
+		Palette[15] = temp;
+
+		setAmigaPal(Palette, 16);
+		waitTOF();
+	}
+
+	fade(false, 0);
+	blackAllScreen();
+#endif
+	g_music->newCheckMusic();
+
+	readPict("p:Intro/Title.A", true);
+	readPict("p:Intro/AB", true);
+	musicDelay();
+	readPict("p:Intro/BA", true);
+	readPict("p:Intro/AC", true);
+	musicDelay();
+#if !defined(DOSCODE)
+	musicDelay(); // more credits on this page now
+#endif
+	readPict("p:Intro/CA", true);
+	readPict("p:Intro/AD", true);
+	musicDelay();
+#if !defined(DOSCODE)
+	musicDelay(); // more credits on this page now
+#endif
+	readPict("p:Intro/DA", true);
+	musicDelay();
+
+	g_music->newOpen("p:Intro/Intro.1");  /* load the picture into the buffer */
+
+	g_music->newCheckMusic();
+	blackAllScreen();
+	g_music->fillUpMusic(true);
+
+	getFont("P:Map.font", msgfont);
+
+	nopalchange = true;
+	noscreenchange = true;
+	readPict("p:Intro/Intro.1", true);
+	noscreenchange = false;
+	nopalchange = false;
+
+	for (counter = 0; counter < 16; counter++) {
+		Palette[counter] = ((diffcmap[counter * 3] >> 2) << 8) +
+		                   ((diffcmap[counter * 3 + 1] >> 2) << 4) +
+		                   (diffcmap[counter * 3 + 2] >> 2);
+	}
+
+	doPictText("i.1", true);
+	doPictText("i.2A", true);
+	doPictText("i.2B", true);
+
+	freeAllStolenMem();
+
+	blackAllScreen();
+	g_music->fillUpMusic(true);
+
+	IntroDoBlack = true;
+	NReadPict("Station1", true);
+	doPictText("i.3", false);
+
+	NReadPict("Station2", true);
+	doPictText("i.4", false);
+
+	NReadPict("Stiles4", true);
+	doPictText("i.5", false);
+
+	NReadPict("Stiles3", true);
+	doPictText("i.6", false);
+
+	NReadPict("Platform2", true);
+	doPictText("i.7", false);
+
+	NReadPict("Subway.1", true);
+	doPictText("i.8", false);
+
+	NReadPict("Subway.2", true);
+
+	doPictText("i.9", false);
+	doPictText("i.10", false);
+	doPictText("i.11", false);
+
+	if (!QuitIntro)
+		for (counter = 0; counter < 50; counter++) {
+			for (counter1 = (8 * 3); counter1 < (255 * 3); counter1++)
+				diffcmap[counter1] = 255 - diffcmap[counter1];
+
+			g_music->newCheckMusic();
+			waitTOF();
+			VGASetPal(diffcmap, 256);
+			waitTOF();
+			waitTOF();
+		}
+
+	doPictText("i.12", false);
+	doPictText("i.13", false);
+
+	IntroDoBlack = false;
+	NReadPict("Daed0", true);
+	doPictText("i.14", false);
+
+	NReadPict("Daed1", true);
+	doPictText("i.15", false);
+
+	NReadPict("Daed2", true);
+	doPictText("i.16", false);
+	doPictText("i.17", false);
+	doPictText("i.18", false);
+
+	NReadPict("Daed3", true);
+	doPictText("i.19", false);
+	doPictText("i.20", false);
+
+	NReadPict("Daed4", true);
+	doPictText("i.21", false);
+
+	NReadPict("Daed5", true);
+	doPictText("i.22", false);
+	doPictText("i.23", false);
+	doPictText("i.24", false);
+
+	NReadPict("Daed6", true);
+	doPictText("i.25", false);
+	doPictText("i.26", false);
+
+	NReadPict("Daed7", false);
+	doPictText("i.27", false);
+	doPictText("i.28", false);
+	stopDiffEnd();
+
+	NReadPict("Daed8", true);
+	doPictText("i.29", false);
+	doPictText("i.30", false);
+
+	NReadPict("Daed9", true);
+	doPictText("i.31", false);
+	doPictText("i.32", false);
+	doPictText("i.33", false);
+
+	NReadPict("Daed9a", true);
+	NReadPict("Daed10", true);
+	doPictText("i.34", false);
+	doPictText("i.35", false);
+	doPictText("i.36", false);
+
+	NReadPict("SubX", true);
+
+	if (QuitIntro) {
+		setAPen(0);
+		rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1);
+		DoBlack = true;
+	}
+
+	hidemouse = false;
+}
+
+} // End of namespace Lab
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
new file mode 100644
index 0000000..edde50b
--- /dev/null
+++ b/engines/lab/lab.cpp
@@ -0,0 +1,68 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+ /*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "common/debug-channels.h"
+#include "common/scummsys.h"
+#include "common/error.h"
+#include "common/fs.h"
+#include "common/rect.h"
+
+#include "engines/util.h"
+
+#include "lab/lab.h"
+#include "lab/labfun.h"
+
+namespace Lab {
+
+bool LabEngine::hasFeature(EngineFeature f) const {
+	return (f == kSupportsRTL) ? true : false;
+}
+
+LabEngine::LabEngine(OSystem *syst)
+ : Engine(syst) {
+}
+
+LabEngine::~LabEngine() {
+	// Remove all of our debug levels here
+	DebugMan.clearAllDebugChannels();
+}
+
+Common::Error LabEngine::run() {
+	// Initialize graphics using following:
+	initGraphics(320, 200, false);
+
+	g_music = new Music();
+
+	inner_main();
+
+	return Common::kNoError;
+}
+
+} // End of namespace Lab
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
new file mode 100644
index 0000000..3b1e411
--- /dev/null
+++ b/engines/lab/lab.h
@@ -0,0 +1,52 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+ /*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#ifndef LAB_H
+#define LAB_H
+
+#include "common/array.h"
+
+#include "engines/engine.h"
+
+namespace Lab {
+
+class LabEngine : public Engine {
+public:
+	LabEngine(OSystem *syst);
+	~LabEngine();
+
+	virtual Common::Error run();
+
+	bool hasFeature(EngineFeature f) const;
+};
+
+} // End of namespace Lab
+
+#endif // LAB_H
diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
new file mode 100644
index 0000000..90db66f
--- /dev/null
+++ b/engines/lab/labfile.cpp
@@ -0,0 +1,549 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/labfun.h"
+#include "lab/mouse.h"
+#include "lab/storage.h"
+#include "common/file.h"
+
+namespace Lab {
+
+#define MAXREADSIZE 30720L
+#define DMABUGSIZE  0     /* The number of bytes the DMA driver might screw */
+/* NOTE: set to 0 for non-CDTV machines.          */
+
+
+
+static byte *buffer = NULL, *realbufferstart = NULL, *startoffilestorage = NULL;
+
+byte **startoffile = &startoffilestorage;
+static uint32 buffersize, realbuffersize;
+
+uint32 ReadSoFar;
+bool ReadIsError, ReadIsDone;
+
+
+#if defined(WIN32)
+#define stat _stat
+#endif
+
+/*****************************************************************************/
+/* Returns the size of a file.                                               */
+/*****************************************************************************/
+uint32 sizeOfFile(const char *name) {
+	Common::File file;
+
+	file.open(translateFileName(name));
+	if (!file.isOpen()) {
+		warning("Cannot open file %s", translateFileName(name));
+
+		return 0;
+	}
+	uint32 size = file.size();
+	file.close();
+
+	return size;
+}
+
+
+
+
+/*-------------------- Routines that buffer a whole file --------------------*/
+
+
+
+/*----- divides up and manages the buffer -----*/
+
+
+
+#define MAXMARKERS        15
+
+
+
+typedef struct {
+	char name[32];
+	void *Start, *End;
+} FileMarker;
+
+
+
+static FileMarker FileMarkers[MAXMARKERS];
+static uint16 CurMarker  = 0;
+static void *MemPlace   = NULL;
+
+
+
+
+
+/*****************************************************************************/
+/* Frees a File's resources.                                                 */
+/*****************************************************************************/
+static void freeFile(uint16 RMarker) {
+	FileMarkers[RMarker].name[0] = 0;
+	FileMarkers[RMarker].Start  = NULL;
+	FileMarkers[RMarker].End    = NULL;
+}
+
+
+
+
+
+/*****************************************************************************/
+/* Gets a chunk of memory from the buffer.                                   */
+/*****************************************************************************/
+static void *getCurMem(uint32 size) {
+	void *ptr = 0;
+
+	warning ("STUB: getCurMem(%d)", size);
+
+#if 0
+	if ((((char *) MemPlace) + size - 1) >=
+	        (((char *) buffer) + buffersize))
+		MemPlace = buffer;
+
+	ptr = MemPlace;
+	((char *)MemPlace) += size;
+
+	for (int counter = 0; counter < MAXMARKERS; counter++) {
+		if (FileMarkers[counter].name[0]) {
+			if (((FileMarkers[counter].Start >= ptr) &&
+			        (FileMarkers[counter].Start < MemPlace))  ||
+			        ((FileMarkers[counter].End >= ptr) &&
+			         (FileMarkers[counter].End < MemPlace))    ||
+			        ((ptr >= FileMarkers[counter].Start) &&
+			         (ptr <= FileMarkers[counter].End)))
+
+				freeFile(counter);
+		}
+	}
+#endif
+	return ptr;
+}
+
+
+
+
+/*****************************************************************************/
+/* Checks if a file is already buffered.                                     */
+/*****************************************************************************/
+byte **isBuffered(const char *fileName) {
+	uint16 RMarker;
+
+	if (fileName == NULL)
+		return NULL;
+
+	RMarker = 0;
+
+	while (RMarker < MAXMARKERS) {
+		if (strcmp(FileMarkers[RMarker].name, fileName) == 0) {
+			*startoffile = (byte *) FileMarkers[RMarker].Start;
+			return startoffile;
+		} else
+			RMarker++;
+	}
+
+	return NULL;
+}
+
+
+
+
+/*****************************************************************************/
+/* Grabs a chunk of memory from the room buffer, and manages it for a        */
+/* particular room. If it returns true, then the file is already in memory. */
+/*****************************************************************************/
+bool allocFile(void **Ptr, uint32 Size, const char *fileName) {
+	uint16 RMarker;
+	byte **temp;
+
+	Size += DMABUGSIZE;
+
+	if (1 & Size)  /* Memory is required to be even aligned */
+		Size++;
+
+	temp = isBuffered(fileName);
+
+	if (temp) {
+		*Ptr = *temp;
+		return true;
+	}
+
+	RMarker = CurMarker;
+	CurMarker++;
+
+	if (CurMarker >= MAXMARKERS)
+		CurMarker = 0;
+
+	freeFile(RMarker);
+	strcpy(FileMarkers[RMarker].name, fileName);
+
+	*Ptr = getCurMem(Size);
+	FileMarkers[RMarker].Start = *Ptr;
+	FileMarkers[RMarker].End   = (void *)(((char *)(*Ptr)) + Size - 1);
+
+	return false;
+}
+
+
+
+
+
+/*----- Main routines -----*/
+
+
+/*****************************************************************************/
+/* Reads a file into memory.                                                 */
+/*****************************************************************************/
+byte **openFile(const char *name) {
+	warning("STUB: openFile");
+
+	return NULL;
+#if 0
+	char *tempbuffer, *Buffer;
+	int32 Size, Left;
+	int FPtr, ReadSize, myread;
+
+	ReadSoFar   = 0L;
+	ReadIsError = false;
+	ReadIsDone  = false;
+
+	if ((buffer == NULL) || (name == NULL)) {
+		ReadIsError = true;
+		ReadIsDone  = true;
+		return NULL;
+	}
+
+	Size = sizeOfFile(name);
+
+	if (!Size || (Size > ((int32) buffersize))) {
+		ReadIsError = true;
+		ReadIsDone  = true;
+		return NULL;
+	}
+
+	if (allocFile((void **) &Buffer, Size, name)) { /* Get place in Buffer     */
+		*startoffile = Buffer;                        /* If the file is buffered */
+
+		ReadSoFar   = Size;
+		ReadIsError = false;
+		ReadIsDone  = true;
+
+		return startoffile;
+	}
+
+#if defined(WIN32)
+#if defined(DEMODATA)
+	{
+		FILE *fh = fopen("c:\\depot\\labyrinth\\demodata.log", "a+w");
+		fprintf(fh, "%s\n", name);
+		fclose(fh);
+	}
+#endif
+
+	FPtr = open(translateFileName(name), O_RDONLY | O_BINARY);
+#else
+	FPtr = open(translateFileName(name), O_RDONLY);
+#endif
+
+	if (FPtr != -1) {
+		Left = Size;
+		tempbuffer = Buffer;
+		*startoffile = Buffer;
+
+		while (Left) {
+			fileCheckMusic(Left);
+
+			if (Left > MAXREADSIZE)
+				ReadSize = MAXREADSIZE;
+			else
+				ReadSize = (int) Left;
+
+			if (!(myread = read(FPtr, tempbuffer, ReadSize + DMABUGSIZE))) {
+				ReadIsError = false;
+				ReadIsDone  = true;
+
+				close(FPtr);
+				return NULL;
+			}
+
+			/* Not necessary for IBM version
+			      if ((ReadSize == MAXREADSIZE) && DMABUGSIZE)
+			        Seek(FPtr, -DMABUGSIZE, (int32) OFFSET_CURRENT);
+			 */
+
+			ReadSoFar  += ReadSize;
+			tempbuffer += ReadSize;
+			Left       -= ReadSize;
+		}
+
+		ReadIsDone = true;
+		close(FPtr);
+		return startoffile;
+	} else {
+		ReadIsError = false;
+		ReadIsDone  = true;
+
+		return NULL;
+	}
+#endif
+}
+
+
+
+/*****************************************************************************/
+/* Reads a block of memory.                                                  */
+/*****************************************************************************/
+void readBlock(void *Buffer, uint32 Size, byte **File) {
+	memcpy(Buffer, *File, (size_t) Size);
+	(*File) += Size;
+}
+
+
+
+/*****************************************************************************/
+/* Reads on character.                                                       */
+/*****************************************************************************/
+char readChar(char **File) {
+	char c = **File;
+
+	(*File)++;
+	return c;
+}
+
+
+
+
+/*****************************************************************************/
+/* Skips a chunk of memory.                                                  */
+/*****************************************************************************/
+void skip(byte **File, uint32 skip) {
+	(*File) += skip;
+}
+
+
+
+/*****************************************************************************/
+/* Resets the internal buffers to empty.                                     */
+/*****************************************************************************/
+void resetBuffer(void) {
+	uint16 RMarker;
+
+	CurMarker = 0;
+	RMarker   = 0;
+	MemPlace  = buffer;
+
+	while (RMarker < MAXMARKERS) {
+		freeFile(RMarker);
+		RMarker++;
+	}
+}
+
+
+
+/*****************************************************************************/
+/* Initializes the buffer.                                                   */
+/*****************************************************************************/
+bool initBuffer(uint32 BufSize, bool IsGraphicsMem) {
+	if (!allocate((void **) &buffer, BufSize))
+		buffer = NULL;
+
+	buffersize = BufSize;
+	realbuffersize = buffersize;
+	realbufferstart = buffer;
+
+	resetBuffer();
+
+	return (buffer != NULL);
+}
+
+
+
+
+/*****************************************************************************/
+/* Frees the buffer.                                                         */
+/*****************************************************************************/
+void freeBuffer(void) {
+	freeAllStolenMem();
+
+	if (buffer)
+		deallocate(buffer, buffersize);
+}
+
+
+
+
+/*------------------------------------------------------------------------*/
+/* The following routines allow stealing of memory from the buffer (which */
+/* later may or may not be given back).                                   */
+/*------------------------------------------------------------------------*/
+
+
+
+
+/*****************************************************************************/
+/* Clears all the buffers.                                                   */
+/*****************************************************************************/
+static void flushBuffers(void) {
+	uint16 RMarker;
+
+	RMarker = 0;
+
+	while (RMarker < MAXMARKERS) {
+		freeFile(RMarker);
+		RMarker++;
+	}
+}
+
+
+
+/*****************************************************************************/
+/* Steal some memory from the buffer                                         */
+/*****************************************************************************/
+void *stealBufMem(int32 Size) {
+	void *Mem;
+
+	Size += DMABUGSIZE;
+
+	flushBuffers();
+	Mem = buffer;
+
+	buffer += Size;
+	buffersize -= Size;
+	MemPlace = buffer;
+
+	return Mem;
+}
+
+
+Common::File *openPartial(const char *name) {
+	Common::File *f;
+
+	f = new Common::File();
+	f->open(translateFileName(name));
+
+	if (!f->isOpen()) {
+		delete f;
+		return 0;
+	}
+
+	return f;
+}
+
+
+/*****************************************************************************/
+/* Frees all the memory stolen from the buffer.                              */
+/*****************************************************************************/
+void freeAllStolenMem(void) {
+	flushBuffers();
+
+	buffer = realbufferstart;
+	buffersize = realbuffersize;
+	MemPlace = buffer;
+}
+
+
+
+
+/*--------------- Routines that read partial chunks of a file ---------------*/
+
+
+
+/*****************************************************************************/
+/* Reads Size amount of bytes into buffer.                                   */
+/*****************************************************************************/
+uint32 readPartial(int32 File, void *buf, uint32 Size) {
+	uint32 haveread = 0;
+
+	warning("STUB: readPartial");
+
+#if 0
+	uint32 nsize;
+
+	while (Size) {
+		if (Size > MAXREADSIZE)
+			nsize = MAXREADSIZE;
+		else
+			nsize = Size;
+
+		haveread += (uint32)(read((int) File, buf, (int) nsize));
+		Size -= nsize;
+		((char *) buf) += nsize;
+		updateMouse();
+	}
+#endif
+	return haveread;
+}
+
+
+
+/*****************************************************************************/
+/* Reads Size amount of bytes into buffer.  Use this one if the data must    */
+/* absolutely be correct (compressed data for example).  Otherwise, because  */
+/* of the DMA bug, last two bytes may be screwed.                            */
+/*****************************************************************************/
+uint32 newReadPartial(int32 File, void *buf, uint32 Size) {
+	return readPartial((int) File, buf, Size);
+}
+
+
+
+/*****************************************************************************/
+/* Reads Size amount of bytes into buffer.  Use this one if the data must    */
+/* absolutely be correct (compressed data for example).  Otherwise, because  */
+/* of the DMA bug, last two bytes may be screwed.  This one will work if the */
+/* data is not padded the extra two bytes.                                   */
+/*****************************************************************************/
+uint32 bufferedReadPartial(int32 File, void *buf, uint32 Size) {
+	return readPartial(File, buf, Size);
+}
+
+
+
+/*****************************************************************************/
+/* Sets the current position in the file relative to the beginning of the    */
+/* file.                                                                     */
+/*****************************************************************************/
+void setPos(int32 File, uint32 Place) {
+	warning("STUB: setPos");
+	//lseek((int) File, (int32) Place, SEEK_SET);
+}
+
+
+
+/*****************************************************************************/
+/* Skips a certain number of bytes either forward or backwards.              */
+/*****************************************************************************/
+void skipPartial(int32 File, int32 Skip) {
+	warning("STUB: skipPartial");
+
+	//lseek((int) File, Skip, SEEK_CUR);
+}
+
+} // End of namespace Lab
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
new file mode 100644
index 0000000..08130f3
--- /dev/null
+++ b/engines/lab/labfun.h
@@ -0,0 +1,393 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#ifndef LAB_LABFUN_H
+#define LAB_LABFUN_H
+
+#include "lab/stddefines.h"
+#include "lab/parsetypes.h"
+#include "common/file.h"
+
+namespace Lab {
+
+/* Direction defines */
+#define NORTH   0
+#define SOUTH   1
+#define EAST    2
+#define WEST    3
+
+
+
+/* Generic co-ordinate define. */
+typedef struct {
+	uint16 x1, y1;
+} Cords;
+
+struct Image;
+struct TextFont;
+
+/*----------------------------*/
+/*------ From Audioi.c -------*/
+/*----------------------------*/
+
+bool initAudio(void);
+
+void freeAudio(void);
+
+void initSampleRate(uint16 SampleSpeed);
+
+bool musicBufferEmpty(uint16 i);
+
+void playMusicBlock(void *Ptr, uint32 Size, uint16 BufferNum, uint16 SampleSpeed);
+
+void updateSoundBuffers(void);
+
+void flushAudio(void);
+
+void playMusic(uint16 SampleSpeed, uint16 Volume, uint32 Length, bool flush, void *Data);
+
+
+
+
+/*----------------------------*/
+/*----- From graphics.c ------*/
+/*----------------------------*/
+
+/* Reads in pictures */
+
+bool readPict(const char *filename, bool PlayOnce);
+
+bool readMusic(const char *filename);
+
+byte *readPictToMem(const char *filename, uint16 x, uint16 y);
+
+/* Window text stuff */
+
+uint32 flowText(void *font,  /* the TextAttr pointer */
+                uint16 spacing,          /* How much vertical spacing between the lines */
+                uint16 pencolor,         /* pen number to use for text */
+                uint16 backpen,          /* the background color */
+                bool fillback,                /* Whether to fill the background */
+                bool centerh,                 /* Whether to center the text horizontally */
+                bool centerv,                 /* Whether to center the text vertically */
+                bool output,                  /* Whether to output any text */
+                uint16 x1,               /* Cords */
+                uint16 y1, uint16 x2, uint16 y2, const char *text); /* The text itself */
+
+uint32 flowTextToMem(struct Image *DestIm, void *font,     /* the TextAttr pointer */
+                     uint16 spacing,          /* How much vertical spacing between the lines */
+                     uint16 pencolor,         /* pen number to use for text */
+                     uint16 backpen,          /* the background color */
+                     bool fillback,                /* Whether to fill the background */
+                     bool centerh,                 /* Whether to center the text horizontally */
+                     bool centerv,                 /* Whether to center the text vertically */
+                     bool output,                  /* Whether to output any text */
+                     uint16 x1,               /* Cords */
+                     uint16 y1, uint16 x2, uint16 y2, const char *text); /* The text itself */
+
+void drawMessage(const char *text);
+
+void longDrawMessage(const char *text);
+
+bool readFont(char *filename, void *font, void *data);
+
+/* The Wipes */
+
+void doWipe(uint16 WipeType, CloseDataPtr *CPtr, char *filename);
+
+
+/* Double Buffer stuff */
+
+void newFlipViews(void *scrPtr, uint16 *newpal, uint16 numcolors);
+
+void flipViews(void *scrPtr);
+
+
+
+
+/*----------------------------*/
+/*----- From Interface.c -----*/
+/*----------------------------*/
+
+struct Gadget *addGadButton(uint16 x, uint16 y, void *UpImage, void *DownImage, uint16 id);
+
+void gadgetsOnOff(void *gptr, void *win, int32 num, bool on);
+
+/*----------------------*/
+/*---- From Intro.c ----*/
+/*----------------------*/
+
+void introSequence(void);
+
+
+
+/*----------------------*/
+/*----- From Lab.c -----*/
+/*----------------------*/
+
+void eatMessages(void);
+
+bool setUpScreens(void);
+
+void drawPanel(void);
+
+bool quitPlaying(void);
+
+
+
+/*---------------------------*/
+/*------ From LabFile.c -----*/
+/*---------------------------*/
+
+uint32 sizeOfFile(const char *name);
+
+/* Buffer a whole file */
+
+byte **isBuffered(const char *fileName);
+
+byte **openFile(const char *name);
+
+void readBlock(void *Buffer, uint32 Size, byte **File);
+
+char readChar(char **File);
+
+void skip(byte **File, uint32 skip);
+
+void resetBuffer(void);
+
+bool initBuffer(uint32 BufSize, bool IsGraphicsMem);
+
+void freeBuffer(void);
+
+
+/* Functions that borrow memory from the buffer */
+
+bool allocFile(void **Ptr, uint32 Size, const char *fileName);
+
+void *stealBufMem(int32 Size);
+
+void freeAllStolenMem(void);
+
+
+/* Read chunks of a file */
+
+
+Common::File *openPartial(const char *name);
+
+void closePartial(int32 File);
+
+uint32 readPartial(int32 File, void *buffer, uint32 Size);
+
+uint32 newReadPartial(int32 File, void *buffer, uint32 Size);
+
+uint32 bufferedReadPartial(int32 File, void *buffer, uint32 Size);
+
+
+void setPos(int32 File, uint32 Place);
+
+void skipPartial(int32 File, int32 Skip);
+
+
+
+/*---------------------------*/
+/*------ From LabText.c -----*/
+/*---------------------------*/
+
+bool initLabText(void);
+
+void freeLabText(void);
+
+void decrypt(byte *text);
+
+
+
+/*---------------------------*/
+/*----- From LabMusic.c -----*/
+/*---------------------------*/
+
+#define MANYBUFFERS        5L
+#define MAXBUFFERS         5L
+#define MINBUFFERS         2L
+
+class Music {
+public:
+	Music();
+
+	byte **newOpen(const char *name);
+	bool initMusic(void);
+	void freeMusic(void);
+	void fillUpMusic(bool doit);
+	void updateMusic(void);
+	void checkMusic(void);
+	void newCheckMusic(void);
+	void closeMusic(void);
+	void setMusic(bool on);
+	void restartBackMusic(void);
+	void pauseBackMusic(void);
+	void changeMusic(const char *newmusic);
+	void resetMusic(void);
+	void fileCheckMusic(uint32 filelength);
+
+	bool _winmusic, _doNotFileFlushAudio;
+	bool _turnMusicOn;
+	bool _musicOn;
+
+private:
+	void fillbuffer(uint16 unit);
+	uint16 getManyBuffersLeft(void);
+	void startMusic(bool startatbegin);
+
+	Common::File *_file;
+	Common::File *_tFile;
+	bool _musicPaused;
+
+	bool _tMusicOn;
+	uint32 _tFileLength;
+	uint32 _tLeftInFile;
+
+	uint16 _manyBuffers;
+
+	void *_musicBuffer[MAXBUFFERS];
+	uint16 _musicFilledTo, _musicPlaying, _musicOnBuffer;
+
+	uint32 _filelength, _leftinfile;
+};
+
+
+extern Music *g_music;
+
+/*---------------------------*/
+/*----- From LabSets.c ------*/
+/*---------------------------*/
+
+typedef struct {
+	uint16 lastElement, array[1];
+} LargeSetRecord;
+
+typedef LargeSetRecord *LargeSet;
+
+
+
+bool createSet(LargeSet *set, uint16 last);
+
+void deleteSet(LargeSet set);
+
+bool In(LargeSet set, uint16 element);
+
+void inclElement(LargeSet set, uint16 element);
+
+void exclElement(LargeSet set, uint16 element);
+
+
+
+
+/*---------------------------*/
+/*----- From Machine.c ------*/
+/*---------------------------*/
+
+uint16 scaleX(uint16 x);
+
+uint16 scaleY(uint16 y);
+
+uint16 VGAScaleX(uint16 x);
+
+uint16 VGAScaleY(uint16 y);
+
+int16 VGAScaleXs(int16 x);
+
+int16 VGAScaleYs(int16 y);
+
+uint16 SVGACord(uint16 cord);
+
+uint16 VGAUnScaleX(uint16 x);
+
+uint16 VGAUnScaleY(uint16 y);
+
+char *translateFileName(const char *filename);
+
+
+
+/*---------------------------*/
+/*-------- From Map.c -------*/
+/*---------------------------*/
+
+void fade(bool fadein, uint16 res);
+
+void setAmigaPal(uint16 *pal, uint16 numcolors);
+
+char *getText(const char *filename);
+
+bool getFont(const char *filename, TextFont *textfont);
+
+void readImage(byte **buffer, Image **im);
+
+void doMap(LargeSet RoomsFound, uint16 CurRoom);
+
+void doJournal(LargeSet Conditions);
+
+void doNotes(void);
+
+void doWestPaper(void);
+
+void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+
+uint16 doDisks(void);
+
+bool saveRestoreGame(void);
+
+
+
+/*--------------------------*/
+/*----- From saveGame.c ----*/
+/*--------------------------*/
+
+bool saveFloppy(char *path, uint16 RoomNum, uint16 Direction, uint16 NumQuarters, LargeSet Conditions, LargeSet Rooms, uint16 filenum, uint16 type);
+
+bool readFloppy(char *path, uint16 *RoomNum, uint16 *Direction, uint16 *NumQuarters, LargeSet Conditions, LargeSet Rooms, uint16 filenum, uint16 type);
+
+
+
+/*--------------------------*/
+/*----- From Special.c -----*/
+/*--------------------------*/
+
+void showCombination(const char *filename);
+
+void mouseCombination(LargeSet Conditions, uint16 x, uint16 y);
+
+void showTile(const char *filename, bool showsolution);
+
+void mouseTile(LargeSet Conditions, uint16 x, uint16 y);
+
+void inner_main();
+
+} // End of namespace Lab
+
+#endif /* LAB_LABFUN_H */
diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
new file mode 100644
index 0000000..e15dfa7
--- /dev/null
+++ b/engines/lab/labmusic.cpp
@@ -0,0 +1,543 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/stddefines.h"
+#include "lab/storage.h"
+#include "lab/labfun.h"
+#include "lab/timing.h"
+#include "lab/mouse.h"
+
+namespace Lab {
+
+#define MUSICBUFSIZE   (2 * 65536L)
+
+#define SAMPLESPEED    15000L
+
+extern bool EffectPlaying;
+Music *g_music;
+
+Music::Music() {
+	_file = 0;
+	_tFile = 0;
+	_musicPaused = false;
+
+	_tMusicOn = false;
+	_tFileLength = 0;
+	_tLeftInFile = 0;
+
+	_manyBuffers = MANYBUFFERS;
+
+	_musicFilledTo = 0;
+	_musicPlaying  = 0;
+	_musicOnBuffer = 0;
+
+	_filelength = 0;
+	_leftinfile = 0;
+
+	_musicOn = false;
+	_turnMusicOn = false;
+	_winmusic = false;
+	_doNotFileFlushAudio = false;
+}
+
+/*****************************************************************************/
+/* Figures out which buffer is currently playing based on messages sent to   */
+/* it from the Audio device.                                                 */
+/*****************************************************************************/
+void Music::updateMusic(void) {
+	uint16 i;
+
+#if !defined(DOSCODE)
+	//SDL_ProcessInput(0);
+#endif
+	updateMouse();
+
+	if (EffectPlaying)
+		updateSoundBuffers();
+	else if (_musicOn) {
+		for (i = 0; i < 2; i++) {
+			if (musicBufferEmpty(i)) {
+				playMusicBlock(_musicBuffer[_musicPlaying], MUSICBUFSIZE, i, SAMPLESPEED);
+
+				if (_musicPlaying)
+					_musicOnBuffer = _musicPlaying - 1;
+				else
+					_musicOnBuffer = _manyBuffers - 1;
+
+				_musicPlaying++;
+
+				if (_musicPlaying >= _manyBuffers)
+					_musicPlaying = 0;
+			}
+		}
+	}
+}
+
+
+void Music::fillbuffer(uint16 unit) {
+	uint32 Size = MUSICBUFSIZE;
+	void *ptr  = _musicBuffer[unit];
+#if defined(DOSCODE)
+	char *endptr;
+#endif
+
+	if (Size < _leftinfile) {
+		_file->read(ptr, Size);
+		_leftinfile -= Size;
+	} else {
+		_file->read(ptr, _leftinfile);
+
+#if defined(DOSCODE)
+		endptr = ptr;
+		endptr += _leftinfile - 2;
+
+		memset((void *)(((uint32) ptr) + _leftinfile), *endptr, Size - _leftinfile);
+#else
+		memset((char *)ptr + _leftinfile, 0, Size - _leftinfile);
+#endif
+
+		_file->seek(0);
+		_leftinfile = _filelength;
+	}
+}
+
+
+
+/*****************************************************************************/
+/* Figures out how many *complete* buffers of music left to play.            */
+/*****************************************************************************/
+uint16 Music::getManyBuffersLeft(void) {
+	uint16 mp = _musicOnBuffer;
+
+	if (mp == _musicFilledTo) /* Already filled */
+		return _manyBuffers;
+	else if (mp > _musicFilledTo)
+		return _manyBuffers - (mp - _musicFilledTo);
+	else
+		return _musicFilledTo - mp;
+}
+
+
+
+/*****************************************************************************/
+/* Fills up the buffers that have already been played if necessary; if doit  */
+/* is set to TRUE then it will fill up all empty buffers.  Otherwise, it     */
+/* Check if there are MINBUFFERS or less buffers that are playing.           */
+/*****************************************************************************/
+void Music::fillUpMusic(bool doit) {
+	int16 ManyLeft, ManyFill;
+
+	updateMusic();
+
+	if (!_musicOn)
+		return;
+
+	ManyLeft = getManyBuffersLeft();
+
+	if (ManyLeft < MINBUFFERS)
+		doit = true;
+	else if (ManyLeft == _manyBuffers)  /* All the buffers are already full */
+		doit = false;
+
+	if (doit && (ManyLeft < _manyBuffers) && ManyLeft) {
+		ManyFill = _manyBuffers - ManyLeft - 1;
+
+		while (ManyFill > 0) {
+			_musicFilledTo++;
+
+			if (_musicFilledTo >= _manyBuffers)
+				_musicFilledTo = 0;
+
+			fillbuffer(_musicFilledTo);
+			updateMusic();
+
+			ManyFill--;
+		}
+
+		updateMusic();
+
+		ManyLeft = getManyBuffersLeft();
+
+		if (ManyLeft < _manyBuffers) {
+			ManyFill = _manyBuffers - ManyLeft - 1;
+
+			while (ManyFill > 0) {
+				_musicFilledTo++;
+
+				if (_musicFilledTo >= _manyBuffers)
+					_musicFilledTo = 0;
+
+				fillbuffer(_musicFilledTo);
+				updateMusic();
+
+				ManyFill--;
+			}
+		}
+	}
+
+	updateMusic();
+
+	/* NYI: A check for dirty cds; for instance, if lots of buffers already
+	   played */
+}
+
+
+
+
+/*****************************************************************************/
+/* Starts up the music initially.                                            */
+/*****************************************************************************/
+void Music::startMusic(bool startatbegin) {
+	uint16 counter;
+
+	if (!_musicOn)
+		return;
+
+	flushAudio();
+
+	if (startatbegin) {
+		_file->seek(0);
+		_leftinfile  = _filelength;
+	}
+
+	initSampleRate(SAMPLESPEED);
+
+	_musicPlaying  = 0;
+	_musicOnBuffer = 0;
+	_musicFilledTo = _manyBuffers - 1;
+
+	_musicOn = false;
+
+	for (counter = 0; counter < _manyBuffers; counter++)
+		fillbuffer(counter);
+
+	_musicOn = true;
+	updateMusic();
+}
+
+
+
+
+
+
+/*****************************************************************************/
+/* Initializes the music buffers.                                            */
+/*****************************************************************************/
+bool Music::initMusic(void) {
+	uint16 counter;
+	bool mem;
+
+	if (!_turnMusicOn)
+		return true;
+
+	_musicOn = true;
+	_musicPaused = false;
+
+	const char *filename;
+
+	if (_winmusic)
+		filename = "Music:WinGame";
+	else
+		filename = "Music:BackGrou";
+
+	mem = true;
+
+	if (_musicBuffer[0] == NULL) {
+		for (counter = 0; counter < _manyBuffers; counter++)
+			mem = mem && allocatedos((void **) & (_musicBuffer[counter]), MUSICBUFSIZE);
+	}
+
+	if (mem) {
+		_filelength = sizeOfFile(filename);
+		_file = openPartial(filename);
+
+		if (_file) {
+			startMusic(true);
+			return true;
+		}
+	}
+
+	_musicOn = false;
+	return false;
+}
+
+
+
+/*****************************************************************************/
+/* Frees up the music buffers and closes the file.                           */
+/*****************************************************************************/
+void Music::freeMusic(void) {
+	_musicOn = false;
+
+	if (_file->isOpen())
+		_file->close();
+
+	_file = 0;
+}
+
+
+/*****************************************************************************/
+/* Pauses the background music.                                              */
+/*****************************************************************************/
+void Music::pauseBackMusic(void) {
+	if (!_musicPaused && _musicOn) {
+		updateMusic();
+		_musicOn = false;
+		flushAudio();
+
+		if (_musicPlaying)
+			_musicPlaying--;
+		else
+			_musicPlaying = _manyBuffers - 1;
+
+		_musicPaused = true;
+	}
+}
+
+
+
+/*****************************************************************************/
+/* Restarts the paused background music.                                     */
+/*****************************************************************************/
+void Music::restartBackMusic(void) {
+	if (_musicPaused) {
+		flushAudio();
+		_musicOn = true;
+		updateMusic();
+		_musicPaused = false;
+	}
+}
+
+
+
+
+
+/*****************************************************************************/
+/* Checks to see if need to fill buffers fill of music.                      */
+/*****************************************************************************/
+void Music::checkMusic(void) {
+	updateMusic();
+
+	if (!_musicOn)
+		return;
+
+	fillUpMusic(false);
+}
+
+
+
+/*****************************************************************************/
+/* Checks to see if need to fill buffers fill of music.                      */
+/*****************************************************************************/
+void Music::newCheckMusic(void) {
+	checkMusic();
+}
+
+
+
+
+
+/*****************************************************************************/
+/* Turns the music on and off.                                               */
+/*****************************************************************************/
+void Music::setMusic(bool on) {
+	flushAudio();
+
+	if (on && !_musicOn) {
+		_musicOn = true;
+		startMusic(true);
+	} else if (!on && _musicOn) {
+		_musicOn = false;
+		updateMusic();
+	} else
+		_musicOn = on;
+}
+
+/*****************************************************************************/
+/* Changes the background music to something else.                           */
+/*****************************************************************************/
+void Music::changeMusic(const char *newmusic) {
+	if (!_tFile) {
+		_tFile = _file;
+		_tMusicOn = _musicOn;
+		_tFileLength = _filelength;
+#if defined(DOSCODE)
+		_tLeftInFile = _leftinfile;
+#else
+		_tLeftInFile = _leftinfile + 65536L;
+
+		if (_tLeftInFile > _tFileLength)
+			_tLeftInFile = _leftinfile;
+
+#endif
+	}
+
+	_file = openPartial(newmusic);
+
+	if (_file) {
+		_musicOn = true;   /* turn it off */
+		setMusic(false);
+
+		_filelength = sizeOfFile(newmusic);
+
+		_musicOn = false;  /* turn it back on */
+		setMusic(true);
+	} else {
+		_file  = _tFile;
+		_tFile = 0;
+	}
+}
+
+
+
+/*****************************************************************************/
+/* Changes the background music to the original piece playing.               */
+/*****************************************************************************/
+void Music::resetMusic(void) {
+	if (!_tFile)
+		return;
+
+	if (_file->isOpen())
+		_file->close();
+
+	_file      = _tFile;
+	_filelength = _tFileLength;
+	_leftinfile = _tLeftInFile;
+
+	_file->seek(_filelength - _leftinfile);
+
+	_musicOn = true;
+	setMusic(false);
+	updateMusic();
+
+	if (!_tMusicOn) {
+		_tFile = 0;
+		return;
+	}
+
+	_musicOn = _tMusicOn;
+	startMusic(false);
+
+	_tFile = 0;
+}
+
+
+
+
+
+#define FUDGEFACTOR  5L
+#define READSPEED    (2 * 130000L)
+
+
+
+/*****************************************************************************/
+/* Checks whether or note enough memory in music buffer before loading any   */
+/* files.  Fills it if not.  Does not take into account the current buffer   */
+/* playing; a built in fudge factor.  We've also got another FUDGEFACTOR     */
+/* defined above in case things go wrong.                                    */
+/*                                                                           */
+/* Here, the seconds are multipled by 10.                                    */
+/*****************************************************************************/
+byte **Music::newOpen(const char *name) {
+	uint32 filelength, LeftSecs, Time;
+
+	byte **file;
+
+	if (name == NULL) {
+		return NULL;
+	}
+
+	if ((strcmp(name, "") == 0) || (strcmp(name, " ") == 0)) {
+		return NULL;
+	}
+
+	if ((file = isBuffered(name))) {
+		return file;
+	}
+
+	if (_musicOn) {
+		updateMusic();
+
+#if defined(DOSCODE)
+		LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / SAMPLESPEED;
+#else
+		LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / (2 * SAMPLESPEED);
+#endif
+
+		filelength = sizeOfFile(name) * 10;
+		Time = 10 +                           /* Seek time for the music and the file */
+		       (filelength / READSPEED) +     /* Read time for the file */
+		       FUDGEFACTOR;
+
+		if (Time >= LeftSecs)
+			fillUpMusic(true);
+	}
+
+	if (!_doNotFileFlushAudio && EffectPlaying)
+		flushAudio();
+
+	file = openFile(name);
+	checkMusic();
+	return file;
+}
+
+
+
+/*****************************************************************************/
+/* Checks whether or note enough memory in music buffer to continue loading  */
+/* in a file.   Fills the music buffer if not.  Does not take into account   */
+/* the current buffer playing; a built in fudge factor.  We've also got      */
+/* another FUDGEFACTOR defined above in case things go wrong.                */
+/*                                                                           */
+/* Here, the seconds are multipled by 10.                                    */
+/*****************************************************************************/
+void Music::fileCheckMusic(uint32 filelength) {
+	uint32 LeftSecs, Time;
+
+	if (_musicOn) {
+		updateMusic();
+
+#if defined(DOSCODE)
+		LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / SAMPLESPEED;
+#else
+		LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / (2 * SAMPLESPEED);
+#endif
+
+		filelength *= 10;
+		Time = 5 +                            /* Seek time for the music */
+		       (filelength / READSPEED) +     /* Read time for the file  */
+		       FUDGEFACTOR;
+
+		if (Time >= LeftSecs)
+			fillUpMusic(true);
+	}
+}
+
+} // End of namespace Lab
diff --git a/engines/lab/labsets.cpp b/engines/lab/labsets.cpp
new file mode 100644
index 0000000..5faf1cc
--- /dev/null
+++ b/engines/lab/labsets.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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/stddefines.h"
+#include "lab/labfun.h"
+#include "lab/storage.h"
+
+namespace Lab {
+
+const uint32 LargeSetSIZE = sizeof(LargeSetRecord) - 2;
+
+
+
+/*****************************************************************************/
+/* Creates a large set.                                                      */
+/*****************************************************************************/
+bool createSet(LargeSet *set, uint16 last) {
+	last = (((last + 15) >> 4) << 4);
+
+	if (allocate((void **) set, (last >> 3) + LargeSetSIZE)) {
+		(*set)->lastElement  = last;
+		return true;
+	} else /* Not Enough Memory! */
+		return false;
+
+}
+
+
+
+
+/*****************************************************************************/
+/* Deletes a large set.                                                      */
+/*****************************************************************************/
+void deleteSet(LargeSet set) {
+	if (set != NULL)
+		deallocate(set, (set->lastElement >> 3) + LargeSetSIZE);
+}
+
+
+
+
+/*****************************************************************************/
+/* Tests if an element is in the set.                                        */
+/*****************************************************************************/
+bool In(LargeSet set, uint16 element) {
+	return ((1 << ((element - 1) % 16)) & (set->array[(element - 1) >> 4])) > 0;
+}
+
+
+
+/*****************************************************************************/
+/* Sets an element in the Large set.                                         */
+/*****************************************************************************/
+void inclElement(LargeSet set, uint16 element) {
+	INCL((set->array[(element - 1) >> 4]), (1 << ((element - 1) % 16)));
+}
+
+
+
+/*****************************************************************************/
+/* Removes an element in the Large set.                                      */
+/*****************************************************************************/
+void exclElement(LargeSet set, uint16 element) {
+	EXCL((set->array[(element - 1) >> 4]), (1 << ((element - 1) % 16)));
+}
+
+} // End of namespace Lab
diff --git a/engines/lab/labtext.cpp b/engines/lab/labtext.cpp
new file mode 100644
index 0000000..d90929f
--- /dev/null
+++ b/engines/lab/labtext.cpp
@@ -0,0 +1,168 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/stddefines.h"
+#include "lab/storage.h"
+#include "lab/labfun.h"
+
+namespace Lab {
+
+static uint32 SizeOfMemChunk;
+static char *BeginOfMemChunk, *CurPlace;
+
+
+char *LOWERFLOORS, *MIDDLEFLOORS, *UPPERFLOORS, *MEDMAZEFLOORS, *HEDGEMAZEFLOORS, *SURMAZEFLOORS, *CARNIVALFLOOR, *SURMAZEMSG, *FACINGNORTH, *FACINGEAST, *FACINGSOUTH, *FACINGWEST, *LAMPONMSG, *TURNLEFT, *TURNRIGHT, *GOFORWARDDIR, *NOPATH, *TAKEITEM, *SAVETEXT, *LOADTEXT, *BOOKMARKTEXT, *PERSONALTEXT, *DISKTEXT, *SAVEBOOK, *RESTOREBOOK, *SAVEFLASH, *RESTOREFLASH, *SAVEDISK, *RESTOREDISK, *NODISKINDRIVE, *WRITEPROTECTED, *SELECTDISK, *FORMATFLOPPY, *FORMATTING, *NOTHING, *USEONWHAT, *TAKEWHAT, *MOVEWHAT, *OPENWHAT, *CLOSEWHAT, *LOOKWHAT, *USEMAP, *USEJOURNAL, *TURNLAMPON, *TURNLAMPOFF, *USEWHISKEY, *USEPITH, *USEHELMET;
+
+
+#define LABTEXTFILE "Lab:Rooms/LabText"
+
+
+
+
+/*****************************************************************************/
+/* Gets the next string from the list, and changes the end of string marker  */
+/* from an end of line to a null character.                                  */
+/*****************************************************************************/
+static void setString(char **string) {
+	*string = CurPlace;
+
+	while (*CurPlace != '\n')
+		CurPlace++;
+
+	*CurPlace = 0;
+	CurPlace++;
+}
+
+
+
+/*****************************************************************************/
+/* Initializes everything for the Labyrinth text stuff                       */
+/*****************************************************************************/
+bool initLabText(void) {
+	if ((SizeOfMemChunk = sizeOfFile(LABTEXTFILE)))
+		if (allocate((void **) &BeginOfMemChunk, SizeOfMemChunk)) {
+			Common::File *file = openPartial(LABTEXTFILE);
+
+			if (file) {
+				file->read(BeginOfMemChunk, SizeOfMemChunk);
+				file->close();
+
+				CurPlace = BeginOfMemChunk;
+
+				setString(&LOWERFLOORS);
+				setString(&MIDDLEFLOORS);
+				setString(&UPPERFLOORS);
+				setString(&MEDMAZEFLOORS);
+				setString(&HEDGEMAZEFLOORS);
+				setString(&SURMAZEFLOORS);
+				setString(&CARNIVALFLOOR);
+				setString(&SURMAZEMSG);
+
+				setString(&FACINGNORTH);
+				setString(&FACINGEAST);
+				setString(&FACINGSOUTH);
+				setString(&FACINGWEST);
+
+				setString(&LAMPONMSG);
+
+				setString(&TURNLEFT);
+				setString(&TURNRIGHT);
+				setString(&GOFORWARDDIR);
+				setString(&NOPATH);
+				setString(&TAKEITEM);
+
+				setString(&SAVETEXT);
+				setString(&LOADTEXT);
+				setString(&BOOKMARKTEXT);
+				setString(&PERSONALTEXT);
+				setString(&DISKTEXT);
+
+				setString(&SAVEBOOK);
+				setString(&RESTOREBOOK);
+				setString(&SAVEFLASH);
+				setString(&RESTOREFLASH);
+				setString(&SAVEDISK);
+				setString(&RESTOREDISK);
+				setString(&NODISKINDRIVE);
+				setString(&WRITEPROTECTED);
+				setString(&SELECTDISK);
+
+				setString(&FORMATFLOPPY);
+				setString(&FORMATTING);
+
+				setString(&NOTHING);
+				setString(&USEONWHAT);
+				setString(&TAKEWHAT);
+				setString(&MOVEWHAT);
+				setString(&OPENWHAT);
+				setString(&CLOSEWHAT);
+				setString(&LOOKWHAT);
+
+				setString(&USEMAP);
+				setString(&USEJOURNAL);
+				setString(&TURNLAMPON);
+				setString(&TURNLAMPOFF);
+				setString(&USEWHISKEY);
+				setString(&USEPITH);
+				setString(&USEHELMET);
+
+				return true;
+			}
+		}
+
+	return false;
+}
+
+
+/*****************************************************************************/
+/* Frees the memory from the Labyrinth text stuff.                           */
+/*****************************************************************************/
+void freeLabText(void) {
+	if (SizeOfMemChunk && BeginOfMemChunk)
+		deallocate(BeginOfMemChunk, SizeOfMemChunk);
+}
+
+
+
+
+/*****************************************************************************/
+/* Decrypts a chunk of text.                                                 */
+/*****************************************************************************/
+void decrypt(byte *text) {
+	if (text == NULL)
+		return;
+
+	while (*text != '\0') {
+		(*text) -= (byte) 95;
+		text++;
+	}
+}
+
+} // End of namespace Lab
diff --git a/engines/lab/machine.cpp b/engines/lab/machine.cpp
new file mode 100644
index 0000000..ab46ce6
--- /dev/null
+++ b/engines/lab/machine.cpp
@@ -0,0 +1,372 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/stddefines.h"
+
+namespace Lab {
+
+bool IsHiRes = false;
+
+/*****************************************************************************/
+/* Scales the x co-ordinates to that of the new display.  In the room parser */
+/* file, co-ordinates are set up on a 360x336 display.                       */
+/*****************************************************************************/
+uint16 scaleX(uint16 x) {
+	if (IsHiRes)
+		return (uint16)((x * 16) / 9);
+	else
+		return (uint16)((x * 8) / 9);
+}
+
+
+
+
+/*****************************************************************************/
+/* Scales the y co-ordinates to that of the new display.  In the room parser */
+/* file, co-ordinates are set up on a 368x336 display.                       */
+/*****************************************************************************/
+uint16 scaleY(uint16 y) {
+	if (IsHiRes)
+		return (y + (y / 14));
+	else
+		return ((y * 10) / 24);
+}
+
+
+
+
+/*****************************************************************************/
+/* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
+/*****************************************************************************/
+uint16 VGAScaleX(uint16 x) {
+	if (IsHiRes)
+		return (x * 2);
+	else
+		return x;
+}
+
+
+
+
+/*****************************************************************************/
+/* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
+/*****************************************************************************/
+uint16 VGAScaleY(uint16 y) {
+	if (IsHiRes)
+		return ((y * 12) / 5);
+	else
+		return y;
+}
+
+
+
+/*****************************************************************************/
+/* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
+/*****************************************************************************/
+int16 VGAScaleXs(int16 x) {
+	if (IsHiRes)
+		return (x * 2);
+	else
+		return x;
+}
+
+
+
+
+/*****************************************************************************/
+/* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
+/*****************************************************************************/
+int16 VGAScaleYs(int16 y) {
+	if (IsHiRes)
+		return ((y * 12) / 5);
+	else
+		return y;
+}
+
+
+
+
+uint16 SVGACord(uint16 cord) {
+	if (IsHiRes)
+		return cord;
+	else
+		return 0;
+}
+
+
+
+
+/*****************************************************************************/
+/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
+/*****************************************************************************/
+uint16 VGAUnScaleX(uint16 x) {
+	if (IsHiRes)
+		return (x / 2);
+	else
+		return x;
+}
+
+
+
+
+/*****************************************************************************/
+/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
+/*****************************************************************************/
+uint16 VGAUnScaleY(uint16 y) {
+	if (IsHiRes)
+		return ((y * 5) / 12);
+	else
+		return y;
+}
+
+
+
+
+#if defined(WIN32)
+/*****************************************************************************/
+/* Replaces all occurences of a character in a string with a new one.        */
+/*****************************************************************************/
+static void strrplc(char *text, char orig, char replace) {
+	uint16 counter;
+
+	counter = 0;
+
+	while (text[counter]) {
+		if (text[counter] == orig)
+			text[counter] = replace;
+
+		counter++;
+	}
+}
+#endif
+
+
+/*****************************************************************************/
+/* Checks to see if all the characters in the second string are at the start */
+/* of the first.                                                             */
+/*****************************************************************************/
+static bool strstart(const char **Source, const char *Start) {
+	uint16 len1, len2, counter;
+
+	len1 = strlen(*Source);
+	len2 = strlen(Start);
+
+	if (len1 < len2)
+		return false;
+
+	for (counter = 0; counter < len2; counter++)
+		if ((*Source)[counter] != Start[counter])
+			return false;
+
+	(*Source) += len2;
+	return true;
+}
+
+
+static char NewFileName[255];
+
+/*****************************************************************************/
+/* Modifes the filename so that paths and stuff are correct.  Should mostly  */
+/* deal with assigns and the '/' instead of '\' on IBM systems.              */
+/*                                                                           */
+/* NOTE: Make a *copy* of the string, and modify that.  It would be a real   */
+/* *bad* idea to modify the original.  Since Labyrinth only focuses its      */
+/* attention to one file at a time, it would be fine to have one variable    */
+/* not on the stack which is used to store the new filename.                 */
+/*****************************************************************************/
+static void mystrupr(char *s) {
+	char c;
+
+	while ((c = *s) != 0)
+		*s++ = toupper(c);
+}
+
+char *translateFileName(const char *filename) {
+	char tempfilename[255];
+	char *dot;
+
+	strcpy(tempfilename, filename);
+	mystrupr(tempfilename);
+
+	*NewFileName = 0;
+	filename = tempfilename;
+
+	if (strstart(&filename, "P:")) {
+		if (IsHiRes)
+			strcat(NewFileName, "GAME/SPICT/");
+		else
+			strcat(NewFileName, "GAME/PICT/");
+	} else if (strstart(&filename, "LAB:"))
+		strcat(NewFileName, "GAME/");
+	else if (strstart(&filename, "MUSIC:"))
+		strcat(NewFileName, "GAME/MUSIC/");
+
+	strcat(NewFileName, filename);
+
+	dot = strrchr(NewFileName, '.');
+
+	if (dot != NewFileName && dot != NULL && dot[4] != '/') { // Linux may start with '.'
+		dot[4] = 0; // Back to the days of 8.3, even if your OS was never DOSish!!
+	}
+
+	return NewFileName;
+}
+
+#if defined(USE_SWAP)
+
+uint16 swapUShort(uint16 value) {
+	char *b = (char *)&value;
+	char t = b[0];
+	b[0] = b[1];
+	b[1] = t;
+	return value;
+}
+uint16 *swapUShortPtr(uint16 *ptr, int count) {
+	while (count-- > 0) {
+		char *b = (char *)ptr++;
+		char t = b[0];
+		b[0] = b[1];
+		b[1] = t;
+	}
+
+	return ptr;
+}
+int16 swapShort(int16 value) {
+	char *b = (char *)&value;
+	char t = b[0];
+	b[0] = b[1];
+	b[1] = t;
+	return value;
+}
+int16 *swapShortPtr(int16 *ptr, int count) {
+	while (count-- > 0) {
+		char *b = (char *)ptr++;
+		char t = b[0];
+		b[0] = b[1];
+		b[1] = t;
+	}
+
+	return ptr;
+}
+unsigned int swapUInt(unsigned int value) {
+	char *b = (char *)&value;
+	char t = b[0];
+	b[0] = b[3];
+	b[3] = t;
+	t = b[1];
+	b[1] = b[2];
+	b[2] = t;
+	return value;
+}
+unsigned int *swapUIntPtr(unsigned int *ptr, int count) {
+	while (count-- > 0) {
+		char *b = (char *)ptr++;
+		char t = b[0];
+		b[0] = b[3];
+		b[3] = t;
+		t = b[1];
+		b[1] = b[2];
+		b[2] = t;
+	}
+
+	return ptr;
+}
+int swapInt(int value) {
+	char *b = (char *)&value;
+	char t = b[0];
+	b[0] = b[3];
+	b[3] = t;
+	t = b[1];
+	b[1] = b[2];
+	b[2] = t;
+	return value;
+}
+int *swapIntPtr(int *ptr, int count) {
+	while (count-- > 0) {
+		char *b = (char *)ptr++;
+		char t = b[0];
+		b[0] = b[3];
+		b[3] = t;
+		t = b[1];
+		b[1] = b[2];
+		b[2] = t;
+	}
+
+	return ptr;
+}
+uint32 swapULong(uint32 value) {
+	char *b = (char *)&value;
+	char t = b[0];
+	b[0] = b[3];
+	b[3] = t;
+	t = b[1];
+	b[1] = b[2];
+	b[2] = t;
+	return value;
+}
+uint32 *swapULongPtr(uint32 *ptr, int count) {
+	while (count-- > 0) {
+		char *b = (char *)ptr++;
+		char t = b[0];
+		b[0] = b[3];
+		b[3] = t;
+		t = b[1];
+		b[1] = b[2];
+		b[2] = t;
+	}
+
+	return ptr;
+}
+int32 swapLong(int32 value) {
+	char *b = (char *)&value;
+	char t = b[0];
+	b[0] = b[3];
+	b[3] = t;
+	t = b[1];
+	b[1] = b[2];
+	b[2] = t;
+	return value;
+}
+int32 *swapLongPtr(int32 *ptr, int count) {
+	while (count-- > 0) {
+		char *b = (char *)ptr++;
+		char t = b[0];
+		b[0] = b[3];
+		b[3] = t;
+		t = b[1];
+		b[1] = b[2];
+		b[2] = t;
+	}
+
+	return ptr;
+}
+#endif
+
+} // End of namespace Lab
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
new file mode 100644
index 0000000..f6e9499
--- /dev/null
+++ b/engines/lab/map.cpp
@@ -0,0 +1,955 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/storage.h"
+#include "lab/labfun.h"
+#include "lab/diff.h"
+#include "lab/vga.h"
+#include "lab/text.h"
+#include "lab/mouse.h"
+#include "lab/parsefun.h"
+#include "lab/parsetypes.h"
+#include "lab/interface.h"
+#include "lab/text.h"
+#include "lab/stddefines.h"
+
+namespace Lab {
+
+static struct TextFont *BigMsgFont;
+static struct TextFont bmf;
+
+
+extern uint16 Direction;
+extern bool IsHiRes;
+extern uint32 VGAScreenWidth, VGAScreenHeight;
+
+#if !defined(DOSCODE)
+extern CloseDataPtr CPtr;
+extern uint16 RoomNum;
+#endif
+
+/*****************************************************************************/
+/* Converts an Amiga palette (up to 16 colors) to a VGA palette, then sets   */
+/* the VGA palette.                                                          */
+/*****************************************************************************/
+void setAmigaPal(uint16 *pal, uint16 numcolors) {
+	char vgapal[16 * 3];
+	uint16 counter, vgacount;
+
+	if (numcolors > 16)
+		numcolors = 16;
+
+	vgacount = 0;
+
+	for (counter = 0; counter < numcolors; counter++) {
+		vgapal[vgacount]   = (char)(((pal[counter] & 0xf00) >> 8) << 2);
+		vgacount++;
+		vgapal[vgacount] = (char)(((pal[counter] & 0x0f0) >> 4) << 2);
+		vgacount++;
+		vgapal[vgacount] = (char)(((pal[counter] & 0x00f)) << 2);
+		vgacount++;
+	}
+
+	writeColorRegsSmooth(vgapal, 0, 16);
+}
+
+
+/*****************************************************************************/
+/* Gets a font from disk and puts it into temporary memory.                  */
+/*****************************************************************************/
+bool getFont(const char *filename, TextFont *textfont) {
+	byte *fontbuffer;
+
+	fontbuffer = (byte *)stealBufMem(sizeOfFile(filename) -
+	                         (sizeof(struct TextFont) + 4));
+	g_music->checkMusic();
+
+	if (fontbuffer == NULL)
+		return false;
+
+	return openFontMem(filename, textfont, fontbuffer);
+}
+
+
+
+
+/*****************************************************************************/
+/* Gets a chunk of text and puts it into the graphics memory.                */
+/*****************************************************************************/
+char *getText(const char *filename) {
+	bool dodecrypt;
+	byte **tfile;
+
+	g_music->checkMusic();
+	dodecrypt = (isBuffered(filename) == NULL);
+	tfile = g_music->newOpen(filename);
+
+	if (!tfile)
+		return NULL;
+
+	if (dodecrypt)
+		decrypt(*tfile);
+
+	return (char *)*tfile;
+}
+
+
+
+/*****************************************************************************/
+/* Reads in an image from disk.                                              */
+/*****************************************************************************/
+void readImage(byte **buffer, Image **im) {
+	uint32 size;
+
+	(*im) = (Image *)(*buffer);
+
+	(*im)->Width = READ_LE_UINT16(*buffer);
+	(*im)->Height = READ_LE_UINT16(*buffer + 2);
+
+	*buffer += 8; /* sizeof(struct Image); */
+
+	size = (*im)->Width * (*im)->Height;
+
+	if (1L & size)
+		size++;
+
+	(*im)->ImageData = (byte *)(*buffer);
+	(*buffer) += size;
+}
+
+
+
+
+
+
+/*---------------------------------------------------------------------------*/
+/*------------------------------ The Map stuff ------------------------------*/
+/*---------------------------------------------------------------------------*/
+
+
+
+extern RoomData *Rooms;
+extern char *ViewPath;
+
+static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge,
+			 *HRoom, *VRoom, *Maze, *HugeMaze, *Path, *MapNorth,
+			 *MapEast, *MapSouth, *MapWest, *XMark, *Back, *BackAlt,
+			 *Down, *DownAlt, *Up, *UpAlt;
+
+static uint16 MaxRooms;
+static MapData *Maps;
+
+extern char *LOWERFLOORS, *MIDDLEFLOORS, *UPPERFLOORS, *MEDMAZEFLOORS, *HEDGEMAZEFLOORS, *SURMAZEFLOORS, *CARNIVALFLOOR, *SURMAZEMSG;
+
+extern TextFont *MsgFont;
+
+uint16 *FadePalette;
+
+static uint16 MapGadX[3] = {101, 55, 8}, MapGadY[3] = {105, 105, 105};
+#if !defined(DOSCODE)
+static Gadget downgadget = { 101, 105, 2, VKEY_DNARROW, 0L, NULL, NULL, NULL },
+			  upgadget   = {  55, 105, 1, VKEY_UPARROW, 0L, NULL, NULL, &downgadget },
+			  backgadget = {   8, 105, 0, 0, 0L, NULL, NULL, &upgadget },
+#else
+static Gadget downgadget = { 101, 105, 2, 0L, NULL, NULL, NULL },
+			  upgadget   = {  55, 105, 1, 0L, NULL, NULL, &downgadget },
+			  backgadget = {   8, 105, 0, 0L, NULL, NULL, &upgadget },
+#endif
+*MapGadgetList = &backgadget;
+
+static uint16 AmigaMapPalette[] = {
+	0x0BA8, 0x0C11, 0x0A74, 0x0076,
+	0x0A96, 0x0DCB, 0x0CCA, 0x0222,
+	0x0444, 0x0555, 0x0777, 0x0999,
+	0x0AAA, 0x0ED0, 0x0EEE, 0x0694
+};
+
+
+#define LOWERFLOOR     1
+#define MIDDLEFLOOR    2
+#define UPPERFLOOR     3
+#define MEDMAZEFLOOR   4
+#define HEDGEMAZEFLOOR 5
+#define SURMAZEFLOOR   6
+#define CARNIVAL       7
+
+
+
+static uint16 mapScaleX(uint16 x) {
+	if (IsHiRes)
+		return (x - 45);
+	else
+		return ((x - 45) >> 1);
+}
+
+
+
+static uint16 mapScaleY(uint16 y) {
+	if (IsHiRes)
+		return y;
+	else
+		return ((y - 35) >> 1) - (y >> 6);
+}
+
+
+
+
+/*****************************************************************************/
+/* Loads in the map data.                                                    */
+/*****************************************************************************/
+static bool loadMapData(void) {
+	byte **buffer, Temp[5];
+	int32 Size;
+	struct Gadget *gptr;
+	uint16 counter;
+
+	BigMsgFont = &bmf;
+
+	if (!getFont("P:Map.fon", BigMsgFont))
+		BigMsgFont = MsgFont;
+
+	Size = sizeOfFile("P:MapImage");
+	resetBuffer();  /* Make images load into start of buffer */
+	buffer = g_music->newOpen("P:MapImage");
+
+	if (!buffer)
+		return false;
+
+	stealBufMem(Size); /* Now freeze that buffer from further use */
+
+	readImage(buffer, &Map);
+
+	readImage(buffer, &Room);
+	readImage(buffer, &UpArrowRoom);
+	readImage(buffer, &DownArrowRoom);
+	readImage(buffer, &HRoom);
+	readImage(buffer, &VRoom);
+	readImage(buffer, &Maze);
+	readImage(buffer, &HugeMaze);
+
+	readImage(buffer, &MapNorth);
+	readImage(buffer, &MapEast);
+	readImage(buffer, &MapSouth);
+	readImage(buffer, &MapWest);
+
+	readImage(buffer, &Path);
+	readImage(buffer, &Bridge);
+
+	readImage(buffer, &Back);
+	readImage(buffer, &BackAlt);
+	readImage(buffer, &Up);
+	readImage(buffer, &UpAlt);
+	readImage(buffer, &Down);
+	readImage(buffer, &DownAlt);
+
+	backgadget.Im    = Back;
+	backgadget.ImAlt = BackAlt;
+	upgadget.Im      = Up;
+	upgadget.ImAlt   = UpAlt;
+	downgadget.Im    = Down;
+	downgadget.ImAlt = DownAlt;
+
+	counter = 0;
+	gptr = MapGadgetList;
+
+	while (gptr) {
+		gptr->x = VGAScaleX(MapGadX[counter]);
+		gptr->y = VGAScaleY(MapGadY[counter]);
+		gptr = gptr->NextGadget;
+		counter++;
+	}
+
+	buffer = g_music->newOpen("Lab:Maps");
+	stealBufMem(sizeOfFile("Lab:Maps"));  /* Freeze the memory for the maps */
+	readBlock(Temp, 4L, buffer);
+	Temp[4] = 0;
+
+	if (strcmp((char *)Temp, "MAP0") == 0) {
+		readBlock(&MaxRooms, 2L, buffer);
+#if !defined(DOSCODE)
+		swapUShortPtr(&MaxRooms, 1);
+#endif
+		Maps = (MapData *)(*buffer);
+#if !defined(DOSCODE)
+
+		for (counter = 1; counter <= MaxRooms; counter++) {
+			swapUShortPtr(&Maps[counter].x, 4);
+			swapULongPtr(&Maps[counter].MapFlags, 1);
+		}
+
+#endif
+	} else
+		return false;
+
+	return true;
+}
+
+
+
+
+static uint16 fadeNumIn(uint16 num, uint16 res, uint16 counter) {
+	return (num - ((((int32)(15 - counter)) * ((int32)(num - res))) / 15));
+}
+
+
+static uint16 fadeNumOut(uint16 num, uint16 res, uint16 counter) {
+	return (num - ((((int32) counter) * ((int32)(num - res))) / 15));
+}
+
+
+
+/*****************************************************************************/
+/* Does the fading of the Palette on the screen.                             */
+/*****************************************************************************/
+void fade(bool fadein, uint16 res) {
+	uint16 pennum, counter, newpal[16];
+
+	for (counter = 0; counter < 16; counter++) {
+		for (pennum = 0; pennum < 16; pennum++) {
+			if (fadein)
+				newpal[pennum] = (0x00F & fadeNumIn(0x00F & FadePalette[pennum], 0x00F & res, counter)) +
+				                 (0x0F0 & fadeNumIn(0x0F0 & FadePalette[pennum], 0x0F0 & res, counter)) +
+				                 (0xF00 & fadeNumIn(0xF00 & FadePalette[pennum], 0xF00 & res, counter));
+			else
+				newpal[pennum] = (0x00F & fadeNumOut(0x00F & FadePalette[pennum], 0x00F & res, counter)) +
+				                 (0x0F0 & fadeNumOut(0x0F0 & FadePalette[pennum], 0x0F0 & res, counter)) +
+				                 (0xF00 & fadeNumOut(0xF00 & FadePalette[pennum], 0xF00 & res, counter));
+		}
+
+		setAmigaPal(newpal, 16);
+		waitTOF();
+		g_music->updateMusic();
+	}
+}
+
+
+
+/*****************************************************************************/
+/* Figures out what a room's coordinates should be.                          */
+/*****************************************************************************/
+static void roomCords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16 *y2) {
+	*x1 = mapScaleX(Maps[CurRoom].x);
+	*y1 = mapScaleY(Maps[CurRoom].y);
+	*x2 = *x1;
+	*y2 = *y1;
+
+	switch (Maps[CurRoom].SpecialID) {
+	case NORMAL:
+	case UPARROWROOM:
+	case DOWNARROWROOM:
+		(*x2) += Room->Width;
+		(*y2) += Room->Height;
+		break;
+
+	case BRIDGEROOM:
+		(*x2) += Bridge->Width;
+		(*y2) += Bridge->Height;
+		break;
+
+	case VCORRIDOR:
+		(*x2) += VRoom->Width;
+		(*y2) += VRoom->Height;
+		break;
+
+	case HCORRIDOR:
+		(*x2) += HRoom->Width;
+		(*y2) += HRoom->Height;
+		break;
+	}
+}
+
+
+
+
+
+/*****************************************************************************/
+/* Draws a room to the bitmap.                                               */
+/*****************************************************************************/
+static void drawRoom(uint16 CurRoom, bool drawx) {
+	uint16 x, y, xx, xy, offset;
+	uint32 flags;
+
+	x = mapScaleX(Maps[CurRoom].x);
+	y = mapScaleY(Maps[CurRoom].y);
+	flags = Maps[CurRoom].MapFlags;
+
+	switch (Maps[CurRoom].SpecialID) {
+	case NORMAL:
+	case UPARROWROOM:
+	case DOWNARROWROOM:
+		if (Maps[CurRoom].SpecialID == NORMAL)
+			drawImage(Room, x, y);
+		else if (Maps[CurRoom].SpecialID == DOWNARROWROOM)
+			drawImage(DownArrowRoom, x, y);
+		else
+			drawImage(UpArrowRoom, x, y);
+
+		offset = (Room->Width - Path->Width) / 2;
+
+		if ((NORTHDOOR & flags) && (y >= Path->Height))
+			drawImage(Path, x + offset, y - Path->Height);
+
+		if (SOUTHDOOR & flags)
+			drawImage(Path, x + offset, y + Room->Height);
+
+		offset = (Room->Height - Path->Height) / 2;
+
+		if (EASTDOOR & flags)
+			drawImage(Path, x + Room->Width, y + offset);
+
+		if (WESTDOOR & flags)
+			drawImage(Path, x - Path->Width, y + offset);
+
+		xx = x + (Room->Width - XMark->Width) / 2;
+		xy = y + (Room->Height - XMark->Height) / 2;
+
+		break;
+
+	case BRIDGEROOM:
+		drawImage(Bridge, x, y);
+
+		xx = x + (Bridge->Width - XMark->Width) / 2;
+		xy = y + (Bridge->Height - XMark->Height) / 2;
+
+		break;
+
+	case VCORRIDOR:
+		drawImage(VRoom, x, y);
+
+		offset = (VRoom->Width - Path->Width) / 2;
+
+		if (NORTHDOOR & flags)
+			drawImage(Path, x + offset, y - Path->Height);
+
+		if (SOUTHDOOR & flags)
+			drawImage(Path, x + offset, y + VRoom->Height);
+
+		offset = (Room->Height - Path->Height) / 2;
+
+		if (EASTDOOR & flags)
+			drawImage(Path, x + VRoom->Width, y + offset);
+
+		if (WESTDOOR & flags)
+			drawImage(Path, x - Path->Width, y + offset);
+
+		if (EASTBDOOR & flags)
+			drawImage(Path, x + VRoom->Width, y - offset - Path->Height + VRoom->Height);
+
+		if (WESTBDOOR & flags)
+			drawImage(Path, x - Path->Width, y - offset - Path->Height + VRoom->Height);
+
+		offset = (VRoom->Height - Path->Height) / 2;
+
+		if (EASTMDOOR & flags)
+			drawImage(Path, x + VRoom->Width, y - offset - Path->Height + VRoom->Height);
+
+		if (WESTMDOOR & flags)
+			drawImage(Path, x - Path->Width, y - offset - Path->Height + VRoom->Height);
+
+		xx = x + (VRoom->Width - XMark->Width) / 2;
+		xy = y + (VRoom->Height - XMark->Height) / 2;
+
+		break;
+
+	case HCORRIDOR:
+		drawImage(HRoom, x, y);
+
+		offset = (Room->Width - Path->Width) / 2;
+
+		if (NORTHDOOR & flags)
+			drawImage(Path, x + offset, y - Path->Height);
+
+		if (SOUTHDOOR & flags)
+			drawImage(Path, x + offset, y + Room->Height);
+
+		if (NORTHRDOOR & flags)
+			drawImage(Path, x - offset - Path->Width + HRoom->Width, y - Path->Height);
+
+		if (SOUTHRDOOR & flags)
+			drawImage(Path, x - offset - Path->Width + HRoom->Width, y + Room->Height);
+
+		offset = (HRoom->Width - Path->Width) / 2;
+
+		if (NORTHMDOOR & flags)
+			drawImage(Path, x - offset - Path->Width + HRoom->Width, y - Path->Height);
+
+		if (SOUTHMDOOR & flags)
+			drawImage(Path, x - offset - Path->Width + HRoom->Width, y + Room->Height);
+
+		offset = (Room->Height - Path->Height) / 2;
+
+		if (EASTDOOR & flags)
+			drawImage(Path, x + HRoom->Width, y + offset);
+
+		if (WESTDOOR & flags)
+			drawImage(Path, x - Path->Width, y + offset);
+
+		xx = x + (HRoom->Width - XMark->Width) / 2;
+		xy = y + (HRoom->Height - XMark->Height) / 2;
+
+		break;
+
+	default:
+		return;
+	}
+
+	if (drawx)
+		drawImage(XMark, xx, xy);
+}
+
+
+
+/*****************************************************************************/
+/* Checks if a floor has been visitted.                                      */
+/*****************************************************************************/
+static bool onFloor(LargeSet RoomsFound, uint16 Floor) {
+	uint16 drawroom;
+
+	for (drawroom = 1; drawroom <= MaxRooms; drawroom++) {
+		if ((Maps[drawroom].PageNumber == Floor)
+		        && In(RoomsFound, drawroom)
+		        && Maps[drawroom].x) {
+			return true;
+		}
+	}
+
+	return false;
+}
+
+
+
+
+/*****************************************************************************/
+/* Figures out which floor, if any, should be gone to if the up arrow is hit */
+/*****************************************************************************/
+static void getUpFloor(LargeSet RoomsFound, uint16 *Floor, bool *isfloor) {
+	do {
+		*isfloor = true;
+
+		if (*Floor < UPPERFLOOR)
+			(*Floor)++;
+		else {
+			*Floor   = CARNIVAL + 1;
+			*isfloor = false;
+			return;
+		}
+	} while ((!onFloor(RoomsFound, *Floor)) && (*Floor <= CARNIVAL));
+}
+
+
+
+
+/*****************************************************************************/
+/* Figures out which floor, if any, should be gone to if the down arrow is   */
+/* hit.                                                                      */
+/*****************************************************************************/
+static void getDownFloor(LargeSet RoomsFound, uint16 *Floor, bool *isfloor) {
+	do {
+		*isfloor = true;
+
+		if ((*Floor == LOWERFLOOR) || (*Floor == 0)) {
+			*Floor   = 0;
+			*isfloor = false;
+			return;
+		} else if (*Floor > UPPERFLOOR) {
+			/* LAB: Labyrinth specific code */
+			if (*Floor == HEDGEMAZEFLOOR)
+				*Floor = UPPERFLOOR;
+			else if ((*Floor == CARNIVAL) || (*Floor == MEDMAZEFLOOR))
+				*Floor = MIDDLEFLOOR;
+			else if (*Floor == SURMAZEFLOOR)
+				*Floor = LOWERFLOOR;
+			else {
+				*Floor = 0;
+				*isfloor = false;
+				return;
+			}
+		} else
+			(*Floor)--;
+
+	} while ((!onFloor(RoomsFound, *Floor)) && *Floor);
+}
+
+
+
+
+
+/*****************************************************************************/
+/* Draws the map                                                             */
+/*****************************************************************************/
+static void drawMap(LargeSet RoomsFound, uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein) {
+	uint16 drawroom;
+	char *sptr;
+
+	uint16 tempfloor;
+	bool noghoast;
+
+	mouseHide();
+
+	if (fadeout)
+		fade(false, 0);
+
+	setAPen(0);
+	rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1);
+
+	drawImage(Map, 0, 0);
+	drawGadgetList(MapGadgetList);
+
+	for (drawroom = 1; drawroom <= MaxRooms; drawroom++) {
+		if ((Maps[drawroom].PageNumber == Floor)
+		        && In(RoomsFound, drawroom)
+		        && Maps[drawroom].x) {
+			drawRoom(drawroom, (bool)(drawroom == CurRoom));
+			g_music->checkMusic();
+		}
+	}
+
+	if ((Maps[CurRoom].PageNumber == Floor)   /* Makes sure the X is drawn in corridors */
+	        && In(RoomsFound, CurRoom)         /* NOTE: this here on purpose just in case there's some wierd condition, like the surreal maze where there are no rooms */
+	        && Maps[CurRoom].x)
+		drawRoom(CurRoom, true);
+
+	tempfloor = Floor;
+	getUpFloor(RoomsFound, &tempfloor, &noghoast);
+
+	if (noghoast)
+		unGhoastGadget(&upgadget);
+	else
+		ghoastGadget(&upgadget, 12);
+
+	tempfloor = Floor;
+	getDownFloor(RoomsFound, &tempfloor, &noghoast);
+
+	if (noghoast)
+		unGhoastGadget(&downgadget);
+	else
+		ghoastGadget(&downgadget, 12);
+
+	/* LAB: Labyrinth specific code */
+	if (Floor == LOWERFLOOR) {
+		if (onFloor(RoomsFound, SURMAZEFLOOR))
+			drawImage(Maze, mapScaleX(538), mapScaleY(277));
+	}
+
+	else if (Floor == MIDDLEFLOOR) {
+		if (onFloor(RoomsFound, CARNIVAL))
+			drawImage(Maze, mapScaleX(358), mapScaleY(72));
+
+		if (onFloor(RoomsFound, MEDMAZEFLOOR))
+			drawImage(Maze, mapScaleX(557), mapScaleY(325));
+	}
+
+	else if (Floor == UPPERFLOOR) {
+		if (onFloor(RoomsFound, HEDGEMAZEFLOOR))
+			drawImage(HugeMaze, mapScaleX(524), mapScaleY(97));
+	}
+
+	else if (Floor == SURMAZEFLOOR) {
+		flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), SURMAZEMSG);
+	}
+
+
+	/* LAB: Labyrinth specific code */
+	sptr = NULL;
+
+	switch (Floor) {
+	case LOWERFLOOR:
+		sptr = LOWERFLOORS;
+		break;
+
+	case MIDDLEFLOOR:
+		sptr = MIDDLEFLOORS;
+		break;
+
+	case UPPERFLOOR:
+		sptr = UPPERFLOORS;
+		break;
+
+	case MEDMAZEFLOOR:
+		sptr = MEDMAZEFLOORS;
+		break;
+
+	case HEDGEMAZEFLOOR:
+		sptr = HEDGEMAZEFLOORS;
+		break;
+
+	case SURMAZEFLOOR:
+		sptr = SURMAZEFLOORS;
+		break;
+
+	case CARNIVAL:
+		sptr = CARNIVALFLOOR;
+		break;
+
+	default:
+		sptr = NULL;
+		break;
+	}
+
+	if (sptr)
+		flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(75), VGAScaleX(134), VGAScaleY(97), sptr);
+
+	if ((sptr = Rooms[CurMsg].RoomMsg))
+		flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr);
+
+	if (fadein)
+		fade(true, 0);
+
+	mouseShow();
+}
+
+
+
+/*****************************************************************************/
+/* Processes the map.                                                        */
+/*****************************************************************************/
+void processMap(uint16 CurRoom, LargeSet RoomsFound) {
+	uint32 Class, place = 1;
+	uint16 Code, Qualifier, MouseX, MouseY, GadgetID, CurFloor, OldFloor, OldMsg, CurMsg, drawroom, x1, y1, x2, y2;
+	char *sptr, newcolor[3];
+	bool drawmap;
+	struct IntuiMessage *Msg;
+
+	CurMsg   = CurRoom;
+	CurFloor = Maps[CurRoom].PageNumber;
+
+	while (1) {
+		g_music->checkMusic();  /* Make sure we check the music at least after every message */
+		Msg = getMsg();
+
+		if (Msg == NULL) {
+			g_music->newCheckMusic();
+
+			if (place <= 14) {
+				newcolor[0] = 14 << 2;
+				newcolor[1] = place << 2;
+				newcolor[2] = newcolor[1];
+			} else {
+				newcolor[0] = 14 << 2;
+				newcolor[1] = (28 - place) << 2;
+				newcolor[2] = newcolor[1];
+			}
+
+			waitTOF();
+			writeColorReg(newcolor, 1);
+			updateMouse();
+			waitTOF();
+			updateMouse();
+			waitTOF();
+			updateMouse();
+			waitTOF();
+			updateMouse();
+
+			place++;
+
+			if (place >= 28)
+				place = 1;
+
+		} else {
+			Class     = Msg->Class;
+			Code      = Msg->Code;
+			GadgetID  = Msg->GadgetID;
+			Qualifier = Msg->Qualifier;
+			MouseX    = Msg->MouseX;
+			MouseY    = Msg->MouseY;
+
+			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) ||
+			        ((Class == RAWKEY) && (Code == 27)))
+				return;
+
+			if (Class == GADGETUP) {
+				if (GadgetID == 0) { /* Quit menu button */
+					return;
+				} else if (GadgetID == 1) { /* Up arrow */
+					OldFloor = CurFloor;
+					getUpFloor(RoomsFound, &CurFloor, &drawmap);
+
+					if (drawmap) {
+						fade(false, 0);
+						drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false);
+						fade(true, 0);
+					} else
+						CurFloor = OldFloor;
+				} else if (GadgetID == 2) { /* Down arrow */
+					OldFloor = CurFloor;
+					getDownFloor(RoomsFound, &CurFloor, &drawmap);
+
+					if (drawmap) {
+						fade(false, 0);
+						drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false);
+						fade(true, 0);
+					} else
+						CurFloor = OldFloor;
+				}
+			}
+
+			else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) {
+				if ((CurFloor == LOWERFLOOR) && (MouseX >= mapScaleX(538)) && (MouseY >= mapScaleY(277))
+				        && (MouseX <= mapScaleX(633)) && (MouseY <= mapScaleY(352))
+				        && onFloor(RoomsFound, SURMAZEFLOOR)) {
+					CurFloor = SURMAZEFLOOR;
+
+					fade(false, 0);
+					drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false);
+					fade(true, 0);
+				}
+
+				else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(358)) && (MouseY >= mapScaleY(71))
+				         && (MouseX <= mapScaleX(452)) && (MouseY <= mapScaleY(147))
+				         && onFloor(RoomsFound, CARNIVAL)) {
+					CurFloor = CARNIVAL;
+
+					fade(false, 0);
+					drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false);
+					fade(true, 0);
+				}
+
+				else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(557)) && (MouseY >= mapScaleY(325))
+				         && (MouseX <= mapScaleX(653)) && (MouseY <= mapScaleY(401))
+				         && onFloor(RoomsFound, MEDMAZEFLOOR)) {
+					CurFloor = MEDMAZEFLOOR;
+
+					fade(false, 0);
+					drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false);
+					fade(true, 0);
+				}
+
+				else if ((CurFloor == UPPERFLOOR) && (MouseX >= mapScaleX(524)) && (MouseY >=  mapScaleY(97))
+				         && (MouseX <= mapScaleX(645)) && (MouseY <= mapScaleY(207))
+				         && onFloor(RoomsFound, HEDGEMAZEFLOOR)) {
+					CurFloor = HEDGEMAZEFLOOR;
+
+					fade(false, 0);
+					drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false);
+					fade(true, 0);
+				}
+
+				else if (MouseX > mapScaleX(314)) {
+					OldMsg = CurMsg;
+
+					for (drawroom = 1; drawroom <= MaxRooms; drawroom++) {
+						roomCords(drawroom, &x1, &y1, &x2, &y2);
+
+						if ((Maps[drawroom].PageNumber == CurFloor)
+						        && In(RoomsFound, drawroom)
+						        && (MouseX >= x1) && (MouseX <= x2)
+						        && (MouseY >= y1) && (MouseY <= y2)) {
+							CurMsg = drawroom;
+						}
+					}
+
+					if (OldMsg != CurMsg) {
+						if (Rooms[CurMsg].RoomMsg == NULL)
+							readViews(CurMsg, ViewPath);
+
+						if ((sptr = Rooms[CurMsg].RoomMsg)) {
+							mouseHide();
+							setAPen(3);
+							rectFill(VGAScaleX(13), VGAScaleY(148), VGAScaleX(135), VGAScaleY(186));
+							flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr);
+
+							if (Maps[OldMsg].PageNumber == CurFloor)
+								drawRoom(OldMsg, (bool)(OldMsg == CurRoom));
+
+							roomCords(CurMsg, &x1, &y1, &x2, &y2);
+							x1 = (x1 + x2) / 2;
+							y1 = (y1 + y2) / 2;
+
+							if ((CurMsg != CurRoom) && (Maps[CurMsg].PageNumber == CurFloor)) {
+								setAPen(1);
+								rectFill(x1 - 1, y1, x1, y1);
+							}
+
+							mouseShow();
+						}
+					}
+				}
+			}
+
+#if !defined(DOSCODE)
+			g_system->updateScreen();
+#endif
+		}
+	}
+}
+
+
+
+/*****************************************************************************/
+/* Cleans up behind itself.                                                  */
+/*****************************************************************************/
+void mapCleanUp(void) {
+	freeAllStolenMem();
+}
+
+
+
+
+/*****************************************************************************/
+/* Does the map processing.                                                  */
+/*****************************************************************************/
+void doMap(LargeSet RoomsFound, uint16 CurRoom) {
+	FadePalette = AmigaMapPalette;
+
+	g_music->checkMusic();
+	loadMapData();
+	blackAllScreen();
+
+	if (Direction == NORTH)
+		XMark = MapNorth;
+	else if (Direction == SOUTH)
+		XMark = MapSouth;
+	else if (Direction == EAST)
+		XMark = MapEast;
+	else if (Direction == WEST)
+		XMark = MapWest;
+
+	drawMap(RoomsFound, CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true);
+	mouseShow();
+	attachGadgetList(MapGadgetList);
+#if !defined(DOSCODE)
+	g_system->updateScreen();
+#endif
+	processMap(CurRoom, RoomsFound);
+	attachGadgetList(NULL);
+	fade(false, 0);
+	blackAllScreen();
+	mouseHide();
+	setAPen(0);
+	rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1);
+	mapCleanUp();
+	blackAllScreen();
+	mouseShow();
+#if !defined(DOSCODE)
+	g_system->updateScreen();
+#endif
+}
+
+} // End of namespace Lab
diff --git a/engines/lab/modernsavegame.cpp b/engines/lab/modernsavegame.cpp
new file mode 100644
index 0000000..2ea5c22
--- /dev/null
+++ b/engines/lab/modernsavegame.cpp
@@ -0,0 +1,127 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/stddefines.h"
+#include "lab/labfun.h"
+#include "lab/modernsavegame.h"
+
+namespace Lab {
+
+byte g_SaveGameImage[SAVED_IMAGE_SIZE]; // 640 x 358
+
+char g_SaveGamePath[512];
+char g_PathSeperator[4];
+
+extern LargeSet        Conditions,
+       RoomsFound;
+
+#define SAVEVERSION         "LBS3"
+
+int getSaveGameList(struct SaveGameInfo *info, int maxNum) {
+	warning("STUB: getSaveGameList");
+
+	return 0;
+
+#if 0
+	char path[512];
+	struct stat statb;
+	int total = 0;
+	int i;
+
+	for (i = 0; i < maxNum; i++) {
+		checkMusic();
+
+		sprintf(path, "%s%s%d", g_SaveGamePath, g_PathSeperator, i);
+		statb.st_size = 0;
+		stat(path, &statb);
+
+		if (statb.st_size > 0) {
+			struct tm *create_date;
+			FILE *fh;
+
+			create_date = localtime(&statb.st_ctime);
+			strcpy(info->SaveGameDate, asctime(create_date));
+
+			fh = fopen(path, "rb");
+
+			if (fh != NULL) {
+				char temp[5];
+				unsigned short t;
+				int toSeek;
+
+				info->Index = i;
+
+				fread(temp, 1, 4, fh);
+				temp[4] = 0;
+
+				fread(&t, 1, 2, fh);
+				info->RoomNumber = swapUShort(t);
+				fread(&t, 1, 2, fh);
+				info->Direction = swapUShort(t);
+
+				toSeek = 2 + Conditions->lastElement / 8 + RoomsFound->lastElement / 8 + 6 + 2 * 16;
+				fseek(fh, toSeek, SEEK_CUR);
+
+				info->SaveGameImage = NULL;
+
+				if (strcmp(temp, SAVEVERSION) == 0) {
+					info->SaveGameImage = malloc(SAVED_IMAGE_SIZE);
+
+					if (info->SaveGameImage != NULL)
+						fread(info->SaveGameImage, 1, SAVED_IMAGE_SIZE, fh);
+				} else {
+					info->SaveGameImage = malloc(SAVED_IMAGE_SIZE);
+
+					if (info->SaveGameImage != NULL)
+						memset(info->SaveGameImage, 0, SAVED_IMAGE_SIZE);
+				}
+
+				fclose(fh);
+
+				info++;
+				total++;
+			}
+		}
+	}
+
+	return total;
+#endif
+}
+
+void freeSaveGameList(struct SaveGameInfo *info, int count) {
+	int i;
+
+	for (i = 0; i < count; i++) {
+		free(info->SaveGameImage);
+		++info;
+	}
+}
+
+} // End of namespace Lab
diff --git a/engines/lab/modernsavegame.h b/engines/lab/modernsavegame.h
new file mode 100644
index 0000000..160f3f9
--- /dev/null
+++ b/engines/lab/modernsavegame.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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#ifndef LAB_MODERNGAMESAVE_H
+#define LAB_MODERNGAMESAVE_H
+
+namespace Lab {
+
+#define MAX_SAVED_GAMES 15
+#define SAVED_IMAGE_SIZE (128 * 72)
+
+extern byte g_SaveGameImage[SAVED_IMAGE_SIZE]; // 640 x 358
+
+struct SaveGameInfo {
+	unsigned short Index;
+	unsigned short RoomNumber;
+	unsigned short Direction;
+	byte *SaveGameImage;
+	char SaveGameDate[128];
+};
+
+int getSaveGameList(struct SaveGameInfo *info, int maxNum);
+void freeSaveGameList(struct SaveGameInfo *info, int count);
+
+} // End of namespace Lab
+
+#endif /* LAB_MODERNGAMESAVE_H */
+
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
new file mode 100644
index 0000000..5edaa78
--- /dev/null
+++ b/engines/lab/module.mk
@@ -0,0 +1,40 @@
+MODULE := engines/lab
+
+MODULE_OBJS := \
+	allocroom.o \
+	audioi.o \
+	detection.o \
+	engine.o \
+	graphics.o \
+	interface.o \
+	intro.o \
+	lab.o \
+	labfile.o \
+	labmusic.o \
+	labsets.o \
+	labtext.o \
+	machine.o \
+	map.o \
+	modernsavegame.o \
+	mouse.o \
+	processroom.o \
+	readdiff.o \
+	readparse.o \
+	savegame.o \
+	savegamepalmap.o \
+	special.o \
+	storage.o \
+	text.o \
+	timing.o \
+	undiff.o \
+	vga.o
+
+
+# This module can be built as a plugin
+ifeq ($(ENABLE_LAB), DYNAMIC_PLUGIN)
+PLUGIN := 1
+endif
+
+# Include common rules
+include $(srcdir)/rules.mk
+
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
new file mode 100644
index 0000000..857a397
--- /dev/null
+++ b/engines/lab/mouse.cpp
@@ -0,0 +1,569 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/mouse.h"
+#include "lab/vga.h"
+#include "lab/stddefines.h"
+#include "lab/timing.h"
+#include "lab/interface.h"
+
+namespace Lab {
+
+extern bool IsHiRes;
+extern uint32 VGAScreenWidth, VGAScreenHeight;
+
+void mouseHideXY(void);
+
+#if defined(DOSCODE)
+/*****************************************************************************/
+/* Standard mouse calling template.                                          */
+/*****************************************************************************/
+static void mouse(int16 *m1, int16 *m2, int16 *m3, int16 *m4) {
+	union REGS reg;
+
+	reg.w.ax = *m1;
+	reg.w.bx = *m2;
+	reg.w.cx = *m3;
+	reg.w.dx = *m4;
+
+	int386(0x33, &reg, &reg);
+
+	*m1 = reg.w.ax;
+	*m2 = reg.w.bx;
+	*m3 = reg.w.cx;
+	*m4 = reg.w.dx;
+}
+#endif
+
+
+static bool LeftClick = false;
+static uint16 leftx = 0, lefty = 0;
+static bool RightClick = false;
+static uint16 rightx = 0, righty = 0;
+
+static bool MouseHidden = true, QuitMouseHandler = false;
+static int32 NumHidden   = 1;
+static uint16 CurMouseX, CurMouseY;
+static uint16 MouseImageWidth = 10, MouseImageHeight = 15;
+static struct Gadget *LastGadgetHit = NULL;
+struct Gadget *ScreenGadgetList = NULL;
+static byte MouseData[] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
+						   1, 7, 1, 0, 0, 0, 0, 0, 0, 0,
+						   1, 7, 7, 1, 0, 0, 0, 0, 0, 0,
+						   1, 7, 7, 7, 1, 0, 0, 0, 0, 0,
+						   1, 7, 7, 7, 7, 1, 0, 0, 0, 0,
+						   1, 7, 7, 7, 7, 7, 1, 0, 0, 0,
+						   1, 7, 7, 7, 7, 7, 7, 1, 0, 0,
+						   1, 7, 7, 7, 7, 7, 7, 7, 1, 0,
+						   1, 7, 7, 7, 7, 7, 1, 1, 1, 1,
+						   1, 7, 7, 1, 7, 7, 1, 0, 0, 0,
+						   1, 7, 1, 0, 1, 7, 7, 1, 0, 0,
+						   1, 1, 0, 0, 1, 7, 7, 1, 0, 0,
+						   0, 0, 0, 0, 0, 1, 7, 7, 1, 0,
+						   0, 0, 0, 0, 0, 1, 7, 7, 1, 0,
+						   0, 0, 0, 0, 0, 0, 1, 1, 0, 0};
+
+
+static struct Image MouseImage, BackImage;
+static byte BackImageBuffer[256];
+static uint16 backx, backy;
+
+static bool drawmouse = false, gadhit    = false;
+static struct Gadget *hitgad = NULL;
+
+void mouseShowXY(uint16 CurMouseX, uint16 CurMouseY);
+
+/*****************************************************************************/
+/* Checks whether or not the cords fall within one of the gadgets in a list  */
+/* of gadgets.                                                               */
+/*****************************************************************************/
+static Gadget *checkGadgetHit(struct Gadget *gadlist, uint16 x, uint16 y) {
+	uint16 counter;
+
+	while (gadlist != NULL) {
+		if ((x >= gadlist->x) && (y >= gadlist->y) &&
+		        (x <= (gadlist->x + gadlist->Im->Width)) &&
+		        (y <= (gadlist->y + gadlist->Im->Height)) &&
+		        !(GADGETOFF & gadlist->GadgetFlags)) {
+			if (IsHiRes) {
+				gadhit = true;
+				hitgad = gadlist;
+			} else {
+				QuitMouseHandler = true;
+				VGAStorePage();
+				mouseHideXY();
+				drawImage(gadlist->ImAlt, gadlist->x, gadlist->y);
+				mouseShowXY(x, y);
+
+				for (counter = 0; counter < 3; counter++)
+					waitTOF();
+
+				mouseHideXY();
+				drawImage(gadlist->Im, gadlist->x, gadlist->y);
+				mouseShowXY(x, y);
+				VGARestorePage();
+				QuitMouseHandler = false;
+			}
+
+			return gadlist;
+		} else {
+			gadlist = gadlist->NextGadget;
+		}
+	}
+
+	return NULL;
+}
+
+
+
+void attachGadgetList(struct Gadget *GadList) {
+	if (ScreenGadgetList != GadList)
+		LastGadgetHit = NULL;
+
+	ScreenGadgetList = GadList;
+}
+
+
+
+
+static void drawMouse(void) {
+	if (BackImage.ImageData) {
+#if !defined(DOSCODE)
+
+		if (backx <= 640 - BackImage.Width && backy <= 480 - BackImage.Height)
+#endif
+			drawMaskImage(&MouseImage, backx, backy);
+	} else {
+#if !defined(DOSCODE)
+
+		if (CurMouseX <= 640 - MouseImage.Width && CurMouseY <= 480 - MouseImage.Height)
+#endif
+			drawMaskImage(&MouseImage, CurMouseX, CurMouseY);
+	}
+}
+
+
+
+static void getBackMouse(void) {
+	BackImage.Width = MouseImage.Width;
+	BackImage.Height = MouseImage.Height;
+	BackImage.ImageData = BackImageBuffer;
+
+	backx = CurMouseX;
+	backy = CurMouseY;
+
+#if !defined(DOSCODE)
+
+	if (/* backx >= 0 && backy >= 0 && */ backx <= 640 - BackImage.Width && backy <= 480 - BackImage.Height)
+#endif
+		readScreenImage(&BackImage, backx, backy);
+}
+
+static void restoreBackMouse(void) {
+	if (BackImage.ImageData) {
+#if !defined(DOSCODE)
+
+		if (/* backx >= 0 && backy >= 0 && */ backx <= 640 - BackImage.Width && backy <= 480 - BackImage.Height)
+#endif
+			drawImage(&BackImage, backx, backy);
+
+		BackImage.ImageData = NULL;
+	}
+}
+
+
+static struct Gadget *TempGad;
+
+
+#if defined(DOSCODE)
+#pragma off (check_stack)
+void _loadds far mouse_handler(int32 max, int32 mcx, int32 mdx) {
+#pragma aux mouse_handler parm [EAX] [ECX] [EDX]
+#else
+void mouse_handler(int32 max, int32 mcx, int32 mdx) {
+#endif
+
+	if (!IsHiRes)
+		mcx /= 2;
+
+	if (max & 0x01) { /* mouse Move */
+		if ((CurMouseX != mcx) || (CurMouseY != mdx)) {
+			CurMouseX = mcx;
+			CurMouseY = mdx;
+
+			if (IsHiRes && !QuitMouseHandler) {
+				drawmouse = true;
+			} else if (!MouseHidden && !QuitMouseHandler) {
+				VGAStorePage();
+				restoreBackMouse();
+				getBackMouse();
+				drawMouse();
+				VGARestorePage();
+			}
+		}
+	}
+
+	if ((max & 0x02) && (NumHidden < 2)) { /* Left mouse button click */
+		if (ScreenGadgetList)
+			TempGad = checkGadgetHit(ScreenGadgetList, mcx, mdx);
+		else
+			TempGad = NULL;
+
+		if (TempGad) {
+			LastGadgetHit = TempGad;
+		} else {
+			LeftClick = true;
+			leftx     = mcx;
+			lefty     = mdx;
+		}
+	}
+
+	if ((max & 0x08) && (NumHidden < 2)) { /* Right mouse button click */
+		RightClick = true;
+		rightx     = mcx;
+		righty     = mdx;
+	}
+}
+
+
+
+
+void updateMouse(void) {
+	uint16 counter;
+#if !defined(DOSCODE)
+	bool doUpdateDisplay = false;
+#endif
+
+	if (drawmouse && !MouseHidden) {
+		QuitMouseHandler = true;
+		drawmouse = false;
+		restoreBackMouse();
+		getBackMouse();
+		drawMouse();
+		QuitMouseHandler = false;
+#if !defined(DOSCODE)
+		doUpdateDisplay = true;
+#endif
+	}
+
+	if (gadhit) {
+		gadhit = false;
+		QuitMouseHandler = true;
+		mouseHide();
+		drawImage(hitgad->ImAlt, hitgad->x, hitgad->y);
+		mouseShow();
+
+		for (counter = 0; counter < 3; counter++)
+			waitTOF();
+
+		mouseHide();
+		drawImage(hitgad->Im, hitgad->x, hitgad->y);
+		mouseShow();
+#if !defined(DOSCODE)
+		doUpdateDisplay = true;
+#endif
+		QuitMouseHandler = false;
+	}
+
+#if !defined(DOSCODE)
+
+	if (doUpdateDisplay)
+		g_system->updateScreen();
+
+#endif
+}
+
+
+
+
+/*****************************************************************************/
+/* Initializes the mouse.                                                    */
+/*****************************************************************************/
+bool initMouse(void) {
+#if defined(DOSCODE)
+	void (interrupt far * int_handler)();
+	int32 vector;
+	byte firstbyte;
+	struct SREGS sregs;
+	union REGS inregs, outregs;
+	int (far * function_ptr)();
+	int16 m1, m2, m3, m4;
+
+	segread(&sregs);
+
+	/* Determine mouse-driver interrupt address */
+	int_handler = _dos_getvect(0x33);        /* Get interrupt vector       */
+	firstbyte = *(byte far *) int_handler;  /* Get first instruction of interrupt */
+	vector = (int32) int_handler;
+
+	if ((vector == 0L) || (firstbyte == 0xcf)) { /* Vector should not be zero            */
+		/* First instruction should not be iret */
+		return false;
+	}
+
+	m1 = 0;
+	mouse(&m1, &m2, &m3, &m4);
+
+	if (m1 != -1)
+		return false;
+
+	m1 = 0x0f;
+	m3 = 3;
+	m4 = 10;
+	mouse(&m1, &m2, &m3, &m4);
+
+	m1 = 0x07;
+	m3 = 0;
+	m4 = VGAScreenWidth - MouseImageWidth;
+
+	if (!IsHiRes) m4 *= 2;
+
+	mouse(&m1, &m2, &m3, &m4);
+
+	m1 = 0x08;
+	m3 = 0;
+	m4 = VGAScreenHeight - MouseImageHeight;
+	mouse(&m1, &m2, &m3, &m4);
+#endif
+
+	BackImage.ImageData = NULL;
+	MouseImage.ImageData = MouseData;
+	MouseImage.Width = MouseImageWidth;
+	MouseImage.Height = MouseImageHeight;
+
+	mouseMove(0, 0);
+
+#if defined(DOSCODE)
+
+	if (IsHiRes) {
+		m1 = 0x0f;
+		m3 = 0x03;
+		m4 = 0x04;
+		mouse(&m1, &m2, &m3, &m4);
+	}
+
+	inregs.w.ax = 0xc;
+	inregs.w.cx = 0x01 + 0x02 + 0x08;  /* mouse move, left and right mouse clicks */
+	function_ptr = mouse_handler;
+	inregs.x.edx = FP_OFF(function_ptr);
+	sregs.es     = FP_SEG(function_ptr);
+	int386x(0x33, &inregs, &outregs, &sregs);
+
+	/* mouse reset and status */
+	return mouseReset();
+#endif
+
+	return true;
+}
+
+
+
+/*****************************************************************************/
+/* Resets the mouse.                                                         */
+/*****************************************************************************/
+bool mouseReset(void) {
+#if defined(DOSCODE)
+	int16 m1 = 0, dum;
+
+	mouse(&m1, &dum, &dum, &dum);
+	return (m1 == -1);
+#else
+	return true;
+#endif
+}
+
+
+
+/*****************************************************************************/
+/* Shows the mouse.                                                          */
+/*****************************************************************************/
+void mouseShow(void) {
+	QuitMouseHandler = true;
+	VGAStorePage();
+	mouseShowXY(CurMouseX, CurMouseY);
+	VGARestorePage();
+	QuitMouseHandler = false;
+}
+
+
+
+
+
+/*****************************************************************************/
+/* Shows the mouse.                                                          */
+/*****************************************************************************/
+void mouseShowXY(uint16 MouseX, uint16 MouseY) {
+	QuitMouseHandler = true;
+
+	if (NumHidden)
+		NumHidden--;
+
+	if ((NumHidden == 0) && MouseHidden) {
+		CurMouseX = MouseX;
+		CurMouseY = MouseY;
+		getBackMouse();
+		drawMouse();
+#if !defined(DOSCODE)
+		g_system->updateScreen();
+#endif
+		MouseHidden = false;
+	}
+
+	QuitMouseHandler = false;
+}
+
+
+
+/*****************************************************************************/
+/* Hides the mouse.                                                          */
+/*****************************************************************************/
+void mouseHide(void) {
+	QuitMouseHandler = true;
+
+	NumHidden++;
+
+	if (NumHidden && !MouseHidden) {
+		MouseHidden = true;
+		VGAStorePage();
+		restoreBackMouse();
+		VGARestorePage();
+	}
+
+	QuitMouseHandler = false;
+}
+
+
+
+
+/*****************************************************************************/
+/* Hides the mouse.                                                          */
+/*****************************************************************************/
+void mouseHideXY(void) {
+	QuitMouseHandler = true;
+
+	NumHidden++;
+
+	if (NumHidden && !MouseHidden) {
+		MouseHidden = true;
+		restoreBackMouse();
+	}
+
+	QuitMouseHandler = false;
+}
+
+
+
+
+
+/*****************************************************************************/
+/* Gets the current mouse co-ordinates.  NOTE: On IBM version, will scale    */
+/* from virtual to screen co-ordinates automatically.                        */
+/*****************************************************************************/
+void mouseXY(uint16 *x, uint16 *y) {
+	int xx = 0, yy = 0;
+	//SDL_GetMousePos(&xx, &yy);
+	warning("STUB: mouseXY");
+	*x = (uint16)xx;
+	*y = (uint16)yy;
+
+	if (!IsHiRes)
+		(*x) /= 2;
+}
+
+
+
+
+/*****************************************************************************/
+/* Moves the mouse to new co-ordinates.                                      */
+/*****************************************************************************/
+void mouseMove(uint16 x, uint16 y) {
+#if defined(DOSCODE)
+	int16 m1 = 4, dum;
+#endif
+
+	if (!IsHiRes)
+		x *= 2;
+
+	g_system->warpMouse(x, y);
+
+	if (!MouseHidden) {
+		QuitMouseHandler = true;
+		mouseXY(&CurMouseX, &CurMouseY);
+		VGAStorePage();
+		restoreBackMouse();
+		getBackMouse();
+		drawMouse();
+		VGARestorePage();
+#if !defined(DOSCODE)
+		g_system->updateScreen();
+#endif
+		QuitMouseHandler = false;
+	}
+}
+
+
+
+
+/*****************************************************************************/
+/* Checks whether or not the mouse buttons have been pressed, and the last   */
+/* co-ordinates of the button press.  leftbutton tells whether to check the  */
+/* left or right button.                                                     */
+/*****************************************************************************/
+bool mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
+	if (leftbutton) {
+		if (LeftClick) {
+			*x = leftx;
+			*y = lefty;
+			LeftClick = false;
+			return true;
+		}
+	} else {
+		if (RightClick) {
+			*x = rightx;
+			*y = righty;
+			RightClick = false;
+			return true;
+		}
+	}
+
+	return false;
+}
+
+
+
+
+Gadget *mouseGadget(void) {
+	Gadget *Temp = LastGadgetHit;
+
+	LastGadgetHit = NULL;
+	return Temp;
+}
+
+} // End of namespace Lab
diff --git a/engines/lab/mouse.h b/engines/lab/mouse.h
new file mode 100644
index 0000000..e8bc7bf
--- /dev/null
+++ b/engines/lab/mouse.h
@@ -0,0 +1,62 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/stddefines.h"
+
+#ifndef LAB_MOUSE_H
+#define LAB_MOUSE_H
+
+namespace Lab {
+
+struct Gadget;
+
+bool initMouse(void);
+
+bool mouseReset(void);
+
+void updateMouse(void);
+
+void mouseShow(void);
+
+void mouseHide(void);
+
+void mouseXY(uint16 *x, uint16 *y);
+
+void mouseMove(uint16 x, uint16 y);
+
+bool mouseButton(uint16 *x, uint16 *y, bool leftbutton);
+
+Gadget *mouseGadget(void);
+
+void attachGadgetList(struct Gadget *GadList);
+
+} // End of namespace Lab
+
+#endif /* LAB_MOUSE_H */
diff --git a/engines/lab/parsefun.h b/engines/lab/parsefun.h
new file mode 100644
index 0000000..4e1dc5d
--- /dev/null
+++ b/engines/lab/parsefun.h
@@ -0,0 +1,101 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#ifndef LAB_PARSEFUN_H
+#define LAB_PARSEFUN_H
+
+#include "lab/stddefines.h"
+#include "lab/labfun.h"
+#include "lab/parsetypes.h"
+
+namespace Lab {
+
+/* From Parser.c */
+
+bool parse(const char *InputFile);
+
+
+/* From allocRoom.c */
+
+bool initRoomBuffer(void);
+
+void freeRoomBuffer(void);
+
+void allocRoom(void **Ptr, uint16 Size, uint16 RoomNum);
+
+/* From ReadParse.c */
+
+bool readRoomData(const char *fileName);
+
+bool readInventory(const char *fileName);
+
+char *numtostr(char *text, uint16 Num);
+
+bool readViews(uint16 RoomNum, const char *Path);
+
+bool readInitialConditions(LargeSet Conditions, const char *fileName);
+
+
+
+/* From ProcessRoom.c */
+
+ViewDataPtr getViewData(uint16 RoomNum, uint16 Direction);
+
+char *getPictName(CloseDataPtr *LCPtr);
+
+void drawDirection(CloseDataPtr LCPtr);
+
+bool processArrow(uint16 *Direction, uint16 Arrow);
+
+void setCurCloseAbs(uint16 x, uint16 y, CloseDataPtr *cptr);
+
+void setCurClose(uint16 x, uint16 y, CloseDataPtr *cptr);
+
+bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr);
+
+bool doActionRule(int16 x, int16 y, int16 Action, int16 RoomNum, CloseDataPtr *LCPtr);
+
+bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *LCPtr);
+
+bool doGoForward(CloseDataPtr *LCPtr);
+
+bool doTurn(uint16 from, uint16 to, CloseDataPtr *LCPtr);
+
+bool doMainView(CloseDataPtr *LCPtr);
+
+/*
+   bool doConditions(int16           x,
+                     int16           y,
+                     CloseDataPtr *LCPtr);
+ */
+
+} // End of namespace Lab
+
+#endif /* LAB_PARSEFUN_H */
diff --git a/engines/lab/parsetypes.h b/engines/lab/parsetypes.h
new file mode 100644
index 0000000..defe9af
--- /dev/null
+++ b/engines/lab/parsetypes.h
@@ -0,0 +1,237 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#ifndef LAB_PARSETYPES_H
+#define LAB_PARSETYPES_H
+
+namespace Lab {
+
+#define MAXFILELEN 31
+
+
+
+/*------------------------------- Action types ------------------------------*/
+#define PLAYSOUND     1
+#define PLAYSOUNDCONT 2
+#define SHOWDIFF      3
+#define SHOWDIFFCONT  4
+#define LOADDIFF      5
+#define LOADBM        6
+#define SHOWBM        7
+#define WIPECMD       8
+#define NOUPDATE      9
+#define FORCEUPDATE  10
+#define SHOWCURPICT  11
+#define SETELEMENT   12
+#define UNSETELEMENT 13
+#define SHOWMESSAGE  14
+#define SHOWMESSAGES 15
+#define SETPOSITION  16
+#define SETCLOSEUP   17
+#define MAINVIEW     18
+#define SUBINV       19
+#define ADDINV       20
+#define SHOWDIR      21
+#define WAITSECS     22
+#define STOPMUSIC    23
+#define STARTMUSIC   24
+#define CHANGEMUSIC  25
+#define RESETMUSIC   26
+#define FILLMUSIC    27
+#define WAITSOUND    28
+#define CLEARSOUND   29
+#define WINMUSIC     30
+#define WINGAME      31
+#define LOSTGAME     32
+#define RESETBUFFER  33
+#define SPECIALCMD   34
+#define CSHOWMESSAGE 35
+#define PLAYSOUNDB   36
+
+
+
+/* Rule Types */
+#define ACTION      1
+#define OPERATE     2
+#define GOFORWARD   3
+#define CONDITIONS  4
+#define TURN        5
+#define GOMAINVIEW  6
+#define TURNFROMTO  7
+
+
+
+/*----------------------------- Rule Type Action ----------------------------*/
+#define TAKE        1
+#define MOVE        2
+#define OPENDOOR    3
+#define CLOSEDOOR   4
+#define TAKEDEF     5
+
+#if defined(WIN32)
+#pragma pack(push, 1)
+#endif
+
+typedef struct closeData {
+	uint16 x1, y1, x2, y2;
+	int16 CloseUpType;                  /* if > 0, an object.  If < 0,
+                                                        an item */
+	uint16 depth;               /* Level of the closeup. */
+	char *GraphicName, *Message;
+	struct closeData *NextCloseUp, *SubCloseUps;
+} CloseData;
+
+typedef CloseData *CloseDataPtr;
+
+
+
+typedef struct viewData {
+	int16 *Condition;
+	char *GraphicName;
+	struct viewData *NextCondition;
+	CloseDataPtr closeUps;
+
+} viewData;
+
+typedef viewData *ViewDataPtr;
+
+
+struct Action {
+	int16 ActionType, Param1, Param2, Param3;
+	byte *Data;            /* Message, or a pointer to array
+                                                  of messages. */
+	Action *NextAction;
+
+};
+
+typedef Action *ActionPtr;
+
+
+
+typedef struct rule {
+	int16 RuleType, Param1, Param2, *Condition;
+
+	ActionPtr ActionList;
+	struct rule *NextRule;
+
+} Rule;
+
+typedef Rule *RulePtr;
+
+
+
+typedef struct {
+	uint16 NorthDoor, SouthDoor, EastDoor, WestDoor;
+
+	byte WipeType;
+
+	ViewDataPtr NorthView, SouthView, EastView, WestView;
+	RulePtr RuleList;
+	char *RoomMsg;
+
+} RoomData;
+
+
+
+typedef struct inventoryData {
+	/* New inventory stuff */
+	/*
+	               int16 *Condition;
+	               char *GraphicName,
+	 * InvName;
+	               struct inventoryData *NextInventory;
+	               CloseDataPtr          closeUps;
+	               RulePtr               RuleList;
+	 */
+
+	/* Old inventory stuff */
+	uint16 Many;
+	char *name, *BInvName;
+} InventoryData;
+
+
+
+/* Map Flags */
+
+/* Where the doors are; in a corridor, assumed to be left doors */
+#define     NORTHDOOR        1L
+#define     EASTDOOR         2L
+#define     SOUTHDOOR        4L
+#define     WESTDOOR         8L
+
+/* Where the doors are in corridors; M means middle, R means right, B means bottom */
+#define     NORTHMDOOR      16L
+#define     NORTHRDOOR      32L
+#define     SOUTHMDOOR      64L
+#define     SOUTHRDOOR     128L
+
+#define     EASTMDOOR       16L
+#define     EASTBDOOR       32L
+#define     WESTMDOOR       64L
+#define     WESTBDOOR      128L
+
+/* Special Map ID's */
+#define     NORMAL           0
+#define     UPARROWROOM      1
+#define     DOWNARROWROOM    2
+#define     BRIDGEROOM       3
+#define     VCORRIDOR        4
+#define     HCORRIDOR        5
+#define     MEDMAZE          6
+#define     HEDGEMAZE        7
+#define     SURMAZE          8
+#define     MULTIMAZEF1      9
+#define     MULTIMAZEF2     10
+#define     MULTIMAZEF3     11
+
+
+
+typedef struct {
+	uint16 x, y, PageNumber, SpecialID;
+	uint32 MapFlags;
+
+} MapData;
+
+#if defined(WIN32)
+#pragma pack(pop)
+#endif
+
+#if !defined(DOSCODE)
+typedef struct {
+	uint16 RoomNum;
+	uint16 Direction;
+} CrumbData;
+
+#define MAX_CRUMBS          128
+#endif
+
+} // End of namespace Lab
+
+#endif /* LAB_PARSETYPES_H */
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
new file mode 100644
index 0000000..2af9fa0
--- /dev/null
+++ b/engines/lab/processroom.cpp
@@ -0,0 +1,1056 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/stddefines.h"
+#include "lab/labfun.h"
+#include "lab/parsetypes.h"
+#include "lab/parsefun.h"
+#include "lab/timing.h"
+#include "lab/diff.h"
+#include "lab/vga.h"
+#if !defined(DOSCODE)
+#include "lab/interface.h"
+#endif
+
+namespace Lab {
+
+#ifdef GAME_TRIAL
+extern int g_IsRegistered;
+#endif
+
+
+/* Global parser data */
+
+RoomData *Rooms;
+InventoryData *Inventory;
+uint16 NumInv, RoomNum, ManyRooms, HighestCondition, Direction;
+LargeSet Conditions, RoomsFound;
+
+
+extern char *FACINGNORTH, *FACINGEAST, *FACINGSOUTH, *FACINGWEST;
+extern bool LongWinInFront;
+
+
+#define NOFILE         "no file"
+
+
+
+extern const char *CurFileName;
+
+const char *ViewPath = "LAB:Rooms/";
+
+
+const char *NewFileName;
+
+
+extern bool DoNotDrawMessage;
+extern bool NoFlip, IsBM, noupdatediff, waiteffect, mwaiteffect, QuitLab, EffectPlaying, soundplaying, MusicOn, DoBlack, ContMusic, DoNotReset;
+extern char diffcmap[256 * 3];
+
+extern CloseDataPtr CPtr;
+
+
+
+/*****************************************************************************/
+/* Generates a random number.                                                */
+/*****************************************************************************/
+uint16 getRandom(uint16 max) {
+	uint32 secs, micros;
+
+	getTime(&secs, &micros);
+	return ((micros + secs) % max);
+}
+
+
+
+
+/*****************************************************************************/
+/* Checks whether all the conditions in a condition list are met.            */
+/*****************************************************************************/
+static bool checkConditions(int16 *Condition) {
+	int16 Counter;
+	bool res;
+
+	if (Condition == NULL)
+		return true;
+
+	if (Condition[0] == 0)
+		return true;
+
+	Counter = 1;
+	res     = In(Conditions, Condition[0]);
+
+	while (Condition[Counter] && res) {
+		res = In(Conditions, Condition[Counter]);
+		Counter++;
+	}
+
+	return res;
+}
+
+
+
+
+/*****************************************************************************/
+/* Gets the current ViewDataPointer.                                         */
+/*****************************************************************************/
+ViewDataPtr getViewData(uint16 roomNum, uint16 direction) {
+	ViewDataPtr *VPtr = NULL, ViewPtr;
+	bool doit = true;
+
+	if (direction == NORTH)
+		VPtr = &Rooms[roomNum].NorthView;
+	else if (direction == SOUTH)
+		VPtr = &Rooms[roomNum].SouthView;
+	else if (direction == EAST)
+		VPtr = &Rooms[roomNum].EastView;
+	else if (direction == WEST)
+		VPtr = &Rooms[roomNum].WestView;
+
+	if (*VPtr == NULL)
+		readViews(roomNum, ViewPath);
+
+	ViewPtr = *VPtr;
+
+	do {
+		if (checkConditions(ViewPtr->Condition))
+			doit = false;
+		else
+			ViewPtr = ViewPtr->NextCondition;
+
+	} while (doit);
+
+	return ViewPtr;
+}
+
+
+
+/*****************************************************************************/
+/* Gets an object, if any, from the user's click on the screen.              */
+/*****************************************************************************/
+static CloseData *getObject(uint16 x, uint16 y, CloseDataPtr LCPtr) {
+	ViewDataPtr VPtr;
+
+	if (LCPtr == NULL) {
+		VPtr = getViewData(RoomNum, Direction);
+		LCPtr = VPtr->closeUps;
+	}
+
+	else
+		LCPtr = LCPtr->SubCloseUps;
+
+
+	while (LCPtr != NULL) {
+		if ((x >= scaleX(LCPtr->x1)) && (y >= scaleY(LCPtr->y1)) &&
+		        (x <= scaleX(LCPtr->x2)) && (y <= scaleY(LCPtr->y2)))
+			return LCPtr;
+
+		LCPtr = LCPtr->NextCloseUp;
+	}
+
+	return NULL;
+}
+
+
+
+
+/*****************************************************************************/
+/* Goes through the list of closeups to find a match.                        */
+/* NYI: Known bug here.  If there are two objects that have closeups, and    */
+/*      some of the closeups have the same hit boxes, then this returns the  */
+/*      first occurence of the object with the same hit box.                 */
+/*****************************************************************************/
+static CloseDataPtr findCPtrMatch(CloseDataPtr Main, CloseDataPtr List) {
+	CloseDataPtr cptr;
+
+	while (List) {
+		if ((Main->x1 == List->x1) && (Main->x2 == List->x2) &&
+		        (Main->y1 == List->y1) && (Main->y2 == List->y2) &&
+		        (Main->depth == List->depth))
+			return List;
+
+		cptr = findCPtrMatch(Main, List->SubCloseUps);
+
+		if (cptr)
+			return cptr;
+		else
+			List = List->NextCloseUp;
+	}
+
+	return NULL;
+}
+
+
+
+
+
+
+/*****************************************************************************/
+/* Returns the current picture name.                                         */
+/*****************************************************************************/
+char *getPictName(CloseDataPtr *LCPtr) {
+	ViewDataPtr ViewPtr;
+
+	ViewPtr = getViewData(RoomNum, Direction);
+
+	if (*LCPtr != NULL) {
+		*LCPtr = findCPtrMatch(*LCPtr, ViewPtr->closeUps);
+
+		if (*LCPtr)
+			return (*LCPtr)->GraphicName;
+	}
+
+	return ViewPtr->GraphicName;
+}
+
+
+/*****************************************************************************/
+/* Draws the current direction to the screen.                                */
+/*****************************************************************************/
+void drawDirection(CloseDataPtr LCPtr) {
+	char Message[250];
+	/*
+	   char test[15];
+	 */
+
+	if (LCPtr != NULL) {
+		if (LCPtr->Message) {
+			drawMessage(LCPtr->Message);
+			return;
+		}
+	}
+
+
+	Message[0] = '\0';
+
+	if (Rooms[RoomNum].RoomMsg) {
+		strcpy(Message, Rooms[RoomNum].RoomMsg);
+		strcat(Message, ", ");
+	}
+
+	if (Direction == NORTH)
+		strcat(Message, FACINGNORTH);
+	else if (Direction == EAST)
+		strcat(Message, FACINGEAST);
+	else if (Direction == SOUTH)
+		strcat(Message, FACINGSOUTH);
+	else if (Direction == WEST)
+		strcat(Message, FACINGWEST);
+
+	/*
+	   numtostr(test, RoomNum);
+	   strcat(Message, ", ");
+	   strcat(Message, test);
+	 */
+
+	drawMessage(Message);
+}
+
+#if !defined(DOSCODE)
+void getRoomMessage(int MyRoomNum, int MyDirection, char *msg) {
+	getViewData(MyRoomNum, MyDirection);
+
+	msg[0] = '\0';
+
+	if (Rooms[MyRoomNum].RoomMsg) {
+		strcpy(msg, Rooms[MyRoomNum].RoomMsg);
+		strcat(msg, ", ");
+	}
+
+	if (MyDirection == NORTH)
+		strcat(msg, FACINGNORTH);
+	else if (MyDirection == EAST)
+		strcat(msg, FACINGEAST);
+	else if (MyDirection == SOUTH)
+		strcat(msg, FACINGSOUTH);
+	else if (MyDirection == WEST)
+		strcat(msg, FACINGWEST);
+}
+#endif
+
+
+
+
+
+/*****************************************************************************/
+/* process a arrow gadget movement.                                          */
+/*****************************************************************************/
+bool processArrow(uint16 *direction, uint16 Arrow) {
+	uint16 room = 1;
+
+	if (Arrow == 1) { /* Forward */
+		if (*direction == NORTH)
+			room = Rooms[RoomNum].NorthDoor;
+		else if (*direction == SOUTH)
+			room = Rooms[RoomNum].SouthDoor;
+		else if (*direction == EAST)
+			room = Rooms[RoomNum].EastDoor;
+		else if (*direction == WEST)
+			room = Rooms[RoomNum].WestDoor;
+
+		if (room == 0)
+			return false;
+		else
+			RoomNum = room;
+	} else if (Arrow == 0) { /* Left */
+		if (*direction == NORTH)
+			*direction = WEST;
+		else if (*direction == WEST)
+			*direction = SOUTH;
+		else if (*direction == SOUTH)
+			*direction = EAST;
+		else
+			*direction = NORTH;
+	} else if (Arrow == 2) { /* Right */
+		if (*direction == NORTH)
+			*direction = EAST;
+		else if (*direction == EAST)
+			*direction = SOUTH;
+		else if (*direction == SOUTH)
+			*direction = WEST;
+		else
+			*direction = NORTH;
+	}
+
+	return true;
+}
+
+
+
+
+
+/*****************************************************************************/
+/* Sets the current close up data, but uses absolute cords.                  */
+/*****************************************************************************/
+void setCurCloseAbs(uint16 x, uint16 y, CloseDataPtr *cptr) {
+	ViewDataPtr VPtr;
+	CloseDataPtr LCPtr;
+
+	if (*cptr == NULL) {
+		VPtr = getViewData(RoomNum, Direction);
+		LCPtr = VPtr->closeUps;
+	} else
+		LCPtr = (*cptr)->SubCloseUps;
+
+
+	while (LCPtr != NULL) {
+		if ((x >= LCPtr->x1) && (y >= LCPtr->y1) &&
+		        (x <= LCPtr->x2) && (y <= LCPtr->y2) &&
+		        (LCPtr->GraphicName)) {
+			*cptr = LCPtr;
+			return;
+		}
+
+		LCPtr = LCPtr->NextCloseUp;
+	}
+}
+
+
+
+
+
+/*****************************************************************************/
+/* Sets the current close up data.                                           */
+/*****************************************************************************/
+void setCurClose(uint16 x, uint16 y, CloseDataPtr *cptr) {
+	ViewDataPtr VPtr;
+	CloseDataPtr LCPtr;
+
+	if (*cptr == NULL) {
+		VPtr = getViewData(RoomNum, Direction);
+		LCPtr = VPtr->closeUps;
+	} else
+		LCPtr = (*cptr)->SubCloseUps;
+
+
+	while (LCPtr != NULL) {
+		if ((x >= scaleX(LCPtr->x1)) && (y >= scaleY(LCPtr->y1)) &&
+		        (x <= scaleX(LCPtr->x2)) && (y <= scaleY(LCPtr->y2)) &&
+		        (LCPtr->GraphicName)) {
+			*cptr = LCPtr;
+			return;
+		}
+
+		LCPtr = LCPtr->NextCloseUp;
+	}
+}
+
+
+
+/*****************************************************************************/
+/* Takes the currently selected item.                                        */
+/*****************************************************************************/
+bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
+	ViewDataPtr VPtr;
+	CloseDataPtr LCPtr;
+
+	if (*cptr == NULL) {
+		VPtr = getViewData(RoomNum, Direction);
+		LCPtr = VPtr->closeUps;
+	} else if ((*cptr)->CloseUpType < 0) {
+		inclElement(Conditions, abs((*cptr)->CloseUpType));
+		return true;
+	} else
+		LCPtr = (*cptr)->SubCloseUps;
+
+
+	while (LCPtr != NULL) {
+		if ((x >= scaleX(LCPtr->x1)) && (y >= scaleY(LCPtr->y1)) &&
+		        (x <= scaleX(LCPtr->x2)) && (y <= scaleY(LCPtr->y2)) &&
+		        (LCPtr->CloseUpType < 0)) {
+			inclElement(Conditions, abs(LCPtr->CloseUpType));
+			return true;
+		}
+
+		LCPtr = LCPtr->NextCloseUp;
+	}
+
+	return false;
+}
+
+
+
+/*****************************************************************************/
+/* Processes the action list.                                                */
+/*****************************************************************************/
+static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
+	CloseDataPtr TLCPtr;
+	bool FirstLoaded = true;
+	char **str, *Test;
+	uint16 counter;
+	uint32 StartSecs, StartMicros, CurSecs, CurMicros;
+
+	while (APtr) {
+		g_music->newCheckMusic();
+
+		switch (APtr->ActionType) {
+		case PLAYSOUND:
+			mwaiteffect = true; /* Plays a sound, but waits for it to be done before continuing */
+			ContMusic = false;
+			readMusic((char *)APtr->Data);
+			mwaiteffect = false;
+			break;
+
+		case PLAYSOUNDB:
+			mwaiteffect = false; /* Plays a sound in the background. */
+			ContMusic = false;
+			readMusic((char *)APtr->Data);
+			break;
+
+		case PLAYSOUNDCONT:
+			g_music->_doNotFileFlushAudio = true;
+			ContMusic = true;
+			readMusic((char *)APtr->Data);
+			break;
+
+		case SHOWDIFF:
+			readPict((char *)APtr->Data, true);
+			break;
+
+		case SHOWDIFFCONT:
+			readPict((char *)APtr->Data, false);
+			break;
+
+		case LOADDIFF:
+			if (FirstLoaded) {
+				resetBuffer();
+				FirstLoaded = false;
+			}
+
+			if (APtr->Data)
+				g_music->newOpen((char *)APtr->Data);          /* Puts a file into memory */
+
+			break;
+
+		case WIPECMD:
+			doWipe(APtr->Param1, LCPtr, (char *)APtr->Data);
+			break;
+
+		case NOUPDATE:
+			noupdatediff = true;
+			DoBlack = false;
+			break;
+
+		case FORCEUPDATE:
+			CurFileName = " ";
+			break;
+
+		case SHOWCURPICT:
+			Test = getPictName(LCPtr);
+
+			if (strcmp(Test, CurFileName) != 0) {
+				CurFileName = Test;
+				readPict(CurFileName, true);
+			}
+
+			break;
+
+		case SETELEMENT:
+			inclElement(Conditions, APtr->Param1);
+			break;
+
+		case UNSETELEMENT:
+			exclElement(Conditions, APtr->Param1);
+			break;
+
+		case SHOWMESSAGE:
+			DoNotDrawMessage = false;
+
+			if (LongWinInFront)
+				longDrawMessage((char *)APtr->Data);
+			else
+				drawMessage((char *)APtr->Data);
+
+			DoNotDrawMessage = true;
+			break;
+
+		case CSHOWMESSAGE:
+			if (*LCPtr == NULL) {
+				DoNotDrawMessage = false;
+				drawMessage((char *)APtr->Data);
+				DoNotDrawMessage = true;
+			}
+
+			break;
+
+		case SHOWMESSAGES:
+			str = (char **)APtr->Data;
+			DoNotDrawMessage = false;
+			drawMessage(str[getRandom(APtr->Param1)]);
+			DoNotDrawMessage = true;
+			break;
+
+		case SETPOSITION:
+#if defined(LABDEMO)
+
+			// if teleporting to room 45 or 49
+			if (APtr->Param1 == 45 || APtr->Param1 == 49) {
+				extern void doTrialBlock();
+
+				// Time to pay up!
+				doTrialBlock();
+
+				CurFileName = getPictName(LCPtr);
+				readPict(CurFileName, true);
+
+				APtr = NULL;
+				continue;
+			}
+
+#endif
+#if defined(GAME_TRIAL)
+
+			if (APtr->Param1 & 0x8000) { // check registration if high-bit set
+				if (!g_IsRegistered) {
+					extern int trialCheckInGame();
+					int result;
+
+					// Time to pay up!
+					result = trialCheckInGame();
+
+					CurFileName = getPictName(LCPtr);
+					readPict(CurFileName, true);
+
+					if (!g_IsRegistered) {
+						APtr = NULL;
+						continue;
+					}
+				}
+
+				// fix-up data
+				APtr->Param1 &= 0x7fff; // clear high-bit
+			}
+
+#endif
+			RoomNum   = APtr->Param1;
+			Direction = APtr->Param2 - 1;
+			*LCPtr      = NULL;
+			DoBlack    = true;
+			break;
+
+		case SETCLOSEUP:
+			TLCPtr = getObject(scaleX(APtr->Param1), scaleY(APtr->Param2), *LCPtr);
+
+			if (TLCPtr)
+				*LCPtr = TLCPtr;
+
+			break;
+
+		case MAINVIEW:
+			*LCPtr = NULL;
+			break;
+
+		case SUBINV:
+			if (Inventory[APtr->Param1].Many)
+				(Inventory[APtr->Param1].Many)--;
+
+			if (Inventory[APtr->Param1].Many == 0)
+				exclElement(Conditions, APtr->Param1);
+
+			break;
+
+		case ADDINV:
+			(Inventory[APtr->Param1].Many) += APtr->Param2;
+			inclElement(Conditions, APtr->Param1);
+			break;
+
+		case SHOWDIR:
+			DoNotDrawMessage = false;
+			break;
+
+		case WAITSECS:
+			addCurTime(APtr->Param1, 0, &StartSecs, &StartMicros);
+
+#if !defined(DOSCODE)
+			g_system->updateScreen();
+#endif
+
+			while (1) {
+				g_music->newCheckMusic();
+				diffNextFrame();
+				getTime(&CurSecs, &CurMicros);
+
+				if ((CurSecs > StartSecs) || ((CurSecs == StartSecs) &&
+				                              (CurMicros >= StartMicros)))
+					break;
+			}
+
+			break;
+
+		case STOPMUSIC:
+			g_music->setMusic(false);
+			break;
+
+		case STARTMUSIC:
+			g_music->setMusic(true);
+			break;
+
+		case CHANGEMUSIC:
+			if (g_music->_turnMusicOn) {
+				g_music->changeMusic((const char *)APtr->Data);
+				DoNotReset = true;
+			}
+
+			break;
+
+		case RESETMUSIC:
+			if (g_music->_turnMusicOn) {
+				g_music->resetMusic();
+				DoNotReset = false;
+			}
+
+			break;
+
+		case FILLMUSIC:
+			g_music->fillUpMusic(true);
+			break;
+
+		case WAITSOUND:
+			while (EffectPlaying) {
+				g_music->updateMusic();
+				diffNextFrame();
+				waitTOF();
+			}
+
+			break;
+
+		case CLEARSOUND:
+			if (ContMusic) {
+				ContMusic = false;
+				flushAudio();
+			} else if (EffectPlaying)
+				flushAudio();
+
+			break;
+
+		case WINMUSIC:
+			if (g_music->_turnMusicOn) {
+				g_music->_winmusic = true;
+				g_music->freeMusic();
+				g_music->initMusic();
+			}
+
+			break;
+
+		case WINGAME:
+			QuitLab = true;
+			break;
+
+		case LOSTGAME:
+			QuitLab = true;
+			break;
+
+		case RESETBUFFER:
+			resetBuffer();
+			break;
+
+		case SPECIALCMD:
+			if (APtr->Param1 == 0)
+				DoBlack = true;
+			else if (APtr->Param1 == 1)
+				DoBlack = (CPtr == NULL);
+			else if (APtr->Param1 == 2)
+				DoBlack = (CPtr != NULL);
+			else if (APtr->Param1 == 5) { /* inverse the palette */
+				for (counter = (8 * 3); counter < (255 * 3); counter++)
+					diffcmap[counter] = 255 - diffcmap[counter];
+
+				waitTOF();
+				VGASetPal(diffcmap, 256);
+				waitTOF();
+				waitTOF();
+			} else if (APtr->Param1 == 4) { /* white the palette */
+				whiteScreen();
+				waitTOF();
+				waitTOF();
+			} else if (APtr->Param1 == 6) { /* Restore the palette */
+				waitTOF();
+				VGASetPal(diffcmap, 256);
+				waitTOF();
+				waitTOF();
+			} else if (APtr->Param1 == 7) { /* Quick pause */
+				waitTOF();
+				waitTOF();
+				waitTOF();
+			}
+
+			break;
+		}
+
+		APtr = APtr->NextAction;
+	}
+
+	if (ContMusic) {
+		ContMusic = false;
+		flushAudio();
+	} else {
+		while (EffectPlaying) {
+			g_music->updateMusic();
+			diffNextFrame();
+			waitTOF();
+		}
+	}
+
+	g_music->_doNotFileFlushAudio = false;
+}
+
+
+
+
+
+/*****************************************************************************/
+/* Does the work for doActionRule.                                           */
+/*****************************************************************************/
+static bool doActionRuleSub(int16 Action, int16 roomNum, CloseDataPtr LCPtr, CloseDataPtr *Set, bool AllowDefaults) {
+	RulePtr RPtr;
+
+	Action++;
+
+	if (LCPtr) {
+		RPtr = Rooms[roomNum].RuleList;
+
+		if ((RPtr == NULL) && (roomNum == 0)) {
+			readViews(roomNum, ViewPath);
+			RPtr = Rooms[roomNum].RuleList;
+		}
+
+
+		while (RPtr) {
+			if ((RPtr->RuleType == ACTION) &&
+			        ((RPtr->Param1 == Action) || ((RPtr->Param1 == 0) && AllowDefaults))) {
+				if (((RPtr->Param2 == LCPtr->CloseUpType) ||
+				        ((RPtr->Param2 == 0) && AllowDefaults))
+				        ||
+				        ((Action == 1) && (RPtr->Param2 == (-LCPtr->CloseUpType)))) {
+					if (checkConditions(RPtr->Condition)) {
+						doActions(RPtr->ActionList, Set);
+						return true;
+					}
+				}
+			}
+
+			RPtr = RPtr->NextRule;
+		}
+	}
+
+	return false;
+}
+
+
+
+
+/*****************************************************************************/
+/* Goes through the rules if an action is taken.                             */
+/*****************************************************************************/
+bool doActionRule(int16 x, int16 y, int16 Action, int16 roomNum, CloseDataPtr *LCPtr) {
+	CloseDataPtr TLCPtr;
+
+	if (roomNum)
+		NewFileName = NOFILE;
+	else
+		NewFileName = CurFileName;
+
+	TLCPtr = getObject(x, y, *LCPtr);
+
+	if (doActionRuleSub(Action, roomNum, TLCPtr, LCPtr, false))
+		return true;
+	else if (doActionRuleSub(Action, roomNum, *LCPtr, LCPtr, false))
+		return true;
+	else if (doActionRuleSub(Action, roomNum, TLCPtr, LCPtr, true))
+		return true;
+	else if (doActionRuleSub(Action, roomNum, *LCPtr, LCPtr, true))
+		return true;
+
+	return false;
+}
+
+
+
+/*****************************************************************************/
+/* Does the work for doActionRule.                                           */
+/*****************************************************************************/
+static bool doOperateRuleSub(int16 ItemNum, int16 roomNum, CloseDataPtr LCPtr, CloseDataPtr *Set, bool AllowDefaults) {
+	RulePtr RPtr;
+
+	if (LCPtr)
+		if (LCPtr->CloseUpType > 0) {
+			RPtr = Rooms[roomNum].RuleList;
+
+			if ((RPtr == NULL) && (roomNum == 0)) {
+				readViews(roomNum, ViewPath);
+				RPtr = Rooms[roomNum].RuleList;
+			}
+
+			while (RPtr) {
+				if ((RPtr->RuleType == OPERATE) &&
+				        ((RPtr->Param1 == ItemNum) || ((RPtr->Param1 == 0) && AllowDefaults)) &&
+				        ((RPtr->Param2 == LCPtr->CloseUpType) || ((RPtr->Param2 == 0) && AllowDefaults))) {
+					if (checkConditions(RPtr->Condition)) {
+						doActions(RPtr->ActionList, Set);
+						return true;
+					}
+				}
+
+				RPtr = RPtr->NextRule;
+			}
+		}
+
+	return false;
+}
+
+
+
+
+/*****************************************************************************/
+/* Goes thru the rules if the user tries to operate an item on an object.    */
+/*****************************************************************************/
+bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *LCPtr) {
+	CloseDataPtr TLCPtr;
+
+	NewFileName = NOFILE;
+
+	TLCPtr = getObject(x, y, *LCPtr);
+
+	if (doOperateRuleSub(ItemNum, RoomNum, TLCPtr, LCPtr, false))
+		return true;
+	else if (doOperateRuleSub(ItemNum, RoomNum, *LCPtr, LCPtr, false))
+		return true;
+	else if (doOperateRuleSub(ItemNum, RoomNum, TLCPtr, LCPtr, true))
+		return true;
+	else if (doOperateRuleSub(ItemNum, RoomNum, *LCPtr, LCPtr, true))
+		return true;
+
+	else {
+		NewFileName = CurFileName;
+
+		if (doOperateRuleSub(ItemNum, 0, TLCPtr, LCPtr, false))
+			return true;
+		else if (doOperateRuleSub(ItemNum, 0, *LCPtr, LCPtr, false))
+			return true;
+		else if (doOperateRuleSub(ItemNum, 0, TLCPtr, LCPtr, true))
+			return true;
+		else if (doOperateRuleSub(ItemNum, 0, *LCPtr, LCPtr, true))
+			return true;
+	}
+
+	return false;
+}
+
+
+
+
+/*****************************************************************************/
+/* Goes thru the rules if the user tries to go forward.                      */
+/*****************************************************************************/
+bool doGoForward(CloseDataPtr *LCPtr) {
+	RulePtr RPtr;
+
+	RPtr = Rooms[RoomNum].RuleList;
+
+	while (RPtr) {
+		if ((RPtr->RuleType == GOFORWARD) && (RPtr->Param1 == (Direction + 1))) {
+			if (checkConditions(RPtr->Condition)) {
+				doActions(RPtr->ActionList, LCPtr);
+				return true;
+			}
+		}
+
+		RPtr = RPtr->NextRule;
+	}
+
+	return false;
+}
+
+
+
+/*****************************************************************************/
+/* Goes thru the rules if the user tries to turn.                            */
+/*****************************************************************************/
+bool doTurn(uint16 from, uint16 to, CloseDataPtr *LCPtr) {
+	RulePtr RPtr;
+
+	from++;
+	to++;
+
+	RPtr = Rooms[RoomNum].RuleList;
+
+	while (RPtr) {
+		if ((RPtr->RuleType == TURN) ||
+
+		        ((RPtr->RuleType == TURNFROMTO) &&
+		         (RPtr->Param1   == from) && (RPtr->Param2 == to))) {
+			if (checkConditions(RPtr->Condition)) {
+				doActions(RPtr->ActionList, LCPtr);
+				return true;
+			}
+		}
+
+		RPtr = RPtr->NextRule;
+	}
+
+	return false;
+}
+
+
+
+
+/*****************************************************************************/
+/* Goes thru the rules if the user tries to go to the main view              */
+/*****************************************************************************/
+bool doMainView(CloseDataPtr *LCPtr) {
+	RulePtr RPtr;
+
+	RPtr = Rooms[RoomNum].RuleList;
+
+	while (RPtr) {
+		if (RPtr->RuleType == GOMAINVIEW) {
+			if (checkConditions(RPtr->Condition)) {
+				doActions(RPtr->ActionList, LCPtr);
+				return true;
+			}
+		}


Commit: b396135a4db8ba9796803b98d648dea77269d8d3
    https://github.com/scummvm/scummvm/commit/b396135a4db8ba9796803b98d648dea77269d8d3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Fix compilation

Changed paths:
    engines/lab/savegamepalmap.cpp



diff --git a/engines/lab/savegamepalmap.cpp b/engines/lab/savegamepalmap.cpp
index 786a557..a93b1c3 100644
--- a/engines/lab/savegamepalmap.cpp
+++ b/engines/lab/savegamepalmap.cpp
@@ -32,7 +32,7 @@
 
  namespace Lab {
 
- const byte ThePalMap[] = {
+ extern const byte ThePalMap[] = {
  0x73, 0x73, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
  0x20, 0x20, 0x20, 0x23, 0x23, 0x23, 0x1E, 0xE3, 0xE3, 0xE3,
  0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE1,


Commit: 11a7ffaabe89920b6481e0efeb744b5efc222996
    https://github.com/scummvm/scummvm/commit/11a7ffaabe89920b6481e0efeb744b5efc222996
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Started rendering pipeline

Changed paths:
    engines/lab/savegamepalmap.cpp
    engines/lab/special.cpp
    engines/lab/vga.cpp
    engines/lab/vga.h



diff --git a/engines/lab/savegamepalmap.cpp b/engines/lab/savegamepalmap.cpp
index a93b1c3..0678b78 100644
--- a/engines/lab/savegamepalmap.cpp
+++ b/engines/lab/savegamepalmap.cpp
@@ -19,7 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
  */
- 
+
  /*
  * This code is based on Labyrinth of Time code with assistance of
  *
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 5542b05..8275517 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -1224,7 +1224,7 @@ static void drawSaveLoad() {
 	rectFill(274, 450, 274, 450);
 	rectFill(274, 454, 276, 454);
 
-	g_system->updateScreen();
+	WSDL_UpdateScreen();
 }
 
 static void makeThumbnail(struct SaveGameInfo *info) {
@@ -1535,7 +1535,7 @@ bool saveRestoreGame(void) {
 	setAPen(0);
 	rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1);
 	blackScreen();
-	g_system->updateScreen();
+	WSDL_UpdateScreen();
 
 	journalCleanUp();
 
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 235d247..728b152 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -43,6 +43,9 @@ uint32 VGAScreenWidth = 320UL,
 
 uint32 VGABASEADDRESS = 0xA0000L;
 
+byte *g_DisplayBuffer = 0;
+byte *g_Pixels = 0;
+
 
 /*****************************************************************************/
 /* Sets the display mode.                                                    */
@@ -61,6 +64,10 @@ bool createScreen(bool HiRes) {
 	VGAScreenHeight = 480;
 	VGAPages        = 1;
 	VGABytesPerPage = 640 * 480;
+
+	g_DisplayBuffer = (byte *)malloc(VGABytesPerPage);
+	g_Pixels = (byte *)calloc(VGABytesPerPage, 4);
+
 	return true;
 }
 
@@ -84,19 +91,27 @@ void VGARestorePage(void) {
 	// does nothing in SDL
 }
 
-
-void waitTOF(void) {
-	warning("STUB: waitTOF");
-	//WSDL_WaitTOF(1);
+void WSDL_ProcessInput() {
 }
 
+void waitTOF() {
+	int untilOutOfRefresh = 1;
 
-// NOTE: I don't think this function is called anywhere in the code.
-void waitTOFQuick(void) {
-	warning("STUB: waitTOFQuick");
-	//WSDL_WaitTOF(0);
-}
+	g_ScreenIsLocked = 0;
 
+  	if (g_ScreenWasLocked || untilOutOfRefresh) {
+		g_system->copyRectToScreen(g_DisplayBuffer, VGAScreenWidth, 0, 0, VGAScreenWidth, VGAScreenHeight);
+		g_system->updateScreen();
+  	}
+
+  	g_ScreenWasLocked = 0;
+  	WSDL_ProcessInput();
+
+  	for (uint32 now = g_system->getMillis(); now - g_LastWaitTOFTicks <= 0xF; now = g_system->getMillis() )
+  		g_system->delayMillis(g_LastWaitTOFTicks - now + 17);
+
+  	g_LastWaitTOFTicks = now;
+}
 
 static char curvgapal[256 * 3];
 
@@ -153,7 +168,28 @@ void VGASetPal(void *cmap,
 		writeColorRegs((char *) cmap, 0, numcolors);
 }
 
+byte *WSDL_LockVideo() {
+	g_ScreenWasLocked = 1;
+	g_ScreenIsLocked = 1;
 
+	return g_DisplayBuffer;
+}
+
+void WSDL_UnlockVideo() {
+	g_ScreenIsLocked = 0;
+}
+
+void WSDL_UpdateScreen() {
+	WSDL_UnlockVideo();
+
+	if (g_ScreenWasLocked && !g_IgnoreUpdateDisplay) {
+		g_system->copyRectToScreen(g_DisplayBuffer, VGAScreenWidth, 0, 0, VGAScreenWidth, VGAScreenHeight);
+  		g_system->updateScreen();
+  	}
+
+	g_ScreenWasLocked = 0;
+	WSDL_ProcessInput(0);
+}
 
 /*****************************************************************************/
 /* Returns the base address of the current VGA display.                      */
@@ -162,18 +198,13 @@ byte *getVGABaseAddr(void) {
 	if (VGABASEADDRESS != 1)
 		return (byte *)VGABASEADDRESS;
 
-	warning("STUB: getVGABaseAddr");
-	return 0; // WSDL_LockVideo();
+	return WSDL_LockVideo();
 }
 
-#if !defined(DOSCODE)
 void ungetVGABaseAddr() {
-	warning("STUB: ungetVGABaseAddr");
 	if (VGABASEADDRESS == 1)
-		; //WSDL_UnlockVideo();
+		WSDL_UnlockVideo();
 }
-#endif
-
 
 /*****************************************************************************/
 /* Gets information about the current display.                               */
diff --git a/engines/lab/vga.h b/engines/lab/vga.h
index 7080f4a..6ed7347 100644
--- a/engines/lab/vga.h
+++ b/engines/lab/vga.h
@@ -95,6 +95,8 @@ void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 
 void ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 
+void WSDL_UpdateScreen();
+
 } // End of namespace Lab
 
 #endif /* LAB_VGA_H */


Commit: bbddd32d38a03544ddab6e36e6853ddc128d0254
    https://github.com/scummvm/scummvm/commit/bbddd32d38a03544ddab6e36e6853ddc128d0254
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Further rendering pipeline fixes

Changed paths:
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/lab.cpp
    engines/lab/labmusic.cpp
    engines/lab/map.cpp
    engines/lab/mouse.cpp
    engines/lab/processroom.cpp
    engines/lab/readdiff.cpp
    engines/lab/special.cpp
    engines/lab/stddefines.h
    engines/lab/vga.cpp
    engines/lab/vga.h



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index b0b8614..3edf896 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -786,7 +786,7 @@ static void process(void) {
 				CPtr = NULL;
 #if !defined(DOSCODE)
 				mayShowCrumbIndicator();
-				g_system->updateScreen();
+				WSDL_UpdateScreen();
 #endif
 			}
 
@@ -824,7 +824,7 @@ static void process(void) {
 
 #if !defined(DOSCODE)
 				mayShowCrumbIndicator();
-				g_system->updateScreen();
+				WSDL_UpdateScreen();
 
 				if (!FollowingCrumbs)
 					eatMessages();
@@ -838,7 +838,7 @@ static void process(void) {
 				drawRoomMessage(CurInv, CPtr);
 				ForceDraw = false;
 #if !defined(DOSCODE)
-				g_system->updateScreen();
+				WSDL_UpdateScreen();
 #endif
 			}
 		}
@@ -878,13 +878,13 @@ static void process(void) {
 
 					GotMessage = true;
 					mayShowCrumbIndicator();
-					g_system->updateScreen();
+					WSDL_UpdateScreen();
 					goto from_crumbs;
 				}
 			}
 
 			mayShowCrumbIndicator();
-			g_system->updateScreen();
+			WSDL_UpdateScreen();
 #endif
 		} else {
 			GotMessage = true;
@@ -918,7 +918,7 @@ from_crumbs:
 					NumCrumbs = 0;
 					DroppingCrumbs = true;
 					mayShowCrumbIndicator();
-					g_system->updateScreen();
+					WSDL_UpdateScreen();
 				}
 
 				else if (Code == 'f' || Code == 'F' ||
@@ -941,7 +941,7 @@ from_crumbs:
 								interfaceOn(); /* Sets the correct gadget list */
 								drawPanel();
 								drawRoomMessage(CurInv, CPtr);
-								g_system->updateScreen();
+								WSDL_UpdateScreen();
 							}
 						} else {
 							BreadCrumbs[0].RoomNum = 0;
@@ -949,7 +949,7 @@ from_crumbs:
 
 							// Need to hide indicator!!!!
 							mayShowCrumbIndicatorOff();
-							g_system->updateScreen();
+							WSDL_UpdateScreen();
 						}
 					}
 				}
@@ -1068,7 +1068,7 @@ from_crumbs:
 					drawPanel();
 					drawRoomMessage(CurInv, CPtr);
 #if !defined(DOSCODE)
-					g_system->updateScreen();
+					WSDL_UpdateScreen();
 #endif
 				}
 			}
@@ -1083,7 +1083,7 @@ from_crumbs:
 						CPtr = NULL;
 #if !defined(DOSCODE)
 						mayShowCrumbIndicator();
-						g_system->updateScreen();
+						WSDL_UpdateScreen();
 #endif
 					}
 
@@ -1107,7 +1107,7 @@ from_crumbs:
 						drawRoomMessage(CurInv, CPtr);
 #if !defined(DOSCODE)
 						mayShowCrumbIndicator();
-						g_system->updateScreen();
+						WSDL_UpdateScreen();
 #endif
 					} else {
 						Old        = ActionMode;
@@ -1130,7 +1130,7 @@ from_crumbs:
 							drawMessage(LOOKWHAT);
 
 #if !defined(DOSCODE)
-						g_system->updateScreen();
+						WSDL_UpdateScreen();
 #endif
 					}
 				}
@@ -1139,7 +1139,7 @@ from_crumbs:
 					doUse(MAPNUM);
 #if !defined(DOSCODE)
 					mayShowCrumbIndicator();
-					g_system->updateScreen();
+					WSDL_UpdateScreen();
 #endif
 				}
 
@@ -1165,7 +1165,7 @@ from_crumbs:
 						ForceDraw = true;
 #if !defined(DOSCODE)
 						mayShowCrumbIndicator();
-						g_system->updateScreen();
+						WSDL_UpdateScreen();
 #endif
 					} else if (GadID == 7) {
 						OldRoomNum = RoomNum;
@@ -1241,7 +1241,7 @@ from_crumbs:
 						}
 
 						mayShowCrumbIndicator();
-						g_system->updateScreen();
+						WSDL_UpdateScreen();
 #endif
 					}
 				}
@@ -1261,7 +1261,7 @@ from_crumbs:
 					drawPanel();
 					drawRoomMessage(CurInv, CPtr);
 #if !defined(DOSCODE)
-					g_system->updateScreen();
+					WSDL_UpdateScreen();
 #endif
 				}
 
@@ -1288,14 +1288,14 @@ from_crumbs:
 						drawMessage("Disk operation failed.");
 						VGASetPal(initcolors, 8);
 #if !defined(DOSCODE)
-						g_system->updateScreen();
+						WSDL_UpdateScreen();
 #endif
 						g_system->delayMillis(1000);
 					}
 
 #if !defined(DOSCODE)
 					else {
-						g_system->updateScreen();
+						WSDL_UpdateScreen();
 					}
 
 #endif
@@ -1312,7 +1312,7 @@ from_crumbs:
 						drawMessage(USEONWHAT);
 						MainDisplay = true;
 #if !defined(DOSCODE)
-						g_system->updateScreen();
+						WSDL_UpdateScreen();
 #endif
 					}
 				}
@@ -1332,7 +1332,7 @@ from_crumbs:
 						Test = getInvName(CurInv);
 
 #if !defined(DOSCODE)
-					g_system->updateScreen();
+					WSDL_UpdateScreen();
 #endif
 				}
 
@@ -1342,7 +1342,7 @@ from_crumbs:
 					DoNotDrawMessage = false;
 					drawRoomMessage(CurInv, CPtr);
 #if !defined(DOSCODE)
-					g_system->updateScreen();
+					WSDL_UpdateScreen();
 #endif
 				}
 
@@ -1352,7 +1352,7 @@ from_crumbs:
 					DoNotDrawMessage = false;
 					drawRoomMessage(CurInv, CPtr);
 #if !defined(DOSCODE)
-					g_system->updateScreen();
+					WSDL_UpdateScreen();
 #endif
 				}
 
@@ -1362,7 +1362,7 @@ from_crumbs:
 					NumCrumbs = 0;
 					DroppingCrumbs = true;
 					mayShowCrumbIndicator();
-					g_system->updateScreen();
+					WSDL_UpdateScreen();
 				}
 
 				else if (GadID == 6) { /* follow crumbs */
@@ -1383,14 +1383,14 @@ from_crumbs:
 							interfaceOn(); /* Sets the correct gadget list */
 							drawPanel();
 							drawRoomMessage(CurInv, CPtr);
-							g_system->updateScreen();
+							WSDL_UpdateScreen();
 						} else {
 							BreadCrumbs[0].RoomNum = 0;
 							DroppingCrumbs = false;
 
 							// Need to hide indicator!!!!
 							mayShowCrumbIndicatorOff();
-							g_system->updateScreen();
+							WSDL_UpdateScreen();
 						}
 					}
 				}
@@ -1474,7 +1474,7 @@ from_crumbs:
 
 #if !defined(DOSCODE)
 				mayShowCrumbIndicator();
-				g_system->updateScreen();
+				WSDL_UpdateScreen();
 #endif
 			}
 
@@ -1527,7 +1527,7 @@ from_crumbs:
 				drawRoomMessage(CurInv, CPtr);
 #if !defined(DOSCODE)
 				mayShowCrumbIndicator();
-				g_system->updateScreen();
+				WSDL_UpdateScreen();
 #endif
 			}
 		}
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index bcaed9c..dba2811 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -336,7 +336,8 @@ uint32 flowText(void *font,      /* the TextAttr pointer */
 }
 
 
-extern uint32 VGABASEADDRESS, VGABytesPerPage;
+extern uint32 VGABytesPerPage;
+extern byte *VGABASEADDRESS;
 
 
 /******************************************************************************/
@@ -353,13 +354,15 @@ uint32 flowTextToMem(struct Image *DestIm, void *font,     /* the TextAttr point
                      uint16 x1,               /* Cords */
                      uint16 y1, uint16 x2, uint16 y2, const char *str) { /* The text itself */
 	uint32 res, vgabyte = VGABytesPerPage;
+	byte *tmp = VGABASEADDRESS;
 
-	//VGABASEADDRESS = (uint32)(DestIm->ImageData);
+	VGABASEADDRESS = DestIm->ImageData;
 	VGABytesPerPage = (uint32) DestIm->Width * (int32) DestIm->Height;
 
 	res = flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str);
 
 	VGABytesPerPage = vgabyte;
+	VGABASEADDRESS = tmp;
 
 	return res;
 }
@@ -593,7 +596,7 @@ static void doScrollBlack(void) {
 		setAPen(0);
 		rectFill(0, nheight, width - 1, nheight + by - 1);
 
-		g_system->updateScreen();
+		WSDL_UpdateScreen();
 
 		if (!IsHiRes) {
 			if (nheight <= (height / 8))
@@ -695,7 +698,7 @@ static void doScrollWipe(char *filename) {
 
 		copyPage(width, height, nheight, startline, mem);
 
-		g_system->updateScreen();
+		WSDL_UpdateScreen();
 
 		if (!nheight)
 			startline += by;
@@ -741,7 +744,7 @@ static void doScrollBounce(void) {
 		startline -= newby[counter];
 		copyPage(width, height, 0, startline, mem);
 
-		g_system->updateScreen();
+		WSDL_UpdateScreen();
 		waitTOF();
 	}
 
@@ -750,7 +753,7 @@ static void doScrollBounce(void) {
 		startline += newby1[counter - 1];
 		copyPage(width, height, 0, startline, mem);
 
-		g_system->updateScreen();
+		WSDL_UpdateScreen();
 		waitTOF();
 
 	}
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index edde50b..7054072 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -56,7 +56,7 @@ LabEngine::~LabEngine() {
 
 Common::Error LabEngine::run() {
 	// Initialize graphics using following:
-	initGraphics(320, 200, false);
+	initGraphics(640, 480, true);
 
 	g_music = new Music();
 
diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index e15dfa7..d7edc2b 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -102,6 +102,9 @@ void Music::updateMusic(void) {
 
 
 void Music::fillbuffer(uint16 unit) {
+	return;
+
+	warning("STUB: Music::fillbuffer");
 	uint32 Size = MUSICBUFSIZE;
 	void *ptr  = _musicBuffer[unit];
 #if defined(DOSCODE)
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index f6e9499..d32154e 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -60,7 +60,7 @@ extern uint16 RoomNum;
 /* the VGA palette.                                                          */
 /*****************************************************************************/
 void setAmigaPal(uint16 *pal, uint16 numcolors) {
-	char vgapal[16 * 3];
+	byte vgapal[16 * 3];
 	uint16 counter, vgacount;
 
 	if (numcolors > 16)
@@ -69,11 +69,11 @@ void setAmigaPal(uint16 *pal, uint16 numcolors) {
 	vgacount = 0;
 
 	for (counter = 0; counter < numcolors; counter++) {
-		vgapal[vgacount]   = (char)(((pal[counter] & 0xf00) >> 8) << 2);
+		vgapal[vgacount]   = (byte)(((pal[counter] & 0xf00) >> 8) << 2);
 		vgacount++;
-		vgapal[vgacount] = (char)(((pal[counter] & 0x0f0) >> 4) << 2);
+		vgapal[vgacount] = (byte)(((pal[counter] & 0x0f0) >> 4) << 2);
 		vgacount++;
-		vgapal[vgacount] = (char)(((pal[counter] & 0x00f)) << 2);
+		vgapal[vgacount] = (byte)(((pal[counter] & 0x00f)) << 2);
 		vgacount++;
 	}
 
@@ -733,7 +733,8 @@ static void drawMap(LargeSet RoomsFound, uint16 CurRoom, uint16 CurMsg, uint16 F
 void processMap(uint16 CurRoom, LargeSet RoomsFound) {
 	uint32 Class, place = 1;
 	uint16 Code, Qualifier, MouseX, MouseY, GadgetID, CurFloor, OldFloor, OldMsg, CurMsg, drawroom, x1, y1, x2, y2;
-	char *sptr, newcolor[3];
+	char *sptr;
+	byte newcolor[3];
 	bool drawmap;
 	struct IntuiMessage *Msg;
 
@@ -894,7 +895,7 @@ void processMap(uint16 CurRoom, LargeSet RoomsFound) {
 			}
 
 #if !defined(DOSCODE)
-			g_system->updateScreen();
+			WSDL_UpdateScreen();
 #endif
 		}
 	}
@@ -935,7 +936,7 @@ void doMap(LargeSet RoomsFound, uint16 CurRoom) {
 	mouseShow();
 	attachGadgetList(MapGadgetList);
 #if !defined(DOSCODE)
-	g_system->updateScreen();
+	WSDL_UpdateScreen();
 #endif
 	processMap(CurRoom, RoomsFound);
 	attachGadgetList(NULL);
@@ -948,7 +949,7 @@ void doMap(LargeSet RoomsFound, uint16 CurRoom) {
 	blackAllScreen();
 	mouseShow();
 #if !defined(DOSCODE)
-	g_system->updateScreen();
+	WSDL_UpdateScreen();
 #endif
 }
 
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index 857a397..ff2474e 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -295,7 +295,7 @@ void updateMouse(void) {
 #if !defined(DOSCODE)
 
 	if (doUpdateDisplay)
-		g_system->updateScreen();
+		WSDL_UpdateScreen();
 
 #endif
 }
@@ -431,7 +431,7 @@ void mouseShowXY(uint16 MouseX, uint16 MouseY) {
 		getBackMouse();
 		drawMouse();
 #if !defined(DOSCODE)
-		g_system->updateScreen();
+		WSDL_UpdateScreen();
 #endif
 		MouseHidden = false;
 	}
@@ -522,7 +522,7 @@ void mouseMove(uint16 x, uint16 y) {
 		drawMouse();
 		VGARestorePage();
 #if !defined(DOSCODE)
-		g_system->updateScreen();
+		WSDL_UpdateScreen();
 #endif
 		QuitMouseHandler = false;
 	}
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 2af9fa0..d9f40b4 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -629,7 +629,7 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
 			addCurTime(APtr->Param1, 0, &StartSecs, &StartMicros);
 
 #if !defined(DOSCODE)
-			g_system->updateScreen();
+			WSDL_UpdateScreen();
 #endif
 
 			while (1) {
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index 2af49e9..1ceeb44 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -110,7 +110,7 @@ void unDiff(byte *NewBuf, byte *OldBuf, byte *DiffData, uint16 bytesperrow, bool
 }
 
 
-static char blackbuffer[256 * 3];
+static byte blackbuffer[256 * 3];
 
 /*****************************************************************************/
 /* Changes the front screen to black.                                        */
@@ -220,7 +220,7 @@ void diffNextFrame(void) {
 #if !defined(DOSCODE)
 
 			if (DispBitMap->Flags & BITMAPF_VIDEO)
-				g_system->updateScreen();
+				WSDL_UpdateScreen();
 
 #endif
 
@@ -366,7 +366,7 @@ void diffNextFrame(void) {
 					ungetVGABaseAddr();
 
 				if (!didTOF)
-					g_system->updateScreen();
+					WSDL_UpdateScreen();
 
 #endif
 				return;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 8275517..4e842a1 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -1284,10 +1284,9 @@ static void addSaveSlot() {
 	makeThumbnail(info);
 
 	mouseHide();
-	warning("STUB: addSaveSlot()");
-	//SDL_IgnoreUpdateDisplay(1);
+	WSDL_IgnoreUpdateDisplay(1);
 	loadBackPict("P:ModSave", false);
-	//SDL_IgnoreUpdateDisplay(0);
+	WSDL_IgnoreUpdateDisplay(0);
 	drawSaveLoad();
 	mouseShow();
 }
@@ -1299,10 +1298,9 @@ static void selectSave(int n) {
 	g_CurSaveGameNumber = n;
 
 	mouseHide();
-	warning("STUB: selectSave()");
-	//SDL_IgnoreUpdateDisplay(1);
+	WSDL_IgnoreUpdateDisplay(1);
 	loadBackPict("P:ModSave", false);
-	//SDL_IgnoreUpdateDisplay(0);
+	WSDL_IgnoreUpdateDisplay(0);
 	drawSaveLoad();
 	mouseShow();
 }
@@ -1312,10 +1310,9 @@ static void selectSaveSet(int n) {
 		g_CurSaveSet = n;
 
 		mouseHide();
-		warning("STUB: selectSaveSet");
-		//SDL_IgnoreUpdateDisplay(1);
+		WSDL_IgnoreUpdateDisplay(1);
 		loadBackPict("P:ModSave", false);
-		//SDL_IgnoreUpdateDisplay(0);
+		WSDL_IgnoreUpdateDisplay(0);
 		drawSaveLoad();
 		mouseShow();
 	}
diff --git a/engines/lab/stddefines.h b/engines/lab/stddefines.h
index b7e5fa6..cd3156f 100644
--- a/engines/lab/stddefines.h
+++ b/engines/lab/stddefines.h
@@ -38,7 +38,7 @@
 namespace Lab {
 
 #define IS_MACOSX 1
-#define USE_SWAP 1
+#define USE_NOSWAP 1
 
 
 #define INCL(BITSET,BIT) ((BITSET) |= (BIT))
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 728b152..8badc70 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -32,6 +32,8 @@
 #include "lab/stddefines.h"
 #include "lab/storage.h"
 
+#include "graphics/palette.h"
+
 namespace Lab {
 
 //static uint16 NotInRefresh = 0;
@@ -41,11 +43,15 @@ uint32 VGAScreenWidth = 320UL,
               VGAPages        = 1UL,
               VGABytesPerPage = 65536UL;
 
-uint32 VGABASEADDRESS = 0xA0000L;
+byte *VGABASEADDRESS = 0;
 
 byte *g_DisplayBuffer = 0;
 byte *g_Pixels = 0;
 
+int g_ScreenWasLocked = 0;
+int g_IgnoreUpdateDisplay = 0;
+int g_LastWaitTOFTicks = 0;
+
 
 /*****************************************************************************/
 /* Sets the display mode.                                                    */
@@ -58,8 +64,8 @@ void setMode(char mode) {
 /* Sets up either a low-res or a high-res 256 color screen.                  */
 /*****************************************************************************/
 bool createScreen(bool HiRes) {
-//	VGABASEADDRESS  = (unsigned long)malloc(640 * 480);
-	VGABASEADDRESS  = 1;
+	//VGABASEADDRESS  = (unsigned long)malloc(640 * 480);
+	VGABASEADDRESS  = 0;
 	VGAScreenWidth  = 640;
 	VGAScreenHeight = 480;
 	VGAPages        = 1;
@@ -91,29 +97,37 @@ void VGARestorePage(void) {
 	// does nothing in SDL
 }
 
-void WSDL_ProcessInput() {
+void WSDL_ProcessInput(int state) {
 }
 
 void waitTOF() {
 	int untilOutOfRefresh = 1;
 
-	g_ScreenIsLocked = 0;
-
   	if (g_ScreenWasLocked || untilOutOfRefresh) {
 		g_system->copyRectToScreen(g_DisplayBuffer, VGAScreenWidth, 0, 0, VGAScreenWidth, VGAScreenHeight);
 		g_system->updateScreen();
   	}
 
   	g_ScreenWasLocked = 0;
-  	WSDL_ProcessInput();
+  	WSDL_ProcessInput(0);
 
-  	for (uint32 now = g_system->getMillis(); now - g_LastWaitTOFTicks <= 0xF; now = g_system->getMillis() )
+  	uint32 now;
+
+  	for (now = g_system->getMillis(); now - g_LastWaitTOFTicks <= 0xF; now = g_system->getMillis() )
   		g_system->delayMillis(g_LastWaitTOFTicks - now + 17);
 
   	g_LastWaitTOFTicks = now;
 }
 
-static char curvgapal[256 * 3];
+void WSDL_SetColors(byte *buf, uint16 first, uint16 numreg, uint16 slow) {
+
+	g_system->getPaletteManager()->setPalette(buf, first, numreg);
+
+	if (slow)
+    	waitTOF();
+}
+
+static byte curvgapal[256 * 3];
 
 /*****************************************************************************/
 /* Writes any number of the 256 color registers.                             */
@@ -126,57 +140,41 @@ static char curvgapal[256 * 3];
 /*           The length of the buffer is 3 times the number of registers     */
 /*           selected.                                                       */
 /*****************************************************************************/
-void writeColorRegs(char *buf,
-                    uint16 first,
-                    uint16 numreg) {
-	warning("STUB: writeColorRegs");
-	//WSDL_SetColors(buf, first, numreg, 0);
+void writeColorRegs(byte *buf, uint16 first, uint16 numreg) {
+	WSDL_SetColors(buf, first, numreg, 0);
 	memcpy(&(curvgapal[first * 3]), buf, numreg * 3);
 }
 
-
-
-
-void writeColorRegsSmooth(char *buf,
-                          uint16 first,
-                          uint16 numreg) {
-	warning("STUB: writeColorRegsSmooth");
-	//WSDL_SetColors(buf, first, numreg, 1);
+void writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg) {
+	WSDL_SetColors(buf, first, numreg, 1);
 	memcpy(&(curvgapal[first * 3]), buf, numreg * 3);
 }
 
-
-
-
 /*****************************************************************************/
 /* Sets one of the 256 (0..255) color registers.  buf is a char pointer,     */
 /* the first character in the string is the red value, then green, then      */
 /* blue.  Each color value is a 6 bit value.                                 */
 /*****************************************************************************/
-void writeColorReg(char *buf,
-                   uint16 regnum) {
+void writeColorReg(byte *buf, uint16 regnum) {
 	writeColorRegs(buf, regnum, 1);
 }
 
-
-
-
-
-void VGASetPal(void *cmap,
-               uint16 numcolors) {
+void VGASetPal(void *cmap, uint16 numcolors) {
 	if (memcmp(cmap, curvgapal, numcolors * 3) != 0)
-		writeColorRegs((char *) cmap, 0, numcolors);
+		writeColorRegs((byte *)cmap, 0, numcolors);
 }
 
 byte *WSDL_LockVideo() {
 	g_ScreenWasLocked = 1;
-	g_ScreenIsLocked = 1;
 
 	return g_DisplayBuffer;
 }
 
 void WSDL_UnlockVideo() {
-	g_ScreenIsLocked = 0;
+}
+
+void WSDL_IgnoreUpdateDisplay(int state) {
+	g_IgnoreUpdateDisplay = state;
 }
 
 void WSDL_UpdateScreen() {
@@ -195,14 +193,14 @@ void WSDL_UpdateScreen() {
 /* Returns the base address of the current VGA display.                      */
 /*****************************************************************************/
 byte *getVGABaseAddr(void) {
-	if (VGABASEADDRESS != 1)
-		return (byte *)VGABASEADDRESS;
+	if (VGABASEADDRESS)
+		return VGABASEADDRESS;
 
 	return WSDL_LockVideo();
 }
 
 void ungetVGABaseAddr() {
-	if (VGABASEADDRESS == 1)
+	if (!VGABASEADDRESS)
 		WSDL_UnlockVideo();
 }
 
@@ -213,15 +211,10 @@ void getMode(uint16 *Mode) {
 	// Only one mode in SDL.
 }
 
-
-
-
 /*****************************************************************************/
 /* Draws an image to the screen.                                             */
 /*****************************************************************************/
-void drawImage(struct Image *Im,
-               uint16 x,
-               uint16 y) {
+void drawImage(struct Image *Im, uint16 x, uint16 y) {
 #if !defined(DOSCODE)
 	int sx, sy, dx, dy, w, h;
 
@@ -337,9 +330,7 @@ void drawImage(struct Image *Im,
 /*****************************************************************************/
 /* Draws an image to the screen.                                             */
 /*****************************************************************************/
-void drawMaskImage(struct Image *Im,
-                   uint16 x,
-                   uint16 y) {
+void drawMaskImage(struct Image *Im, uint16 x, uint16 y) {
 #if !defined(DOSCODE)
 	int sx, sy, dx, dy, w, h;
 
@@ -469,9 +460,7 @@ void drawMaskImage(struct Image *Im,
 /*****************************************************************************/
 /* Reads an image from the screen.                                           */
 /*****************************************************************************/
-void readScreenImage(struct Image *Im,
-                     uint16 x,
-                     uint16 y) {
+void readScreenImage(struct Image *Im, uint16 x, uint16 y) {
 #if !defined(DOSCODE)
 	int sx, sy, dx, dy, w, h;
 
@@ -588,14 +577,8 @@ void readScreenImage(struct Image *Im,
 /* Blits a piece of one image to another.                                    */
 /* NOTE: for our purposes, assumes that ImDest is to be in VGA memory.       */
 /*****************************************************************************/
-void bltBitMap(struct Image *ImSource,
-               uint16 xs,
-               uint16 ys,
-               struct Image *ImDest,
-               uint16 xd,
-               uint16 yd,
-               uint16 width,
-               uint16 height) {
+void bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest,
+					uint16 xd, uint16 yd, uint16 width, uint16 height) {
 #if !defined(DOSCODE)
 	// I think the old code assumed that the source image data was valid for the given box.
 	// I will proceed on that assumption.
@@ -727,11 +710,7 @@ byte *TempScrollData;
 /* The TempScrollData variable must be initialized to some memory, or this   */
 /* function will fail.                                                       */
 /*****************************************************************************/
-void scrollDisplayX(int16 dx,
-                    uint16 x1,
-                    uint16 y1,
-                    uint16 x2,
-                    uint16 y2) {
+void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	struct Image Im;
 	uint16 temp;
 
@@ -777,11 +756,7 @@ void scrollDisplayX(int16 dx,
 /*****************************************************************************/
 /* Scrolls the display in the y direction by blitting.                       */
 /*****************************************************************************/
-void scrollDisplayY(int16 dy,
-                    uint16 x1,
-                    uint16 y1,
-                    uint16 x2,
-                    uint16 y2) {
+void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	struct Image Im;
 	uint16 temp;
 
@@ -837,10 +812,7 @@ void setAPen(uint16 pennum) {
 /*****************************************************************************/
 /* Fills in a rectangle.                                                     */
 /*****************************************************************************/
-void rectFill(uint16 x1,
-              uint16 y1,
-              uint16 x2,
-              uint16 y2) {
+void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 #if !defined(DOSCODE)
 	int dx, dy, w, h;
 
@@ -952,9 +924,7 @@ void rectFill(uint16 x1,
 /*****************************************************************************/
 /* Draws a horizontal line.                                                  */
 /*****************************************************************************/
-void drawVLine(uint16 x,
-               uint16 y1,
-               uint16 y2) {
+void drawVLine(uint16 x, uint16 y1, uint16 y2) {
 	rectFill(x, y1, x, y2);
 }
 
@@ -964,9 +934,7 @@ void drawVLine(uint16 x,
 /*****************************************************************************/
 /* Draws a vertical line.                                                    */
 /*****************************************************************************/
-void drawHLine(uint16 x1,
-               uint16 y,
-               uint16 x2) {
+void drawHLine(uint16 x1, uint16 y, uint16 x2) {
 	rectFill(x1, y, x2, y);
 }
 
@@ -976,11 +944,7 @@ void drawHLine(uint16 x1,
 /*****************************************************************************/
 /* Ghoasts a region on the screen using the desired pen color.               */
 /*****************************************************************************/
-void ghoastRect(uint16 pencolor,
-                uint16 x1,
-                uint16 y1,
-                uint16 x2,
-                uint16 y2) {
+void ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 #if !defined(DOSCODE)
 	int dx, dy, w, h;
 
diff --git a/engines/lab/vga.h b/engines/lab/vga.h
index 6ed7347..fc5f981 100644
--- a/engines/lab/vga.h
+++ b/engines/lab/vga.h
@@ -63,11 +63,11 @@ byte *getVGABaseAddr(void);
 void ungetVGABaseAddr();
 #endif
 
-void writeColorReg(char *buf, uint16 regnum);
+void writeColorReg(byte *buf, uint16 regnum);
 
-void writeColorRegs(char *buf, uint16 first, uint16 numreg);
+void writeColorRegs(byte *buf, uint16 first, uint16 numreg);
 
-void writeColorRegsSmooth(char *buf, uint16 first, uint16 numreg);
+void writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg);
 
 void VGASetPal(void *cmap, uint16 numcolors);
 
@@ -97,6 +97,8 @@ void ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 
 void WSDL_UpdateScreen();
 
+void WSDL_IgnoreUpdateDisplay(int state);
+
 } // End of namespace Lab
 
 #endif /* LAB_VGA_H */


Commit: dfa0a1ef0b23e0343ddf98c545cdae2a51d85c77
    https://github.com/scummvm/scummvm/commit/dfa0a1ef0b23e0343ddf98c545cdae2a51d85c77
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Implement openFile(), first gfx output!

Changed paths:
    engines/lab/labfile.cpp



diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
index 90db66f..adef2f0 100644
--- a/engines/lab/labfile.cpp
+++ b/engines/lab/labfile.cpp
@@ -222,97 +222,32 @@ bool allocFile(void **Ptr, uint32 Size, const char *fileName) {
 /* Reads a file into memory.                                                 */
 /*****************************************************************************/
 byte **openFile(const char *name) {
-	warning("STUB: openFile");
+	byte *buf;
 
-	return NULL;
-#if 0
-	char *tempbuffer, *Buffer;
-	int32 Size, Left;
-	int FPtr, ReadSize, myread;
-
-	ReadSoFar   = 0L;
-	ReadIsError = false;
-	ReadIsDone  = false;
-
-	if ((buffer == NULL) || (name == NULL)) {
-		ReadIsError = true;
-		ReadIsDone  = true;
-		return NULL;
-	}
+	Common::File file;
 
-	Size = sizeOfFile(name);
+	file.open(translateFileName(name));
+	if (!file.isOpen()) {
+		warning("Cannot open file %s", translateFileName(name));
 
-	if (!Size || (Size > ((int32) buffersize))) {
 		ReadIsError = true;
 		ReadIsDone  = true;
 		return NULL;
 	}
 
-	if (allocFile((void **) &Buffer, Size, name)) { /* Get place in Buffer     */
-		*startoffile = Buffer;                        /* If the file is buffered */
+	uint32 size = file.size();
 
-		ReadSoFar   = Size;
-		ReadIsError = false;
-		ReadIsDone  = true;
+	buf = (byte *)malloc(size);
 
-		return startoffile;
+	if (!buf) {
+		error("Unable to allocate %d bytes file file %s", size, name);
 	}
 
-#if defined(WIN32)
-#if defined(DEMODATA)
-	{
-		FILE *fh = fopen("c:\\depot\\labyrinth\\demodata.log", "a+w");
-		fprintf(fh, "%s\n", name);
-		fclose(fh);
-	}
-#endif
-
-	FPtr = open(translateFileName(name), O_RDONLY | O_BINARY);
-#else
-	FPtr = open(translateFileName(name), O_RDONLY);
-#endif
-
-	if (FPtr != -1) {
-		Left = Size;
-		tempbuffer = Buffer;
-		*startoffile = Buffer;
-
-		while (Left) {
-			fileCheckMusic(Left);
-
-			if (Left > MAXREADSIZE)
-				ReadSize = MAXREADSIZE;
-			else
-				ReadSize = (int) Left;
-
-			if (!(myread = read(FPtr, tempbuffer, ReadSize + DMABUGSIZE))) {
-				ReadIsError = false;
-				ReadIsDone  = true;
-
-				close(FPtr);
-				return NULL;
-			}
+	*startoffile = buf;
 
-			/* Not necessary for IBM version
-			      if ((ReadSize == MAXREADSIZE) && DMABUGSIZE)
-			        Seek(FPtr, -DMABUGSIZE, (int32) OFFSET_CURRENT);
-			 */
+	file.read(buf, size);
 
-			ReadSoFar  += ReadSize;
-			tempbuffer += ReadSize;
-			Left       -= ReadSize;
-		}
-
-		ReadIsDone = true;
-		close(FPtr);
-		return startoffile;
-	} else {
-		ReadIsError = false;
-		ReadIsDone  = true;
-
-		return NULL;
-	}
-#endif
+	return startoffile;
 }
 
 


Commit: 0dbcb7160c78ed8697afbdd87182f1a52b497824
    https://github.com/scummvm/scummvm/commit/0dbcb7160c78ed8697afbdd87182f1a52b497824
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Added input

Changed paths:
    engines/lab/engine.cpp
    engines/lab/interface.cpp
    engines/lab/machine.cpp
    engines/lab/mouse.h
    engines/lab/vga.cpp
    engines/lab/vga.h



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 3edf896..184b7e0 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -860,8 +860,7 @@ static void process(void) {
 				if (result != 0) {
 					int x = 0, y = 0;
 
-					warning("STUB: getMousePos()");
-					//SDL_GetMousePos(&x, &y);
+					WSDL_GetMousePos(&x, &y);
 
 					Class     = GADGETUP;
 					Qualifier = 0;
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 91111ae..acf7c8b 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -169,8 +169,8 @@ static struct Gadget *checkNumGadgetHit(struct Gadget *gadlist, uint16 key) {
 /* Checks whether or not a key has been pressed.                             */
 /*****************************************************************************/
 static bool keyPress(uint16 *KeyCode) {
-	if (_keyPressed.keycode) {
-		*KeyCode = _keyPressed.keycode;
+	if (WSDL_HasNextChar()) {
+        *KeyCode = WSDL_GetNextChar();
 		return true;
 	}
 
diff --git a/engines/lab/machine.cpp b/engines/lab/machine.cpp
index ab46ce6..da8744a 100644
--- a/engines/lab/machine.cpp
+++ b/engines/lab/machine.cpp
@@ -248,7 +248,7 @@ uint16 swapUShort(uint16 value) {
 	b[1] = t;
 	return value;
 }
-uint16 *swapUShortPtr(uint16 *ptr, int count) {
+uint16 *wapUShortPtsr(uint16 *ptr, int count) {
 	while (count-- > 0) {
 		char *b = (char *)ptr++;
 		char t = b[0];
diff --git a/engines/lab/mouse.h b/engines/lab/mouse.h
index e8bc7bf..108afc2 100644
--- a/engines/lab/mouse.h
+++ b/engines/lab/mouse.h
@@ -57,6 +57,8 @@ Gadget *mouseGadget(void);
 
 void attachGadgetList(struct Gadget *GadList);
 
+void mouse_handler(int32 max, int32 mcx, int32 mdx);
+
 } // End of namespace Lab
 
 #endif /* LAB_MOUSE_H */
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 8badc70..c8960a4 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -31,9 +31,12 @@
 #include "lab/vga.h"
 #include "lab/stddefines.h"
 #include "lab/storage.h"
+#include "lab/mouse.h"
 
 #include "graphics/palette.h"
 
+#include "common/events.h"
+
 namespace Lab {
 
 //static uint16 NotInRefresh = 0;
@@ -52,6 +55,13 @@ int g_ScreenWasLocked = 0;
 int g_IgnoreUpdateDisplay = 0;
 int g_LastWaitTOFTicks = 0;
 
+int g_MouseX = 0;
+int g_MouseY = 0;
+
+uint16 g_NextKeyIn = 0;
+uint16 g_KeyBuf[64];
+uint16 g_NextKeyOut = 0;
+bool g_MouseAtEdge = false;
 
 /*****************************************************************************/
 /* Sets the display mode.                                                    */
@@ -97,9 +107,123 @@ void VGARestorePage(void) {
 	// does nothing in SDL
 }
 
-void WSDL_ProcessInput(int state) {
+void changeVolume(int delta) {
+	warning("STUB: changeVolume()");
+}
+
+uint16 WSDL_GetNextChar() {
+	uint16 c = 0;
+
+	WSDL_ProcessInput(0);
+	if (g_NextKeyIn != g_NextKeyOut) {
+		c = g_KeyBuf[g_NextKeyOut];
+		g_NextKeyOut = ((((unsigned int)((g_NextKeyOut + 1) >> 31) >> 26) + (byte)g_NextKeyOut + 1) & 0x3F)
+                 - ((unsigned int)((g_NextKeyOut + 1) >> 31) >> 26);
+  	}
+
+	return c;
+}
+
+bool WSDL_HasNextChar() {
+	WSDL_ProcessInput(0);
+	return g_NextKeyIn != g_NextKeyOut;
+}
+
+void WSDL_ProcessInput(bool can_delay) {
+	int n;
+	int lastMouseAtEdge;
+	int flags = 0;
+
+	Common::Event event;
+
+	if (1 /*!g_IgnoreProcessInput*/) {
+		while (g_system->getEventManager()->pollEvent(event)) {
+			switch (event.type) {
+			case Common::EVENT_RBUTTONDOWN:
+				flags |= 8;
+				mouse_handler(flags, g_MouseX, g_MouseY);
+				break;
+
+			case Common::EVENT_LBUTTONDOWN:
+				flags |= 2;
+				mouse_handler(flags, g_MouseX, g_MouseY);
+				break;
+
+			case Common::EVENT_MOUSEMOVE:
+				lastMouseAtEdge = g_MouseAtEdge;
+				g_MouseAtEdge = false;
+				g_MouseX = event.mouse.x;
+				if (event.mouse.x <= 0) {
+					g_MouseX = 0;
+					g_MouseAtEdge = true;
+				}
+				if (g_MouseX > 639) {
+					g_MouseX = 640;
+					g_MouseAtEdge = true;
+				}
+
+				g_MouseY = event.mouse.y;
+				if (event.mouse.y <= 0) {
+					g_MouseY = 0;
+					g_MouseAtEdge = true;
+				}
+				if (g_MouseY > 479) {
+					g_MouseY = 480;
+					g_MouseAtEdge = true;
+				}
+
+				if (!lastMouseAtEdge || !g_MouseAtEdge)
+					mouse_handler(1, g_MouseX, g_MouseY);
+
+				break;
+
+			case Common::EVENT_KEYDOWN:
+				switch (event.kbd.keycode) {
+				case Common::KEYCODE_LEFTBRACKET:
+					changeVolume(-1);
+					break;
+
+				case Common::KEYCODE_RIGHTBRACKET:
+					changeVolume(1);
+					break;
+
+				case Common::KEYCODE_z:
+					//saveSettings();
+					break;
+
+				default:
+					n = ((((unsigned int)((g_NextKeyIn + 1) >> 31) >> 26) + (byte)g_NextKeyIn + 1) & 0x3F)
+					- ((unsigned int)((g_NextKeyIn + 1) >> 31) >> 26);
+					if (n != g_NextKeyOut) {
+						g_KeyBuf[g_NextKeyIn] = event.kbd.keycode;
+						g_NextKeyIn = n;
+					}
+				}
+				break;
+
+			case Common::EVENT_QUIT:
+			case Common::EVENT_RTL:
+			default:
+				break;
+			}
+
+			g_system->copyRectToScreen(g_DisplayBuffer, VGAScreenWidth, 0, 0, VGAScreenWidth, VGAScreenHeight);
+			g_system->updateScreen();
+		}
+	}
+
+	if (can_delay)
+		g_system->delayMillis(10);
+}
+
+void WSDL_GetMousePos(int *x, int *y) {
+	WSDL_ProcessInput(0);
+
+	*x = g_MouseX;
+	*y = g_MouseY;
 }
 
+
 void waitTOF() {
 	int untilOutOfRefresh = 1;
 
diff --git a/engines/lab/vga.h b/engines/lab/vga.h
index fc5f981..a0b2f63 100644
--- a/engines/lab/vga.h
+++ b/engines/lab/vga.h
@@ -99,6 +99,14 @@ void WSDL_UpdateScreen();
 
 void WSDL_IgnoreUpdateDisplay(int state);
 
+void WSDL_GetMousePos(int *x, int *y);
+
+uint16 WSDL_GetNextChar();
+
+bool WSDL_HasNextChar();
+
+void WSDL_ProcessInput(bool can_delay);
+
 } // End of namespace Lab
 
 #endif /* LAB_VGA_H */


Commit: 78b46fb026d0a504212d6600a12fabc2ad3231cb
    https://github.com/scummvm/scummvm/commit/78b46fb026d0a504212d6600a12fabc2ad3231cb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: fix input processing

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 184b7e0..91132e6 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -719,11 +719,6 @@ int didintro = false; // change to int do labw.c can access
 #endif
 static bool novesa = false, noaudio = false;
 
-
-void processEvents() {
-	warning("STUB: processEvents()");
-}
-
 /******************************************************************************/
 /* Processes user input events.                                               */
 /******************************************************************************/
@@ -771,7 +766,7 @@ static void process(void) {
 	/* Set up initial picture. */
 
 	while (1) {
-		processEvents();
+		WSDL_ProcessInput(1);
 
 		if (GotMessage) {
 			if (QuitLab) {


Commit: bff3cc390f56defe9b2e7debc046e0a1673fe413
    https://github.com/scummvm/scummvm/commit/bff3cc390f56defe9b2e7debc046e0a1673fe413
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Fix game palette

Changed paths:
    engines/lab/vga.cpp



diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index c8960a4..9fb9f99 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -244,8 +244,13 @@ void waitTOF() {
 }
 
 void WSDL_SetColors(byte *buf, uint16 first, uint16 numreg, uint16 slow) {
+	byte tmp[256 * 3];
 
-	g_system->getPaletteManager()->setPalette(buf, first, numreg);
+	for (int i = 0; i < 256 * 3; i++) {
+		tmp[i] = buf[i] * 4;
+	}
+
+	g_system->getPaletteManager()->setPalette(tmp, first, numreg);
 
 	if (slow)
     	waitTOF();


Commit: 62ceb496a926d4b906f3c276797bb3ab4c47829c
    https://github.com/scummvm/scummvm/commit/62ceb496a926d4b906f3c276797bb3ab4c47829c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Cleanup

Changed paths:
    engines/lab/labmusic.cpp
    engines/lab/storage.cpp
    engines/lab/storage.h



diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index d7edc2b..9fcee09 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -270,21 +270,17 @@ bool Music::initMusic(void) {
 	else
 		filename = "Music:BackGrou";
 
-	mem = true;
-
 	if (_musicBuffer[0] == NULL) {
 		for (counter = 0; counter < _manyBuffers; counter++)
-			mem = mem && allocatedos((void **) & (_musicBuffer[counter]), MUSICBUFSIZE);
+			_musicBuffer[counter] = malloc(MUSICBUFSIZE);
 	}
 
-	if (mem) {
-		_filelength = sizeOfFile(filename);
-		_file = openPartial(filename);
+	_filelength = sizeOfFile(filename);
+	_file = openPartial(filename);
 
-		if (_file) {
-			startMusic(true);
-			return true;
-		}
+	if (_file) {
+		startMusic(true);
+		return true;
 	}
 
 	_musicOn = false;
diff --git a/engines/lab/storage.cpp b/engines/lab/storage.cpp
index 0d21b93..a94d21c 100644
--- a/engines/lab/storage.cpp
+++ b/engines/lab/storage.cpp
@@ -45,39 +45,6 @@ bool allocate(void **Ptr, uint32 Size) {
 }
 
 
-
-
-/*****************************************************************************/
-/* Allocates a piece of chip memory.                                         */
-/*****************************************************************************/
-bool allocatechip(void **Ptr, uint32 Size) {
-	return allocate(Ptr, Size);
-}
-
-/*****************************************************************************/
-/* Allocates a chunk of dos memory.                                          */
-/*****************************************************************************/
-bool allocatedos(void **Ptr, uint32 Size) {
-#if defined(DOSCODE)
-	static union REGS regs;
-
-	regs.x.eax = 0x100;
-	regs.x.ebx = (Size >> 4);
-	int386(0x31, &regs, &regs);
-
-	if (regs.x.cflag) {
-		*Ptr = NULL;
-		return false;
-	}
-
-	*Ptr = (char *)((regs.x.eax & 0xFFFF) << 4);
-	return (*Ptr != NULL);
-#else
-	*Ptr = malloc(Size);
-	return (*Ptr != NULL);
-#endif
-}
-
 /*****************************************************************************/
 /* Deallocates a piece of memory.                                            */
 /*****************************************************************************/
diff --git a/engines/lab/storage.h b/engines/lab/storage.h
index bb14bef..c93c58c 100644
--- a/engines/lab/storage.h
+++ b/engines/lab/storage.h
@@ -37,10 +37,6 @@ namespace Lab {
 
 bool allocate(void **Ptr, uint32 Size);
 
-bool allocatechip(void **Ptr, uint32 Size);
-
-bool allocatedos(void **Ptr, uint32 Size);
-
 void deallocate(void *Ptr, uint32 Size);
 
 } // End of namespace Lab


Commit: 3a8cafa41ec8a91fa7e5cc34d0307af52f141fcb
    https://github.com/scummvm/scummvm/commit/3a8cafa41ec8a91fa7e5cc34d0307af52f141fcb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Kill storage.h

Changed paths:
  R engines/lab/storage.cpp
  R engines/lab/storage.h
    engines/lab/allocroom.cpp
    engines/lab/engine.cpp
    engines/lab/interface.cpp
    engines/lab/labfile.cpp
    engines/lab/labmusic.cpp
    engines/lab/labsets.cpp
    engines/lab/labtext.cpp
    engines/lab/map.cpp
    engines/lab/module.mk
    engines/lab/readparse.cpp
    engines/lab/text.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/allocroom.cpp b/engines/lab/allocroom.cpp
index 208d7ce..8ca69ef 100644
--- a/engines/lab/allocroom.cpp
+++ b/engines/lab/allocroom.cpp
@@ -28,9 +28,8 @@
  *
  */
 
-#include "lab/storage.h"
-#include "lab/parsetypes.h"
 #include "lab/stddefines.h"
+#include "lab/parsetypes.h"
 
 namespace Lab {
 
@@ -65,7 +64,7 @@ bool initRoomBuffer(void) {
 
 	CurMarker = 0;
 
-	if (allocate((void **)&RoomBuffer, ROOMBUFFERSIZE)) {
+	if ((RoomBuffer = calloc(ROOMBUFFERSIZE, 1))) {
 		MemPlace = RoomBuffer;
 		MemLeftInBuffer = ROOMBUFFERSIZE;
 
@@ -85,7 +84,7 @@ bool initRoomBuffer(void) {
 /*****************************************************************************/
 void freeRoomBuffer(void) {
 	if (RoomBuffer)
-		deallocate(RoomBuffer, ROOMBUFFERSIZE);
+		free(RoomBuffer);
 }
 
 
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 91132e6..83bf396 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -34,7 +34,6 @@
 #include "lab/vga.h"
 #include "lab/timing.h"
 #include "lab/text.h"
-#include "lab/storage.h"
 #include "lab/parsefun.h"
 #include "lab/interface.h"
 #include "lab/mouse.h"
@@ -264,7 +263,7 @@ bool setUpScreens(void) {
 	if (MovePanelBufferSize == 0L)
 		return false;
 
-	if (!allocate((void **) &MovePanelBuffer, MovePanelBufferSize))
+	if (!(MovePanelBuffer = (byte *)calloc(MovePanelBufferSize, 1)))
 		return false;
 
 	Common::File *file = openPartial("P:Control");
@@ -329,7 +328,7 @@ bool setUpScreens(void) {
 	if (InvPanelBufferSize == 0L)
 		return false;
 
-	if (!allocate((void **) &InvPanelBuffer, InvPanelBufferSize))
+	if (!(InvPanelBuffer = (byte *)calloc(InvPanelBufferSize, 1)))
 		return false;
 
 	file = openPartial("P:Inv");
@@ -1010,8 +1009,8 @@ from_crumbs:
 
 						IsHiRes = !IsHiRes;
 
-						deallocate(MovePanelBuffer, MovePanelBufferSize);
-						deallocate(InvPanelBuffer, InvPanelBufferSize);
+						free(MovePanelBuffer);
+						free(InvPanelBuffer);
 						freeButtonList(MoveGadgetList);
 						freeButtonList(InvGadgetList);
 						MoveGadgetList = NULL;
@@ -1534,18 +1533,18 @@ from_crumbs:
 		deleteSet(RoomsFound);
 
 	if (Rooms)
-		deallocate(Rooms, (ManyRooms + 1) * sizeof(RoomData));
+		free(Rooms);
 
 	if (Inventory) {
 		for (Code = 1; Code <= NumInv; Code++) {
 			if (Inventory[Code].name)
-				deallocate(Inventory[Code].name, strlen(Inventory[Code].name) + 1);
+				free(Inventory[Code].name);
 
 			if (Inventory[Code].BInvName)
-				deallocate(Inventory[Code].BInvName, strlen(Inventory[Code].BInvName) + 1);
+				free(Inventory[Code].BInvName);
 		}
 
-		deallocate(Inventory, (NumInv + 1) * sizeof(InventoryData));
+		free(Inventory);
 	}
 }
 
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index acf7c8b..859277c 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -30,7 +30,6 @@
 
 #include "lab/stddefines.h"
 #include "lab/interface.h"
-#include "lab/storage.h"
 #include "lab/timing.h"
 #include "lab/mouse.h"
 #include "lab/vga.h"
@@ -45,7 +44,7 @@ Common::KeyState _keyPressed;
 struct Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt) {
 	Gadget *gptr;
 
-	if (allocate((void **)&gptr, sizeof(struct Gadget))) {
+	if ((gptr = (Gadget *)calloc(sizeof(struct Gadget), 1))) {
 		gptr->x = x;
 		gptr->y = y;
 		gptr->GadgetID = id;
@@ -71,7 +70,7 @@ void freeButtonList(Gadget *gptrlist) {
 		gptr = next;
 		next = next->NextGadget;
 
-		deallocate(gptr, sizeof(struct Gadget));
+		free(gptr);
 	}
 }
 
diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
index adef2f0..e4045b5 100644
--- a/engines/lab/labfile.cpp
+++ b/engines/lab/labfile.cpp
@@ -30,7 +30,6 @@
 
 #include "lab/labfun.h"
 #include "lab/mouse.h"
-#include "lab/storage.h"
 #include "common/file.h"
 
 namespace Lab {
@@ -306,8 +305,7 @@ void resetBuffer(void) {
 /* Initializes the buffer.                                                   */
 /*****************************************************************************/
 bool initBuffer(uint32 BufSize, bool IsGraphicsMem) {
-	if (!allocate((void **) &buffer, BufSize))
-		buffer = NULL;
+	buffer = (byte *)calloc(BufSize, 1);
 
 	buffersize = BufSize;
 	realbuffersize = buffersize;
@@ -328,7 +326,7 @@ void freeBuffer(void) {
 	freeAllStolenMem();
 
 	if (buffer)
-		deallocate(buffer, buffersize);
+		free(buffer);
 }
 
 
diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index 9fcee09..ac7ba70 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -29,7 +29,6 @@
  */
 
 #include "lab/stddefines.h"
-#include "lab/storage.h"
 #include "lab/labfun.h"
 #include "lab/timing.h"
 #include "lab/mouse.h"
diff --git a/engines/lab/labsets.cpp b/engines/lab/labsets.cpp
index 5faf1cc..c6f3d33 100644
--- a/engines/lab/labsets.cpp
+++ b/engines/lab/labsets.cpp
@@ -30,7 +30,6 @@
 
 #include "lab/stddefines.h"
 #include "lab/labfun.h"
-#include "lab/storage.h"
 
 namespace Lab {
 
@@ -44,7 +43,7 @@ const uint32 LargeSetSIZE = sizeof(LargeSetRecord) - 2;
 bool createSet(LargeSet *set, uint16 last) {
 	last = (((last + 15) >> 4) << 4);
 
-	if (allocate((void **) set, (last >> 3) + LargeSetSIZE)) {
+	if ((*set = (LargeSet)calloc((last >> 3) + LargeSetSIZE, 1))) {
 		(*set)->lastElement  = last;
 		return true;
 	} else /* Not Enough Memory! */
@@ -59,8 +58,8 @@ bool createSet(LargeSet *set, uint16 last) {
 /* Deletes a large set.                                                      */
 /*****************************************************************************/
 void deleteSet(LargeSet set) {
-	if (set != NULL)
-		deallocate(set, (set->lastElement >> 3) + LargeSetSIZE);
+	if (set)
+		free(set);
 }
 
 
diff --git a/engines/lab/labtext.cpp b/engines/lab/labtext.cpp
index d90929f..7acb014 100644
--- a/engines/lab/labtext.cpp
+++ b/engines/lab/labtext.cpp
@@ -29,7 +29,6 @@
  */
 
 #include "lab/stddefines.h"
-#include "lab/storage.h"
 #include "lab/labfun.h"
 
 namespace Lab {
@@ -67,7 +66,7 @@ static void setString(char **string) {
 /*****************************************************************************/
 bool initLabText(void) {
 	if ((SizeOfMemChunk = sizeOfFile(LABTEXTFILE)))
-		if (allocate((void **) &BeginOfMemChunk, SizeOfMemChunk)) {
+		if ((BeginOfMemChunk = (char *)calloc(SizeOfMemChunk, 1))) {
 			Common::File *file = openPartial(LABTEXTFILE);
 
 			if (file) {
@@ -146,7 +145,7 @@ bool initLabText(void) {
 /*****************************************************************************/
 void freeLabText(void) {
 	if (SizeOfMemChunk && BeginOfMemChunk)
-		deallocate(BeginOfMemChunk, SizeOfMemChunk);
+		free(BeginOfMemChunk);
 }
 
 
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index d32154e..c56f699 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -28,7 +28,7 @@
  *
  */
 
-#include "lab/storage.h"
+#include "lab/stddefines.h"
 #include "lab/labfun.h"
 #include "lab/diff.h"
 #include "lab/vga.h"
@@ -38,7 +38,6 @@
 #include "lab/parsetypes.h"
 #include "lab/interface.h"
 #include "lab/text.h"
-#include "lab/stddefines.h"
 
 namespace Lab {
 
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index 5edaa78..09156a7 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -23,7 +23,6 @@ MODULE_OBJS := \
 	savegame.o \
 	savegamepalmap.o \
 	special.o \
-	storage.o \
 	text.o \
 	timing.o \
 	undiff.o \
diff --git a/engines/lab/readparse.cpp b/engines/lab/readparse.cpp
index e970942..7734a23 100644
--- a/engines/lab/readparse.cpp
+++ b/engines/lab/readparse.cpp
@@ -31,7 +31,6 @@
 #include "lab/labfun.h"
 #include "lab/parsetypes.h"
 #include "lab/parsefun.h"
-#include "lab/storage.h"
 #include "lab/stddefines.h"
 
 namespace Lab {
@@ -56,7 +55,7 @@ static uint16 allocroom;
 
 static bool rallocate(void **Ptr, uint32 Size) {
 	if (UseMemory)
-		return allocate(Ptr, Size);
+		return ((*Ptr = calloc(Size, 1)) != 0);
 	else {
 		allocRoom(Ptr, (uint16) Size, allocroom);
 		return true;
@@ -89,7 +88,7 @@ bool readRoomData(const char *fileName) {
 		swapUShortPtr(&HighestCondition, 1);
 #endif
 
-		if (allocate((void **) &Rooms, (ManyRooms + 1) * sizeof(RoomData))) {
+		if ((Rooms = (RoomData *)calloc(ManyRooms + 1, sizeof(RoomData)))) {
 			for (Counter = 1; Counter <= ManyRooms; Counter++) {
 				readBlock(&(Rooms[Counter].NorthDoor), 2L, file);
 				readBlock(&(Rooms[Counter].SouthDoor), 2L, file);
diff --git a/engines/lab/storage.cpp b/engines/lab/storage.cpp
deleted file mode 100644
index a94d21c..0000000
--- a/engines/lab/storage.cpp
+++ /dev/null
@@ -1,56 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "lab/stddefines.h"
-
-namespace Lab {
-
-/*****************************************************************************/
-/* Allocates a chunk of memory.                                              */
-/*****************************************************************************/
-bool allocate(void **Ptr, uint32 Size) {
-	(*Ptr) = malloc(Size);
-
-	if (*Ptr)
-		memset(*Ptr, 0, (size_t) Size);
-
-	return (*Ptr != NULL);
-}
-
-
-/*****************************************************************************/
-/* Deallocates a piece of memory.                                            */
-/*****************************************************************************/
-void deallocate(void *Ptr, uint32 Size) {
-	if (Ptr)
-		free(Ptr);
-}
-
-} // End of namespace Lab
diff --git a/engines/lab/storage.h b/engines/lab/storage.h
deleted file mode 100644
index c93c58c..0000000
--- a/engines/lab/storage.h
+++ /dev/null
@@ -1,44 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "lab/stddefines.h"
-
-#ifndef LAB_STORAGE_H
-#define LAB_STORAGE_H
-
-namespace Lab {
-
-bool allocate(void **Ptr, uint32 Size);
-
-void deallocate(void *Ptr, uint32 Size);
-
-} // End of namespace Lab
-
-#endif /* LAB_STORAGE_H */
diff --git a/engines/lab/text.cpp b/engines/lab/text.cpp
index 4376dba..5795a08 100644
--- a/engines/lab/text.cpp
+++ b/engines/lab/text.cpp
@@ -30,7 +30,6 @@
 
 #include "lab/stddefines.h"
 #include "lab/labfun.h"
-#include "lab/storage.h"
 #include "lab/text.h"
 #include "lab/vga.h"
 
@@ -81,7 +80,7 @@ bool openFont(const char *TextFontPath, struct TextFont **tf) {
 	char header[5];
 	int32 filesize, headersize = 4L + 2L + 256 * 3 + 4L;
 
-	if (allocate((void **)tf, sizeof(struct TextFont))) {
+	if ((*tf = (TextFont *)calloc(sizeof(struct TextFont), 1))) {
 		filesize = sizeOfFile(TextFontPath);
 		file = g_music->newOpen(TextFontPath);
 
@@ -102,14 +101,14 @@ bool openFont(const char *TextFontPath, struct TextFont **tf) {
 #endif
 				skip(file, 4L);
 
-				if (allocate((void **) & ((*tf)->data), (*tf)->DataLength)) {
+				if (((*tf)->data = (byte *)calloc((*tf)->DataLength, 1))) {
 					readBlock((*tf)->data, (*tf)->DataLength, file);
 					return true;
 				}
 			}
 		}
 
-		deallocate(*tf, sizeof(struct TextFont));
+		free(*tf);
 	}
 
 	*tf = NULL;
@@ -123,9 +122,9 @@ bool openFont(const char *TextFontPath, struct TextFont **tf) {
 void closeFont(struct TextFont *tf) {
 	if (tf) {
 		if (tf->data && tf->DataLength)
-			deallocate(tf->data, tf->DataLength);
+			free(tf->data);
 
-		deallocate(tf, sizeof(struct TextFont));
+		free(tf);
 	}
 }
 
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 9fb9f99..2e5bd9b 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -30,7 +30,6 @@
 
 #include "lab/vga.h"
 #include "lab/stddefines.h"
-#include "lab/storage.h"
 #include "lab/mouse.h"
 
 #include "graphics/palette.h"


Commit: abded17657503419a12a4831094bc8d9d8005c95
    https://github.com/scummvm/scummvm/commit/abded17657503419a12a4831094bc8d9d8005c95
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Simplify stddefines.h

Changed paths:
    engines/lab/audioi.cpp
    engines/lab/labsets.cpp
    engines/lab/special.cpp
    engines/lab/stddefines.h



diff --git a/engines/lab/audioi.cpp b/engines/lab/audioi.cpp
index 44ba56e..37aecd5 100644
--- a/engines/lab/audioi.cpp
+++ b/engines/lab/audioi.cpp
@@ -328,7 +328,7 @@ void updateSoundBuffers(void) {
 
 	for (int i = 0; i < 2; i++) {
 		if ((AIL_sound_buffer_status(hdriver, i) == DAC_DONE) && firstblock.len) {
-			tempblock.len = min(16384L, firstblock.len);
+			tempblock.len = MIN(16384L, firstblock.len);
 			firstblock.len -= tempblock.len;
 
 			if (!(bufnum ^= 1)) {
@@ -373,7 +373,7 @@ void updateSoundBuffers(void) {
 	for (int i = 0; i < 2; i++) {
 		if ((SDLSoundBufferStatus(i) == DAC_DONE) && firstblock.len) {
 			// use extra memory for 16-bit samples
-			tempblock.len = min(PLAYBUFSIZE, firstblock.len);
+			tempblock.len = MIN(PLAYBUFSIZE, firstblock.len);
 			firstblock.len -= tempblock.len;
 
 			if (!(bufnum ^= 1)) {
diff --git a/engines/lab/labsets.cpp b/engines/lab/labsets.cpp
index c6f3d33..86fd6fd 100644
--- a/engines/lab/labsets.cpp
+++ b/engines/lab/labsets.cpp
@@ -63,6 +63,10 @@ void deleteSet(LargeSet set) {
 }
 
 
+#define INCL(BITSET,BIT) ((BITSET) |= (BIT))
+
+#define EXCL(BITSET,BIT) ((BITSET) &= (~(BIT)))
+
 
 
 /*****************************************************************************/
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 4e842a1..50589ed 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -66,6 +66,12 @@ extern uint32 VGAScreenWidth, VGAScreenHeight;
 static uint16 hipal[20];
 extern uint16 *FadePalette;
 
+#define INCL(BITSET,BIT) ((BITSET) |= (BIT))
+
+#define SETBIT(BITSET,BITNUM)   INCL(BITSET, (1 << (BITNUM)))
+
+#define INBIT(BITSET,BITNUM)    ( ((1 << (BITNUM)) & (BITSET)) > 0 )
+
 
 static byte *loadBackPict(const char *fileName, bool tomem) {
 	uint16 counter;
diff --git a/engines/lab/stddefines.h b/engines/lab/stddefines.h
index cd3156f..a9d685b 100644
--- a/engines/lab/stddefines.h
+++ b/engines/lab/stddefines.h
@@ -40,28 +40,6 @@ namespace Lab {
 #define IS_MACOSX 1
 #define USE_NOSWAP 1
 
-
-#define INCL(BITSET,BIT) ((BITSET) |= (BIT))
-
-#define EXCL(BITSET,BIT) ((BITSET) &= (~(BIT)))
-
-
-
-#define SETBIT(BITSET,BITNUM)   INCL(BITSET, (1 << (BITNUM)))
-
-#define UNSETBIT(BITSET,BITNUM) EXCL(BITSET, (1 << (BITNUM)))
-
-#define INBIT(BITSET,BITNUM)    ( ((1 << (BITNUM)) & (BITSET)) > 0 )
-
-#if !defined(WIN32)
-#ifndef min
-#define min(a,b) ((a)<(b) ? (a) : (b))
-#endif
-#ifndef max
-#define max(a,b) ((a)>(b) ? (a) : (b))
-#endif
-#endif
-
 #if defined(IS_MACOSX)
 #define getTime Lab_GetTime
 #define delay Lab_Delay


Commit: 6ab5edf7629ae2166b0fdc9773005d240ade5d3e
    https://github.com/scummvm/scummvm/commit/6ab5edf7629ae2166b0fdc9773005d240ade5d3e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Further cleanup

Changed paths:
    engines/lab/labfile.cpp
    engines/lab/labfun.h



diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
index e4045b5..7c7875a 100644
--- a/engines/lab/labfile.cpp
+++ b/engines/lab/labfile.cpp
@@ -401,82 +401,4 @@ void freeAllStolenMem(void) {
 	MemPlace = buffer;
 }
 
-
-
-
-/*--------------- Routines that read partial chunks of a file ---------------*/
-
-
-
-/*****************************************************************************/
-/* Reads Size amount of bytes into buffer.                                   */
-/*****************************************************************************/
-uint32 readPartial(int32 File, void *buf, uint32 Size) {
-	uint32 haveread = 0;
-
-	warning("STUB: readPartial");
-
-#if 0
-	uint32 nsize;
-
-	while (Size) {
-		if (Size > MAXREADSIZE)
-			nsize = MAXREADSIZE;
-		else
-			nsize = Size;
-
-		haveread += (uint32)(read((int) File, buf, (int) nsize));
-		Size -= nsize;
-		((char *) buf) += nsize;
-		updateMouse();
-	}
-#endif
-	return haveread;
-}
-
-
-
-/*****************************************************************************/
-/* Reads Size amount of bytes into buffer.  Use this one if the data must    */
-/* absolutely be correct (compressed data for example).  Otherwise, because  */
-/* of the DMA bug, last two bytes may be screwed.                            */
-/*****************************************************************************/
-uint32 newReadPartial(int32 File, void *buf, uint32 Size) {
-	return readPartial((int) File, buf, Size);
-}
-
-
-
-/*****************************************************************************/
-/* Reads Size amount of bytes into buffer.  Use this one if the data must    */
-/* absolutely be correct (compressed data for example).  Otherwise, because  */
-/* of the DMA bug, last two bytes may be screwed.  This one will work if the */
-/* data is not padded the extra two bytes.                                   */
-/*****************************************************************************/
-uint32 bufferedReadPartial(int32 File, void *buf, uint32 Size) {
-	return readPartial(File, buf, Size);
-}
-
-
-
-/*****************************************************************************/
-/* Sets the current position in the file relative to the beginning of the    */
-/* file.                                                                     */
-/*****************************************************************************/
-void setPos(int32 File, uint32 Place) {
-	warning("STUB: setPos");
-	//lseek((int) File, (int32) Place, SEEK_SET);
-}
-
-
-
-/*****************************************************************************/
-/* Skips a certain number of bytes either forward or backwards.              */
-/*****************************************************************************/
-void skipPartial(int32 File, int32 Skip) {
-	warning("STUB: skipPartial");
-
-	//lseek((int) File, Skip, SEEK_CUR);
-}
-
 } // End of namespace Lab
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 08130f3..995177b 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -203,18 +203,6 @@ Common::File *openPartial(const char *name);
 
 void closePartial(int32 File);
 
-uint32 readPartial(int32 File, void *buffer, uint32 Size);
-
-uint32 newReadPartial(int32 File, void *buffer, uint32 Size);
-
-uint32 bufferedReadPartial(int32 File, void *buffer, uint32 Size);
-
-
-void setPos(int32 File, uint32 Place);
-
-void skipPartial(int32 File, int32 Skip);
-
-
 
 /*---------------------------*/
 /*------ From LabText.c -----*/


Commit: 471dbaa758f0ebea9f3d76caa7fd769c6809d395
    https://github.com/scummvm/scummvm/commit/471dbaa758f0ebea9f3d76caa7fd769c6809d395
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Started objectifying LargeSets

Changed paths:
    engines/lab/engine.cpp
    engines/lab/lab.h
    engines/lab/labfun.h
    engines/lab/labsets.cpp
    engines/lab/labtext.cpp
    engines/lab/machine.cpp
    engines/lab/map.cpp
    engines/lab/modernsavegame.cpp
    engines/lab/parsefun.h
    engines/lab/processroom.cpp
    engines/lab/readparse.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 83bf396..dec1806 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -53,7 +53,6 @@ extern bool DoBlack, waiteffect, EffectPlaying, stopsound, DoNotDrawMessage, IsH
 extern RoomData *Rooms;
 extern InventoryData *Inventory;
 extern uint16 NumInv, RoomNum, ManyRooms, HighestCondition, Direction;
-extern LargeSet Conditions, RoomsFound;
 CloseDataPtr CPtr;
 
 #if !defined(DOSCODE)
@@ -223,8 +222,8 @@ static void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr) {
 	}
 
 	if (Alternate) {
-		if ((CurInv <= NumInv) && In(Conditions, CurInv) && Inventory[CurInv].BInvName) {
-			if ((CurInv == LAMPNUM) && In(Conditions, LAMPON))  /* LAB: Labyrith specific */
+		if ((CurInv <= NumInv) && g_engine->_conditions->in(CurInv) && Inventory[CurInv].BInvName) {
+			if ((CurInv == LAMPNUM) && g_engine->_conditions->in(LAMPON))  /* LAB: Labyrith specific */
 				drawMessage(LAMPONMSG);
 			else if (Inventory[CurInv].Many > 1) {
 				ManyPtr = numtostr(ManyText, Inventory[CurInv].Many);
@@ -518,10 +517,10 @@ static const char *getInvName(uint16 CurInv) {
 	if (MainDisplay)
 		return Inventory[CurInv].BInvName;
 
-	if ((CurInv == LAMPNUM) && In(Conditions, LAMPON))
+	if ((CurInv == LAMPNUM) && g_engine->_conditions->in(LAMPON))
 		return "P:Mines/120";
 
-	else if ((CurInv == BELTNUM) && In(Conditions, BELTGLOW))
+	else if ((CurInv == BELTNUM) && g_engine->_conditions->in(BELTGLOW))
 		return "P:Future/BeltGlow";
 
 	else if (CurInv == WESTPAPERNUM) {
@@ -617,12 +616,12 @@ static bool doUse(uint16 CurInv) {
 	else if (CurInv == LAMPNUM) {            /* LAB: Labyrinth specific */
 		interfaceOff();
 
-		if (In(Conditions, LAMPON)) {
+		if (g_engine->_conditions->in(LAMPON)) {
 			drawMessage(TURNLAMPOFF);
-			exclElement(Conditions, LAMPON);
+			g_engine->_conditions->exclElement(LAMPON);
 		} else {
 			drawMessage(TURNLAMPON);
-			inclElement(Conditions, LAMPON);
+			g_engine->_conditions->inclElement(LAMPON);
 		}
 
 		DoBlack = false;
@@ -635,25 +634,25 @@ static bool doUse(uint16 CurInv) {
 	}
 
 	else if (CurInv == BELTNUM) {                    /* LAB: Labyrinth specific */
-		if (!In(Conditions, BELTGLOW))
-			inclElement(Conditions, BELTGLOW);
+		if (!g_engine->_conditions->in(BELTGLOW))
+			g_engine->_conditions->inclElement(BELTGLOW);
 
 		DoBlack = false;
 		Test = getInvName(CurInv);
 	}
 
 	else if (CurInv == WHISKEYNUM) {                 /* LAB: Labyrinth specific */
-		inclElement(Conditions, USEDHELMET);
+		g_engine->_conditions->inclElement(USEDHELMET);
 		drawMessage(USEWHISKEY);
 	}
 
 	else if (CurInv == PITHHELMETNUM) {              /* LAB: Labyrinth specific */
-		inclElement(Conditions, USEDHELMET);
+		g_engine->_conditions->inclElement(USEDHELMET);
 		drawMessage(USEPITH);
 	}
 
 	else if (CurInv == HELMETNUM) {                  /* LAB: Labyrinth specific */
-		inclElement(Conditions, USEDHELMET);
+		g_engine->_conditions->inclElement(USEDHELMET);
 		drawMessage(USEHELMET);
 	}
 
@@ -678,7 +677,7 @@ static void decIncInv(uint16 *CurInv, bool dec) {
 		(*CurInv)++;
 
 	while (*CurInv && (*CurInv <= NumInv)) {
-		if (In(Conditions, *CurInv) && Inventory[*CurInv].BInvName) {
+		if (g_engine->_conditions->in(*CurInv) && Inventory[*CurInv].BInvName) {
 			Test = getInvName(*CurInv);
 			break;
 		}
@@ -696,7 +695,7 @@ static void decIncInv(uint16 *CurInv, bool dec) {
 			*CurInv = 1;
 
 		while (*CurInv && (*CurInv <= NumInv)) {
-			if (In(Conditions, *CurInv) && Inventory[*CurInv].BInvName) {
+			if (g_engine->_conditions->in(*CurInv) && Inventory[*CurInv].BInvName) {
 				Test = getInvName(*CurInv);
 				break;
 			}
@@ -749,13 +748,13 @@ static void process(void) {
 	readRoomData("LAB:Doors");
 	readInventory("LAB:Inventor");
 
-	if (!createSet(&Conditions, HighestCondition + 1))
+	if (!(g_engine->_conditions = new LargeSet(HighestCondition + 1)))
 		return;
 
-	if (!createSet(&RoomsFound, ManyRooms + 1))
+	if (!(g_engine->_roomsFound = new LargeSet(ManyRooms + 1)))
 		return;
 
-	readInitialConditions(Conditions, "LAB:Conditio");
+	g_engine->_conditions->readInitialConditions("LAB:Conditio");
 
 	LongWinInFront = false;
 	drawPanel();
@@ -789,7 +788,7 @@ static void process(void) {
 				Test = getPictName(&CPtr);
 
 			if (noupdatediff) {
-				inclElement(RoomsFound, RoomNum); /* Potentially entered another room */
+				g_engine->_roomsFound->inclElement(RoomNum); /* Potentially entered another room */
 				ForceDraw = (strcmp(Test, CurFileName) != 0) || ForceDraw;
 
 				noupdatediff = false;
@@ -798,7 +797,7 @@ static void process(void) {
 
 			else if (strcmp(Test, CurFileName) != 0) {
 				interfaceOff();
-				inclElement(RoomsFound, RoomNum); /* Potentially entered another room */
+				g_engine->_roomsFound->inclElement(RoomNum); /* Potentially entered another room */
 				CurFileName = Test;
 
 				if (CPtr) {
@@ -1090,7 +1089,7 @@ from_crumbs:
 
 						MainDisplay = false;
 
-						if (LastInv && In(Conditions, LastInv)) {
+						if (LastInv && g_engine->_conditions->in(LastInv)) {
 							CurInv = LastInv;
 							Test = getInvName(CurInv);
 						} else
@@ -1172,7 +1171,7 @@ from_crumbs:
 
 							if (OldRoomNum != RoomNum) {
 								drawMessage(GOFORWARDDIR);
-								inclElement(RoomsFound, RoomNum); /* Potentially entered a new room */
+								g_engine->_roomsFound->inclElement(RoomNum); /* Potentially entered a new room */
 								CurFileName = " ";
 								ForceDraw = true;
 							} else {
@@ -1316,11 +1315,11 @@ from_crumbs:
 					if ((CurInv == 0) || (CurInv > NumInv)) {
 						CurInv = 1;
 
-						while ((CurInv <= NumInv) && (!In(Conditions, CurInv)))
+						while ((CurInv <= NumInv) && (!g_engine->_conditions->in(CurInv)))
 							CurInv++;
 					}
 
-					if ((CurInv <= NumInv) && In(Conditions, CurInv) &&
+					if ((CurInv <= NumInv) && g_engine->_conditions->in(CurInv) &&
 					        Inventory[CurInv].BInvName)
 						Test = getInvName(CurInv);
 
@@ -1454,11 +1453,11 @@ from_crumbs:
 					}
 
 					else if ((ActionMode == 5)  &&
-					         In(Conditions, CurInv)) { /* Use an item on something else */
+					         g_engine->_conditions->in(CurInv)) { /* Use an item on something else */
 						if (doOperateRule(MouseX, MouseY, CurInv, &CPtr)) {
 							CurFileName = NewFileName;
 
-							if (!In(Conditions, CurInv))
+							if (!g_engine->_conditions->in(CurInv))
 								decIncInv(&CurInv, false);
 						} else if (MouseY < (VGAScaleY(149) + SVGACord(2)))
 							drawMessage(NOTHING);
@@ -1510,7 +1509,7 @@ from_crumbs:
 				interfaceOn(); /* Sets the correct gadget list */
 
 				if (Alternate) {
-					if (LastInv && In(Conditions, LastInv))
+					if (LastInv && g_engine->_conditions->in(LastInv))
 						CurInv = LastInv;
 					else
 						decIncInv(&CurInv, false);
@@ -1526,11 +1525,8 @@ from_crumbs:
 		}
 	}
 
-	if (Conditions)
-		deleteSet(Conditions);
-
-	if (RoomsFound)
-		deleteSet(RoomsFound);
+	delete g_engine->_conditions;
+	delete g_engine->_roomsFound;
 
 	if (Rooms)
 		free(Rooms);
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 3b1e411..4242955 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -34,6 +34,7 @@
 #include "common/array.h"
 
 #include "engines/engine.h"
+#include "lab/labfun.h"
 
 namespace Lab {
 
@@ -45,6 +46,8 @@ public:
 	virtual Common::Error run();
 
 	bool hasFeature(EngineFeature f) const;
+
+	LargeSet *_conditions, *_roomsFound;
 };
 
 } // End of namespace Lab
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 995177b..93d5166 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -275,26 +275,23 @@ extern Music *g_music;
 /*----- From LabSets.c ------*/
 /*---------------------------*/
 
-typedef struct {
-	uint16 lastElement, array[1];
-} LargeSetRecord;
-
-typedef LargeSetRecord *LargeSet;
-
-
-
-bool createSet(LargeSet *set, uint16 last);
-
-void deleteSet(LargeSet set);
+class LargeSet {
+public:
+    LargeSet(uint16 last);
 
-bool In(LargeSet set, uint16 element);
+    ~LargeSet();
 
-void inclElement(LargeSet set, uint16 element);
+    bool in(set, uint16 element);
 
-void exclElement(LargeSet set, uint16 element);
+    void inclElement(uint16 element);
 
+    void exclElement(uint16 element);
 
+    bool readInitialConditions(const char *fileName);
 
+private:
+    uint16 *_array;
+};
 
 /*---------------------------*/
 /*----- From Machine.c ------*/
diff --git a/engines/lab/labsets.cpp b/engines/lab/labsets.cpp
index 86fd6fd..cee9cda 100644
--- a/engines/lab/labsets.cpp
+++ b/engines/lab/labsets.cpp
@@ -33,65 +33,57 @@
 
 namespace Lab {
 
-const uint32 LargeSetSIZE = sizeof(LargeSetRecord) - 2;
-
-
-
-/*****************************************************************************/
-/* Creates a large set.                                                      */
-/*****************************************************************************/
-bool createSet(LargeSet *set, uint16 last) {
+LabSet::LabSet(uint16 last) {
 	last = (((last + 15) >> 4) << 4);
 
-	if ((*set = (LargeSet)calloc((last >> 3) + LargeSetSIZE, 1))) {
-		(*set)->lastElement  = last;
-		return true;
-	} else /* Not Enough Memory! */
-		return false;
-
+	_array = (uint16 *)calloc(last >> 3);
 }
 
-
-
-
-/*****************************************************************************/
-/* Deletes a large set.                                                      */
-/*****************************************************************************/
-void deleteSet(LargeSet set) {
-	if (set)
-		free(set);
+LargeSet::~LargeSet() {
+	free(_array);
 }
 
-
-#define INCL(BITSET,BIT) ((BITSET) |= (BIT))
-
-#define EXCL(BITSET,BIT) ((BITSET) &= (~(BIT)))
-
-
-
-/*****************************************************************************/
-/* Tests if an element is in the set.                                        */
-/*****************************************************************************/
-bool In(LargeSet set, uint16 element) {
-	return ((1 << ((element - 1) % 16)) & (set->array[(element - 1) >> 4])) > 0;
+bool LargeSet::in(uint16 element) {
+	return ((1 << ((element - 1) % 16)) & (_array[(element - 1) >> 4])) > 0;
 }
 
-
-
-/*****************************************************************************/
-/* Sets an element in the Large set.                                         */
-/*****************************************************************************/
-void inclElement(LargeSet set, uint16 element) {
-	INCL((set->array[(element - 1) >> 4]), (1 << ((element - 1) % 16)));
+void LargeSet::inclElement(uint16 element) {
+	_array[(element - 1) >> 4]) |= 1 << ((element - 1) % 16);
 }
 
+void LargeSet::exclElement(uint16 element) {
+	_array[(element - 1) >> 4] &= ~(1 << ((element - 1) % 16));
+}
 
+bool LargeSet::readInitialConditions(const char *fileName) {
+	byte **file;
+	uint16 many, set;
+	char temp[5];
+
+	if ((file = g_music->newOpen(fileName)) != NULL) {
+		readBlock(temp, 4L, file);
+		temp[4] = '\0';
+
+		if (strcmp(temp, "CON0") != 0)
+			return false;
+
+		readBlock(&many, 2L, file);
+#if !defined(DOSCODE)
+		swapUShortPtr(&many, 1);
+#endif
+
+		for (int counter = 0; counter < many; counter++) {
+			readBlock(&set, 2L, file);
+#if !defined(DOSCODE)
+			swapUShortPtr(&set, 1);
+#endif
+			inclElement(set);
+		}
+	} else
+		return false;
 
-/*****************************************************************************/
-/* Removes an element in the Large set.                                      */
-/*****************************************************************************/
-void exclElement(LargeSet set, uint16 element) {
-	EXCL((set->array[(element - 1) >> 4]), (1 << ((element - 1) % 16)));
+	return true;
 }
 
+
 } // End of namespace Lab
diff --git a/engines/lab/labtext.cpp b/engines/lab/labtext.cpp
index 7acb014..673f8d0 100644
--- a/engines/lab/labtext.cpp
+++ b/engines/lab/labtext.cpp
@@ -159,7 +159,7 @@ void decrypt(byte *text) {
 		return;
 
 	while (*text != '\0') {
-		(*text) -= (byte) 95;
+		(*text) -= (byte)95;
 		text++;
 	}
 }
diff --git a/engines/lab/machine.cpp b/engines/lab/machine.cpp
index da8744a..c1bdd00 100644
--- a/engines/lab/machine.cpp
+++ b/engines/lab/machine.cpp
@@ -147,27 +147,6 @@ uint16 VGAUnScaleY(uint16 y) {
 }
 
 
-
-
-#if defined(WIN32)
-/*****************************************************************************/
-/* Replaces all occurences of a character in a string with a new one.        */
-/*****************************************************************************/
-static void strrplc(char *text, char orig, char replace) {
-	uint16 counter;
-
-	counter = 0;
-
-	while (text[counter]) {
-		if (text[counter] == orig)
-			text[counter] = replace;
-
-		counter++;
-	}
-}
-#endif
-
-
 /*****************************************************************************/
 /* Checks to see if all the characters in the second string are at the start */
 /* of the first.                                                             */
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index c56f699..d3380b7 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -528,12 +528,12 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
 /*****************************************************************************/
 /* Checks if a floor has been visitted.                                      */
 /*****************************************************************************/
-static bool onFloor(LargeSet RoomsFound, uint16 Floor) {
+static bool onFloor(uint16 Floor) {
 	uint16 drawroom;
 
 	for (drawroom = 1; drawroom <= MaxRooms; drawroom++) {
 		if ((Maps[drawroom].PageNumber == Floor)
-		        && In(RoomsFound, drawroom)
+		        && g_engine->_roomsFound->in(drawroom)
 		        && Maps[drawroom].x) {
 			return true;
 		}
@@ -623,7 +623,7 @@ static void drawMap(LargeSet RoomsFound, uint16 CurRoom, uint16 CurMsg, uint16 F
 
 	for (drawroom = 1; drawroom <= MaxRooms; drawroom++) {
 		if ((Maps[drawroom].PageNumber == Floor)
-		        && In(RoomsFound, drawroom)
+		        && g_engine->_roomsFound->in(drawroom)
 		        && Maps[drawroom].x) {
 			drawRoom(drawroom, (bool)(drawroom == CurRoom));
 			g_music->checkMusic();
@@ -631,7 +631,7 @@ static void drawMap(LargeSet RoomsFound, uint16 CurRoom, uint16 CurMsg, uint16 F
 	}
 
 	if ((Maps[CurRoom].PageNumber == Floor)   /* Makes sure the X is drawn in corridors */
-	        && In(RoomsFound, CurRoom)         /* NOTE: this here on purpose just in case there's some wierd condition, like the surreal maze where there are no rooms */
+	        && g_engine->_roomsFound->in(CurRoom) /* NOTE: this here on purpose just in case there's some wierd condition, like the surreal maze where there are no rooms */
 	        && Maps[CurRoom].x)
 		drawRoom(CurRoom, true);
 
@@ -858,7 +858,7 @@ void processMap(uint16 CurRoom, LargeSet RoomsFound) {
 						roomCords(drawroom, &x1, &y1, &x2, &y2);
 
 						if ((Maps[drawroom].PageNumber == CurFloor)
-						        && In(RoomsFound, drawroom)
+						        && g_engine->_roomsFound->in(drawroom)
 						        && (MouseX >= x1) && (MouseX <= x2)
 						        && (MouseY >= y1) && (MouseY <= y2)) {
 							CurMsg = drawroom;
diff --git a/engines/lab/modernsavegame.cpp b/engines/lab/modernsavegame.cpp
index 2ea5c22..2be33b8 100644
--- a/engines/lab/modernsavegame.cpp
+++ b/engines/lab/modernsavegame.cpp
@@ -39,9 +39,6 @@ byte g_SaveGameImage[SAVED_IMAGE_SIZE]; // 640 x 358
 char g_SaveGamePath[512];
 char g_PathSeperator[4];
 
-extern LargeSet        Conditions,
-       RoomsFound;
-
 #define SAVEVERSION         "LBS3"
 
 int getSaveGameList(struct SaveGameInfo *info, int maxNum) {
diff --git a/engines/lab/parsefun.h b/engines/lab/parsefun.h
index 4e1dc5d..e6794ee 100644
--- a/engines/lab/parsefun.h
+++ b/engines/lab/parsefun.h
@@ -60,9 +60,6 @@ char *numtostr(char *text, uint16 Num);
 
 bool readViews(uint16 RoomNum, const char *Path);
 
-bool readInitialConditions(LargeSet Conditions, const char *fileName);
-
-
 
 /* From ProcessRoom.c */
 
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index d9f40b4..19e1133 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -51,8 +51,6 @@ extern int g_IsRegistered;
 RoomData *Rooms;
 InventoryData *Inventory;
 uint16 NumInv, RoomNum, ManyRooms, HighestCondition, Direction;
-LargeSet Conditions, RoomsFound;
-
 
 extern char *FACINGNORTH, *FACINGEAST, *FACINGSOUTH, *FACINGWEST;
 extern bool LongWinInFront;
@@ -105,10 +103,10 @@ static bool checkConditions(int16 *Condition) {
 		return true;
 
 	Counter = 1;
-	res     = In(Conditions, Condition[0]);
+	res     = g_engine->_conditions->in(Condition[0]);
 
 	while (Condition[Counter] && res) {
-		res = In(Conditions, Condition[Counter]);
+		res = g_engine->_conditions->in(Condition[Counter]);
 		Counter++;
 	}
 
@@ -415,7 +413,7 @@ bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
 		VPtr = getViewData(RoomNum, Direction);
 		LCPtr = VPtr->closeUps;
 	} else if ((*cptr)->CloseUpType < 0) {
-		inclElement(Conditions, abs((*cptr)->CloseUpType));
+		g_engine->_conditions->inclElement(abs((*cptr)->CloseUpType));
 		return true;
 	} else
 		LCPtr = (*cptr)->SubCloseUps;
@@ -425,7 +423,7 @@ bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
 		if ((x >= scaleX(LCPtr->x1)) && (y >= scaleY(LCPtr->y1)) &&
 		        (x <= scaleX(LCPtr->x2)) && (y <= scaleY(LCPtr->y2)) &&
 		        (LCPtr->CloseUpType < 0)) {
-			inclElement(Conditions, abs(LCPtr->CloseUpType));
+			g_engine->_conditions->inclElement(abs(LCPtr->CloseUpType));
 			return true;
 		}
 
@@ -513,11 +511,11 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
 			break;
 
 		case SETELEMENT:
-			inclElement(Conditions, APtr->Param1);
+			g_engine->_conditions->inclElement(APtr->Param1);
 			break;
 
 		case UNSETELEMENT:
-			exclElement(Conditions, APtr->Param1);
+			g_engine->_conditions->exclElement(APtr->Param1);
 			break;
 
 		case SHOWMESSAGE:
@@ -612,13 +610,13 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
 				(Inventory[APtr->Param1].Many)--;
 
 			if (Inventory[APtr->Param1].Many == 0)
-				exclElement(Conditions, APtr->Param1);
+				g_engine->_conditions->exclElement(APtr->Param1);
 
 			break;
 
 		case ADDINV:
 			(Inventory[APtr->Param1].Many) += APtr->Param2;
-			inclElement(Conditions, APtr->Param1);
+			g_engine->_conditions->inclElement(APtr->Param1);
 			break;
 
 		case SHOWDIR:
diff --git a/engines/lab/readparse.cpp b/engines/lab/readparse.cpp
index 7734a23..075c1fd 100644
--- a/engines/lab/readparse.cpp
+++ b/engines/lab/readparse.cpp
@@ -46,9 +46,6 @@ static bool UseMemory = false;
 extern RoomData *Rooms;
 extern InventoryData *Inventory;
 extern uint16 NumInv, ManyRooms, HighestCondition, Direction;
-extern LargeSet Conditions, RoomsFound;
-
-
 
 static uint16 allocroom;
 
@@ -474,40 +471,4 @@ bool readViews(uint16 RoomNum, const char *Path) {
 	return false;
 }
 
-
-
-
-/*****************************************************************************/
-/* Reads the initial conditions and sets the LargeSet accordingly.           */
-/*****************************************************************************/
-bool readInitialConditions(LargeSet conditions, const char *fileName) {
-	byte **file;
-	uint16 many, set;
-	char temp[5];
-
-	if ((file = g_music->newOpen(fileName)) != NULL) {
-		readBlock(temp, 4L, file);
-		temp[4] = '\0';
-
-		if (strcmp(temp, "CON0") != 0)
-			return false;
-
-		readBlock(&many, 2L, file);
-#if !defined(DOSCODE)
-		swapUShortPtr(&many, 1);
-#endif
-
-		for (int counter = 0; counter < many; counter++) {
-			readBlock(&set, 2L, file);
-#if !defined(DOSCODE)
-			swapUShortPtr(&set, 1);
-#endif
-			inclElement(conditions, set);
-		}
-	} else
-		return false;
-
-	return true;
-}
-
 } // End of namespace Lab
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 50589ed..022f203 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -195,20 +195,13 @@ static void changeCombination(LargeSet Conditions, uint16 number) {
 		bltBitMap(Images[combnum], 0, (Images[combnum])->Height - (2 * counter), &(display), VGAScaleX(combx[number]), VGAScaleY(65), (Images[combnum])->Width, 2);
 	}
 
-	/*
-	   if (memcmp(combination, solution, (size_t) 12) == 0)
-	    inclElement(Conditions, COMBINATIONUNLOCKED);
-	   else
-	    exclElement(Conditions, COMBINATIONUNLOCKED);
-	 */
-
 	for (counter = 0; counter < 6; counter++)
 		unlocked = (combination[counter] == solution[counter]) && unlocked;
 
 	if (unlocked)
-		inclElement(Conditions, COMBINATIONUNLOCKED);
+		g_engine->_conditions->inclElement(COMBINATIONUNLOCKED);
 	else
-		exclElement(Conditions, COMBINATIONUNLOCKED);
+		g_engine->_conditions->exclElement(COMBINATIONUNLOCKED);
 
 #if !defined(DOSCODE)
 	ungetVGABaseAddr();
@@ -486,7 +479,7 @@ static void changeTile(LargeSet Conditions, uint16 col, uint16 row) {
 		}
 
 		if (check) {
-			inclElement(Conditions, BRICKOPEN);  /* unlocked combination */
+			g_engine->_conditions->inclElement(BRICKOPEN);  /* unlocked combination */
 			DoBlack = true;
 			check = readPict("p:Up/BDOpen", true);
 		}
@@ -665,10 +658,10 @@ static bool loadJournalData(LargeSet Conditions) {
 	g_music->checkMusic();
 
 	strcpy(filename, "Lab:Rooms/j0");
-	bridge = In(Conditions, BRIDGE0) || In(Conditions, BRIDGE1);
-	dirty  = In(Conditions, DIRTY);
-	news   = !In(Conditions, NONEWS);
-	clean  = !In(Conditions, NOCLEAN);
+	bridge = g_engine->_conditions->in(BRIDGE0) || g_engine->_conditions->in(BRIDGE1);
+	dirty  = g_engine->_conditions->in(DIRTY);
+	news   = !g_engine->_conditions->in(NONEWS);
+	clean  = !g_engine->_conditions->in(NOCLEAN);
 
 	if (bridge && clean && news)
 		filename[11] = '8';
@@ -981,9 +974,6 @@ struct Image *Arrow1, *NoArrow1, *DriveButton;
 
 extern InventoryData *Inventory;
 extern uint16 RoomNum, Direction;
-extern LargeSet Conditions, RoomsFound;
-
-
 
 extern char *SAVETEXT, *LOADTEXT, *BOOKMARKTEXT, *PERSONALTEXT, *DISKTEXT, *SAVEBOOK, *RESTOREBOOK, *SAVEFLASH, *RESTOREFLASH, *SAVEDISK, *RESTOREDISK, *SELECTDISK, *NODISKINDRIVE, *WRITEPROTECTED, *FORMATFLOPPY, *FORMATTING;
 


Commit: cb8f8432966ccee632bf4e79e367d6d941dfdedb
    https://github.com/scummvm/scummvm/commit/cb8f8432966ccee632bf4e79e367d6d941dfdedb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Objectify LabSets

Changed paths:
    engines/lab/engine.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/labfun.h
    engines/lab/labsets.cpp
    engines/lab/map.cpp
    engines/lab/modernsavegame.cpp
    engines/lab/processroom.cpp
    engines/lab/savegame.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index dec1806..4db1451 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -28,6 +28,7 @@
  *
  */
 
+#include "lab/lab.h"
 #include "lab/stddefines.h"
 #include "lab/labfun.h"
 #include "lab/diff.h"
@@ -222,8 +223,8 @@ static void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr) {
 	}
 
 	if (Alternate) {
-		if ((CurInv <= NumInv) && g_engine->_conditions->in(CurInv) && Inventory[CurInv].BInvName) {
-			if ((CurInv == LAMPNUM) && g_engine->_conditions->in(LAMPON))  /* LAB: Labyrith specific */
+		if ((CurInv <= NumInv) && g_lab->_conditions->in(CurInv) && Inventory[CurInv].BInvName) {
+			if ((CurInv == LAMPNUM) && g_lab->_conditions->in(LAMPON))  /* LAB: Labyrith specific */
 				drawMessage(LAMPONMSG);
 			else if (Inventory[CurInv].Many > 1) {
 				ManyPtr = numtostr(ManyText, Inventory[CurInv].Many);
@@ -517,10 +518,10 @@ static const char *getInvName(uint16 CurInv) {
 	if (MainDisplay)
 		return Inventory[CurInv].BInvName;
 
-	if ((CurInv == LAMPNUM) && g_engine->_conditions->in(LAMPON))
+	if ((CurInv == LAMPNUM) && g_lab->_conditions->in(LAMPON))
 		return "P:Mines/120";
 
-	else if ((CurInv == BELTNUM) && g_engine->_conditions->in(BELTGLOW))
+	else if ((CurInv == BELTNUM) && g_lab->_conditions->in(BELTGLOW))
 		return "P:Future/BeltGlow";
 
 	else if (CurInv == WESTPAPERNUM) {
@@ -596,7 +597,7 @@ static bool doUse(uint16 CurInv) {
 		stopDiff();
 		CurFileName = " ";
 		CPtr = NULL;
-		doMap(RoomsFound, RoomNum);
+		doMap(RoomNum);
 		VGASetPal(initcolors, 8);
 		drawMessage(NULL);
 		drawPanel();
@@ -608,7 +609,7 @@ static bool doUse(uint16 CurInv) {
 		stopDiff();
 		CurFileName = " ";
 		CPtr = NULL;
-		doJournal(Conditions);
+		doJournal();
 		drawPanel();
 		drawMessage(NULL);
 	}
@@ -616,12 +617,12 @@ static bool doUse(uint16 CurInv) {
 	else if (CurInv == LAMPNUM) {            /* LAB: Labyrinth specific */
 		interfaceOff();
 
-		if (g_engine->_conditions->in(LAMPON)) {
+		if (g_lab->_conditions->in(LAMPON)) {
 			drawMessage(TURNLAMPOFF);
-			g_engine->_conditions->exclElement(LAMPON);
+			g_lab->_conditions->exclElement(LAMPON);
 		} else {
 			drawMessage(TURNLAMPON);
-			g_engine->_conditions->inclElement(LAMPON);
+			g_lab->_conditions->inclElement(LAMPON);
 		}
 
 		DoBlack = false;
@@ -634,25 +635,25 @@ static bool doUse(uint16 CurInv) {
 	}
 
 	else if (CurInv == BELTNUM) {                    /* LAB: Labyrinth specific */
-		if (!g_engine->_conditions->in(BELTGLOW))
-			g_engine->_conditions->inclElement(BELTGLOW);
+		if (!g_lab->_conditions->in(BELTGLOW))
+			g_lab->_conditions->inclElement(BELTGLOW);
 
 		DoBlack = false;
 		Test = getInvName(CurInv);
 	}
 
 	else if (CurInv == WHISKEYNUM) {                 /* LAB: Labyrinth specific */
-		g_engine->_conditions->inclElement(USEDHELMET);
+		g_lab->_conditions->inclElement(USEDHELMET);
 		drawMessage(USEWHISKEY);
 	}
 
 	else if (CurInv == PITHHELMETNUM) {              /* LAB: Labyrinth specific */
-		g_engine->_conditions->inclElement(USEDHELMET);
+		g_lab->_conditions->inclElement(USEDHELMET);
 		drawMessage(USEPITH);
 	}
 
 	else if (CurInv == HELMETNUM) {                  /* LAB: Labyrinth specific */
-		g_engine->_conditions->inclElement(USEDHELMET);
+		g_lab->_conditions->inclElement(USEDHELMET);
 		drawMessage(USEHELMET);
 	}
 
@@ -677,7 +678,7 @@ static void decIncInv(uint16 *CurInv, bool dec) {
 		(*CurInv)++;
 
 	while (*CurInv && (*CurInv <= NumInv)) {
-		if (g_engine->_conditions->in(*CurInv) && Inventory[*CurInv].BInvName) {
+		if (g_lab->_conditions->in(*CurInv) && Inventory[*CurInv].BInvName) {
 			Test = getInvName(*CurInv);
 			break;
 		}
@@ -695,7 +696,7 @@ static void decIncInv(uint16 *CurInv, bool dec) {
 			*CurInv = 1;
 
 		while (*CurInv && (*CurInv <= NumInv)) {
-			if (g_engine->_conditions->in(*CurInv) && Inventory[*CurInv].BInvName) {
+			if (g_lab->_conditions->in(*CurInv) && Inventory[*CurInv].BInvName) {
 				Test = getInvName(*CurInv);
 				break;
 			}
@@ -748,13 +749,13 @@ static void process(void) {
 	readRoomData("LAB:Doors");
 	readInventory("LAB:Inventor");
 
-	if (!(g_engine->_conditions = new LargeSet(HighestCondition + 1)))
+	if (!(g_lab->_conditions = new LargeSet(HighestCondition + 1)))
 		return;
 
-	if (!(g_engine->_roomsFound = new LargeSet(ManyRooms + 1)))
+	if (!(g_lab->_roomsFound = new LargeSet(ManyRooms + 1)))
 		return;
 
-	g_engine->_conditions->readInitialConditions("LAB:Conditio");
+	g_lab->_conditions->readInitialConditions("LAB:Conditio");
 
 	LongWinInFront = false;
 	drawPanel();
@@ -788,7 +789,7 @@ static void process(void) {
 				Test = getPictName(&CPtr);
 
 			if (noupdatediff) {
-				g_engine->_roomsFound->inclElement(RoomNum); /* Potentially entered another room */
+				g_lab->_roomsFound->inclElement(RoomNum); /* Potentially entered another room */
 				ForceDraw = (strcmp(Test, CurFileName) != 0) || ForceDraw;
 
 				noupdatediff = false;
@@ -797,7 +798,7 @@ static void process(void) {
 
 			else if (strcmp(Test, CurFileName) != 0) {
 				interfaceOff();
-				g_engine->_roomsFound->inclElement(RoomNum); /* Potentially entered another room */
+				g_lab->_roomsFound->inclElement(RoomNum); /* Potentially entered another room */
 				CurFileName = Test;
 
 				if (CPtr) {
@@ -1089,7 +1090,7 @@ from_crumbs:
 
 						MainDisplay = false;
 
-						if (LastInv && g_engine->_conditions->in(LastInv)) {
+						if (LastInv && g_lab->_conditions->in(LastInv)) {
 							CurInv = LastInv;
 							Test = getInvName(CurInv);
 						} else
@@ -1171,7 +1172,7 @@ from_crumbs:
 
 							if (OldRoomNum != RoomNum) {
 								drawMessage(GOFORWARDDIR);
-								g_engine->_roomsFound->inclElement(RoomNum); /* Potentially entered a new room */
+								g_lab->_roomsFound->inclElement(RoomNum); /* Potentially entered a new room */
 								CurFileName = " ";
 								ForceDraw = true;
 							} else {
@@ -1315,11 +1316,11 @@ from_crumbs:
 					if ((CurInv == 0) || (CurInv > NumInv)) {
 						CurInv = 1;
 
-						while ((CurInv <= NumInv) && (!g_engine->_conditions->in(CurInv)))
+						while ((CurInv <= NumInv) && (!g_lab->_conditions->in(CurInv)))
 							CurInv++;
 					}
 
-					if ((CurInv <= NumInv) && g_engine->_conditions->in(CurInv) &&
+					if ((CurInv <= NumInv) && g_lab->_conditions->in(CurInv) &&
 					        Inventory[CurInv].BInvName)
 						Test = getInvName(CurInv);
 
@@ -1398,9 +1399,9 @@ from_crumbs:
 
 				if (CPtr) {
 					if ((CPtr->CloseUpType == SPECIALLOCK) && MainDisplay) /* LAB: Labrinth specific code */
-						mouseCombination(Conditions, MouseX, MouseY);
+						mouseCombination(MouseX, MouseY);
 					else if ((CPtr->CloseUpType == SPECIALBRICK) && MainDisplay)
-						mouseTile(Conditions, MouseX, MouseY);
+						mouseTile(MouseX, MouseY);
 					else
 						doit = true;
 				} else
@@ -1453,11 +1454,11 @@ from_crumbs:
 					}
 
 					else if ((ActionMode == 5)  &&
-					         g_engine->_conditions->in(CurInv)) { /* Use an item on something else */
+					         g_lab->_conditions->in(CurInv)) { /* Use an item on something else */
 						if (doOperateRule(MouseX, MouseY, CurInv, &CPtr)) {
 							CurFileName = NewFileName;
 
-							if (!g_engine->_conditions->in(CurInv))
+							if (!g_lab->_conditions->in(CurInv))
 								decIncInv(&CurInv, false);
 						} else if (MouseY < (VGAScaleY(149) + SVGACord(2)))
 							drawMessage(NOTHING);
@@ -1509,7 +1510,7 @@ from_crumbs:
 				interfaceOn(); /* Sets the correct gadget list */
 
 				if (Alternate) {
-					if (LastInv && g_engine->_conditions->in(LastInv))
+					if (LastInv && g_lab->_conditions->in(LastInv))
 						CurInv = LastInv;
 					else
 						decIncInv(&CurInv, false);
@@ -1525,8 +1526,8 @@ from_crumbs:
 		}
 	}
 
-	delete g_engine->_conditions;
-	delete g_engine->_roomsFound;
+	delete g_lab->_conditions;
+	delete g_lab->_roomsFound;
 
 	if (Rooms)
 		free(Rooms);
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 7054072..971543a 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -45,8 +45,11 @@ bool LabEngine::hasFeature(EngineFeature f) const {
 	return (f == kSupportsRTL) ? true : false;
 }
 
+LabEngine *g_lab;
+
 LabEngine::LabEngine(OSystem *syst)
  : Engine(syst) {
+	g_lab = this;
 }
 
 LabEngine::~LabEngine() {
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 4242955..bdb0b4d 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -50,6 +50,8 @@ public:
 	LargeSet *_conditions, *_roomsFound;
 };
 
+extern LabEngine *g_lab;
+
 } // End of namespace Lab
 
 #endif // LAB_H
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 93d5166..abb0871 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -281,7 +281,7 @@ public:
 
     ~LargeSet();
 
-    bool in(set, uint16 element);
+    bool in(uint16 element);
 
     void inclElement(uint16 element);
 
@@ -289,7 +289,8 @@ public:
 
     bool readInitialConditions(const char *fileName);
 
-private:
+public:
+    uint16 _lastElement;
     uint16 *_array;
 };
 
@@ -333,9 +334,9 @@ bool getFont(const char *filename, TextFont *textfont);
 
 void readImage(byte **buffer, Image **im);
 
-void doMap(LargeSet RoomsFound, uint16 CurRoom);
+void doMap(uint16 CurRoom);
 
-void doJournal(LargeSet Conditions);
+void doJournal();
 
 void doNotes(void);
 
@@ -353,9 +354,9 @@ bool saveRestoreGame(void);
 /*----- From saveGame.c ----*/
 /*--------------------------*/
 
-bool saveFloppy(char *path, uint16 RoomNum, uint16 Direction, uint16 NumQuarters, LargeSet Conditions, LargeSet Rooms, uint16 filenum, uint16 type);
+bool saveFloppy(char *path, uint16 RoomNum, uint16 Direction, uint16 NumQuarters, uint16 filenum, uint16 type);
 
-bool readFloppy(char *path, uint16 *RoomNum, uint16 *Direction, uint16 *NumQuarters, LargeSet Conditions, LargeSet Rooms, uint16 filenum, uint16 type);
+bool readFloppy(char *path, uint16 *RoomNum, uint16 *Direction, uint16 *NumQuarters, uint16 filenum, uint16 type);
 
 
 
@@ -365,11 +366,11 @@ bool readFloppy(char *path, uint16 *RoomNum, uint16 *Direction, uint16 *NumQuart
 
 void showCombination(const char *filename);
 
-void mouseCombination(LargeSet Conditions, uint16 x, uint16 y);
+void mouseCombination(uint16 x, uint16 y);
 
 void showTile(const char *filename, bool showsolution);
 
-void mouseTile(LargeSet Conditions, uint16 x, uint16 y);
+void mouseTile(uint16 x, uint16 y);
 
 void inner_main();
 
diff --git a/engines/lab/labsets.cpp b/engines/lab/labsets.cpp
index cee9cda..eefbc79 100644
--- a/engines/lab/labsets.cpp
+++ b/engines/lab/labsets.cpp
@@ -33,10 +33,11 @@
 
 namespace Lab {
 
-LabSet::LabSet(uint16 last) {
+LargeSet::LargeSet(uint16 last) {
 	last = (((last + 15) >> 4) << 4);
 
-	_array = (uint16 *)calloc(last >> 3);
+	_array = (uint16 *)calloc(last >> 3, 2);
+	_lastElement = last;
 }
 
 LargeSet::~LargeSet() {
@@ -48,7 +49,7 @@ bool LargeSet::in(uint16 element) {
 }
 
 void LargeSet::inclElement(uint16 element) {
-	_array[(element - 1) >> 4]) |= 1 << ((element - 1) % 16);
+	_array[(element - 1) >> 4] |= 1 << ((element - 1) % 16);
 }
 
 void LargeSet::exclElement(uint16 element) {
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index d3380b7..eac1364 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -28,6 +28,7 @@
  *
  */
 
+#include "lab/lab.h"
 #include "lab/stddefines.h"
 #include "lab/labfun.h"
 #include "lab/diff.h"
@@ -533,7 +534,7 @@ static bool onFloor(uint16 Floor) {
 
 	for (drawroom = 1; drawroom <= MaxRooms; drawroom++) {
 		if ((Maps[drawroom].PageNumber == Floor)
-		        && g_engine->_roomsFound->in(drawroom)
+		        && g_lab->_roomsFound->in(drawroom)
 		        && Maps[drawroom].x) {
 			return true;
 		}
@@ -548,7 +549,7 @@ static bool onFloor(uint16 Floor) {
 /*****************************************************************************/
 /* Figures out which floor, if any, should be gone to if the up arrow is hit */
 /*****************************************************************************/
-static void getUpFloor(LargeSet RoomsFound, uint16 *Floor, bool *isfloor) {
+static void getUpFloor(uint16 *Floor, bool *isfloor) {
 	do {
 		*isfloor = true;
 
@@ -559,7 +560,7 @@ static void getUpFloor(LargeSet RoomsFound, uint16 *Floor, bool *isfloor) {
 			*isfloor = false;
 			return;
 		}
-	} while ((!onFloor(RoomsFound, *Floor)) && (*Floor <= CARNIVAL));
+	} while ((!onFloor(*Floor)) && (*Floor <= CARNIVAL));
 }
 
 
@@ -569,7 +570,7 @@ static void getUpFloor(LargeSet RoomsFound, uint16 *Floor, bool *isfloor) {
 /* Figures out which floor, if any, should be gone to if the down arrow is   */
 /* hit.                                                                      */
 /*****************************************************************************/
-static void getDownFloor(LargeSet RoomsFound, uint16 *Floor, bool *isfloor) {
+static void getDownFloor(uint16 *Floor, bool *isfloor) {
 	do {
 		*isfloor = true;
 
@@ -593,7 +594,7 @@ static void getDownFloor(LargeSet RoomsFound, uint16 *Floor, bool *isfloor) {
 		} else
 			(*Floor)--;
 
-	} while ((!onFloor(RoomsFound, *Floor)) && *Floor);
+	} while ((!onFloor(*Floor)) && *Floor);
 }
 
 
@@ -603,7 +604,7 @@ static void getDownFloor(LargeSet RoomsFound, uint16 *Floor, bool *isfloor) {
 /*****************************************************************************/
 /* Draws the map                                                             */
 /*****************************************************************************/
-static void drawMap(LargeSet RoomsFound, uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein) {
+static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein) {
 	uint16 drawroom;
 	char *sptr;
 
@@ -623,7 +624,7 @@ static void drawMap(LargeSet RoomsFound, uint16 CurRoom, uint16 CurMsg, uint16 F
 
 	for (drawroom = 1; drawroom <= MaxRooms; drawroom++) {
 		if ((Maps[drawroom].PageNumber == Floor)
-		        && g_engine->_roomsFound->in(drawroom)
+		        && g_lab->_roomsFound->in(drawroom)
 		        && Maps[drawroom].x) {
 			drawRoom(drawroom, (bool)(drawroom == CurRoom));
 			g_music->checkMusic();
@@ -631,12 +632,12 @@ static void drawMap(LargeSet RoomsFound, uint16 CurRoom, uint16 CurMsg, uint16 F
 	}
 
 	if ((Maps[CurRoom].PageNumber == Floor)   /* Makes sure the X is drawn in corridors */
-	        && g_engine->_roomsFound->in(CurRoom) /* NOTE: this here on purpose just in case there's some wierd condition, like the surreal maze where there are no rooms */
+	        && g_lab->_roomsFound->in(CurRoom) /* NOTE: this here on purpose just in case there's some wierd condition, like the surreal maze where there are no rooms */
 	        && Maps[CurRoom].x)
 		drawRoom(CurRoom, true);
 
 	tempfloor = Floor;
-	getUpFloor(RoomsFound, &tempfloor, &noghoast);
+	getUpFloor(&tempfloor, &noghoast);
 
 	if (noghoast)
 		unGhoastGadget(&upgadget);
@@ -644,7 +645,7 @@ static void drawMap(LargeSet RoomsFound, uint16 CurRoom, uint16 CurMsg, uint16 F
 		ghoastGadget(&upgadget, 12);
 
 	tempfloor = Floor;
-	getDownFloor(RoomsFound, &tempfloor, &noghoast);
+	getDownFloor(&tempfloor, &noghoast);
 
 	if (noghoast)
 		unGhoastGadget(&downgadget);
@@ -653,20 +654,20 @@ static void drawMap(LargeSet RoomsFound, uint16 CurRoom, uint16 CurMsg, uint16 F
 
 	/* LAB: Labyrinth specific code */
 	if (Floor == LOWERFLOOR) {
-		if (onFloor(RoomsFound, SURMAZEFLOOR))
+		if (onFloor(SURMAZEFLOOR))
 			drawImage(Maze, mapScaleX(538), mapScaleY(277));
 	}
 
 	else if (Floor == MIDDLEFLOOR) {
-		if (onFloor(RoomsFound, CARNIVAL))
+		if (onFloor(CARNIVAL))
 			drawImage(Maze, mapScaleX(358), mapScaleY(72));
 
-		if (onFloor(RoomsFound, MEDMAZEFLOOR))
+		if (onFloor(MEDMAZEFLOOR))
 			drawImage(Maze, mapScaleX(557), mapScaleY(325));
 	}
 
 	else if (Floor == UPPERFLOOR) {
-		if (onFloor(RoomsFound, HEDGEMAZEFLOOR))
+		if (onFloor(HEDGEMAZEFLOOR))
 			drawImage(HugeMaze, mapScaleX(524), mapScaleY(97));
 	}
 
@@ -729,7 +730,7 @@ static void drawMap(LargeSet RoomsFound, uint16 CurRoom, uint16 CurMsg, uint16 F
 /*****************************************************************************/
 /* Processes the map.                                                        */
 /*****************************************************************************/
-void processMap(uint16 CurRoom, LargeSet RoomsFound) {
+void processMap(uint16 CurRoom) {
 	uint32 Class, place = 1;
 	uint16 Code, Qualifier, MouseX, MouseY, GadgetID, CurFloor, OldFloor, OldMsg, CurMsg, drawroom, x1, y1, x2, y2;
 	char *sptr;
@@ -789,21 +790,21 @@ void processMap(uint16 CurRoom, LargeSet RoomsFound) {
 					return;
 				} else if (GadgetID == 1) { /* Up arrow */
 					OldFloor = CurFloor;
-					getUpFloor(RoomsFound, &CurFloor, &drawmap);
+					getUpFloor(&CurFloor, &drawmap);
 
 					if (drawmap) {
 						fade(false, 0);
-						drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false);
+						drawMap(CurRoom, CurMsg, CurFloor, false, false);
 						fade(true, 0);
 					} else
 						CurFloor = OldFloor;
 				} else if (GadgetID == 2) { /* Down arrow */
 					OldFloor = CurFloor;
-					getDownFloor(RoomsFound, &CurFloor, &drawmap);
+					getDownFloor(&CurFloor, &drawmap);
 
 					if (drawmap) {
 						fade(false, 0);
-						drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false);
+						drawMap(CurRoom, CurMsg, CurFloor, false, false);
 						fade(true, 0);
 					} else
 						CurFloor = OldFloor;
@@ -813,41 +814,41 @@ void processMap(uint16 CurRoom, LargeSet RoomsFound) {
 			else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) {
 				if ((CurFloor == LOWERFLOOR) && (MouseX >= mapScaleX(538)) && (MouseY >= mapScaleY(277))
 				        && (MouseX <= mapScaleX(633)) && (MouseY <= mapScaleY(352))
-				        && onFloor(RoomsFound, SURMAZEFLOOR)) {
+				        && onFloor(SURMAZEFLOOR)) {
 					CurFloor = SURMAZEFLOOR;
 
 					fade(false, 0);
-					drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false);
+					drawMap(CurRoom, CurMsg, CurFloor, false, false);
 					fade(true, 0);
 				}
 
 				else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(358)) && (MouseY >= mapScaleY(71))
 				         && (MouseX <= mapScaleX(452)) && (MouseY <= mapScaleY(147))
-				         && onFloor(RoomsFound, CARNIVAL)) {
+				         && onFloor(CARNIVAL)) {
 					CurFloor = CARNIVAL;
 
 					fade(false, 0);
-					drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false);
+					drawMap(CurRoom, CurMsg, CurFloor, false, false);
 					fade(true, 0);
 				}
 
 				else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(557)) && (MouseY >= mapScaleY(325))
 				         && (MouseX <= mapScaleX(653)) && (MouseY <= mapScaleY(401))
-				         && onFloor(RoomsFound, MEDMAZEFLOOR)) {
+				         && onFloor(MEDMAZEFLOOR)) {
 					CurFloor = MEDMAZEFLOOR;
 
 					fade(false, 0);
-					drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false);
+					drawMap(CurRoom, CurMsg, CurFloor, false, false);
 					fade(true, 0);
 				}
 
 				else if ((CurFloor == UPPERFLOOR) && (MouseX >= mapScaleX(524)) && (MouseY >=  mapScaleY(97))
 				         && (MouseX <= mapScaleX(645)) && (MouseY <= mapScaleY(207))
-				         && onFloor(RoomsFound, HEDGEMAZEFLOOR)) {
+				         && onFloor(HEDGEMAZEFLOOR)) {
 					CurFloor = HEDGEMAZEFLOOR;
 
 					fade(false, 0);
-					drawMap(RoomsFound, CurRoom, CurMsg, CurFloor, false, false);
+					drawMap(CurRoom, CurMsg, CurFloor, false, false);
 					fade(true, 0);
 				}
 
@@ -858,7 +859,7 @@ void processMap(uint16 CurRoom, LargeSet RoomsFound) {
 						roomCords(drawroom, &x1, &y1, &x2, &y2);
 
 						if ((Maps[drawroom].PageNumber == CurFloor)
-						        && g_engine->_roomsFound->in(drawroom)
+						        && g_lab->_roomsFound->in(drawroom)
 						        && (MouseX >= x1) && (MouseX <= x2)
 						        && (MouseY >= y1) && (MouseY <= y2)) {
 							CurMsg = drawroom;
@@ -915,7 +916,7 @@ void mapCleanUp(void) {
 /*****************************************************************************/
 /* Does the map processing.                                                  */
 /*****************************************************************************/
-void doMap(LargeSet RoomsFound, uint16 CurRoom) {
+void doMap(uint16 CurRoom) {
 	FadePalette = AmigaMapPalette;
 
 	g_music->checkMusic();
@@ -931,13 +932,13 @@ void doMap(LargeSet RoomsFound, uint16 CurRoom) {
 	else if (Direction == WEST)
 		XMark = MapWest;
 
-	drawMap(RoomsFound, CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true);
+	drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true);
 	mouseShow();
 	attachGadgetList(MapGadgetList);
 #if !defined(DOSCODE)
 	WSDL_UpdateScreen();
 #endif
-	processMap(CurRoom, RoomsFound);
+	processMap(CurRoom);
 	attachGadgetList(NULL);
 	fade(false, 0);
 	blackAllScreen();
diff --git a/engines/lab/modernsavegame.cpp b/engines/lab/modernsavegame.cpp
index 2be33b8..71eedb9 100644
--- a/engines/lab/modernsavegame.cpp
+++ b/engines/lab/modernsavegame.cpp
@@ -83,7 +83,7 @@ int getSaveGameList(struct SaveGameInfo *info, int maxNum) {
 				fread(&t, 1, 2, fh);
 				info->Direction = swapUShort(t);
 
-				toSeek = 2 + Conditions->lastElement / 8 + RoomsFound->lastElement / 8 + 6 + 2 * 16;
+				toSeek = 2 + Conditions->lastElement / 8 + g_lab->_roomsFound->_lastElement / 8 + 6 + 2 * 16;
 				fseek(fh, toSeek, SEEK_CUR);
 
 				info->SaveGameImage = NULL;
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 19e1133..10d5dfb 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -28,6 +28,7 @@
  *
  */
 
+#include "lab/lab.h"
 #include "lab/stddefines.h"
 #include "lab/labfun.h"
 #include "lab/parsetypes.h"
@@ -103,10 +104,10 @@ static bool checkConditions(int16 *Condition) {
 		return true;
 
 	Counter = 1;
-	res     = g_engine->_conditions->in(Condition[0]);
+	res     = g_lab->_conditions->in(Condition[0]);
 
 	while (Condition[Counter] && res) {
-		res = g_engine->_conditions->in(Condition[Counter]);
+		res = g_lab->_conditions->in(Condition[Counter]);
 		Counter++;
 	}
 
@@ -413,7 +414,7 @@ bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
 		VPtr = getViewData(RoomNum, Direction);
 		LCPtr = VPtr->closeUps;
 	} else if ((*cptr)->CloseUpType < 0) {
-		g_engine->_conditions->inclElement(abs((*cptr)->CloseUpType));
+		g_lab->_conditions->inclElement(abs((*cptr)->CloseUpType));
 		return true;
 	} else
 		LCPtr = (*cptr)->SubCloseUps;
@@ -423,7 +424,7 @@ bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
 		if ((x >= scaleX(LCPtr->x1)) && (y >= scaleY(LCPtr->y1)) &&
 		        (x <= scaleX(LCPtr->x2)) && (y <= scaleY(LCPtr->y2)) &&
 		        (LCPtr->CloseUpType < 0)) {
-			g_engine->_conditions->inclElement(abs(LCPtr->CloseUpType));
+			g_lab->_conditions->inclElement(abs(LCPtr->CloseUpType));
 			return true;
 		}
 
@@ -511,11 +512,11 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
 			break;
 
 		case SETELEMENT:
-			g_engine->_conditions->inclElement(APtr->Param1);
+			g_lab->_conditions->inclElement(APtr->Param1);
 			break;
 
 		case UNSETELEMENT:
-			g_engine->_conditions->exclElement(APtr->Param1);
+			g_lab->_conditions->exclElement(APtr->Param1);
 			break;
 
 		case SHOWMESSAGE:
@@ -610,13 +611,13 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
 				(Inventory[APtr->Param1].Many)--;
 
 			if (Inventory[APtr->Param1].Many == 0)
-				g_engine->_conditions->exclElement(APtr->Param1);
+				g_lab->_conditions->exclElement(APtr->Param1);
 
 			break;
 
 		case ADDINV:
 			(Inventory[APtr->Param1].Many) += APtr->Param2;
-			g_engine->_conditions->inclElement(APtr->Param1);
+			g_lab->_conditions->inclElement(APtr->Param1);
 			break;
 
 		case SHOWDIR:
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index ed25c38..c5d3499 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -28,6 +28,7 @@
  *
  */
 
+#include "lab/lab.h"
 #include "lab/stddefines.h"
 #include "lab/labfun.h"
 #include "lab/modernsavegame.h"
@@ -134,7 +135,7 @@ extern bool FollowingCrumbs;
 /* Writes the game out to disk.                                              */
 /* Assumes that the file has already been openned and is there.              */
 /*****************************************************************************/
-static bool saveGame(uint16 RoomNum, uint16 Direction, uint16 Quarters, LargeSet set1, LargeSet set2, LABFH file) {
+static bool saveGame(uint16 RoomNum, uint16 Direction, uint16 Quarters, LABFH file) {
 #if !defined(DOSCODE)
 	uint16 temp;
 	CrumbData crumbs[sizeof(BreadCrumbs) / sizeof(CrumbData)];
@@ -156,11 +157,11 @@ static bool saveGame(uint16 RoomNum, uint16 Direction, uint16 Quarters, LargeSet
 	saveGameWriteBlock(file, &temp, 2L);
 #endif
 
-	last = set1->lastElement / 8;
-	saveGameWriteBlock(file, &(set1->array[0]), (uint32) last);
+	last = g_lab->_conditions->_lastElement / 8;
+	saveGameWriteBlock(file, g_lab->_conditions->_array, (uint32) last);
 
-	last = set2->lastElement / 8;
-	saveGameWriteBlock(file, &(set2->array[0]), (uint32) last);
+	last = g_lab->_roomsFound->_lastElement / 8;
+	saveGameWriteBlock(file, g_lab->_roomsFound->_array, (uint32) last);
 
 	/* LAB: the combination lock and tile stuff */
 	for (counter = 0; counter < 6; counter++) {
@@ -198,7 +199,7 @@ static bool saveGame(uint16 RoomNum, uint16 Direction, uint16 Quarters, LargeSet
 /* Reads the game from disk.                                                 */
 /* Assumes that the file has already been openned and is there.              */
 /*****************************************************************************/
-static bool loadGame(uint16 *RoomNum, uint16 *Direction, uint16 *Quarters, LargeSet set1, LargeSet set2, LABFH file) {
+static bool loadGame(uint16 *RoomNum, uint16 *Direction, uint16 *Quarters, LABFH file) {
 #if !defined(DOSCODE)
 	uint16 t;
 	CrumbData crumbs[sizeof(BreadCrumbs) / sizeof(CrumbData)];
@@ -230,11 +231,11 @@ static bool loadGame(uint16 *RoomNum, uint16 *Direction, uint16 *Quarters, Large
 	*Quarters = swapUShort(t);
 #endif
 
-	last = set1->lastElement / 8;
-	saveGameReadBlock(file, &(set1->array[0]), (uint32) last);
+	last = g_lab->_conditions->_lastElement / 8;
+	saveGameReadBlock(file, g_lab->_conditions->_array, (uint32) last);
 
-	last = set2->lastElement / 8;
-	saveGameReadBlock(file, &(set2->array[0]), (uint32) last);
+	last = g_lab->_roomsFound->_lastElement / 8;
+	saveGameReadBlock(file, g_lab->_roomsFound->_array, (uint32) last);
 
 	/* LAB: the combination lock and tile stuff */
 	for (counter = 0; counter < 6; counter++) {
@@ -281,7 +282,7 @@ static bool loadGame(uint16 *RoomNum, uint16 *Direction, uint16 *Quarters, Large
 /*****************************************************************************/
 /* Saves the game to the floppy disk.                                        */
 /*****************************************************************************/
-bool saveFloppy(char *path, uint16 RoomNum, uint16 Direction, uint16 NumQuarters, LargeSet Conditions, LargeSet Rooms, uint16 filenum, uint16 type) {
+bool saveFloppy(char *path, uint16 RoomNum, uint16 Direction, uint16 NumQuarters, uint16 filenum, uint16 type) {
 	LABFH FPtr;
 
 	g_music->checkMusic();
@@ -290,7 +291,7 @@ bool saveFloppy(char *path, uint16 RoomNum, uint16 Direction, uint16 NumQuarters
 	FileNum  = filenum;
 
 	if ((FPtr = saveGameOpen(path, true)) != INVALID_LABFH)
-		saveGame(RoomNum, Direction, NumQuarters, Conditions, Rooms, FPtr);
+		saveGame(RoomNum, Direction, NumQuarters, FPtr);
 	else
 		return false;
 
@@ -303,7 +304,7 @@ bool saveFloppy(char *path, uint16 RoomNum, uint16 Direction, uint16 NumQuarters
 /*****************************************************************************/
 /* Reads the game from the floppy disk.                                      */
 /*****************************************************************************/
-bool readFloppy(char *path, uint16 *RoomNum, uint16 *Direction, uint16 *NumQuarters, LargeSet Conditions, LargeSet Rooms, uint16 filenum, uint16 type) {
+bool readFloppy(char *path, uint16 *RoomNum, uint16 *Direction, uint16 *NumQuarters, uint16 filenum, uint16 type) {
 	LABFH FPtr;
 
 	g_music->checkMusic();
@@ -312,7 +313,7 @@ bool readFloppy(char *path, uint16 *RoomNum, uint16 *Direction, uint16 *NumQuart
 	FileNum  = filenum;
 
 	if ((FPtr = saveGameOpen(path, false)) != INVALID_LABFH) {
-		if (!loadGame(RoomNum, Direction, NumQuarters, Conditions, Rooms, FPtr))
+		if (!loadGame(RoomNum, Direction, NumQuarters, FPtr))
 			return false;
 	} else
 		return false;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 022f203..b033386 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -28,6 +28,7 @@
  *
  */
 
+#include "lab/lab.h"
 #include "lab/labfun.h"
 #include "lab/parsefun.h"
 #include "lab/interface.h"
@@ -159,7 +160,7 @@ void showCombination(const char *filename) {
 /*****************************************************************************/
 /* Changes the combination number of one of the slots                        */
 /*****************************************************************************/
-static void changeCombination(LargeSet Conditions, uint16 number) {
+static void changeCombination(uint16 number) {
 	struct Image display;
 	uint16 counter, combnum;
 	bool unlocked = true;
@@ -199,9 +200,9 @@ static void changeCombination(LargeSet Conditions, uint16 number) {
 		unlocked = (combination[counter] == solution[counter]) && unlocked;
 
 	if (unlocked)
-		g_engine->_conditions->inclElement(COMBINATIONUNLOCKED);
+		g_lab->_conditions->inclElement(COMBINATIONUNLOCKED);
 	else
-		g_engine->_conditions->exclElement(COMBINATIONUNLOCKED);
+		g_lab->_conditions->exclElement(COMBINATIONUNLOCKED);
 
 #if !defined(DOSCODE)
 	ungetVGABaseAddr();
@@ -215,7 +216,7 @@ static void changeCombination(LargeSet Conditions, uint16 number) {
 /*****************************************************************************/
 /* Processes mouse clicks and changes the combination.                       */
 /*****************************************************************************/
-void mouseCombination(LargeSet Conditions, uint16 x, uint16 y) {
+void mouseCombination(uint16 x, uint16 y) {
 	uint16 number;
 
 	x = VGAUnScaleX(x);
@@ -237,7 +238,7 @@ void mouseCombination(LargeSet Conditions, uint16 x, uint16 y) {
 		else
 			return;
 
-		changeCombination(Conditions, number);
+		changeCombination(number);
 	}
 }
 
@@ -411,7 +412,7 @@ static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 /*****************************************************************************/
 /* Changes the combination number of one of the slots                        */
 /*****************************************************************************/
-static void changeTile(LargeSet Conditions, uint16 col, uint16 row) {
+static void changeTile(uint16 col, uint16 row) {
 	bool check;
 	int16 scrolltype = -1;
 
@@ -479,7 +480,7 @@ static void changeTile(LargeSet Conditions, uint16 col, uint16 row) {
 		}
 
 		if (check) {
-			g_engine->_conditions->inclElement(BRICKOPEN);  /* unlocked combination */
+			g_lab->_conditions->inclElement(BRICKOPEN);  /* unlocked combination */
 			DoBlack = true;
 			check = readPict("p:Up/BDOpen", true);
 		}
@@ -493,7 +494,7 @@ static void changeTile(LargeSet Conditions, uint16 col, uint16 row) {
 /*****************************************************************************/
 /* Processes mouse clicks and changes the combination.                       */
 /*****************************************************************************/
-void mouseTile(LargeSet Conditions, uint16 x, uint16 y) {
+void mouseTile(uint16 x, uint16 y) {
 	x = VGAUnScaleX(x);
 	y = VGAUnScaleY(y);
 
@@ -504,7 +505,7 @@ void mouseTile(LargeSet Conditions, uint16 x, uint16 y) {
 	y = (y -  26) / 25;
 
 	if ((x < 4) && (y < 4))
-		changeTile(Conditions, x, y);
+		changeTile(x, y);
 }
 
 
@@ -641,7 +642,7 @@ static struct Gadget ForwardG, CancelG, BackG;
 /*****************************************************************************/
 /* Loads in the data for the journal.                                        */
 /*****************************************************************************/
-static bool loadJournalData(LargeSet Conditions) {
+static bool loadJournalData() {
 	byte **buffer;
 	char filename[20];
 	struct Gadget *TopGadget = &BackG;
@@ -658,10 +659,10 @@ static bool loadJournalData(LargeSet Conditions) {
 	g_music->checkMusic();
 
 	strcpy(filename, "Lab:Rooms/j0");
-	bridge = g_engine->_conditions->in(BRIDGE0) || g_engine->_conditions->in(BRIDGE1);
-	dirty  = g_engine->_conditions->in(DIRTY);
-	news   = !g_engine->_conditions->in(NONEWS);
-	clean  = !g_engine->_conditions->in(NOCLEAN);
+	bridge = g_lab->_conditions->in(BRIDGE0) || g_lab->_conditions->in(BRIDGE1);
+	dirty  = g_lab->_conditions->in(DIRTY);
+	news   = !g_lab->_conditions->in(NONEWS);
+	clean  = !g_lab->_conditions->in(NOCLEAN);
 
 	if (bridge && clean && news)
 		filename[11] = '8';
@@ -918,7 +919,7 @@ static void journalCleanUp(void) {
 /*****************************************************************************/
 /* Does the journal processing.                                              */
 /*****************************************************************************/
-void doJournal(LargeSet Conditions) {
+void doJournal() {
 	resetBuffer();
 	blackAllScreen();
 
@@ -936,7 +937,7 @@ void doJournal(LargeSet Conditions) {
 	ScreenImage.ImageData = getVGABaseAddr();
 
 	g_music->checkMusic();
-	loadJournalData(Conditions);
+	loadJournalData();
 
 	drawJournal(0, true);
 
@@ -1338,7 +1339,7 @@ static bool doSaveGame() {
 
 	sprintf(DrivePath, "%s%s%d", g_SaveGamePath, g_PathSeperator, g_CurSaveGameNumber);
 
-	isok = saveFloppy(DrivePath, RoomNum, Direction, Inventory[QUARTERNUM].Many, Conditions, RoomsFound, g_CurSaveGameNumber, device);
+	isok = saveFloppy(DrivePath, RoomNum, Direction, Inventory[QUARTERNUM].Many, g_CurSaveGameNumber, device);
 	g_music->resetMusic();
 
 	if (isok)
@@ -1356,7 +1357,7 @@ static bool doLoadGame() {
 
 	snprintf(drivePath, 260, "%s%s%d", g_SaveGamePath, g_PathSeperator, g_CurSaveGameNumber);
 
-	isok = readFloppy(drivePath, &RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), Conditions, RoomsFound, g_CurSaveGameNumber, device);
+	isok = readFloppy(drivePath, &RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), g_CurSaveGameNumber, device);
 	g_music->resetMusic();
 
 	if (isok)
@@ -1877,9 +1878,9 @@ bool saveRestoreGame(void) {
 			eatMessages();
 
 			if (issave)
-				isok = saveFloppy(DrivePath, RoomNum, Direction, Inventory[QUARTERNUM].Many, Conditions, RoomsFound, filenum, device);
+				isok = saveFloppy(DrivePath, RoomNum, Direction, Inventory[QUARTERNUM].Many, filenum, device);
 			else {
-				isok = readFloppy(DrivePath, &RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), Conditions, RoomsFound, filenum, device);
+				isok = readFloppy(DrivePath, &RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), filenum, device);
 				g_music->resetMusic();
 			}
 		}


Commit: 90f0a8650f3b01fe250b4ceb8dbd66614f8c2699
    https://github.com/scummvm/scummvm/commit/90f0a8650f3b01fe250b4ceb8dbd66614f8c2699
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Fix line endings

Changed paths:
    engines/lab/modernsavegame.cpp
    engines/lab/modernsavegame.h
    engines/lab/vga.cpp



diff --git a/engines/lab/modernsavegame.cpp b/engines/lab/modernsavegame.cpp
index 71eedb9..334e4c5 100644
--- a/engines/lab/modernsavegame.cpp
+++ b/engines/lab/modernsavegame.cpp
@@ -1,124 +1,124 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the 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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "lab/stddefines.h"
-#include "lab/labfun.h"
-#include "lab/modernsavegame.h"
-
-namespace Lab {
-
-byte g_SaveGameImage[SAVED_IMAGE_SIZE]; // 640 x 358
-
-char g_SaveGamePath[512];
-char g_PathSeperator[4];
-
-#define SAVEVERSION         "LBS3"
-
-int getSaveGameList(struct SaveGameInfo *info, int maxNum) {
-	warning("STUB: getSaveGameList");
-
-	return 0;
-
-#if 0
-	char path[512];
-	struct stat statb;
-	int total = 0;
-	int i;
-
-	for (i = 0; i < maxNum; i++) {
-		checkMusic();
-
-		sprintf(path, "%s%s%d", g_SaveGamePath, g_PathSeperator, i);
-		statb.st_size = 0;
-		stat(path, &statb);
-
-		if (statb.st_size > 0) {
-			struct tm *create_date;
-			FILE *fh;
-
-			create_date = localtime(&statb.st_ctime);
-			strcpy(info->SaveGameDate, asctime(create_date));
-
-			fh = fopen(path, "rb");
-
-			if (fh != NULL) {
-				char temp[5];
-				unsigned short t;
-				int toSeek;
-
-				info->Index = i;
-
-				fread(temp, 1, 4, fh);
-				temp[4] = 0;
-
-				fread(&t, 1, 2, fh);
-				info->RoomNumber = swapUShort(t);
-				fread(&t, 1, 2, fh);
-				info->Direction = swapUShort(t);
-
-				toSeek = 2 + Conditions->lastElement / 8 + g_lab->_roomsFound->_lastElement / 8 + 6 + 2 * 16;
-				fseek(fh, toSeek, SEEK_CUR);
-
-				info->SaveGameImage = NULL;
-
-				if (strcmp(temp, SAVEVERSION) == 0) {
-					info->SaveGameImage = malloc(SAVED_IMAGE_SIZE);
-
-					if (info->SaveGameImage != NULL)
-						fread(info->SaveGameImage, 1, SAVED_IMAGE_SIZE, fh);
-				} else {
-					info->SaveGameImage = malloc(SAVED_IMAGE_SIZE);
-
-					if (info->SaveGameImage != NULL)
-						memset(info->SaveGameImage, 0, SAVED_IMAGE_SIZE);
-				}
-
-				fclose(fh);
-
-				info++;
-				total++;
-			}
-		}
-	}
-
-	return total;
-#endif
-}
-
-void freeSaveGameList(struct SaveGameInfo *info, int count) {
-	int i;
-
-	for (i = 0; i < count; i++) {
-		free(info->SaveGameImage);
-		++info;
-	}
-}
-
-} // End of namespace Lab
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/stddefines.h"
+#include "lab/labfun.h"
+#include "lab/modernsavegame.h"
+
+namespace Lab {
+
+byte g_SaveGameImage[SAVED_IMAGE_SIZE]; // 640 x 358
+
+char g_SaveGamePath[512];
+char g_PathSeperator[4];
+
+#define SAVEVERSION         "LBS3"
+
+int getSaveGameList(struct SaveGameInfo *info, int maxNum) {
+	warning("STUB: getSaveGameList");
+
+	return 0;
+
+#if 0
+	char path[512];
+	struct stat statb;
+	int total = 0;
+	int i;
+
+	for (i = 0; i < maxNum; i++) {
+		checkMusic();
+
+		sprintf(path, "%s%s%d", g_SaveGamePath, g_PathSeperator, i);
+		statb.st_size = 0;
+		stat(path, &statb);
+
+		if (statb.st_size > 0) {
+			struct tm *create_date;
+			FILE *fh;
+
+			create_date = localtime(&statb.st_ctime);
+			strcpy(info->SaveGameDate, asctime(create_date));
+
+			fh = fopen(path, "rb");
+
+			if (fh != NULL) {
+				char temp[5];
+				unsigned short t;
+				int toSeek;
+
+				info->Index = i;
+
+				fread(temp, 1, 4, fh);
+				temp[4] = 0;
+
+				fread(&t, 1, 2, fh);
+				info->RoomNumber = swapUShort(t);
+				fread(&t, 1, 2, fh);
+				info->Direction = swapUShort(t);
+
+				toSeek = 2 + Conditions->lastElement / 8 + g_lab->_roomsFound->_lastElement / 8 + 6 + 2 * 16;
+				fseek(fh, toSeek, SEEK_CUR);
+
+				info->SaveGameImage = NULL;
+
+				if (strcmp(temp, SAVEVERSION) == 0) {
+					info->SaveGameImage = malloc(SAVED_IMAGE_SIZE);
+
+					if (info->SaveGameImage != NULL)
+						fread(info->SaveGameImage, 1, SAVED_IMAGE_SIZE, fh);
+				} else {
+					info->SaveGameImage = malloc(SAVED_IMAGE_SIZE);
+
+					if (info->SaveGameImage != NULL)
+						memset(info->SaveGameImage, 0, SAVED_IMAGE_SIZE);
+				}
+
+				fclose(fh);
+
+				info++;
+				total++;
+			}
+		}
+	}
+
+	return total;
+#endif
+}
+
+void freeSaveGameList(struct SaveGameInfo *info, int count) {
+	int i;
+
+	for (i = 0; i < count; i++) {
+		free(info->SaveGameImage);
+		++info;
+	}
+}
+
+} // End of namespace Lab
diff --git a/engines/lab/modernsavegame.h b/engines/lab/modernsavegame.h
index 160f3f9..bbee420 100644
--- a/engines/lab/modernsavegame.h
+++ b/engines/lab/modernsavegame.h
@@ -1,55 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#ifndef LAB_MODERNGAMESAVE_H
-#define LAB_MODERNGAMESAVE_H
-
-namespace Lab {
-
-#define MAX_SAVED_GAMES 15
-#define SAVED_IMAGE_SIZE (128 * 72)
-
-extern byte g_SaveGameImage[SAVED_IMAGE_SIZE]; // 640 x 358
-
-struct SaveGameInfo {
-	unsigned short Index;
-	unsigned short RoomNumber;
-	unsigned short Direction;
-	byte *SaveGameImage;
-	char SaveGameDate[128];
-};
-
-int getSaveGameList(struct SaveGameInfo *info, int maxNum);
-void freeSaveGameList(struct SaveGameInfo *info, int count);
-
-} // End of namespace Lab
-
-#endif /* LAB_MODERNGAMESAVE_H */
-
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#ifndef LAB_MODERNGAMESAVE_H
+#define LAB_MODERNGAMESAVE_H
+
+namespace Lab {
+
+#define MAX_SAVED_GAMES 15
+#define SAVED_IMAGE_SIZE (128 * 72)
+
+extern byte g_SaveGameImage[SAVED_IMAGE_SIZE]; // 640 x 358
+
+struct SaveGameInfo {
+	unsigned short Index;
+	unsigned short RoomNumber;
+	unsigned short Direction;
+	byte *SaveGameImage;
+	char SaveGameDate[128];
+};
+
+int getSaveGameList(struct SaveGameInfo *info, int maxNum);
+void freeSaveGameList(struct SaveGameInfo *info, int count);
+
+} // End of namespace Lab
+
+#endif /* LAB_MODERNGAMESAVE_H */
+
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 2e5bd9b..403fe60 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -1,1205 +1,1205 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the 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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "lab/vga.h"
-#include "lab/stddefines.h"
-#include "lab/mouse.h"
-
-#include "graphics/palette.h"
-
-#include "common/events.h"
-
-namespace Lab {
-
-//static uint16 NotInRefresh = 0;
-
-uint32 VGAScreenWidth = 320UL,
-              VGAScreenHeight = 200UL,
-              VGAPages        = 1UL,
-              VGABytesPerPage = 65536UL;
-
-byte *VGABASEADDRESS = 0;
-
-byte *g_DisplayBuffer = 0;
-byte *g_Pixels = 0;
-
-int g_ScreenWasLocked = 0;
-int g_IgnoreUpdateDisplay = 0;
-int g_LastWaitTOFTicks = 0;
-
-int g_MouseX = 0;
-int g_MouseY = 0;
-
-uint16 g_NextKeyIn = 0;
-uint16 g_KeyBuf[64];
-uint16 g_NextKeyOut = 0;
-bool g_MouseAtEdge = false;
-
-/*****************************************************************************/
-/* Sets the display mode.                                                    */
-/*****************************************************************************/
-void setMode(char mode) {
-	// There are no modes for SDL.
-}
-
-/*****************************************************************************/
-/* Sets up either a low-res or a high-res 256 color screen.                  */
-/*****************************************************************************/
-bool createScreen(bool HiRes) {
-	//VGABASEADDRESS  = (unsigned long)malloc(640 * 480);
-	VGABASEADDRESS  = 0;
-	VGAScreenWidth  = 640;
-	VGAScreenHeight = 480;
-	VGAPages        = 1;
-	VGABytesPerPage = 640 * 480;
-
-	g_DisplayBuffer = (byte *)malloc(VGABytesPerPage);
-	g_Pixels = (byte *)calloc(VGABytesPerPage, 4);
-
-	return true;
-}
-
-
-
-/*****************************************************************************/
-/* Sets the current page on the VGA card.                                    */
-/*****************************************************************************/
-void setPage(uint16 PageNum) {
-	// PageNum should always calculated out to zero for SDL.
-	assert(PageNum == 0);
-}
-
-
-
-void VGAStorePage(void) {
-	// does nothing in SDL
-}
-
-void VGARestorePage(void) {
-	// does nothing in SDL
-}
-
-void changeVolume(int delta) {
-	warning("STUB: changeVolume()");
-}
-
-uint16 WSDL_GetNextChar() {
-	uint16 c = 0;
-
-	WSDL_ProcessInput(0);
-	if (g_NextKeyIn != g_NextKeyOut) {
-		c = g_KeyBuf[g_NextKeyOut];
-		g_NextKeyOut = ((((unsigned int)((g_NextKeyOut + 1) >> 31) >> 26) + (byte)g_NextKeyOut + 1) & 0x3F)
-                 - ((unsigned int)((g_NextKeyOut + 1) >> 31) >> 26);
-  	}
-
-	return c;
-}
-
-bool WSDL_HasNextChar() {
-	WSDL_ProcessInput(0);
-	return g_NextKeyIn != g_NextKeyOut;
-}
-
-void WSDL_ProcessInput(bool can_delay) {
-	int n;
-	int lastMouseAtEdge;
-	int flags = 0;
-
-	Common::Event event;
-
-	if (1 /*!g_IgnoreProcessInput*/) {
-		while (g_system->getEventManager()->pollEvent(event)) {
-			switch (event.type) {
-			case Common::EVENT_RBUTTONDOWN:
-				flags |= 8;
-				mouse_handler(flags, g_MouseX, g_MouseY);
-				break;
-
-			case Common::EVENT_LBUTTONDOWN:
-				flags |= 2;
-				mouse_handler(flags, g_MouseX, g_MouseY);
-				break;
-
-			case Common::EVENT_MOUSEMOVE:
-				lastMouseAtEdge = g_MouseAtEdge;
-				g_MouseAtEdge = false;
-				g_MouseX = event.mouse.x;
-				if (event.mouse.x <= 0) {
-					g_MouseX = 0;
-					g_MouseAtEdge = true;
-				}
-				if (g_MouseX > 639) {
-					g_MouseX = 640;
-					g_MouseAtEdge = true;
-				}
-
-				g_MouseY = event.mouse.y;
-				if (event.mouse.y <= 0) {
-					g_MouseY = 0;
-					g_MouseAtEdge = true;
-				}
-				if (g_MouseY > 479) {
-					g_MouseY = 480;
-					g_MouseAtEdge = true;
-				}
-
-				if (!lastMouseAtEdge || !g_MouseAtEdge)
-					mouse_handler(1, g_MouseX, g_MouseY);
-
-				break;
-
-			case Common::EVENT_KEYDOWN:
-				switch (event.kbd.keycode) {
-				case Common::KEYCODE_LEFTBRACKET:
-					changeVolume(-1);
-					break;
-
-				case Common::KEYCODE_RIGHTBRACKET:
-					changeVolume(1);
-					break;
-
-				case Common::KEYCODE_z:
-					//saveSettings();
-					break;
-
-				default:
-					n = ((((unsigned int)((g_NextKeyIn + 1) >> 31) >> 26) + (byte)g_NextKeyIn + 1) & 0x3F)
-					- ((unsigned int)((g_NextKeyIn + 1) >> 31) >> 26);
-					if (n != g_NextKeyOut) {
-						g_KeyBuf[g_NextKeyIn] = event.kbd.keycode;
-						g_NextKeyIn = n;
-					}
-				}
-				break;
-
-			case Common::EVENT_QUIT:
-			case Common::EVENT_RTL:
-			default:
-				break;
-			}
-
-			g_system->copyRectToScreen(g_DisplayBuffer, VGAScreenWidth, 0, 0, VGAScreenWidth, VGAScreenHeight);
-			g_system->updateScreen();
-		}
-	}
-
-	if (can_delay)
-		g_system->delayMillis(10);
-}
-
-void WSDL_GetMousePos(int *x, int *y) {
-	WSDL_ProcessInput(0);
-
-	*x = g_MouseX;
-	*y = g_MouseY;
-}
-
-
-void waitTOF() {
-	int untilOutOfRefresh = 1;
-
-  	if (g_ScreenWasLocked || untilOutOfRefresh) {
-		g_system->copyRectToScreen(g_DisplayBuffer, VGAScreenWidth, 0, 0, VGAScreenWidth, VGAScreenHeight);
-		g_system->updateScreen();
-  	}
-
-  	g_ScreenWasLocked = 0;
-  	WSDL_ProcessInput(0);
-
-  	uint32 now;
-
-  	for (now = g_system->getMillis(); now - g_LastWaitTOFTicks <= 0xF; now = g_system->getMillis() )
-  		g_system->delayMillis(g_LastWaitTOFTicks - now + 17);
-
-  	g_LastWaitTOFTicks = now;
-}
-
-void WSDL_SetColors(byte *buf, uint16 first, uint16 numreg, uint16 slow) {
-	byte tmp[256 * 3];
-
-	for (int i = 0; i < 256 * 3; i++) {
-		tmp[i] = buf[i] * 4;
-	}
-
-	g_system->getPaletteManager()->setPalette(tmp, first, numreg);
-
-	if (slow)
-    	waitTOF();
-}
-
-static byte curvgapal[256 * 3];
-
-/*****************************************************************************/
-/* Writes any number of the 256 color registers.                             */
-/* first:    the number of the first color register to write.                */
-/* numreg:   the number of registers to write                                */
-/* buf:      a char pointer which contains the selected color registers.     */
-/*           Each value representing a color register occupies 3 bytes in    */
-/*           the array.  The order is red, green then blue.  The first byte  */
-/*           in the array is the red component of the first element selected.*/
-/*           The length of the buffer is 3 times the number of registers     */
-/*           selected.                                                       */
-/*****************************************************************************/
-void writeColorRegs(byte *buf, uint16 first, uint16 numreg) {
-	WSDL_SetColors(buf, first, numreg, 0);
-	memcpy(&(curvgapal[first * 3]), buf, numreg * 3);
-}
-
-void writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg) {
-	WSDL_SetColors(buf, first, numreg, 1);
-	memcpy(&(curvgapal[first * 3]), buf, numreg * 3);
-}
-
-/*****************************************************************************/
-/* Sets one of the 256 (0..255) color registers.  buf is a char pointer,     */
-/* the first character in the string is the red value, then green, then      */
-/* blue.  Each color value is a 6 bit value.                                 */
-/*****************************************************************************/
-void writeColorReg(byte *buf, uint16 regnum) {
-	writeColorRegs(buf, regnum, 1);
-}
-
-void VGASetPal(void *cmap, uint16 numcolors) {
-	if (memcmp(cmap, curvgapal, numcolors * 3) != 0)
-		writeColorRegs((byte *)cmap, 0, numcolors);
-}
-
-byte *WSDL_LockVideo() {
-	g_ScreenWasLocked = 1;
-
-	return g_DisplayBuffer;
-}
-
-void WSDL_UnlockVideo() {
-}
-
-void WSDL_IgnoreUpdateDisplay(int state) {
-	g_IgnoreUpdateDisplay = state;
-}
-
-void WSDL_UpdateScreen() {
-	WSDL_UnlockVideo();
-
-	if (g_ScreenWasLocked && !g_IgnoreUpdateDisplay) {
-		g_system->copyRectToScreen(g_DisplayBuffer, VGAScreenWidth, 0, 0, VGAScreenWidth, VGAScreenHeight);
-  		g_system->updateScreen();
-  	}
-
-	g_ScreenWasLocked = 0;
-	WSDL_ProcessInput(0);
-}
-
-/*****************************************************************************/
-/* Returns the base address of the current VGA display.                      */
-/*****************************************************************************/
-byte *getVGABaseAddr(void) {
-	if (VGABASEADDRESS)
-		return VGABASEADDRESS;
-
-	return WSDL_LockVideo();
-}
-
-void ungetVGABaseAddr() {
-	if (!VGABASEADDRESS)
-		WSDL_UnlockVideo();
-}
-
-/*****************************************************************************/
-/* Gets information about the current display.                               */
-/*****************************************************************************/
-void getMode(uint16 *Mode) {
-	// Only one mode in SDL.
-}
-
-/*****************************************************************************/
-/* Draws an image to the screen.                                             */
-/*****************************************************************************/
-void drawImage(struct Image *Im, uint16 x, uint16 y) {
-#if !defined(DOSCODE)
-	int sx, sy, dx, dy, w, h;
-
-	sx = 0;
-	sy = 0;
-	dx = x;
-	dy = y;
-	w = Im->Width;
-	h = Im->Height;
-
-	if (dx < 0) {
-		sx -= dx;
-		w += dx;
-		dx = 0;
-	}
-
-	if (dy < 0) {
-		sy -= dy;
-		w += dy;
-		dy = 0;
-	}
-
-	if ((uint)(dx + w) > VGAScreenWidth)
-		w = VGAScreenWidth - dx;
-
-	if ((uint)(dy + h) > VGAScreenHeight)
-		h = VGAScreenHeight - dy;
-
-	if (w > 0 && h > 0) {
-		byte *s = Im->ImageData + sy * Im->Width + sx;
-		byte *d = getVGABaseAddr() + dy * VGAScreenWidth + dx;
-
-		while (h-- > 0) {
-			memcpy(d, s, w);
-			s += Im->Width;
-			d += VGAScreenWidth;
-		}
-
-		ungetVGABaseAddr();
-	}
-
-#else
-	uint32  RealOffset,
-	         SegmentOffset,
-	         LeftInSegment;
-	char *video,
-	              *curline,
-	              *imdata = Im->ImageData;
-	uint16 counterx,
-	         countery = 0,
-	         numwholelines,
-	         numpartiallines,
-	         curpage;
-
-	while (countery < Im->Height) {
-		RealOffset = (VGAScreenWidth * (y + countery)) + x;
-		curpage    = RealOffset / VGABytesPerPage;
-		SegmentOffset = RealOffset - (curpage * VGABytesPerPage);
-		LeftInSegment = VGABytesPerPage - SegmentOffset;
-		setPage(curpage);
-		video = (char *)(((int32)(VGABASEADDRESS)) + SegmentOffset);
-
-		numwholelines = LeftInSegment / VGAScreenWidth;
-		numpartiallines = 0;
-		counterx      = LeftInSegment - (numwholelines * VGAScreenWidth);
-
-		if (counterx >= Im->Width)
-			numwholelines++;
-		else
-			numpartiallines = 1;
-
-		while (numwholelines && (countery < Im->Height)) {
-			curline = video;
-
-			for (counterx = 0; counterx < Im->Width; counterx++) {
-				*video = *imdata;
-				video++;
-				imdata++;
-			}
-
-			video = curline;
-			video += VGAScreenWidth;
-			countery ++;
-			numwholelines --;
-			LeftInSegment -= VGAScreenWidth;
-		}
-
-		if (numpartiallines && (countery < Im->Height)) {
-			countery ++;
-			curline = video;
-
-			for (counterx = 0; counterx < Im->Width; counterx++) {
-				if (LeftInSegment == 0L) {
-					setPage(curpage + 1);
-					LeftInSegment = VGABytesPerPage;
-					video = (char *)(VGABASEADDRESS);
-				}
-
-				*video = *imdata;
-				video++;
-				imdata++;
-				LeftInSegment--;
-			}
-		}
-	}
-
-#endif
-}
-
-
-
-
-/*****************************************************************************/
-/* Draws an image to the screen.                                             */
-/*****************************************************************************/
-void drawMaskImage(struct Image *Im, uint16 x, uint16 y) {
-#if !defined(DOSCODE)
-	int sx, sy, dx, dy, w, h;
-
-	sx = 0;
-	sy = 0;
-	dx = x;
-	dy = y;
-	w = Im->Width;
-	h = Im->Height;
-
-	if (dx < 0) {
-		sx -= dx;
-		w += dx;
-		dx = 0;
-	}
-
-	if (dy < 0) {
-		sy -= dy;
-		w += dy;
-		dy = 0;
-	}
-
-	if ((uint)(dx + w) > VGAScreenWidth)
-		w = VGAScreenWidth - dx;
-
-	if ((uint)(dy + h) > VGAScreenHeight)
-		h = VGAScreenHeight - dy;
-
-	if (w > 0 && h > 0) {
-		byte *s = Im->ImageData + sy * Im->Width + sx;
-		byte *d = getVGABaseAddr() + dy * VGAScreenWidth + dx;
-
-		while (h-- > 0) {
-			byte *ss = s;
-			byte *dd = d;
-			int ww = w;
-
-			while (ww-- > 0) {
-				byte c = *ss++;
-
-				if (c) *dd++ = c - 1;
-				else dd++;
-			}
-
-			s += Im->Width;
-			d += VGAScreenWidth;
-		}
-
-		ungetVGABaseAddr();
-	}
-
-#else
-	uint32  RealOffset,
-	         SegmentOffset,
-	         LeftInSegment;
-	char *video,
-	              *curline,
-	              *imdata = Im->ImageData;
-	uint16 counterx,
-	         countery = 0,
-	         numwholelines,
-	         numpartiallines,
-	         curpage;
-
-	while (countery < Im->Height) {
-		RealOffset = (VGAScreenWidth * (y + countery)) + x;
-		curpage    = RealOffset / VGABytesPerPage;
-		SegmentOffset = RealOffset - (curpage * VGABytesPerPage);
-		LeftInSegment = VGABytesPerPage - SegmentOffset;
-		setPage(curpage);
-		video = (char *)(((int32)(VGABASEADDRESS)) + SegmentOffset);
-
-		numwholelines = LeftInSegment / VGAScreenWidth;
-		numpartiallines = 0;
-		counterx      = LeftInSegment - (numwholelines * VGAScreenWidth);
-
-		if (counterx >= Im->Width)
-			numwholelines++;
-		else
-			numpartiallines = 1;
-
-		while (numwholelines && (countery < Im->Height)) {
-			curline = video;
-
-			for (counterx = 0; counterx < Im->Width; counterx++) {
-				if (*imdata)
-					*video = *imdata - 1;
-
-				video++;
-				imdata++;
-			}
-
-			video = curline;
-			video += VGAScreenWidth;
-			countery ++;
-			numwholelines --;
-			LeftInSegment -= VGAScreenWidth;
-		}
-
-		if (numpartiallines && (countery < Im->Height)) {
-			countery ++;
-			curline = video;
-
-			for (counterx = 0; counterx < Im->Width; counterx++) {
-				if (LeftInSegment == 0L) {
-					setPage(curpage + 1);
-					LeftInSegment = VGABytesPerPage;
-					video = (char *)(VGABASEADDRESS);
-				}
-
-				if (*imdata)
-					*video = *imdata - 1;
-
-				video++;
-				imdata++;
-				LeftInSegment--;
-			}
-		}
-	}
-
-#endif
-}
-
-
-
-
-/*****************************************************************************/
-/* Reads an image from the screen.                                           */
-/*****************************************************************************/
-void readScreenImage(struct Image *Im, uint16 x, uint16 y) {
-#if !defined(DOSCODE)
-	int sx, sy, dx, dy, w, h;
-
-	sx = 0;
-	sy = 0;
-	dx = x;
-	dy = y;
-	w = Im->Width;
-	h = Im->Height;
-
-	if (dx < 0) {
-		sx -= dx;
-		w += dx;
-		dx = 0;
-	}
-
-	if (dy < 0) {
-		sy -= dy;
-		w += dy;
-		dy = 0;
-	}
-
-	if ((uint)(dx + w) > VGAScreenWidth)
-		w = VGAScreenWidth - dx;
-
-	if ((uint)(dy + h) > VGAScreenHeight)
-		h = VGAScreenHeight - dy;
-
-	if (w > 0 && h > 0) {
-		byte *s = Im->ImageData + sy * Im->Width + sx;
-		byte *d = getVGABaseAddr() + dy * VGAScreenWidth + dx;
-
-		while (h-- > 0) {
-			memcpy(s, d, w);
-			s += Im->Width;
-			d += VGAScreenWidth;
-		}
-
-		ungetVGABaseAddr();
-	}
-
-#else
-	uint32  RealOffset,
-	         SegmentOffset,
-	         LeftInSegment;
-	char *video,
-	              *curline,
-	              *imdata = Im->ImageData;
-	uint16 counterx,
-	         countery = 0,
-	         numwholelines,
-	         numpartiallines,
-	         curpage;
-
-	while (countery < Im->Height) {
-		RealOffset = (VGAScreenWidth * (y + countery)) + x;
-		curpage    = RealOffset / VGABytesPerPage;
-		SegmentOffset = RealOffset - (curpage * VGABytesPerPage);
-		LeftInSegment = VGABytesPerPage - SegmentOffset;
-		setPage(curpage);
-		video = (char *)(((int32)(VGABASEADDRESS)) + SegmentOffset);
-
-		numwholelines = LeftInSegment / VGAScreenWidth;
-		numpartiallines = 0;
-		counterx      = LeftInSegment - (numwholelines * VGAScreenWidth);
-
-		if (counterx >= Im->Width)
-			numwholelines++;
-		else
-			numpartiallines = 1;
-
-		while (numwholelines && (countery < Im->Height)) {
-			curline = video;
-
-			for (counterx = 0; counterx < Im->Width; counterx++) {
-				*imdata = *video;
-				video++;
-				imdata++;
-			}
-
-			video = curline;
-			video += VGAScreenWidth;
-			countery ++;
-			numwholelines --;
-			LeftInSegment -= VGAScreenWidth;
-		}
-
-		if (numpartiallines && (countery < Im->Height)) {
-			countery ++;
-			curline = video;
-
-			for (counterx = 0; counterx < Im->Width; counterx++) {
-				if (LeftInSegment == 0L) {
-					setPage(curpage + 1);
-					LeftInSegment = VGABytesPerPage;
-					video = (char *)(VGABASEADDRESS);
-				}
-
-				*imdata = *video;
-				video++;
-				imdata++;
-				LeftInSegment--;
-			}
-		}
-	}
-
-#endif
-}
-
-
-
-
-/*****************************************************************************/
-/* Blits a piece of one image to another.                                    */
-/* NOTE: for our purposes, assumes that ImDest is to be in VGA memory.       */
-/*****************************************************************************/
-void bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest,
-					uint16 xd, uint16 yd, uint16 width, uint16 height) {
-#if !defined(DOSCODE)
-	// I think the old code assumed that the source image data was valid for the given box.
-	// I will proceed on that assumption.
-	int sx, sy, dx, dy, w, h;
-
-	sx = xs;
-	sy = ys;
-	dx = xd;
-	dy = yd;
-	w = width;
-	h = height;
-
-	if (dx < 0) {
-		sx -= dx;
-		w += dx;
-		dx = 0;
-	}
-
-	if (dy < 0) {
-		sy -= dy;
-		w += dy;
-		dy = 0;
-	}
-
-	if (dx + w > ImDest->Width) w = ImDest->Width - dx;
-
-	if (dy + h > ImDest->Height) h = ImDest->Height - dy;
-
-	if (w > 0 && h > 0) {
-		byte *s = ImSource->ImageData + sy * ImSource->Width + sx;
-		byte *d = ImDest->ImageData + dy * ImDest->Width + dx;
-
-		while (h-- > 0) {
-			memcpy(d, s, w);
-			s += ImSource->Width;
-			d += ImDest->Width;
-		}
-	}
-
-#else
-	uint32  RealOffset,
-	         SegmentOffset,
-	         LeftInSegment;
-	char *video,
-	              *curdestline,
-	              *cursourceline = ImSource->ImageData,
-	               *imdata;
-	uint16 counterx,
-	         countery = 0,
-	         numwholelines,
-	         numpartiallines,
-	         curpage;
-
-	cursourceline += (((int32) ys) * ImSource->Width) + xs;
-	imdata        = cursourceline;
-
-	while (countery < height) {
-		RealOffset = (ImDest->Width * (yd + countery)) + xd;
-		curpage    = RealOffset / VGABytesPerPage;
-		SegmentOffset = RealOffset - (curpage * VGABytesPerPage);
-		LeftInSegment = VGABytesPerPage - SegmentOffset;
-		setPage(curpage);
-
-		video = (char *)(((int32)(ImDest->ImageData)) + SegmentOffset);
-
-		numwholelines = LeftInSegment / ImDest->Width;
-		numpartiallines = 0;
-		counterx      = LeftInSegment - (numwholelines * ImDest->Width);
-
-		if (counterx >= width)
-			numwholelines++;
-		else
-			numpartiallines = 1;
-
-		while (numwholelines && (countery < height)) {
-			curdestline = video;
-			cursourceline = imdata;
-
-			for (counterx = 0; counterx < width; counterx++) {
-				*video = *imdata;
-				video++;
-				imdata++;
-			}
-
-			video = curdestline;
-			video += ImDest->Width;
-			imdata = cursourceline;
-			imdata += ImSource->Width;
-
-			countery ++;
-			numwholelines --;
-			LeftInSegment -= ImDest->Width;
-		}
-
-		if (numpartiallines && (countery < height)) {
-			countery ++;
-			curdestline = video;
-			cursourceline = imdata;
-
-			for (counterx = 0; counterx < width; counterx++) {
-				if (LeftInSegment == 0L) {
-					setPage(curpage + 1);
-					LeftInSegment = VGABytesPerPage;
-					video = ImDest->ImageData;
-				}
-
-				*video = *imdata;
-				video++;
-				imdata++;
-				LeftInSegment--;
-			}
-
-			video = curdestline;
-			video += ImDest->Width;
-			imdata = cursourceline;
-			imdata += ImSource->Width;
-		}
-	}
-
-#endif
-}
-
-
-byte *TempScrollData;
-
-
-/*****************************************************************************/
-/* Scrolls the display in the x direction by blitting.                       */
-/* The TempScrollData variable must be initialized to some memory, or this   */
-/* function will fail.                                                       */
-/*****************************************************************************/
-void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	struct Image Im;
-	uint16 temp;
-
-	Im.ImageData = TempScrollData;
-
-	if (x1 > x2) {
-		temp = x2;
-		x2 = x1;
-		x1 = temp;
-	}
-
-	if (y1 > y2) {
-		temp = y2;
-		y2 = y1;
-		y1 = temp;
-	}
-
-	if (dx > 0) {
-		Im.Width = x2 - x1 + 1 - dx;
-		Im.Height = y2 - y1 + 1;
-
-		readScreenImage(&Im, x1, y1);
-		drawImage(&Im, x1 + dx, y1);
-
-		setAPen(0);
-		rectFill(x1, y1, x1 + dx - 1, y2);
-	} else if (dx < 0) {
-		Im.Width = x2 - x1 + 1 + dx;
-		Im.Height = y2 - y1 + 1;
-
-		readScreenImage(&Im, x1 - dx, y1);
-		drawImage(&Im, x1, y1);
-
-		setAPen(0);
-		rectFill(x2 + dx + 1, y1, x2, y2);
-	}
-}
-
-
-
-
-
-/*****************************************************************************/
-/* Scrolls the display in the y direction by blitting.                       */
-/*****************************************************************************/
-void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	struct Image Im;
-	uint16 temp;
-
-	Im.ImageData = TempScrollData;
-
-	if (x1 > x2) {
-		temp = x2;
-		x2 = x1;
-		x1 = temp;
-	}
-
-	if (y1 > y2) {
-		temp = y2;
-		y2 = y1;
-		y1 = temp;
-	}
-
-	if (dy > 0) {
-		Im.Width = x2 - x1 + 1;
-		Im.Height = y2 - y1 + 1 - dy;
-
-		readScreenImage(&Im, x1, y1);
-		drawImage(&Im, x1, y1 + dy);
-
-		setAPen(0);
-		rectFill(x1, y1, x2, y1 + dy - 1);
-	} else if (dy < 0) {
-		Im.Width = x2 - x1 + 1;
-		Im.Height = y2 - y1 + 1 + dy;
-
-		readScreenImage(&Im, x1, y1 - dy);
-		drawImage(&Im, x1, y1);
-
-		setAPen(0);
-		rectFill(x1, y2 + dy + 1, x2, y2);
-	}
-}
-
-
-
-static unsigned char curapen = 0;
-
-/*****************************************************************************/
-/* Sets the pen number to use on all the drawing operations.                 */
-/*****************************************************************************/
-void setAPen(uint16 pennum) {
-	curapen = (unsigned char)pennum;
-}
-
-
-
-
-/*****************************************************************************/
-/* Fills in a rectangle.                                                     */
-/*****************************************************************************/
-void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-#if !defined(DOSCODE)
-	int dx, dy, w, h;
-
-	dx = x1;
-	dy = y1;
-	w = x2 - x1 + 1;
-	h = y2 - y1 + 1;
-
-	if (dx < 0) {
-		w += dx;
-		dx = 0;
-	}
-
-	if (dy < 0) {
-		w += dy;
-		dy = 0;
-	}
-
-	if ((uint)(dx + w) > VGAScreenWidth)
-		w = VGAScreenWidth - dx;
-
-	if ((uint)(dy + h) > VGAScreenHeight)
-		h = VGAScreenHeight - dy;
-
-	if (w > 0 && h > 0) {
-		char *d = (char *)getVGABaseAddr() + dy * VGAScreenWidth + dx;
-
-		while (h-- > 0) {
-			char *dd = d;
-			int ww = w;
-
-			while (ww-- > 0) {
-				*dd++ = curapen;
-			}
-
-			d += VGAScreenWidth;
-		}
-
-		ungetVGABaseAddr();
-	}
-
-#else
-	uint32  RealOffset,
-	         SegmentOffset,
-	         LeftInSegment;
-	char *video,
-	              *curline;
-	uint16 counterx,
-	         countery = y1,
-	         numwholelines,
-	         numpartiallines,
-	         curpage;
-
-	while (countery <= y2) {
-		RealOffset = (VGAScreenWidth * countery) + x1;
-		curpage    = RealOffset / VGABytesPerPage;
-		SegmentOffset = RealOffset - (curpage * VGABytesPerPage);
-		LeftInSegment = VGABytesPerPage - SegmentOffset;
-		setPage(curpage);
-		video = (char *)(((int32)(VGABASEADDRESS)) + SegmentOffset);
-
-		numwholelines = LeftInSegment / VGAScreenWidth;
-		numpartiallines = 0;
-		counterx      = LeftInSegment - (numwholelines * VGAScreenWidth);
-
-		if (counterx >= (x2 - x1 + 1))
-			numwholelines++;
-		else
-			numpartiallines = 1;
-
-		while (numwholelines && (countery <= y2)) {
-			curline = video;
-
-			for (counterx = x1; counterx <= x2; counterx++) {
-				*video = curapen;
-				video++;
-			}
-
-			video = curline;
-			video += VGAScreenWidth;
-			countery ++;
-			numwholelines --;
-			LeftInSegment -= VGAScreenWidth;
-		}
-
-		if (numpartiallines && (countery <= y2)) {
-			countery ++;
-			curline = video;
-
-			for (counterx = x1; counterx <= x2; counterx++) {
-				if (LeftInSegment == 0L) {
-					setPage(curpage + 1);
-					LeftInSegment = VGABytesPerPage;
-					video = (char *)(VGABASEADDRESS);
-				}
-
-				*video = curapen;
-				video++;
-				LeftInSegment--;
-			}
-		}
-	}
-
-#endif
-}
-
-
-
-/*****************************************************************************/
-/* Draws a horizontal line.                                                  */
-/*****************************************************************************/
-void drawVLine(uint16 x, uint16 y1, uint16 y2) {
-	rectFill(x, y1, x, y2);
-}
-
-
-
-
-/*****************************************************************************/
-/* Draws a vertical line.                                                    */
-/*****************************************************************************/
-void drawHLine(uint16 x1, uint16 y, uint16 x2) {
-	rectFill(x1, y, x2, y);
-}
-
-
-
-
-/*****************************************************************************/
-/* Ghoasts a region on the screen using the desired pen color.               */
-/*****************************************************************************/
-void ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-#if !defined(DOSCODE)
-	int dx, dy, w, h;
-
-	dx = x1;
-	dy = y1;
-	w = x2 - x1 + 1;
-	h = y2 - y1 + 1;
-
-	if (dx < 0) {
-		w += dx;
-		dx = 0;
-	}
-
-	if (dy < 0) {
-		w += dy;
-		dy = 0;
-	}
-
-	if ((uint)(dx + w) > VGAScreenWidth)
-		w = VGAScreenWidth - dx;
-
-	if ((uint)(dy + h) > VGAScreenHeight)
-		h = VGAScreenHeight - dy;
-
-	if (w > 0 && h > 0) {
-		char *d = (char *)getVGABaseAddr() + dy * VGAScreenWidth + dx;
-
-		while (h-- > 0) {
-			char *dd = d;
-			int ww = w;
-
-			if (dy & 1) {
-				dd++;
-				ww--;
-			}
-
-			while (ww > 0) {
-				*dd = pencolor;
-				dd += 2;
-				ww -= 2;
-			}
-
-			d += VGAScreenWidth;
-			dy++;
-		}
-
-		ungetVGABaseAddr();
-	}
-
-#else
-	uint32  RealOffset,
-	         SegmentOffset;
-	int32           LeftInSegment;
-	char *video,
-	              *curline;
-	uint16 counterx,
-	         countery = y1,
-	         numwholelines,
-	         numpartiallines,
-	         curpage;
-
-	while (countery <= y2) {
-		RealOffset = (VGAScreenWidth * countery) + x1;
-		curpage    = RealOffset / VGABytesPerPage;
-		SegmentOffset = RealOffset - (curpage * VGABytesPerPage);
-		LeftInSegment = VGABytesPerPage - SegmentOffset;
-		setPage(curpage);
-		video = (char *)(((int32)(VGABASEADDRESS)) + SegmentOffset);
-
-		numwholelines = LeftInSegment / VGAScreenWidth;
-		numpartiallines = 0;
-		counterx      = LeftInSegment - (numwholelines * VGAScreenWidth);
-
-		if (counterx >= (x2 - x1 + 1))
-			numwholelines++;
-		else
-			numpartiallines = 1;
-
-		while (numwholelines && (countery <= y2)) {
-			curline = video;
-			counterx = x1;
-
-			if (1 & countery) {
-				video++;
-				counterx ++;
-			}
-
-			while (counterx <= x2) {
-				*video = pencolor;
-				video += 2;
-				counterx += 2;
-			}
-
-			video = curline;
-			video += VGAScreenWidth;
-			countery ++;
-			numwholelines --;
-			LeftInSegment -= VGAScreenWidth;
-		}
-
-		if (numpartiallines && (countery <= y2)) {
-			countery ++;
-			curline = video;
-			counterx = x1;
-
-			if (1 & countery) {
-				video++;
-				counterx ++;
-				LeftInSegment --;
-			}
-
-			while (counterx < x2) {
-				if (LeftInSegment <= 0L) {
-					setPage(curpage + 1);
-					video = (char *)(((int32)(VGABASEADDRESS)) - LeftInSegment);
-					LeftInSegment = VGABytesPerPage + LeftInSegment;
-				}
-
-				*video = pencolor;
-				video += 2;
-				counterx += 2;
-				LeftInSegment -= 2;
-			}
-		}
-	}
-
-#endif
-}
-
-} // End of namespace Lab
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/vga.h"
+#include "lab/stddefines.h"
+#include "lab/mouse.h"
+
+#include "graphics/palette.h"
+
+#include "common/events.h"
+
+namespace Lab {
+
+//static uint16 NotInRefresh = 0;
+
+uint32 VGAScreenWidth = 320UL,
+              VGAScreenHeight = 200UL,
+              VGAPages        = 1UL,
+              VGABytesPerPage = 65536UL;
+
+byte *VGABASEADDRESS = 0;
+
+byte *g_DisplayBuffer = 0;
+byte *g_Pixels = 0;
+
+int g_ScreenWasLocked = 0;
+int g_IgnoreUpdateDisplay = 0;
+int g_LastWaitTOFTicks = 0;
+
+int g_MouseX = 0;
+int g_MouseY = 0;
+
+uint16 g_NextKeyIn = 0;
+uint16 g_KeyBuf[64];
+uint16 g_NextKeyOut = 0;
+bool g_MouseAtEdge = false;
+
+/*****************************************************************************/
+/* Sets the display mode.                                                    */
+/*****************************************************************************/
+void setMode(char mode) {
+	// There are no modes for SDL.
+}
+
+/*****************************************************************************/
+/* Sets up either a low-res or a high-res 256 color screen.                  */
+/*****************************************************************************/
+bool createScreen(bool HiRes) {
+	//VGABASEADDRESS  = (unsigned long)malloc(640 * 480);
+	VGABASEADDRESS  = 0;
+	VGAScreenWidth  = 640;
+	VGAScreenHeight = 480;
+	VGAPages        = 1;
+	VGABytesPerPage = 640 * 480;
+
+	g_DisplayBuffer = (byte *)malloc(VGABytesPerPage);
+	g_Pixels = (byte *)calloc(VGABytesPerPage, 4);
+
+	return true;
+}
+
+
+
+/*****************************************************************************/
+/* Sets the current page on the VGA card.                                    */
+/*****************************************************************************/
+void setPage(uint16 PageNum) {
+	// PageNum should always calculated out to zero for SDL.
+	assert(PageNum == 0);
+}
+
+
+
+void VGAStorePage(void) {
+	// does nothing in SDL
+}
+
+void VGARestorePage(void) {
+	// does nothing in SDL
+}
+
+void changeVolume(int delta) {
+	warning("STUB: changeVolume()");
+}
+
+uint16 WSDL_GetNextChar() {
+	uint16 c = 0;
+
+	WSDL_ProcessInput(0);
+	if (g_NextKeyIn != g_NextKeyOut) {
+		c = g_KeyBuf[g_NextKeyOut];
+		g_NextKeyOut = ((((unsigned int)((g_NextKeyOut + 1) >> 31) >> 26) + (byte)g_NextKeyOut + 1) & 0x3F)
+                 - ((unsigned int)((g_NextKeyOut + 1) >> 31) >> 26);
+  	}
+
+	return c;
+}
+
+bool WSDL_HasNextChar() {
+	WSDL_ProcessInput(0);
+	return g_NextKeyIn != g_NextKeyOut;
+}
+
+void WSDL_ProcessInput(bool can_delay) {
+	int n;
+	int lastMouseAtEdge;
+	int flags = 0;
+
+	Common::Event event;
+
+	if (1 /*!g_IgnoreProcessInput*/) {
+		while (g_system->getEventManager()->pollEvent(event)) {
+			switch (event.type) {
+			case Common::EVENT_RBUTTONDOWN:
+				flags |= 8;
+				mouse_handler(flags, g_MouseX, g_MouseY);
+				break;
+
+			case Common::EVENT_LBUTTONDOWN:
+				flags |= 2;
+				mouse_handler(flags, g_MouseX, g_MouseY);
+				break;
+
+			case Common::EVENT_MOUSEMOVE:
+				lastMouseAtEdge = g_MouseAtEdge;
+				g_MouseAtEdge = false;
+				g_MouseX = event.mouse.x;
+				if (event.mouse.x <= 0) {
+					g_MouseX = 0;
+					g_MouseAtEdge = true;
+				}
+				if (g_MouseX > 639) {
+					g_MouseX = 640;
+					g_MouseAtEdge = true;
+				}
+
+				g_MouseY = event.mouse.y;
+				if (event.mouse.y <= 0) {
+					g_MouseY = 0;
+					g_MouseAtEdge = true;
+				}
+				if (g_MouseY > 479) {
+					g_MouseY = 480;
+					g_MouseAtEdge = true;
+				}
+
+				if (!lastMouseAtEdge || !g_MouseAtEdge)
+					mouse_handler(1, g_MouseX, g_MouseY);
+
+				break;
+
+			case Common::EVENT_KEYDOWN:
+				switch (event.kbd.keycode) {
+				case Common::KEYCODE_LEFTBRACKET:
+					changeVolume(-1);
+					break;
+
+				case Common::KEYCODE_RIGHTBRACKET:
+					changeVolume(1);
+					break;
+
+				case Common::KEYCODE_z:
+					//saveSettings();
+					break;
+
+				default:
+					n = ((((unsigned int)((g_NextKeyIn + 1) >> 31) >> 26) + (byte)g_NextKeyIn + 1) & 0x3F)
+					- ((unsigned int)((g_NextKeyIn + 1) >> 31) >> 26);
+					if (n != g_NextKeyOut) {
+						g_KeyBuf[g_NextKeyIn] = event.kbd.keycode;
+						g_NextKeyIn = n;
+					}
+				}
+				break;
+
+			case Common::EVENT_QUIT:
+			case Common::EVENT_RTL:
+			default:
+				break;
+			}
+
+			g_system->copyRectToScreen(g_DisplayBuffer, VGAScreenWidth, 0, 0, VGAScreenWidth, VGAScreenHeight);
+			g_system->updateScreen();
+		}
+	}
+
+	if (can_delay)
+		g_system->delayMillis(10);
+}
+
+void WSDL_GetMousePos(int *x, int *y) {
+	WSDL_ProcessInput(0);
+
+	*x = g_MouseX;
+	*y = g_MouseY;
+}
+
+
+void waitTOF() {
+	int untilOutOfRefresh = 1;
+
+  	if (g_ScreenWasLocked || untilOutOfRefresh) {
+		g_system->copyRectToScreen(g_DisplayBuffer, VGAScreenWidth, 0, 0, VGAScreenWidth, VGAScreenHeight);
+		g_system->updateScreen();
+  	}
+
+  	g_ScreenWasLocked = 0;
+  	WSDL_ProcessInput(0);
+
+  	uint32 now;
+
+  	for (now = g_system->getMillis(); now - g_LastWaitTOFTicks <= 0xF; now = g_system->getMillis() )
+  		g_system->delayMillis(g_LastWaitTOFTicks - now + 17);
+
+  	g_LastWaitTOFTicks = now;
+}
+
+void WSDL_SetColors(byte *buf, uint16 first, uint16 numreg, uint16 slow) {
+	byte tmp[256 * 3];
+
+	for (int i = 0; i < 256 * 3; i++) {
+		tmp[i] = buf[i] * 4;
+	}
+
+	g_system->getPaletteManager()->setPalette(tmp, first, numreg);
+
+	if (slow)
+    	waitTOF();
+}
+
+static byte curvgapal[256 * 3];
+
+/*****************************************************************************/
+/* Writes any number of the 256 color registers.                             */
+/* first:    the number of the first color register to write.                */
+/* numreg:   the number of registers to write                                */
+/* buf:      a char pointer which contains the selected color registers.     */
+/*           Each value representing a color register occupies 3 bytes in    */
+/*           the array.  The order is red, green then blue.  The first byte  */
+/*           in the array is the red component of the first element selected.*/
+/*           The length of the buffer is 3 times the number of registers     */
+/*           selected.                                                       */
+/*****************************************************************************/
+void writeColorRegs(byte *buf, uint16 first, uint16 numreg) {
+	WSDL_SetColors(buf, first, numreg, 0);
+	memcpy(&(curvgapal[first * 3]), buf, numreg * 3);
+}
+
+void writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg) {
+	WSDL_SetColors(buf, first, numreg, 1);
+	memcpy(&(curvgapal[first * 3]), buf, numreg * 3);
+}
+
+/*****************************************************************************/
+/* Sets one of the 256 (0..255) color registers.  buf is a char pointer,     */
+/* the first character in the string is the red value, then green, then      */
+/* blue.  Each color value is a 6 bit value.                                 */
+/*****************************************************************************/
+void writeColorReg(byte *buf, uint16 regnum) {
+	writeColorRegs(buf, regnum, 1);
+}
+
+void VGASetPal(void *cmap, uint16 numcolors) {
+	if (memcmp(cmap, curvgapal, numcolors * 3) != 0)
+		writeColorRegs((byte *)cmap, 0, numcolors);
+}
+
+byte *WSDL_LockVideo() {
+	g_ScreenWasLocked = 1;
+
+	return g_DisplayBuffer;
+}
+
+void WSDL_UnlockVideo() {
+}
+
+void WSDL_IgnoreUpdateDisplay(int state) {
+	g_IgnoreUpdateDisplay = state;
+}
+
+void WSDL_UpdateScreen() {
+	WSDL_UnlockVideo();
+
+	if (g_ScreenWasLocked && !g_IgnoreUpdateDisplay) {
+		g_system->copyRectToScreen(g_DisplayBuffer, VGAScreenWidth, 0, 0, VGAScreenWidth, VGAScreenHeight);
+  		g_system->updateScreen();
+  	}
+
+	g_ScreenWasLocked = 0;
+	WSDL_ProcessInput(0);
+}
+
+/*****************************************************************************/
+/* Returns the base address of the current VGA display.                      */
+/*****************************************************************************/
+byte *getVGABaseAddr(void) {
+	if (VGABASEADDRESS)
+		return VGABASEADDRESS;
+
+	return WSDL_LockVideo();
+}
+
+void ungetVGABaseAddr() {
+	if (!VGABASEADDRESS)
+		WSDL_UnlockVideo();
+}
+
+/*****************************************************************************/
+/* Gets information about the current display.                               */
+/*****************************************************************************/
+void getMode(uint16 *Mode) {
+	// Only one mode in SDL.
+}
+
+/*****************************************************************************/
+/* Draws an image to the screen.                                             */
+/*****************************************************************************/
+void drawImage(struct Image *Im, uint16 x, uint16 y) {
+#if !defined(DOSCODE)
+	int sx, sy, dx, dy, w, h;
+
+	sx = 0;
+	sy = 0;
+	dx = x;
+	dy = y;
+	w = Im->Width;
+	h = Im->Height;
+
+	if (dx < 0) {
+		sx -= dx;
+		w += dx;
+		dx = 0;
+	}
+
+	if (dy < 0) {
+		sy -= dy;
+		w += dy;
+		dy = 0;
+	}
+
+	if ((uint)(dx + w) > VGAScreenWidth)
+		w = VGAScreenWidth - dx;
+
+	if ((uint)(dy + h) > VGAScreenHeight)
+		h = VGAScreenHeight - dy;
+
+	if (w > 0 && h > 0) {
+		byte *s = Im->ImageData + sy * Im->Width + sx;
+		byte *d = getVGABaseAddr() + dy * VGAScreenWidth + dx;
+
+		while (h-- > 0) {
+			memcpy(d, s, w);
+			s += Im->Width;
+			d += VGAScreenWidth;
+		}
+
+		ungetVGABaseAddr();
+	}
+
+#else
+	uint32  RealOffset,
+	         SegmentOffset,
+	         LeftInSegment;
+	char *video,
+	              *curline,
+	              *imdata = Im->ImageData;
+	uint16 counterx,
+	         countery = 0,
+	         numwholelines,
+	         numpartiallines,
+	         curpage;
+
+	while (countery < Im->Height) {
+		RealOffset = (VGAScreenWidth * (y + countery)) + x;
+		curpage    = RealOffset / VGABytesPerPage;
+		SegmentOffset = RealOffset - (curpage * VGABytesPerPage);
+		LeftInSegment = VGABytesPerPage - SegmentOffset;
+		setPage(curpage);
+		video = (char *)(((int32)(VGABASEADDRESS)) + SegmentOffset);
+
+		numwholelines = LeftInSegment / VGAScreenWidth;
+		numpartiallines = 0;
+		counterx      = LeftInSegment - (numwholelines * VGAScreenWidth);
+
+		if (counterx >= Im->Width)
+			numwholelines++;
+		else
+			numpartiallines = 1;
+
+		while (numwholelines && (countery < Im->Height)) {
+			curline = video;
+
+			for (counterx = 0; counterx < Im->Width; counterx++) {
+				*video = *imdata;
+				video++;
+				imdata++;
+			}
+
+			video = curline;
+			video += VGAScreenWidth;
+			countery ++;
+			numwholelines --;
+			LeftInSegment -= VGAScreenWidth;
+		}
+
+		if (numpartiallines && (countery < Im->Height)) {
+			countery ++;
+			curline = video;
+
+			for (counterx = 0; counterx < Im->Width; counterx++) {
+				if (LeftInSegment == 0L) {
+					setPage(curpage + 1);
+					LeftInSegment = VGABytesPerPage;
+					video = (char *)(VGABASEADDRESS);
+				}
+
+				*video = *imdata;
+				video++;
+				imdata++;
+				LeftInSegment--;
+			}
+		}
+	}
+
+#endif
+}
+
+
+
+
+/*****************************************************************************/
+/* Draws an image to the screen.                                             */
+/*****************************************************************************/
+void drawMaskImage(struct Image *Im, uint16 x, uint16 y) {
+#if !defined(DOSCODE)
+	int sx, sy, dx, dy, w, h;
+
+	sx = 0;
+	sy = 0;
+	dx = x;
+	dy = y;
+	w = Im->Width;
+	h = Im->Height;
+
+	if (dx < 0) {
+		sx -= dx;
+		w += dx;
+		dx = 0;
+	}
+
+	if (dy < 0) {
+		sy -= dy;
+		w += dy;
+		dy = 0;
+	}
+
+	if ((uint)(dx + w) > VGAScreenWidth)
+		w = VGAScreenWidth - dx;
+
+	if ((uint)(dy + h) > VGAScreenHeight)
+		h = VGAScreenHeight - dy;
+
+	if (w > 0 && h > 0) {
+		byte *s = Im->ImageData + sy * Im->Width + sx;
+		byte *d = getVGABaseAddr() + dy * VGAScreenWidth + dx;
+
+		while (h-- > 0) {
+			byte *ss = s;
+			byte *dd = d;
+			int ww = w;
+
+			while (ww-- > 0) {
+				byte c = *ss++;
+
+				if (c) *dd++ = c - 1;
+				else dd++;
+			}
+
+			s += Im->Width;
+			d += VGAScreenWidth;
+		}
+
+		ungetVGABaseAddr();
+	}
+
+#else
+	uint32  RealOffset,
+	         SegmentOffset,
+	         LeftInSegment;
+	char *video,
+	              *curline,
+	              *imdata = Im->ImageData;
+	uint16 counterx,
+	         countery = 0,
+	         numwholelines,
+	         numpartiallines,
+	         curpage;
+
+	while (countery < Im->Height) {
+		RealOffset = (VGAScreenWidth * (y + countery)) + x;
+		curpage    = RealOffset / VGABytesPerPage;
+		SegmentOffset = RealOffset - (curpage * VGABytesPerPage);
+		LeftInSegment = VGABytesPerPage - SegmentOffset;
+		setPage(curpage);
+		video = (char *)(((int32)(VGABASEADDRESS)) + SegmentOffset);
+
+		numwholelines = LeftInSegment / VGAScreenWidth;
+		numpartiallines = 0;
+		counterx      = LeftInSegment - (numwholelines * VGAScreenWidth);
+
+		if (counterx >= Im->Width)
+			numwholelines++;
+		else
+			numpartiallines = 1;
+
+		while (numwholelines && (countery < Im->Height)) {
+			curline = video;
+
+			for (counterx = 0; counterx < Im->Width; counterx++) {
+				if (*imdata)
+					*video = *imdata - 1;
+
+				video++;
+				imdata++;
+			}
+
+			video = curline;
+			video += VGAScreenWidth;
+			countery ++;
+			numwholelines --;
+			LeftInSegment -= VGAScreenWidth;
+		}
+
+		if (numpartiallines && (countery < Im->Height)) {
+			countery ++;
+			curline = video;
+
+			for (counterx = 0; counterx < Im->Width; counterx++) {
+				if (LeftInSegment == 0L) {
+					setPage(curpage + 1);
+					LeftInSegment = VGABytesPerPage;
+					video = (char *)(VGABASEADDRESS);
+				}
+
+				if (*imdata)
+					*video = *imdata - 1;
+
+				video++;
+				imdata++;
+				LeftInSegment--;
+			}
+		}
+	}
+
+#endif
+}
+
+
+
+
+/*****************************************************************************/
+/* Reads an image from the screen.                                           */
+/*****************************************************************************/
+void readScreenImage(struct Image *Im, uint16 x, uint16 y) {
+#if !defined(DOSCODE)
+	int sx, sy, dx, dy, w, h;
+
+	sx = 0;
+	sy = 0;
+	dx = x;
+	dy = y;
+	w = Im->Width;
+	h = Im->Height;
+
+	if (dx < 0) {
+		sx -= dx;
+		w += dx;
+		dx = 0;
+	}
+
+	if (dy < 0) {
+		sy -= dy;
+		w += dy;
+		dy = 0;
+	}
+
+	if ((uint)(dx + w) > VGAScreenWidth)
+		w = VGAScreenWidth - dx;
+
+	if ((uint)(dy + h) > VGAScreenHeight)
+		h = VGAScreenHeight - dy;
+
+	if (w > 0 && h > 0) {
+		byte *s = Im->ImageData + sy * Im->Width + sx;
+		byte *d = getVGABaseAddr() + dy * VGAScreenWidth + dx;
+
+		while (h-- > 0) {
+			memcpy(s, d, w);
+			s += Im->Width;
+			d += VGAScreenWidth;
+		}
+
+		ungetVGABaseAddr();
+	}
+
+#else
+	uint32  RealOffset,
+	         SegmentOffset,
+	         LeftInSegment;
+	char *video,
+	              *curline,
+	              *imdata = Im->ImageData;
+	uint16 counterx,
+	         countery = 0,
+	         numwholelines,
+	         numpartiallines,
+	         curpage;
+
+	while (countery < Im->Height) {
+		RealOffset = (VGAScreenWidth * (y + countery)) + x;
+		curpage    = RealOffset / VGABytesPerPage;
+		SegmentOffset = RealOffset - (curpage * VGABytesPerPage);
+		LeftInSegment = VGABytesPerPage - SegmentOffset;
+		setPage(curpage);
+		video = (char *)(((int32)(VGABASEADDRESS)) + SegmentOffset);
+
+		numwholelines = LeftInSegment / VGAScreenWidth;
+		numpartiallines = 0;
+		counterx      = LeftInSegment - (numwholelines * VGAScreenWidth);
+
+		if (counterx >= Im->Width)
+			numwholelines++;
+		else
+			numpartiallines = 1;
+
+		while (numwholelines && (countery < Im->Height)) {
+			curline = video;
+
+			for (counterx = 0; counterx < Im->Width; counterx++) {
+				*imdata = *video;
+				video++;
+				imdata++;
+			}
+
+			video = curline;
+			video += VGAScreenWidth;
+			countery ++;
+			numwholelines --;
+			LeftInSegment -= VGAScreenWidth;
+		}
+
+		if (numpartiallines && (countery < Im->Height)) {
+			countery ++;
+			curline = video;
+
+			for (counterx = 0; counterx < Im->Width; counterx++) {
+				if (LeftInSegment == 0L) {
+					setPage(curpage + 1);
+					LeftInSegment = VGABytesPerPage;
+					video = (char *)(VGABASEADDRESS);
+				}
+
+				*imdata = *video;
+				video++;
+				imdata++;
+				LeftInSegment--;
+			}
+		}
+	}
+
+#endif
+}
+
+
+
+
+/*****************************************************************************/
+/* Blits a piece of one image to another.                                    */
+/* NOTE: for our purposes, assumes that ImDest is to be in VGA memory.       */
+/*****************************************************************************/
+void bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest,
+					uint16 xd, uint16 yd, uint16 width, uint16 height) {
+#if !defined(DOSCODE)
+	// I think the old code assumed that the source image data was valid for the given box.
+	// I will proceed on that assumption.
+	int sx, sy, dx, dy, w, h;
+
+	sx = xs;
+	sy = ys;
+	dx = xd;
+	dy = yd;
+	w = width;
+	h = height;
+
+	if (dx < 0) {
+		sx -= dx;
+		w += dx;
+		dx = 0;
+	}
+
+	if (dy < 0) {
+		sy -= dy;
+		w += dy;
+		dy = 0;
+	}
+
+	if (dx + w > ImDest->Width) w = ImDest->Width - dx;
+
+	if (dy + h > ImDest->Height) h = ImDest->Height - dy;
+
+	if (w > 0 && h > 0) {
+		byte *s = ImSource->ImageData + sy * ImSource->Width + sx;
+		byte *d = ImDest->ImageData + dy * ImDest->Width + dx;
+
+		while (h-- > 0) {
+			memcpy(d, s, w);
+			s += ImSource->Width;
+			d += ImDest->Width;
+		}
+	}
+
+#else
+	uint32  RealOffset,
+	         SegmentOffset,
+	         LeftInSegment;
+	char *video,
+	              *curdestline,
+	              *cursourceline = ImSource->ImageData,
+	               *imdata;
+	uint16 counterx,
+	         countery = 0,
+	         numwholelines,
+	         numpartiallines,
+	         curpage;
+
+	cursourceline += (((int32) ys) * ImSource->Width) + xs;
+	imdata        = cursourceline;
+
+	while (countery < height) {
+		RealOffset = (ImDest->Width * (yd + countery)) + xd;
+		curpage    = RealOffset / VGABytesPerPage;
+		SegmentOffset = RealOffset - (curpage * VGABytesPerPage);
+		LeftInSegment = VGABytesPerPage - SegmentOffset;
+		setPage(curpage);
+
+		video = (char *)(((int32)(ImDest->ImageData)) + SegmentOffset);
+
+		numwholelines = LeftInSegment / ImDest->Width;
+		numpartiallines = 0;
+		counterx      = LeftInSegment - (numwholelines * ImDest->Width);
+
+		if (counterx >= width)
+			numwholelines++;
+		else
+			numpartiallines = 1;
+
+		while (numwholelines && (countery < height)) {
+			curdestline = video;
+			cursourceline = imdata;
+
+			for (counterx = 0; counterx < width; counterx++) {
+				*video = *imdata;
+				video++;
+				imdata++;
+			}
+
+			video = curdestline;
+			video += ImDest->Width;
+			imdata = cursourceline;
+			imdata += ImSource->Width;
+
+			countery ++;
+			numwholelines --;
+			LeftInSegment -= ImDest->Width;
+		}
+
+		if (numpartiallines && (countery < height)) {
+			countery ++;
+			curdestline = video;
+			cursourceline = imdata;
+
+			for (counterx = 0; counterx < width; counterx++) {
+				if (LeftInSegment == 0L) {
+					setPage(curpage + 1);
+					LeftInSegment = VGABytesPerPage;
+					video = ImDest->ImageData;
+				}
+
+				*video = *imdata;
+				video++;
+				imdata++;
+				LeftInSegment--;
+			}
+
+			video = curdestline;
+			video += ImDest->Width;
+			imdata = cursourceline;
+			imdata += ImSource->Width;
+		}
+	}
+
+#endif
+}
+
+
+byte *TempScrollData;
+
+
+/*****************************************************************************/
+/* Scrolls the display in the x direction by blitting.                       */
+/* The TempScrollData variable must be initialized to some memory, or this   */
+/* function will fail.                                                       */
+/*****************************************************************************/
+void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+	struct Image Im;
+	uint16 temp;
+
+	Im.ImageData = TempScrollData;
+
+	if (x1 > x2) {
+		temp = x2;
+		x2 = x1;
+		x1 = temp;
+	}
+
+	if (y1 > y2) {
+		temp = y2;
+		y2 = y1;
+		y1 = temp;
+	}
+
+	if (dx > 0) {
+		Im.Width = x2 - x1 + 1 - dx;
+		Im.Height = y2 - y1 + 1;
+
+		readScreenImage(&Im, x1, y1);
+		drawImage(&Im, x1 + dx, y1);
+
+		setAPen(0);
+		rectFill(x1, y1, x1 + dx - 1, y2);
+	} else if (dx < 0) {
+		Im.Width = x2 - x1 + 1 + dx;
+		Im.Height = y2 - y1 + 1;
+
+		readScreenImage(&Im, x1 - dx, y1);
+		drawImage(&Im, x1, y1);
+
+		setAPen(0);
+		rectFill(x2 + dx + 1, y1, x2, y2);
+	}
+}
+
+
+
+
+
+/*****************************************************************************/
+/* Scrolls the display in the y direction by blitting.                       */
+/*****************************************************************************/
+void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+	struct Image Im;
+	uint16 temp;
+
+	Im.ImageData = TempScrollData;
+
+	if (x1 > x2) {
+		temp = x2;
+		x2 = x1;
+		x1 = temp;
+	}
+
+	if (y1 > y2) {
+		temp = y2;
+		y2 = y1;
+		y1 = temp;
+	}
+
+	if (dy > 0) {
+		Im.Width = x2 - x1 + 1;
+		Im.Height = y2 - y1 + 1 - dy;
+
+		readScreenImage(&Im, x1, y1);
+		drawImage(&Im, x1, y1 + dy);
+
+		setAPen(0);
+		rectFill(x1, y1, x2, y1 + dy - 1);
+	} else if (dy < 0) {
+		Im.Width = x2 - x1 + 1;
+		Im.Height = y2 - y1 + 1 + dy;
+
+		readScreenImage(&Im, x1, y1 - dy);
+		drawImage(&Im, x1, y1);
+
+		setAPen(0);
+		rectFill(x1, y2 + dy + 1, x2, y2);
+	}
+}
+
+
+
+static unsigned char curapen = 0;
+
+/*****************************************************************************/
+/* Sets the pen number to use on all the drawing operations.                 */
+/*****************************************************************************/
+void setAPen(uint16 pennum) {
+	curapen = (unsigned char)pennum;
+}
+
+
+
+
+/*****************************************************************************/
+/* Fills in a rectangle.                                                     */
+/*****************************************************************************/
+void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+#if !defined(DOSCODE)
+	int dx, dy, w, h;
+
+	dx = x1;
+	dy = y1;
+	w = x2 - x1 + 1;
+	h = y2 - y1 + 1;
+
+	if (dx < 0) {
+		w += dx;
+		dx = 0;
+	}
+
+	if (dy < 0) {
+		w += dy;
+		dy = 0;
+	}
+
+	if ((uint)(dx + w) > VGAScreenWidth)
+		w = VGAScreenWidth - dx;
+
+	if ((uint)(dy + h) > VGAScreenHeight)
+		h = VGAScreenHeight - dy;
+
+	if (w > 0 && h > 0) {
+		char *d = (char *)getVGABaseAddr() + dy * VGAScreenWidth + dx;
+
+		while (h-- > 0) {
+			char *dd = d;
+			int ww = w;
+
+			while (ww-- > 0) {
+				*dd++ = curapen;
+			}
+
+			d += VGAScreenWidth;
+		}
+
+		ungetVGABaseAddr();
+	}
+
+#else
+	uint32  RealOffset,
+	         SegmentOffset,
+	         LeftInSegment;
+	char *video,
+	              *curline;
+	uint16 counterx,
+	         countery = y1,
+	         numwholelines,
+	         numpartiallines,
+	         curpage;
+
+	while (countery <= y2) {
+		RealOffset = (VGAScreenWidth * countery) + x1;
+		curpage    = RealOffset / VGABytesPerPage;
+		SegmentOffset = RealOffset - (curpage * VGABytesPerPage);
+		LeftInSegment = VGABytesPerPage - SegmentOffset;
+		setPage(curpage);
+		video = (char *)(((int32)(VGABASEADDRESS)) + SegmentOffset);
+
+		numwholelines = LeftInSegment / VGAScreenWidth;
+		numpartiallines = 0;
+		counterx      = LeftInSegment - (numwholelines * VGAScreenWidth);
+
+		if (counterx >= (x2 - x1 + 1))
+			numwholelines++;
+		else
+			numpartiallines = 1;
+
+		while (numwholelines && (countery <= y2)) {
+			curline = video;
+
+			for (counterx = x1; counterx <= x2; counterx++) {
+				*video = curapen;
+				video++;
+			}
+
+			video = curline;
+			video += VGAScreenWidth;
+			countery ++;
+			numwholelines --;
+			LeftInSegment -= VGAScreenWidth;
+		}
+
+		if (numpartiallines && (countery <= y2)) {
+			countery ++;
+			curline = video;
+
+			for (counterx = x1; counterx <= x2; counterx++) {
+				if (LeftInSegment == 0L) {
+					setPage(curpage + 1);
+					LeftInSegment = VGABytesPerPage;
+					video = (char *)(VGABASEADDRESS);
+				}
+
+				*video = curapen;
+				video++;
+				LeftInSegment--;
+			}
+		}
+	}
+
+#endif
+}
+
+
+
+/*****************************************************************************/
+/* Draws a horizontal line.                                                  */
+/*****************************************************************************/
+void drawVLine(uint16 x, uint16 y1, uint16 y2) {
+	rectFill(x, y1, x, y2);
+}
+
+
+
+
+/*****************************************************************************/
+/* Draws a vertical line.                                                    */
+/*****************************************************************************/
+void drawHLine(uint16 x1, uint16 y, uint16 x2) {
+	rectFill(x1, y, x2, y);
+}
+
+
+
+
+/*****************************************************************************/
+/* Ghoasts a region on the screen using the desired pen color.               */
+/*****************************************************************************/
+void ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+#if !defined(DOSCODE)
+	int dx, dy, w, h;
+
+	dx = x1;
+	dy = y1;
+	w = x2 - x1 + 1;
+	h = y2 - y1 + 1;
+
+	if (dx < 0) {
+		w += dx;
+		dx = 0;
+	}
+
+	if (dy < 0) {
+		w += dy;
+		dy = 0;
+	}
+
+	if ((uint)(dx + w) > VGAScreenWidth)
+		w = VGAScreenWidth - dx;
+
+	if ((uint)(dy + h) > VGAScreenHeight)
+		h = VGAScreenHeight - dy;
+
+	if (w > 0 && h > 0) {
+		char *d = (char *)getVGABaseAddr() + dy * VGAScreenWidth + dx;
+
+		while (h-- > 0) {
+			char *dd = d;
+			int ww = w;
+
+			if (dy & 1) {
+				dd++;
+				ww--;
+			}
+
+			while (ww > 0) {
+				*dd = pencolor;
+				dd += 2;
+				ww -= 2;
+			}
+
+			d += VGAScreenWidth;
+			dy++;
+		}
+
+		ungetVGABaseAddr();
+	}
+
+#else
+	uint32  RealOffset,
+	         SegmentOffset;
+	int32           LeftInSegment;
+	char *video,
+	              *curline;
+	uint16 counterx,
+	         countery = y1,
+	         numwholelines,
+	         numpartiallines,
+	         curpage;
+
+	while (countery <= y2) {
+		RealOffset = (VGAScreenWidth * countery) + x1;
+		curpage    = RealOffset / VGABytesPerPage;
+		SegmentOffset = RealOffset - (curpage * VGABytesPerPage);
+		LeftInSegment = VGABytesPerPage - SegmentOffset;
+		setPage(curpage);
+		video = (char *)(((int32)(VGABASEADDRESS)) + SegmentOffset);
+
+		numwholelines = LeftInSegment / VGAScreenWidth;
+		numpartiallines = 0;
+		counterx      = LeftInSegment - (numwholelines * VGAScreenWidth);
+
+		if (counterx >= (x2 - x1 + 1))
+			numwholelines++;
+		else
+			numpartiallines = 1;
+
+		while (numwholelines && (countery <= y2)) {
+			curline = video;
+			counterx = x1;
+
+			if (1 & countery) {
+				video++;
+				counterx ++;
+			}
+
+			while (counterx <= x2) {
+				*video = pencolor;
+				video += 2;
+				counterx += 2;
+			}
+
+			video = curline;
+			video += VGAScreenWidth;
+			countery ++;
+			numwholelines --;
+			LeftInSegment -= VGAScreenWidth;
+		}
+
+		if (numpartiallines && (countery <= y2)) {
+			countery ++;
+			curline = video;
+			counterx = x1;
+
+			if (1 & countery) {
+				video++;
+				counterx ++;
+				LeftInSegment --;
+			}
+
+			while (counterx < x2) {
+				if (LeftInSegment <= 0L) {
+					setPage(curpage + 1);
+					video = (char *)(((int32)(VGABASEADDRESS)) - LeftInSegment);
+					LeftInSegment = VGABytesPerPage + LeftInSegment;
+				}
+
+				*video = pencolor;
+				video += 2;
+				counterx += 2;
+				LeftInSegment -= 2;
+			}
+		}
+	}
+
+#endif
+}
+
+} // End of namespace Lab


Commit: 7baabb22c1e787af780a8ec3df87788223b5cd00
    https://github.com/scummvm/scummvm/commit/7baabb22c1e787af780a8ec3df87788223b5cd00
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Cleanup

Changed paths:
    engines/lab/allocroom.cpp
    engines/lab/mouse.cpp



diff --git a/engines/lab/allocroom.cpp b/engines/lab/allocroom.cpp
index 8ca69ef..339ae0b 100644
--- a/engines/lab/allocroom.cpp
+++ b/engines/lab/allocroom.cpp
@@ -176,45 +176,45 @@ static void *getCurMem(uint16 Size) {
 /* Grabs a chunk of memory from the room buffer, and manages it for a        */
 /* particular room.                                                          */
 /*****************************************************************************/
-void allocRoom(void **Ptr, uint16 Size, uint16 RoomNum) {
-	uint16 RMarker;
+void allocRoom(void **Ptr, uint16 size, uint16 roomNum) {
+	uint16 rMarker;
 	bool doit = true;
 
-	if (1 & Size)  /* Memory is required to be even aligned */
-		Size++;
+	if (1 & size)  /* Memory is required to be even aligned */
+		size++;
 
-	RMarker = 0;
+	rMarker = 0;
 
-	while ((RMarker < MAXMARKERS) && doit) {
-		if (RoomMarkers[RMarker].RoomNum == RoomNum)
+	while ((rMarker < MAXMARKERS) && doit) {
+		if (RoomMarkers[rMarker].RoomNum == roomNum)
 			doit = false;
 		else
-			RMarker++;
+			rMarker++;
 	}
 
-	if (RMarker >= MAXMARKERS) {
-		RMarker = CurMarker;
+	if (rMarker >= MAXMARKERS) {
+		rMarker = CurMarker;
 		CurMarker++;
 
 		if (CurMarker >= MAXMARKERS)
 			CurMarker = 0;
 
-		freeRoom(RMarker);
-		RoomMarkers[RMarker].RoomNum = RoomNum;
+		freeRoom(rMarker);
+		RoomMarkers[rMarker].RoomNum = roomNum;
 	}
 
-	*Ptr = getCurMem(Size);
+	*Ptr = getCurMem(size);
 
-	if (RoomMarkers[RMarker].Start0 == NULL) {
-		RoomMarkers[RMarker].Start0 = *Ptr;
-		RoomMarkers[RMarker].End0   = (void *)(((char *)(*Ptr)) + Size - 1);
-	} else if (*Ptr < RoomMarkers[RMarker].Start0) {
-		if (RoomMarkers[RMarker].Start1 == NULL)
-			RoomMarkers[RMarker].Start1 = *Ptr;
+	if (RoomMarkers[rMarker].Start0 == NULL) {
+		RoomMarkers[rMarker].Start0 = *Ptr;
+		RoomMarkers[rMarker].End0   = (void *)(((char *)(*Ptr)) + size - 1);
+	} else if (*Ptr < RoomMarkers[rMarker].Start0) {
+		if (RoomMarkers[rMarker].Start1 == NULL)
+			RoomMarkers[rMarker].Start1 = *Ptr;
 
-		RoomMarkers[RMarker].End1 = (void *)(((char *)(*Ptr)) + Size - 1);
+		RoomMarkers[rMarker].End1 = (void *)(((char *)(*Ptr)) + size - 1);
 	} else
-		RoomMarkers[RMarker].End0 = (void *)(((char *)(*Ptr)) + Size - 1);
+		RoomMarkers[rMarker].End0 = (void *)(((char *)(*Ptr)) + size - 1);
 }
 
 } // End of namespace Lab
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index ff2474e..3d83a0d 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -41,28 +41,6 @@ extern uint32 VGAScreenWidth, VGAScreenHeight;
 
 void mouseHideXY(void);
 
-#if defined(DOSCODE)
-/*****************************************************************************/
-/* Standard mouse calling template.                                          */
-/*****************************************************************************/
-static void mouse(int16 *m1, int16 *m2, int16 *m3, int16 *m4) {
-	union REGS reg;
-
-	reg.w.ax = *m1;
-	reg.w.bx = *m2;
-	reg.w.cx = *m3;
-	reg.w.dx = *m4;
-
-	int386(0x33, &reg, &reg);
-
-	*m1 = reg.w.ax;
-	*m2 = reg.w.bx;
-	*m3 = reg.w.cx;
-	*m4 = reg.w.dx;
-}
-#endif
-
-
 static bool LeftClick = false;
 static uint16 leftx = 0, lefty = 0;
 static bool RightClick = false;
@@ -155,16 +133,10 @@ void attachGadgetList(struct Gadget *GadList) {
 
 static void drawMouse(void) {
 	if (BackImage.ImageData) {
-#if !defined(DOSCODE)
-
 		if (backx <= 640 - BackImage.Width && backy <= 480 - BackImage.Height)
-#endif
 			drawMaskImage(&MouseImage, backx, backy);
 	} else {
-#if !defined(DOSCODE)
-
 		if (CurMouseX <= 640 - MouseImage.Width && CurMouseY <= 480 - MouseImage.Height)
-#endif
 			drawMaskImage(&MouseImage, CurMouseX, CurMouseY);
 	}
 }
@@ -179,19 +151,13 @@ static void getBackMouse(void) {
 	backx = CurMouseX;
 	backy = CurMouseY;
 
-#if !defined(DOSCODE)
-
-	if (/* backx >= 0 && backy >= 0 && */ backx <= 640 - BackImage.Width && backy <= 480 - BackImage.Height)
-#endif
+	if (backx <= 640 - BackImage.Width && backy <= 480 - BackImage.Height)
 		readScreenImage(&BackImage, backx, backy);
 }
 
 static void restoreBackMouse(void) {
 	if (BackImage.ImageData) {
-#if !defined(DOSCODE)
-
-		if (/* backx >= 0 && backy >= 0 && */ backx <= 640 - BackImage.Width && backy <= 480 - BackImage.Height)
-#endif
+		if (backx <= 640 - BackImage.Width && backy <= 480 - BackImage.Height)
 			drawImage(&BackImage, backx, backy);
 
 		BackImage.ImageData = NULL;
@@ -202,14 +168,7 @@ static void restoreBackMouse(void) {
 static struct Gadget *TempGad;
 
 
-#if defined(DOSCODE)
-#pragma off (check_stack)
-void _loadds far mouse_handler(int32 max, int32 mcx, int32 mdx) {
-#pragma aux mouse_handler parm [EAX] [ECX] [EDX]
-#else
 void mouse_handler(int32 max, int32 mcx, int32 mdx) {
-#endif
-
 	if (!IsHiRes)
 		mcx /= 2;
 
@@ -257,9 +216,7 @@ void mouse_handler(int32 max, int32 mcx, int32 mdx) {
 
 void updateMouse(void) {
 	uint16 counter;
-#if !defined(DOSCODE)
 	bool doUpdateDisplay = false;
-#endif
 
 	if (drawmouse && !MouseHidden) {
 		QuitMouseHandler = true;
@@ -268,9 +225,7 @@ void updateMouse(void) {
 		getBackMouse();
 		drawMouse();
 		QuitMouseHandler = false;
-#if !defined(DOSCODE)
 		doUpdateDisplay = true;
-#endif
 	}
 
 	if (gadhit) {
@@ -286,18 +241,12 @@ void updateMouse(void) {
 		mouseHide();
 		drawImage(hitgad->Im, hitgad->x, hitgad->y);
 		mouseShow();
-#if !defined(DOSCODE)
 		doUpdateDisplay = true;
-#endif
 		QuitMouseHandler = false;
 	}
 
-#if !defined(DOSCODE)
-
 	if (doUpdateDisplay)
 		WSDL_UpdateScreen();
-
-#endif
 }
 
 
@@ -307,52 +256,6 @@ void updateMouse(void) {
 /* Initializes the mouse.                                                    */
 /*****************************************************************************/
 bool initMouse(void) {
-#if defined(DOSCODE)
-	void (interrupt far * int_handler)();
-	int32 vector;
-	byte firstbyte;
-	struct SREGS sregs;
-	union REGS inregs, outregs;
-	int (far * function_ptr)();
-	int16 m1, m2, m3, m4;
-
-	segread(&sregs);
-
-	/* Determine mouse-driver interrupt address */
-	int_handler = _dos_getvect(0x33);        /* Get interrupt vector       */
-	firstbyte = *(byte far *) int_handler;  /* Get first instruction of interrupt */
-	vector = (int32) int_handler;
-
-	if ((vector == 0L) || (firstbyte == 0xcf)) { /* Vector should not be zero            */
-		/* First instruction should not be iret */
-		return false;
-	}
-
-	m1 = 0;
-	mouse(&m1, &m2, &m3, &m4);
-
-	if (m1 != -1)
-		return false;
-
-	m1 = 0x0f;
-	m3 = 3;
-	m4 = 10;
-	mouse(&m1, &m2, &m3, &m4);
-
-	m1 = 0x07;
-	m3 = 0;
-	m4 = VGAScreenWidth - MouseImageWidth;
-
-	if (!IsHiRes) m4 *= 2;
-
-	mouse(&m1, &m2, &m3, &m4);
-
-	m1 = 0x08;
-	m3 = 0;
-	m4 = VGAScreenHeight - MouseImageHeight;
-	mouse(&m1, &m2, &m3, &m4);
-#endif
-
 	BackImage.ImageData = NULL;
 	MouseImage.ImageData = MouseData;
 	MouseImage.Width = MouseImageWidth;
@@ -360,26 +263,6 @@ bool initMouse(void) {
 
 	mouseMove(0, 0);
 
-#if defined(DOSCODE)
-
-	if (IsHiRes) {
-		m1 = 0x0f;
-		m3 = 0x03;
-		m4 = 0x04;
-		mouse(&m1, &m2, &m3, &m4);
-	}
-
-	inregs.w.ax = 0xc;
-	inregs.w.cx = 0x01 + 0x02 + 0x08;  /* mouse move, left and right mouse clicks */
-	function_ptr = mouse_handler;
-	inregs.x.edx = FP_OFF(function_ptr);
-	sregs.es     = FP_SEG(function_ptr);
-	int386x(0x33, &inregs, &outregs, &sregs);
-
-	/* mouse reset and status */
-	return mouseReset();
-#endif
-
 	return true;
 }
 
@@ -389,14 +272,7 @@ bool initMouse(void) {
 /* Resets the mouse.                                                         */
 /*****************************************************************************/
 bool mouseReset(void) {
-#if defined(DOSCODE)
-	int16 m1 = 0, dum;
-
-	mouse(&m1, &dum, &dum, &dum);
-	return (m1 == -1);
-#else
 	return true;
-#endif
 }
 
 
@@ -430,9 +306,7 @@ void mouseShowXY(uint16 MouseX, uint16 MouseY) {
 		CurMouseY = MouseY;
 		getBackMouse();
 		drawMouse();
-#if !defined(DOSCODE)
 		WSDL_UpdateScreen();
-#endif
 		MouseHidden = false;
 	}
 
@@ -504,10 +378,6 @@ void mouseXY(uint16 *x, uint16 *y) {
 /* Moves the mouse to new co-ordinates.                                      */
 /*****************************************************************************/
 void mouseMove(uint16 x, uint16 y) {
-#if defined(DOSCODE)
-	int16 m1 = 4, dum;
-#endif
-
 	if (!IsHiRes)
 		x *= 2;
 
@@ -521,9 +391,7 @@ void mouseMove(uint16 x, uint16 y) {
 		getBackMouse();
 		drawMouse();
 		VGARestorePage();
-#if !defined(DOSCODE)
 		WSDL_UpdateScreen();
-#endif
 		QuitMouseHandler = false;
 	}
 }


Commit: fefb78457e8828c64aedb0d6aa9e595d342c0416
    https://github.com/scummvm/scummvm/commit/fefb78457e8828c64aedb0d6aa9e595d342c0416
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Cleanup

Changed paths:
    engines/lab/parsetypes.h
    engines/lab/processroom.cpp
    engines/lab/readdiff.cpp
    engines/lab/text.cpp



diff --git a/engines/lab/parsetypes.h b/engines/lab/parsetypes.h
index defe9af..5120c41 100644
--- a/engines/lab/parsetypes.h
+++ b/engines/lab/parsetypes.h
@@ -105,20 +105,17 @@ typedef struct closeData {
                                                         an item */
 	uint16 depth;               /* Level of the closeup. */
 	char *GraphicName, *Message;
-	struct closeData *NextCloseUp, *SubCloseUps;
+	closeData *NextCloseUp, *SubCloseUps;
 } CloseData;
 
 typedef CloseData *CloseDataPtr;
 
-
-
-typedef struct viewData {
+struct viewData {
 	int16 *Condition;
 	char *GraphicName;
 	struct viewData *NextCondition;
 	CloseDataPtr closeUps;
-
-} viewData;
+};
 
 typedef viewData *ViewDataPtr;
 
@@ -128,26 +125,22 @@ struct Action {
 	byte *Data;            /* Message, or a pointer to array
                                                   of messages. */
 	Action *NextAction;
-
 };
 
 typedef Action *ActionPtr;
 
 
 
-typedef struct rule {
+struct Rule {
 	int16 RuleType, Param1, Param2, *Condition;
 
 	ActionPtr ActionList;
-	struct rule *NextRule;
-
-} Rule;
+	Rule *NextRule;
+};
 
 typedef Rule *RulePtr;
 
-
-
-typedef struct {
+struct RoomData {
 	uint16 NorthDoor, SouthDoor, EastDoor, WestDoor;
 
 	byte WipeType;
@@ -155,26 +148,12 @@ typedef struct {
 	ViewDataPtr NorthView, SouthView, EastView, WestView;
 	RulePtr RuleList;
 	char *RoomMsg;
+};
 
-} RoomData;
-
-
-
-typedef struct inventoryData {
-	/* New inventory stuff */
-	/*
-	               int16 *Condition;
-	               char *GraphicName,
-	 * InvName;
-	               struct inventoryData *NextInventory;
-	               CloseDataPtr          closeUps;
-	               RulePtr               RuleList;
-	 */
-
-	/* Old inventory stuff */
+struct InventoryData {
 	uint16 Many;
 	char *name, *BInvName;
-} InventoryData;
+};
 
 
 
@@ -213,11 +192,10 @@ typedef struct inventoryData {
 
 
 
-typedef struct {
+struct MapData {
 	uint16 x, y, PageNumber, SpecialID;
 	uint32 MapFlags;
-
-} MapData;
+};
 
 #if defined(WIN32)
 #pragma pack(pop)
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 10d5dfb..5699c63 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -36,9 +36,7 @@
 #include "lab/timing.h"
 #include "lab/diff.h"
 #include "lab/vga.h"
-#if !defined(DOSCODE)
 #include "lab/interface.h"
-#endif
 
 namespace Lab {
 
@@ -46,7 +44,6 @@ namespace Lab {
 extern int g_IsRegistered;
 #endif
 
-
 /* Global parser data */
 
 RoomData *Rooms;
@@ -56,27 +53,20 @@ uint16 NumInv, RoomNum, ManyRooms, HighestCondition, Direction;
 extern char *FACINGNORTH, *FACINGEAST, *FACINGSOUTH, *FACINGWEST;
 extern bool LongWinInFront;
 
-
 #define NOFILE         "no file"
 
-
-
 extern const char *CurFileName;
 
 const char *ViewPath = "LAB:Rooms/";
 
-
 const char *NewFileName;
 
-
 extern bool DoNotDrawMessage;
 extern bool NoFlip, IsBM, noupdatediff, waiteffect, mwaiteffect, QuitLab, EffectPlaying, soundplaying, MusicOn, DoBlack, ContMusic, DoNotReset;
 extern char diffcmap[256 * 3];
 
 extern CloseDataPtr CPtr;
 
-
-
 /*****************************************************************************/
 /* Generates a random number.                                                */
 /*****************************************************************************/
@@ -87,9 +77,6 @@ uint16 getRandom(uint16 max) {
 	return ((micros + secs) % max);
 }
 
-
-
-
 /*****************************************************************************/
 /* Checks whether all the conditions in a condition list are met.            */
 /*****************************************************************************/
@@ -114,9 +101,6 @@ static bool checkConditions(int16 *Condition) {
 	return res;
 }
 
-
-
-
 /*****************************************************************************/
 /* Gets the current ViewDataPointer.                                         */
 /*****************************************************************************/
@@ -149,8 +133,6 @@ ViewDataPtr getViewData(uint16 roomNum, uint16 direction) {
 	return ViewPtr;
 }
 
-
-
 /*****************************************************************************/
 /* Gets an object, if any, from the user's click on the screen.              */
 /*****************************************************************************/
@@ -177,9 +159,6 @@ static CloseData *getObject(uint16 x, uint16 y, CloseDataPtr LCPtr) {
 	return NULL;
 }
 
-
-
-
 /*****************************************************************************/
 /* Goes through the list of closeups to find a match.                        */
 /* NYI: Known bug here.  If there are two objects that have closeups, and    */
@@ -206,11 +185,6 @@ static CloseDataPtr findCPtrMatch(CloseDataPtr Main, CloseDataPtr List) {
 	return NULL;
 }
 
-
-
-
-
-
 /*****************************************************************************/
 /* Returns the current picture name.                                         */
 /*****************************************************************************/
@@ -229,7 +203,6 @@ char *getPictName(CloseDataPtr *LCPtr) {
 	return ViewPtr->GraphicName;
 }
 
-
 /*****************************************************************************/
 /* Draws the current direction to the screen.                                */
 /*****************************************************************************/
@@ -272,7 +245,6 @@ void drawDirection(CloseDataPtr LCPtr) {
 	drawMessage(Message);
 }
 
-#if !defined(DOSCODE)
 void getRoomMessage(int MyRoomNum, int MyDirection, char *msg) {
 	getViewData(MyRoomNum, MyDirection);
 
@@ -292,11 +264,6 @@ void getRoomMessage(int MyRoomNum, int MyDirection, char *msg) {
 	else if (MyDirection == WEST)
 		strcat(msg, FACINGWEST);
 }
-#endif
-
-
-
-
 
 /*****************************************************************************/
 /* process a arrow gadget movement.                                          */
@@ -341,10 +308,6 @@ bool processArrow(uint16 *direction, uint16 Arrow) {
 	return true;
 }
 
-
-
-
-
 /*****************************************************************************/
 /* Sets the current close up data, but uses absolute cords.                  */
 /*****************************************************************************/
@@ -371,10 +334,6 @@ void setCurCloseAbs(uint16 x, uint16 y, CloseDataPtr *cptr) {
 	}
 }
 
-
-
-
-
 /*****************************************************************************/
 /* Sets the current close up data.                                           */
 /*****************************************************************************/
@@ -401,8 +360,6 @@ void setCurClose(uint16 x, uint16 y, CloseDataPtr *cptr) {
 	}
 }
 
-
-
 /*****************************************************************************/
 /* Takes the currently selected item.                                        */
 /*****************************************************************************/
@@ -434,8 +391,6 @@ bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
 	return false;
 }
 
-
-
 /*****************************************************************************/
 /* Processes the action list.                                                */
 /*****************************************************************************/
@@ -627,9 +582,7 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
 		case WAITSECS:
 			addCurTime(APtr->Param1, 0, &StartSecs, &StartMicros);
 
-#if !defined(DOSCODE)
 			WSDL_UpdateScreen();
-#endif
 
 			while (1) {
 				g_music->newCheckMusic();
@@ -760,10 +713,6 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
 	g_music->_doNotFileFlushAudio = false;
 }
 
-
-
-
-
 /*****************************************************************************/
 /* Does the work for doActionRule.                                           */
 /*****************************************************************************/
@@ -802,9 +751,6 @@ static bool doActionRuleSub(int16 Action, int16 roomNum, CloseDataPtr LCPtr, Clo
 	return false;
 }
 
-
-
-
 /*****************************************************************************/
 /* Goes through the rules if an action is taken.                             */
 /*****************************************************************************/
@@ -830,8 +776,6 @@ bool doActionRule(int16 x, int16 y, int16 Action, int16 roomNum, CloseDataPtr *L
 	return false;
 }
 
-
-
 /*****************************************************************************/
 /* Does the work for doActionRule.                                           */
 /*****************************************************************************/
@@ -864,9 +808,6 @@ static bool doOperateRuleSub(int16 ItemNum, int16 roomNum, CloseDataPtr LCPtr, C
 	return false;
 }
 
-
-
-
 /*****************************************************************************/
 /* Goes thru the rules if the user tries to operate an item on an object.    */
 /*****************************************************************************/
@@ -885,7 +826,6 @@ bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *LCPtr) {
 		return true;
 	else if (doOperateRuleSub(ItemNum, RoomNum, *LCPtr, LCPtr, true))
 		return true;
-
 	else {
 		NewFileName = CurFileName;
 
@@ -902,9 +842,6 @@ bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *LCPtr) {
 	return false;
 }
 
-
-
-
 /*****************************************************************************/
 /* Goes thru the rules if the user tries to go forward.                      */
 /*****************************************************************************/
@@ -927,8 +864,6 @@ bool doGoForward(CloseDataPtr *LCPtr) {
 	return false;
 }
 
-
-
 /*****************************************************************************/
 /* Goes thru the rules if the user tries to turn.                            */
 /*****************************************************************************/
@@ -957,9 +892,6 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *LCPtr) {
 	return false;
 }
 
-
-
-
 /*****************************************************************************/
 /* Goes thru the rules if the user tries to go to the main view              */
 /*****************************************************************************/
@@ -982,74 +914,4 @@ bool doMainView(CloseDataPtr *LCPtr) {
 	return false;
 }
 
-
-
-
-/*****************************************************************************/
-/* Goes thru the rules whenever (probably after an action or something), and */
-/* sets the conditions.                                                      */
-/*****************************************************************************/
-/*
-   bool doConditions(int16           x,
-                     int16           y,
-                     CloseDataPtr *LCPtr)
-   {
-   RulePtr RPtr;
-
-   NewFileName = NOFILE;
-
-   RPtr = Rooms[RoomNum].RuleList;
-
-   while (RPtr)
-   {
-    if (RPtr->RuleType == CONDITIONS)
-    {
-      if (checkConditions(RPtr->Condition))
-      {
-        doActions(RPtr->ActionList, LCPtr);
-        return true;
-      }
-    }
-
-    RPtr = RPtr->NextRule;
-   }
-   return false;
-   }
- */
-
-#if defined(DEMODATA)
-#include <stdio.h>
-
-static void WriteDemoData_CloseUps(FILE *fh, CloseDataPtr cd) {
-	while (cd != NULL) {
-		if (*cd->GraphicName)
-			fprintf(fh, "%s\n", cd->GraphicName);
-
-		WriteDemoData_CloseUps(fh, cd->SubCloseUps);
-		cd = cd->NextCloseUp;
-	}
-}
-
-static void WriteDemoData_ViewData(FILE *fh, ViewDataPtr vd) {
-	if (vd == NULL)
-		return;
-
-	if (*vd->GraphicName != 0)
-		fprintf(fh, "%s\n", vd->GraphicName);
-
-	WriteDemoData_CloseUps(fh, vd->closeUps);
-}
-
-void writeDemoData() {
-	FILE *fh = fopen("c:\\depot\\labyrinth\\demodata.log", "a+w");
-
-	WriteDemoData_ViewData(fh, getViewData(RoomNum, NORTH));
-	WriteDemoData_ViewData(fh, getViewData(RoomNum, SOUTH));
-	WriteDemoData_ViewData(fh, getViewData(RoomNum, EAST));
-	WriteDemoData_ViewData(fh, getViewData(RoomNum, WEST));
-
-	fclose(fh);
-}
-#endif
-
 } // End of namespace Lab
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index 1ceeb44..2d6c7d8 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -153,8 +153,6 @@ void diffNextFrame(void) {
 	if (header == 65535)  /* Already done. */
 		return;
 
-#if !defined(DOSCODE)
-
 	if (DispBitMap->Flags & BITMAPF_VIDEO) {
 		DispBitMap->Planes[0] = getVGABaseAddr();
 		DispBitMap->Planes[1] = DispBitMap->Planes[0] + 0x10000;
@@ -163,30 +161,12 @@ void diffNextFrame(void) {
 		DispBitMap->Planes[4] = DispBitMap->Planes[3] + 0x10000;
 	}
 
-#endif
-
 	mouseHide();
 
 	while (1) {
-		/* NYI: Don't need.
-		    if (ReadIsError)
-		    {
-		      IsPlaying = false;
-		      mouseShow();
-		      return;
-		    }
-		 */
-
 		if (CurBit >= numchunks) {
 			mouseShow();
 
-#ifdef undef /* NYI: Don't need. */
-
-			while (!ReadIsDone && !ReadIsError)     /* Wait for the file to load */
-				waitTOF();
-
-#endif
-
 			if (!NoFlip && !IsBM) {
 				if (headerdata.fps) {
 					waitForTime(WaitSec, WaitMicros);
@@ -255,9 +235,6 @@ void diffNextFrame(void) {
 			if (IsBM)
 				skip(difffile, size);
 			else {
-#if defined(DOSCODE)
-				setPage(CurBit);
-#endif
 				readBlock(DrawBitMap->Planes[CurBit], size, difffile);
 			}
 
@@ -265,9 +242,6 @@ void diffNextFrame(void) {
 			break;
 
 		case 11L:
-#if defined(DOSCODE)
-			setPage(CurBit);
-#endif
 			skip(difffile, 4L);
 			runLengthDecode(DrawBitMap->Planes[CurBit], *difffile);
 			CurBit++;
@@ -275,9 +249,6 @@ void diffNextFrame(void) {
 			break;
 
 		case 12L:
-#if defined(DOSCODE)
-			setPage(CurBit);
-#endif
 			skip(difffile, 4L);
 			VRunLengthDecode(DrawBitMap->Planes[CurBit], *difffile, DrawBitMap->BytesPerRow);
 			CurBit++;
@@ -285,18 +256,12 @@ void diffNextFrame(void) {
 			break;
 
 		case 20L:
-#if defined(DOSCODE)
-			setPage(CurBit);
-#endif
 			unDiff(DrawBitMap->Planes[CurBit], DispBitMap->Planes[CurBit], *difffile, DrawBitMap->BytesPerRow, false);
 			CurBit++;
 			skip(difffile, size);
 			break;
 
 		case 21L:
-#if defined(DOSCODE)
-			setPage(CurBit);
-#endif
 			unDiff(DrawBitMap->Planes[CurBit], DispBitMap->Planes[CurBit], *difffile, DrawBitMap->BytesPerRow, true);
 			CurBit++;
 			skip(difffile, size);
@@ -341,26 +306,20 @@ void diffNextFrame(void) {
 		}
 		case 65535L:
 			if ((framenumber == 1) || PlayOnce || StopPlayingEnd) {
-#if !defined(DOSCODE)
 				int didTOF = 0;
-#endif
 
 				if (waiteffect) {
 					while (EffectPlaying) {
 						g_music->updateMusic();
 						waitTOF();
-#if !defined(DOSCODE)
 
 						if (DispBitMap->Flags & BITMAPF_VIDEO)
 							didTOF = 1;
-
-#endif
 					}
 				}
 
 				IsPlaying = false;
 				mouseShow();
-#if !defined(DOSCODE)
 
 				if (DispBitMap->Flags & BITMAPF_VIDEO)
 					ungetVGABaseAddr();
@@ -368,7 +327,6 @@ void diffNextFrame(void) {
 				if (!didTOF)
 					WSDL_UpdateScreen();
 
-#endif
 				return;
 			}
 
@@ -382,12 +340,9 @@ void diffNextFrame(void) {
 		}
 	}
 
-#if !defined(DOSCODE)
-
 	if (DispBitMap->Flags & BITMAPF_VIDEO)
 		ungetVGABaseAddr();
 
-#endif
 }
 
 
@@ -453,7 +408,6 @@ void playDiff(void) {
 #endif
 
 	if (header == 0) {
-#if defined(IS_MACOSX)
 		// sizeof(headerdata) != 18, but the padding might be at the end
 		readBlock(&headerdata.Version, 2, difffile);
 		readBlock(&headerdata.x, 2, difffile);
@@ -463,9 +417,7 @@ void playDiff(void) {
 		readBlock(&headerdata.BufferSize, 4, difffile);
 		readBlock(&headerdata.Machine, 2, difffile);
 		readBlock(&headerdata.Flags, 4, difffile);
-#else
-		readBlock(&headerdata, 18, difffile);
-#endif
+
 		skip(difffile, size - 18);
 
 #if !defined(DOSCODE)
@@ -480,19 +432,10 @@ void playDiff(void) {
 		diffheight = headerdata.y;
 		DataBytesPerRow = diffwidth;
 
-#if defined(DOSCODE)
-		numchunks = (((int32) diffwidth) * diffheight) / VGABytesPerPage;
-
-		if ((numchunks * VGABytesPerPage) < (((int32) diffwidth) * diffheight))
-			numchunks++;
-
-#else
 		numchunks = (((int32) diffwidth) * diffheight) / 0x10000;
 
 		if ((uint32)(numchunks * 0x10000) < (uint32)(((int32) diffwidth) * diffheight))
 			numchunks++;
-
-#endif
 	} else {
 		return;
 	}
diff --git a/engines/lab/text.cpp b/engines/lab/text.cpp
index 5795a08..92711ac 100644
--- a/engines/lab/text.cpp
+++ b/engines/lab/text.cpp
@@ -284,9 +284,7 @@ void text(struct TextFont *tf, uint16 x, uint16 y, uint16 color, const char *tex
 		text++;
 	}
 
-#if !defined(DOSCODE)
 	ungetVGABaseAddr();
-#endif
 }
 
 } // End of namespace Lab


Commit: 58182bd77af8433e00b7b7475633bd1d6ddf13b0
    https://github.com/scummvm/scummvm/commit/58182bd77af8433e00b7b7475633bd1d6ddf13b0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Cleanup

Changed paths:
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/interface.cpp
    engines/lab/interface.h
    engines/lab/intro.cpp
    engines/lab/labfile.cpp
    engines/lab/labfun.h
    engines/lab/map.cpp
    engines/lab/modernsavegame.cpp
    engines/lab/modernsavegame.h
    engines/lab/mouse.cpp
    engines/lab/mouse.h
    engines/lab/readdiff.cpp
    engines/lab/special.cpp
    engines/lab/text.h
    engines/lab/vga.cpp
    engines/lab/vga.h



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 4db1451..6104270 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -45,7 +45,7 @@ const char *CurFileName = " ";
 
 bool LongWinInFront = false;
 
-struct TextFont *MsgFont;
+TextFont *MsgFont;
 
 extern bool DoBlack, waiteffect, EffectPlaying, stopsound, DoNotDrawMessage, IsHiRes, nopalchange, DoMusic;
 
@@ -131,13 +131,13 @@ static uint32 BUFFERSIZE = BIGBUFFERSIZE;
 
 static byte *MovePanelBuffer, *InvPanelBuffer;
 static uint32 MovePanelBufferSize, InvPanelBufferSize;
-static struct Image *MoveImages[20],
+static Image *MoveImages[20],
 #if defined(DOSCODE)
 		*InvImages[6];
 #else
 		*InvImages[10];
 #endif
-static struct Gadget *MoveGadgetList, *InvGadgetList;
+static Gadget *MoveGadgetList, *InvGadgetList;
 
 
 static char initcolors[] = { '\x00', '\x00', '\x00', '\x30',
@@ -251,7 +251,7 @@ static uint16 OldMode;
 bool setUpScreens(void) {
 	uint16 counter;
 	byte *bufferstorage, **buffer = &bufferstorage;
-	struct Gadget *curgad;
+	Gadget *curgad;
 	uint16 y;
 
 	if (!createScreen(IsHiRes))
@@ -395,8 +395,8 @@ uint16 curmousex = 0, curmousey = 0;
 /* Permanently flips the imagry of a gadget.                                  */
 /******************************************************************************/
 static void perFlipGadget(uint16 GadID) {
-	struct Image *Temp;
-	struct Gadget *TopGad;
+	Image *Temp;
+	Gadget *TopGad;
 
 	TopGad = MoveGadgetList;
 
@@ -424,7 +424,7 @@ static void perFlipGadget(uint16 GadID) {
 /* Eats all the available messages.                                           */
 /******************************************************************************/
 void eatMessages(void) {
-	struct IntuiMessage *Msg;
+	IntuiMessage *Msg;
 
 	do {
 		Msg = getMsg();
@@ -722,7 +722,7 @@ static bool novesa = false, noaudio = false;
 /* Processes user input events.                                               */
 /******************************************************************************/
 static void process(void) {
-	struct IntuiMessage *Msg;
+	IntuiMessage *Msg;
 	uint32 Class;
 
 	uint16 Code, Qualifier, MouseX, MouseY, ActionMode = 4, CurInv = MAPNUM, /* Lab: Labyrinth specific initialization */
@@ -1801,8 +1801,8 @@ int followCrumbs() {
 byte dropCrumbs[] = { 0x00 };
 byte dropCrumbsOff[] = { 0x00 };
 
-struct Image DropCrumbsImage = { 24, 24, dropCrumbs };
-struct Image DropCrumbsOffImage = { 24, 24, dropCrumbsOff };
+Image DropCrumbsImage = { 24, 24, dropCrumbs };
+Image DropCrumbsOffImage = { 24, 24, dropCrumbsOff };
 
 void mayShowCrumbIndicator() {
 	if (DroppingCrumbs && MainDisplay) {
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index dba2811..ba7c232 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -39,10 +39,10 @@
 
 namespace Lab {
 
-struct BitMap bit1, bit2, *DispBitMap = &bit1, *DrawBitMap = &bit1;
+BitMap bit1, bit2, *DispBitMap = &bit1, *DrawBitMap = &bit1;
 
 
-extern struct BitMap RawDiffBM;
+extern BitMap RawDiffBM;
 extern char diffcmap[256 * 3], lastcmap[256 * 3];
 extern bool IsBM, NoFlip, nopalchange, ContMusic;
 
@@ -50,7 +50,7 @@ extern int32 ReadSoFar;
 extern bool ReadIsDone, ReadIsError;
 extern bool DoBlack, EffectPlaying, stopsound;
 extern bool IsHiRes;
-extern struct TextFont *MsgFont;
+extern TextFont *MsgFont;
 extern const char *CurFileName;
 
 
@@ -229,7 +229,7 @@ static void getWord(char *WordBuffer, const char *MainBuffer, uint16 *WordWidth)
 /* Gets a line of text for flowText; makes sure that its length is less than  */
 /* or equal to the maximum width.                                             */
 /******************************************************************************/
-static void getLine(struct TextFont *tf, char *LineBuffer, const char **MainBuffer, uint16 LineWidth) {
+static void getLine(TextFont *tf, char *LineBuffer, const char **MainBuffer, uint16 LineWidth) {
 	uint16 CurWidth = 0, WordWidth;
 	char WordBuffer[100];
 	bool doit = true;
@@ -256,8 +256,6 @@ static void getLine(struct TextFont *tf, char *LineBuffer, const char **MainBuff
 		} else
 			doit = false;
 	}
-
-	/* NYI: Would add code here to break up words in case they were longer than a line */
 }
 
 
@@ -281,7 +279,7 @@ uint32 flowText(void *font,      /* the TextAttr pointer */
                 bool output,                  /* Whether to output any text */
                 uint16 x1,               /* Cords */
                 uint16 y1, uint16 x2, uint16 y2, const char *str) { /* The text itself */
-	struct TextFont *msgfont = (TextFont *)font;
+	TextFont *msgfont = (TextFont *)font;
 	char linebuffer[256];
 	const char *temp;
 	uint16 numlines, actlines, fontheight, width;
@@ -343,7 +341,7 @@ extern byte *VGABASEADDRESS;
 /******************************************************************************/
 /* Calls flowText, but flows it to memory.  Same restrictions as flowText.    */
 /******************************************************************************/
-uint32 flowTextToMem(struct Image *DestIm, void *font,     /* the TextAttr pointer */
+uint32 flowTextToMem(Image *DestIm, void *font,     /* the TextAttr pointer */
                      uint16 spacing,          /* How much vertical spacing between the lines */
                      uint16 pencolor,         /* pen number to use for text */
                      uint16 backpen,          /* the background color */
@@ -527,7 +525,7 @@ void copyLong64(uint32 *Dest, uint32 *Source, uint32 Many64) {
 /*****************************************************************************/
 static void doScrollBlack(void) {
 	byte *mem, *tempmem;
-	struct Image Im;
+	Image Im;
 	uint16 width, height, by, nheight, CurPage;
 	uint32 size, copysize;
 	uint32 *BaseAddr;
@@ -619,7 +617,7 @@ static void doScrollBlack(void) {
 
 
 
-extern struct BitMap RawDiffBM;
+extern BitMap RawDiffBM;
 extern DIFFHeader headerdata;
 
 
@@ -768,7 +766,7 @@ static void doScrollBounce(void) {
 /*****************************************************************************/
 static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
 	uint16 LastY, CurY, counter, linesdone = 0, lineslast;
-	struct Image ImSource, ImDest;
+	Image ImSource, ImDest;
 
 	if (IsHiRes) {
 		lineslast = 3;
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 859277c..e843d9b 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -41,16 +41,14 @@ extern bool IsHiRes;
 
 Common::KeyState _keyPressed;
 
-struct Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt) {
+Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt) {
 	Gadget *gptr;
 
-	if ((gptr = (Gadget *)calloc(sizeof(struct Gadget), 1))) {
+	if ((gptr = new Gadget())) {
 		gptr->x = x;
 		gptr->y = y;
 		gptr->GadgetID = id;
-#if !defined(DOSCODE)
 		gptr->KeyEquiv = key;
-#endif
 		gptr->Im = im;
 		gptr->ImAlt = imalt;
 		gptr->NextGadget = NULL;
@@ -64,7 +62,7 @@ struct Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im
 
 
 void freeButtonList(Gadget *gptrlist) {
-	struct Gadget *gptr, *next = gptrlist;
+	Gadget *gptr, *next = gptrlist;
 
 	while (next) {
 		gptr = next;
@@ -80,7 +78,7 @@ void freeButtonList(Gadget *gptrlist) {
 /*****************************************************************************/
 /* Draws a gadget list to the screen.                                        */
 /*****************************************************************************/
-void drawGadgetList(struct Gadget *gadlist) {
+void drawGadgetList(Gadget *gadlist) {
 	while (gadlist) {
 		drawImage(gadlist->Im, gadlist->x, gadlist->y);
 
@@ -95,7 +93,7 @@ void drawGadgetList(struct Gadget *gadlist) {
 /*****************************************************************************/
 /* Ghoasts a gadget, and makes it unavailable for using.                     */
 /*****************************************************************************/
-void ghoastGadget(struct Gadget *curgad, uint16 pencolor) {
+void ghoastGadget(Gadget *curgad, uint16 pencolor) {
 	ghoastRect(pencolor, curgad->x, curgad->y, curgad->x + curgad->Im->Width - 1, curgad->y + curgad->Im->Height - 1);
 	curgad->GadgetFlags |= GADGETOFF;
 }
@@ -105,7 +103,7 @@ void ghoastGadget(struct Gadget *curgad, uint16 pencolor) {
 /*****************************************************************************/
 /* Unghoasts a gadget, and makes it available again.                         */
 /*****************************************************************************/
-void unGhoastGadget(struct Gadget *curgad) {
+void unGhoastGadget(Gadget *curgad) {
 	drawImage(curgad->Im, curgad->x, curgad->y);
 	curgad->GadgetFlags &= !(GADGETOFF);
 }
@@ -114,20 +112,18 @@ void unGhoastGadget(struct Gadget *curgad) {
 /*****************************************************************************/
 /* Make a key press have the right case for a gadget KeyEquiv value.         */
 /*****************************************************************************/
-#if !defined(DOSCODE)
 uint16 makeGadgetKeyEquiv(uint16 key) {
 	if (Common::isAlnum(key))
 		key = tolower(key);
 
 	return key;
 }
-#endif
 
 /*****************************************************************************/
 /* Checks whether or not the cords fall within one of the gadgets in a list  */
 /* of gadgets.                                                               */
 /*****************************************************************************/
-static struct Gadget *checkNumGadgetHit(struct Gadget *gadlist, uint16 key) {
+static Gadget *checkNumGadgetHit(Gadget *gadlist, uint16 key) {
 #if !defined(DOSCODE)
 	uint16 gkey = key - '0';
 #else
@@ -177,17 +173,16 @@ static bool keyPress(uint16 *KeyCode) {
 }
 
 
-struct IntuiMessage IMessage;
-extern struct Gadget *ScreenGadgetList;
+IntuiMessage IMessage;
+extern Gadget *ScreenGadgetList;
 
-struct IntuiMessage *getMsg(void) {
-	struct Gadget *curgad;
+IntuiMessage *getMsg(void) {
+	Gadget *curgad;
 	int Qualifiers;
 
 	updateMouse();
-#if !defined(DOSCODE)
+
 	Qualifiers = _keyPressed.flags;
-#endif
 
 	if ((curgad = mouseGadget()) != NULL) {
 		updateMouse();
@@ -196,21 +191,15 @@ struct IntuiMessage *getMsg(void) {
 		IMessage.GadgetID = curgad->GadgetID;
 		IMessage.Qualifier = Qualifiers;
 		return &IMessage;
-	}
-
-	else if (mouseButton(&IMessage.MouseX, &IMessage.MouseY, true)) { /* Left Button */
+	} else if (mouseButton(&IMessage.MouseX, &IMessage.MouseY, true)) { /* Left Button */
 		IMessage.Qualifier = IEQUALIFIER_LEFTBUTTON | Qualifiers;
 		IMessage.Class = MOUSEBUTTONS;
 		return &IMessage;
-	}
-
-	else if (mouseButton(&IMessage.MouseX, &IMessage.MouseY, false)) { /* Right Button */
+	} else if (mouseButton(&IMessage.MouseX, &IMessage.MouseY, false)) { /* Right Button */
 		IMessage.Qualifier = IEQUALIFIER_RBUTTON | Qualifiers;
 		IMessage.Class = MOUSEBUTTONS;
 		return &IMessage;
-	}
-
-	else if (keyPress(&IMessage.Code)) { /* Keyboard key */
+	} else if (keyPress(&IMessage.Code)) { /* Keyboard key */
 		curgad = checkNumGadgetHit(ScreenGadgetList, IMessage.Code);
 
 		if (curgad) {
diff --git a/engines/lab/interface.h b/engines/lab/interface.h
index cb0115d..b077f3b 100644
--- a/engines/lab/interface.h
+++ b/engines/lab/interface.h
@@ -49,8 +49,8 @@ struct Gadget {
 	uint16 KeyEquiv; // if not zero, a key that activates gadget
 #endif
 	uint32 GadgetFlags;
-	struct Image *Im, *ImAlt;
-	struct Gadget *NextGadget;
+	Image *Im, *ImAlt;
+	Gadget *NextGadget;
 };
 
 extern Common::KeyState _keyPressed;
@@ -119,21 +119,17 @@ extern Common::KeyState _keyPressed;
 
 
 
-struct Gadget *createButton(uint16 x, uint16 y, uint16 id,
-#if !defined(DOSCODE)
-                            uint16 key,
-#endif
-                            struct Image *im, struct Image *imalt);
+Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt);
 
 void freeButtonList(void *gptrlist);
 
-void drawGadgetList(struct Gadget *gadlist);
+void drawGadgetList(Gadget *gadlist);
 
-void ghoastGadget(struct Gadget *curgad, uint16 pencolor);
+void ghoastGadget(Gadget *curgad, uint16 pencolor);
 
-void unGhoastGadget(struct Gadget *curgad);
+void unGhoastGadget(Gadget *curgad);
 
-struct IntuiMessage *getMsg(void);
+IntuiMessage *getMsg(void);
 
 void replyMsg(void *Msg);
 
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index ae822cb..bac197e 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -37,7 +37,7 @@
 
 namespace Lab {
 
-static struct TextFont filler, *msgfont = &filler;
+static TextFont filler, *msgfont = &filler;
 
 extern bool nopalchange, noscreenchange, hidemouse, DoBlack, NoFlip, IsHiRes;
 
@@ -63,7 +63,7 @@ extern int32 longcharsdrawn;
 /* the message port.                                                          */
 /******************************************************************************/
 void introEatMessages(void) {
-	struct IntuiMessage *Msg;
+	IntuiMessage *Msg;
 
 	while (1) {
 		Msg = getMsg();
@@ -88,7 +88,7 @@ void introEatMessages(void) {
 /*****************************************************************************/
 static void doPictText(const char *Filename, bool isscreen) {
 	uint32 lastsecs = 0L, lastmicros = 0L, secs = 0L, micros = 0L;
-	struct IntuiMessage *Msg;
+	IntuiMessage *Msg;
 	char filename[50] = "Lab:rooms/Intro/";
 	byte *curplace, **tfile;
 	bool DrawNextText = true, End = false, Begin = true;
diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
index 7c7875a..01f1ffa 100644
--- a/engines/lab/labfile.cpp
+++ b/engines/lab/labfile.cpp
@@ -86,10 +86,10 @@ uint32 sizeOfFile(const char *name) {
 
 
 
-typedef struct {
+struct FileMarker {
 	char name[32];
 	void *Start, *End;
-} FileMarker;
+};
 
 
 
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index abb0871..6f304d0 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -52,6 +52,7 @@ typedef struct {
 
 struct Image;
 struct TextFont;
+struct Gadget;
 
 /*----------------------------*/
 /*------ From Audioi.c -------*/
@@ -101,7 +102,7 @@ uint32 flowText(void *font,  /* the TextAttr pointer */
                 uint16 x1,               /* Cords */
                 uint16 y1, uint16 x2, uint16 y2, const char *text); /* The text itself */
 
-uint32 flowTextToMem(struct Image *DestIm, void *font,     /* the TextAttr pointer */
+uint32 flowTextToMem(Image *DestIm, void *font,     /* the TextAttr pointer */
                      uint16 spacing,          /* How much vertical spacing between the lines */
                      uint16 pencolor,         /* pen number to use for text */
                      uint16 backpen,          /* the background color */
@@ -136,7 +137,7 @@ void flipViews(void *scrPtr);
 /*----- From Interface.c -----*/
 /*----------------------------*/
 
-struct Gadget *addGadButton(uint16 x, uint16 y, void *UpImage, void *DownImage, uint16 id);
+Gadget *addGadButton(uint16 x, uint16 y, void *UpImage, void *DownImage, uint16 id);
 
 void gadgetsOnOff(void *gptr, void *win, int32 num, bool on);
 
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index eac1364..5f22746 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -42,8 +42,8 @@
 
 namespace Lab {
 
-static struct TextFont *BigMsgFont;
-static struct TextFont bmf;
+static TextFont *BigMsgFont;
+static TextFont bmf;
 
 
 extern uint16 Direction;
@@ -87,8 +87,7 @@ void setAmigaPal(uint16 *pal, uint16 numcolors) {
 bool getFont(const char *filename, TextFont *textfont) {
 	byte *fontbuffer;
 
-	fontbuffer = (byte *)stealBufMem(sizeOfFile(filename) -
-	                         (sizeof(struct TextFont) + 4));
+	fontbuffer = (byte *)stealBufMem(sizeOfFile(filename) - (sizeof(TextFont) + 4));
 	g_music->checkMusic();
 
 	if (fontbuffer == NULL)
@@ -227,7 +226,7 @@ static uint16 mapScaleY(uint16 y) {
 static bool loadMapData(void) {
 	byte **buffer, Temp[5];
 	int32 Size;
-	struct Gadget *gptr;
+	Gadget *gptr;
 	uint16 counter;
 
 	BigMsgFont = &bmf;
@@ -736,7 +735,7 @@ void processMap(uint16 CurRoom) {
 	char *sptr;
 	byte newcolor[3];
 	bool drawmap;
-	struct IntuiMessage *Msg;
+	IntuiMessage *Msg;
 
 	CurMsg   = CurRoom;
 	CurFloor = Maps[CurRoom].PageNumber;
diff --git a/engines/lab/modernsavegame.cpp b/engines/lab/modernsavegame.cpp
index 334e4c5..f9f558b 100644
--- a/engines/lab/modernsavegame.cpp
+++ b/engines/lab/modernsavegame.cpp
@@ -41,7 +41,7 @@ char g_PathSeperator[4];
 
 #define SAVEVERSION         "LBS3"
 
-int getSaveGameList(struct SaveGameInfo *info, int maxNum) {
+int getSaveGameList(SaveGameInfo *info, int maxNum) {
 	warning("STUB: getSaveGameList");
 
 	return 0;
@@ -112,7 +112,7 @@ int getSaveGameList(struct SaveGameInfo *info, int maxNum) {
 #endif
 }
 
-void freeSaveGameList(struct SaveGameInfo *info, int count) {
+void freeSaveGameList(SaveGameInfo *info, int count) {
 	int i;
 
 	for (i = 0; i < count; i++) {
diff --git a/engines/lab/modernsavegame.h b/engines/lab/modernsavegame.h
index bbee420..ee53cd0 100644
--- a/engines/lab/modernsavegame.h
+++ b/engines/lab/modernsavegame.h
@@ -46,8 +46,8 @@ struct SaveGameInfo {
 	char SaveGameDate[128];
 };
 
-int getSaveGameList(struct SaveGameInfo *info, int maxNum);
-void freeSaveGameList(struct SaveGameInfo *info, int count);
+int getSaveGameList(SaveGameInfo *info, int maxNum);
+void freeSaveGameList(SaveGameInfo *info, int count);
 
 } // End of namespace Lab
 
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index 3d83a0d..753e8ff 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -50,8 +50,8 @@ static bool MouseHidden = true, QuitMouseHandler = false;
 static int32 NumHidden   = 1;
 static uint16 CurMouseX, CurMouseY;
 static uint16 MouseImageWidth = 10, MouseImageHeight = 15;
-static struct Gadget *LastGadgetHit = NULL;
-struct Gadget *ScreenGadgetList = NULL;
+static Gadget *LastGadgetHit = NULL;
+Gadget *ScreenGadgetList = NULL;
 static byte MouseData[] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
 						   1, 7, 1, 0, 0, 0, 0, 0, 0, 0,
 						   1, 7, 7, 1, 0, 0, 0, 0, 0, 0,
@@ -69,12 +69,12 @@ static byte MouseData[] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
 						   0, 0, 0, 0, 0, 0, 1, 1, 0, 0};
 
 
-static struct Image MouseImage, BackImage;
+static Image MouseImage, BackImage;
 static byte BackImageBuffer[256];
 static uint16 backx, backy;
 
 static bool drawmouse = false, gadhit    = false;
-static struct Gadget *hitgad = NULL;
+static Gadget *hitgad = NULL;
 
 void mouseShowXY(uint16 CurMouseX, uint16 CurMouseY);
 
@@ -82,7 +82,7 @@ void mouseShowXY(uint16 CurMouseX, uint16 CurMouseY);
 /* Checks whether or not the cords fall within one of the gadgets in a list  */
 /* of gadgets.                                                               */
 /*****************************************************************************/
-static Gadget *checkGadgetHit(struct Gadget *gadlist, uint16 x, uint16 y) {
+static Gadget *checkGadgetHit(Gadget *gadlist, uint16 x, uint16 y) {
 	uint16 counter;
 
 	while (gadlist != NULL) {
@@ -121,7 +121,7 @@ static Gadget *checkGadgetHit(struct Gadget *gadlist, uint16 x, uint16 y) {
 
 
 
-void attachGadgetList(struct Gadget *GadList) {
+void attachGadgetList(Gadget *GadList) {
 	if (ScreenGadgetList != GadList)
 		LastGadgetHit = NULL;
 
@@ -165,7 +165,7 @@ static void restoreBackMouse(void) {
 }
 
 
-static struct Gadget *TempGad;
+static Gadget *TempGad;
 
 
 void mouse_handler(int32 max, int32 mcx, int32 mdx) {
diff --git a/engines/lab/mouse.h b/engines/lab/mouse.h
index 108afc2..8a9a3b7 100644
--- a/engines/lab/mouse.h
+++ b/engines/lab/mouse.h
@@ -55,7 +55,7 @@ bool mouseButton(uint16 *x, uint16 *y, bool leftbutton);
 
 Gadget *mouseGadget(void);
 
-void attachGadgetList(struct Gadget *GadList);
+void attachGadgetList(Gadget *GadList);
 
 void mouse_handler(int32 max, int32 mcx, int32 mdx);
 
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index 2d6c7d8..8da94d6 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -37,7 +37,7 @@
 
 namespace Lab {
 
-extern struct BitMap *DispBitMap, *DrawBitMap;
+extern BitMap *DispBitMap, *DrawBitMap;
 extern uint32 VGABytesPerPage;
 
 /*
@@ -88,7 +88,7 @@ static bool continuous,
 
 char diffcmap[256 * 3], lastcmap[256 * 3];
 
-struct BitMap RawDiffBM;
+BitMap RawDiffBM;
 
 
 
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index b033386..3ab548a 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -54,7 +54,7 @@ int g_IsRegistered;
 
 extern bool nopalchange, DoBlack, IsHiRes;
 
-extern struct BitMap *DispBitMap, *DrawBitMap;
+extern BitMap *DispBitMap, *DrawBitMap;
 extern char diffcmap[3 * 256];
 
 extern uint32 VGAScreenWidth, VGAScreenHeight;
@@ -106,7 +106,7 @@ static byte *loadBackPict(const char *fileName, bool tomem) {
 
 
 
-static struct Image *Images[10];
+static Image *Images[10];
 
 
 uint16 combination[6] = {0, 0, 0, 0, 0, 0}, solution[] = {0, 4, 0, 8, 7, 2};
@@ -161,7 +161,7 @@ void showCombination(const char *filename) {
 /* Changes the combination number of one of the slots                        */
 /*****************************************************************************/
 static void changeCombination(uint16 number) {
-	struct Image display;
+	Image display;
 	uint16 counter, combnum;
 	bool unlocked = true;
 
@@ -251,7 +251,7 @@ void mouseCombination(uint16 x, uint16 y) {
 
 
 
-struct Image *Tiles[16];
+Image *Tiles[16];
 int16 CurTile[4] [4] = {
 	{ 1, 5,  9, 13 },
 	{ 2, 6, 10, 14 },
@@ -513,9 +513,9 @@ void mouseTile(uint16 x, uint16 y) {
 /*------------------------ Does the detective notes. ------------------------*/
 /*---------------------------------------------------------------------------*/
 
-extern struct TextFont *MsgFont;
-static struct TextFont *BigMsgFont;
-static struct TextFont bmfont;
+extern TextFont *MsgFont;
+static TextFont *BigMsgFont;
+static TextFont bmfont;
 
 
 /*****************************************************************************/
@@ -631,10 +631,10 @@ static uint16 JPage = 0;
 
 static bool lastpage = false;
 
-static struct Image *JCancel, *JCancelAlt, *JLeft, *JLeftAlt, *JRight, *JRightAlt, JBackImage, ScreenImage;
+static Image *JCancel, *JCancelAlt, *JLeft, *JLeftAlt, *JRight, *JRightAlt, JBackImage, ScreenImage;
 
 static uint16 JGadX[3] = {80, 144, 194}, JGadY[3] = {162, 164, 162};
-static struct Gadget ForwardG, CancelG, BackG;
+static Gadget ForwardG, CancelG, BackG;
 
 
 
@@ -645,7 +645,7 @@ static struct Gadget ForwardG, CancelG, BackG;
 static bool loadJournalData() {
 	byte **buffer;
 	char filename[20];
-	struct Gadget *TopGadget = &BackG;
+	Gadget *TopGadget = &BackG;
 	uint16 counter;
 	bool bridge, dirty, news, clean;
 
@@ -863,13 +863,13 @@ static void drawJournal(uint16 wipenum, bool needFade) {
 /* Processes user input.                                                     */
 /*****************************************************************************/
 static void processJournal() {
-	struct IntuiMessage *Msg;
+	IntuiMessage *Msg;
 	uint32 Class;
 	uint16 Qualifier, GadID;
 
 	while (1) {
 		g_music->checkMusic();  /* Make sure we check the music at least after every message */
-		Msg = (struct IntuiMessage *) getMsg();
+		Msg = (IntuiMessage *) getMsg();
 
 		if (Msg == NULL) {
 			g_music->newCheckMusic();
@@ -970,7 +970,7 @@ void doJournal() {
 /*---------------------------------------------------------------------------*/
 
 
-struct Image *Arrow1, *NoArrow1, *DriveButton;
+Image *Arrow1, *NoArrow1, *DriveButton;
 
 
 extern InventoryData *Inventory;
@@ -1084,7 +1084,7 @@ void getRoomMessage(int MyRoomNum, int MyDirection, char *msg);
 extern char g_SaveGamePath[512];
 extern char g_PathSeperator[4];
 
-struct SaveGameInfo g_SaveGameInfo[MAX_SAVED_GAMES];
+SaveGameInfo g_SaveGameInfo[MAX_SAVED_GAMES];
 int g_TotalSavedGames;
 char g_CommonPalette[3 * 256];
 int g_LastSaveGameNumber = 0;
@@ -1093,7 +1093,19 @@ int g_CurSaveSet = 0;
 int g_PendingNewSave = 0;
 
 enum UI_Ident {
-	ID_SAVE, ID_LOAD, ID_NEWSLOT, ID_1_TO_5, ID_6_TO_10, ID_11_TO_15, ID_SLOT_A, ID_SLOT_B, ID_SLOT_C, ID_SLOT_D, ID_SLOT_E, ID_CANCEL, ID_LAST
+	ID_SAVE,
+	ID_LOAD,
+	ID_NEWSLOT,
+	ID_1_TO_5,
+	ID_6_TO_10,
+	ID_11_TO_15,
+	ID_SLOT_A,
+	ID_SLOT_B,
+	ID_SLOT_C,
+	ID_SLOT_D,
+	ID_SLOT_E,
+	ID_CANCEL,
+	ID_LAST
 };
 
 struct ModernUI {
@@ -1101,12 +1113,27 @@ struct ModernUI {
 	int x, y, w, h;
 };
 
-struct ModernUI theUI[ID_LAST] = {
-	{ ID_LOAD,      491, 182, 128,  54 }, { ID_SAVE,      491, 255, 128,  54 }, { ID_NEWSLOT,   491, 328, 128,  54 }, { ID_1_TO_5,     27,  40, 146,  25 }, { ID_6_TO_10,   175,  40, 146,  25 }, { ID_11_TO_15,  323,  40, 146,  25 }, { ID_SLOT_A,     27,  67, 442,  72 }, { ID_SLOT_B,     27, 142, 442,  72 }, { ID_SLOT_C,     27, 217, 442,  72 }, { ID_SLOT_D,     27, 292, 442,  72 }, { ID_SLOT_E,     27, 367, 442,  72 }, { ID_CANCEL,    531, 405,  52,  52 }
+ModernUI theUI[ID_LAST] = {
+	{ ID_LOAD,      491, 182, 128,  54 },
+	{ ID_SAVE,      491, 255, 128,  54 },
+	{ ID_NEWSLOT,   491, 328, 128,  54 },
+	{ ID_1_TO_5,     27,  40, 146,  25 },
+	{ ID_6_TO_10,   175,  40, 146,  25 },
+	{ ID_11_TO_15,  323,  40, 146,  25 },
+	{ ID_SLOT_A,     27,  67, 442,  72 },
+	{ ID_SLOT_B,     27, 142, 442,  72 },
+	{ ID_SLOT_C,     27, 217, 442,  72 },
+	{ ID_SLOT_D,     27, 292, 442,  72 },
+	{ ID_SLOT_E,     27, 367, 442,  72 },
+	{ ID_CANCEL,    531, 405,  52,  52 }
 };
 
 enum {
-	SG_BLACK = 1, SG_TAN = 14, SG_DKTAN = 38, SG_WHITE = 105, SG_YELLOW = 118
+	SG_BLACK = 1,
+	SG_TAN   = 14,
+	SG_DKTAN = 38,
+	SG_WHITE = 105,
+	SG_YELLOW = 118
 };
 
 /*****************************************************************************/
@@ -1178,7 +1205,7 @@ static void drawSaveLoad() {
 	for (i = 0, j = 5 * g_CurSaveSet; i < 5; i++, j++) {
 		uint16 hue, y;
 		char num_text[4];
-		struct Image thumbnail, screen;
+		Image thumbnail, screen;
 
 		if (j < g_TotalSavedGames + g_PendingNewSave) {
 			char msg[256];
@@ -1224,7 +1251,7 @@ static void drawSaveLoad() {
 	WSDL_UpdateScreen();
 }
 
-static void makeThumbnail(struct SaveGameInfo *info) {
+static void makeThumbnail(SaveGameInfo *info) {
 	char *pictName;
 	CloseDataPtr CPtr = NULL;
 	byte *BitMapMem;
@@ -1260,7 +1287,7 @@ static void makeThumbnail(struct SaveGameInfo *info) {
 }
 
 static void addSaveSlot() {
-	struct SaveGameInfo *info;
+	SaveGameInfo *info;
 
 	if (g_PendingNewSave || g_TotalSavedGames == MAX_SAVED_GAMES)
 		return;
@@ -1370,7 +1397,7 @@ static bool doLoadGame() {
 /* Processes user input.                                                     */
 /*****************************************************************************/
 static bool processSaveLoad() {
-	struct IntuiMessage *Msg;
+	IntuiMessage *Msg;
 
 	uint32 Class;
 	uint16 Qualifier, MouseX, MouseY, Code;
@@ -1700,7 +1727,7 @@ static void checkFiles(void) {
 /* Processes user input.                                                     */
 /*****************************************************************************/
 static uint16 processSaveRestore(uint16 type) {
-	struct IntuiMessage *Msg;
+	IntuiMessage *Msg;
 
 	uint32 Class;
 	uint16 Qualifier, MouseX, MouseY, Code, Temp;
@@ -1913,7 +1940,8 @@ static uint16 monpage;
 static const char *TextFileName;
 
 
-struct Image *MonButton, *AltMonButton, *MonQuit, *AltMonQuit, *MonBack, *AltMonBack, *MonDown, *AltMonDown, *MonUp, *AltMonUp;
+Image *MonButton, *AltMonButton, *MonQuit, *AltMonQuit, *MonBack, *AltMonBack,
+		*MonDown, *AltMonDown, *MonUp, *AltMonUp;
 
 
 
@@ -2004,7 +2032,7 @@ static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2,
 /* Processes user input.                                                     */
 /*****************************************************************************/
 static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	struct IntuiMessage *Msg;
+	IntuiMessage *Msg;
 	uint32 Class;
 	uint16 Qualifier, Code, MouseX, MouseY;
 	const char *Test = " ", *StartFileName = TextFileName;
@@ -2158,7 +2186,7 @@ void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1,
 
 #if defined(LABDEMO)
 void doTrialBlock() {
-	struct IntuiMessage *Msg;
+	IntuiMessage *Msg;
 
 	uint32 Class;
 	uint16 Qualifier, MouseX, MouseY, Code, Temp;
diff --git a/engines/lab/text.h b/engines/lab/text.h
index 4947fda..254a137 100644
--- a/engines/lab/text.h
+++ b/engines/lab/text.h
@@ -52,17 +52,17 @@ struct TextFont {
 #pragma pack(pop)
 #endif
 
-bool openFontMem(const char *TextFontPath, struct TextFont *tf, byte *fontbuffer);
+bool openFontMem(const char *TextFontPath, TextFont *tf, byte *fontbuffer);
 
-bool openFont(const char *TextFontPath, struct TextFont **tf);
+bool openFont(const char *TextFontPath, TextFont **tf);
 
-void closeFont(struct TextFont *tf);
+void closeFont(TextFont *tf);
 
-uint16 textLength(struct TextFont *tf, const char *text, uint16 numchars);
+uint16 textLength(TextFont *tf, const char *text, uint16 numchars);
 
-uint16 textHeight(struct TextFont *tf);
+uint16 textHeight(TextFont *tf);
 
-void text(struct TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numchars);
+void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numchars);
 
 } // End of namespace Lab
 
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 403fe60..10e52e1 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -342,7 +342,7 @@ void getMode(uint16 *Mode) {
 /*****************************************************************************/
 /* Draws an image to the screen.                                             */
 /*****************************************************************************/
-void drawImage(struct Image *Im, uint16 x, uint16 y) {
+void drawImage(Image *Im, uint16 x, uint16 y) {
 #if !defined(DOSCODE)
 	int sx, sy, dx, dy, w, h;
 
@@ -458,7 +458,7 @@ void drawImage(struct Image *Im, uint16 x, uint16 y) {
 /*****************************************************************************/
 /* Draws an image to the screen.                                             */
 /*****************************************************************************/
-void drawMaskImage(struct Image *Im, uint16 x, uint16 y) {
+void drawMaskImage(Image *Im, uint16 x, uint16 y) {
 #if !defined(DOSCODE)
 	int sx, sy, dx, dy, w, h;
 
@@ -588,7 +588,7 @@ void drawMaskImage(struct Image *Im, uint16 x, uint16 y) {
 /*****************************************************************************/
 /* Reads an image from the screen.                                           */
 /*****************************************************************************/
-void readScreenImage(struct Image *Im, uint16 x, uint16 y) {
+void readScreenImage(Image *Im, uint16 x, uint16 y) {
 #if !defined(DOSCODE)
 	int sx, sy, dx, dy, w, h;
 
@@ -839,7 +839,7 @@ byte *TempScrollData;
 /* function will fail.                                                       */
 /*****************************************************************************/
 void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	struct Image Im;
+	Image Im;
 	uint16 temp;
 
 	Im.ImageData = TempScrollData;
@@ -885,7 +885,7 @@ void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 /* Scrolls the display in the y direction by blitting.                       */
 /*****************************************************************************/
 void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	struct Image Im;
+	Image Im;
 	uint16 temp;
 
 	Im.ImageData = TempScrollData;
diff --git a/engines/lab/vga.h b/engines/lab/vga.h
index a0b2f63..8c1d372 100644
--- a/engines/lab/vga.h
+++ b/engines/lab/vga.h
@@ -73,13 +73,13 @@ void VGASetPal(void *cmap, uint16 numcolors);
 
 /*---------- Drawing Routines ----------*/
 
-void drawImage(struct Image *Im, uint16 x, uint16 y);
+void drawImage(Image *Im, uint16 x, uint16 y);
 
-void drawMaskImage(struct Image *Im, uint16 x, uint16 y);
+void drawMaskImage(Image *Im, uint16 x, uint16 y);
 
-void readScreenImage(struct Image *Im, uint16 x, uint16 y);
+void readScreenImage(Image *Im, uint16 x, uint16 y);
 
-void bltBitMap(struct Image *ImSource, uint16 xs, uint16 ys, struct Image *ImDest, uint16 xd, uint16 yd, uint16 width, uint16 height);
+void bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest, uint16 xd, uint16 yd, uint16 width, uint16 height);
 
 void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 


Commit: 85ea7da24e2f10c0e2a5834a468c34ca5a4602b4
    https://github.com/scummvm/scummvm/commit/85ea7da24e2f10c0e2a5834a468c34ca5a4602b4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Improved detection

Changed paths:
    engines/lab/detection.cpp



diff --git a/engines/lab/detection.cpp b/engines/lab/detection.cpp
index f7632c7..a7d70eb 100644
--- a/engines/lab/detection.cpp
+++ b/engines/lab/detection.cpp
@@ -36,7 +36,7 @@
 #include "lab/lab.h"
 
 static const PlainGameDescriptor lab_setting[] = {
-	{ "lab", "Labyrith of Time Engine game" },
+	{ "lab", "Labyrith of Time" },
 	{ 0, 0 }
 };
 
@@ -47,6 +47,7 @@ static const ADGameDescription labDescriptions[] = {
 		{
 			{ "doors",   0, "d77536010e7e5ae17ee066323ceb9585", 2537 },
 			{ "notes11", 0, "63e873f659f8f46f9809d16a2bf653c7", 3562 },
+			{ "inv",     0, "8c3677dba0113067619f88d301795b39", 23472 },
 			{ NULL, 0, NULL, 0 }
 		},
 		Common::EN_ANY,
@@ -56,6 +57,50 @@ static const ADGameDescription labDescriptions[] = {
 	},
 	{
 		"lab",
+		"lowres",
+		{
+			{ "doors",   0, "d77536010e7e5ae17ee066323ceb9585", 2537 },
+			{ "notes11", 0, "63e873f659f8f46f9809d16a2bf653c7", 3562 },
+			{ "inv",     0, "1633476827f614554be53d358ac2f8c0", 5076 },
+			{ NULL, 0, NULL, 0 }
+		},
+		Common::EN_ANY,
+		Common::kPlatformDOS,
+		ADGF_NO_FLAGS,
+		GUIO0()
+	},
+	{
+		"lab",
+		"Rerelease",
+		{
+			{ "doors",   0, "d77536010e7e5ae17ee066323ceb9585", 2537 },
+			{ "notes11", 0, "63e873f659f8f46f9809d16a2bf653c7", 3562 },
+			{ "inv",     0, "0a5377f0673454b1743322471892ad43", 39120 },
+			{ "48",      0, "fb2d990c5fb5dd36a618e5ca8136b740", 892 },
+			{ NULL, 0, NULL, 0 }
+		},
+		Common::EN_ANY,
+		Common::kPlatformWindows,
+		ADGF_NO_FLAGS,
+		GUIO0()
+	},
+	{
+		"lab",
+		"Trial",
+		{
+			{ "doors",   0, "d77536010e7e5ae17ee066323ceb9585", 2537 },
+			{ "notes11", 0, "63e873f659f8f46f9809d16a2bf653c7", 3562 },
+			{ "inv",     0, "0a5377f0673454b1743322471892ad43", 39120 },
+			{ "48",      0, "a319ba9bab20b24200257e826b5494e1", 892 },
+			{ NULL, 0, NULL, 0 }
+		},
+		Common::EN_ANY,
+		Common::kPlatformWindows,
+		ADGF_DEMO,
+		GUIO0()
+	},
+	{
+		"lab",
 		"",
 		AD_ENTRY1s("doors", "7bf458df6ec30cc8ef4665e4d7c77f59", 2537),
 		Common::EN_ANY,
@@ -69,6 +114,9 @@ static const ADGameDescription labDescriptions[] = {
 static const char *const directoryGlobs[] = {
         "fonts",
 		"game",
+		"pict",
+		"spict",
+		"rooms",
         0
 };
 
@@ -77,7 +125,7 @@ public:
 	LabMetaEngine() : AdvancedMetaEngine(labDescriptions, sizeof(ADGameDescription), lab_setting) {
 		_singleid = "lab";
 
-		_maxScanDepth = 2;
+		_maxScanDepth = 3;
 		_directoryGlobs = directoryGlobs;
 	}
 


Commit: 7ee90c693f962e54041f0bb30ab9d98521bba545
    https://github.com/scummvm/scummvm/commit/7ee90c693f962e54041f0bb30ab9d98521bba545
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Cleanup

Changed paths:
    engines/lab/graphics.cpp



diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index ba7c232..41f4a79 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -69,9 +69,6 @@ extern uint32 VGAScreenWidth, VGAScreenHeight, VGAPages, VGABytesPerPage;
 /*****************************************************************************/
 bool readPict(const char *filename, bool PlayOnce) {
 	byte **file = NULL;
-#if defined(DOSCODE)
-	uint16 counter;
-#endif
 
 	stopDiff();
 
@@ -90,26 +87,12 @@ bool readPict(const char *filename, bool PlayOnce) {
 
 	DispBitMap->BytesPerRow = VGAScreenWidth;
 	DispBitMap->Rows        = VGAScreenHeight;
-#if defined(DOSCODE)
-	DispBitMap->Flags       = 0;
-#else
 	DispBitMap->Flags       = BITMAPF_VIDEO;
-#endif
 	DispBitMap->Depth       = VGAPages;
-#if defined(DOSCODE)
-
-	for (counter = 0; counter < VGAPages; counter++)
-		DispBitMap->Planes[counter] = getVGABaseAddr();
-
-#else
-	// playDiff deals with resetting planes for the "video" display.
-#endif
 
 	readDiff(PlayOnce);
 
-#if !defined(DOSCODE)
 	ungetVGABaseAddr();
-#endif
 
 	return true;
 }
@@ -144,9 +127,6 @@ bool readMusic(const char *filename) {
 byte *readPictToMem(const char *filename, uint16 x, uint16 y) {
 	byte **file = NULL;
 	byte *Mem, *CurMem;
-#if defined(DOSCODE)
-	uint16 counter;
-#endif
 
 	stopDiff();
 
@@ -166,20 +146,11 @@ byte *readPictToMem(const char *filename, uint16 x, uint16 y) {
 	DispBitMap->Rows        = y;
 	DispBitMap->Flags       = 0;
 	DispBitMap->Depth       = VGAPages;
-#if defined(DOSCODE)
-
-	for (counter = 0; counter < VGAPages; counter++) {
-		DispBitMap->Planes[counter] = CurMem;
-		CurMem += VGABytesPerPage;
-	}
-
-#else
 	DispBitMap->Planes[0] = CurMem;
 	DispBitMap->Planes[1] = DispBitMap->Planes[0] + 0x10000;
 	DispBitMap->Planes[2] = DispBitMap->Planes[1] + 0x10000;
 	DispBitMap->Planes[3] = DispBitMap->Planes[2] + 0x10000;
 	DispBitMap->Planes[4] = DispBitMap->Planes[3] + 0x10000;
-#endif
 
 	readDiff(true);
 
@@ -534,18 +505,8 @@ static void doScrollBlack(void) {
 	width = VGAScaleX(320);
 	height = VGAScaleY(149) + SVGACord(2);
 
-	/*
-	   while (EffectPlaying)
-	   {
-	    g_music->updateMusic();
-	    waitTOF();
-	   }
-	 */
-
 	allocFile((void **) &mem, (int32) width * (int32) height, "Temp Mem");
-	/*
-	   mem = stealBufMem((int32) width * (int32) height);
-	 */
+
 	Im.Width = width;
 	Im.Height = height;
 	Im.ImageData = mem;
@@ -564,9 +525,7 @@ static void doScrollBlack(void) {
 		if (!IsHiRes)
 			waitTOF();
 
-#if !defined(DOSCODE)
 		BaseAddr = (uint32 *) getVGABaseAddr();
-#endif
 
 		if (by > nheight)
 			by = nheight;
@@ -608,10 +567,7 @@ static void doScrollBlack(void) {
 
 	freeAllStolenMem();
 	mouseShow();
-
-#if !defined(DOSCODE)
 	ungetVGABaseAddr();
-#endif
 }
 
 
@@ -628,7 +584,7 @@ static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startli
 	uint16 CurPage;
 	uint32 *BaseAddr;
 
-	BaseAddr = (uint32 *) getVGABaseAddr();
+	BaseAddr = (uint32 *)getVGABaseAddr();
 
 	size = (int32)(height - nheight) * (int32) width;
 	mem += startline * width;
@@ -650,9 +606,7 @@ static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startli
 		OffSet = 0;
 	}
 
-#if !defined(DOSCODE)
 	ungetVGABaseAddr();
-#endif
 }
 
 
@@ -839,9 +793,7 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
 					linesdone = 0;
 				}
 
-#if !defined(DOSCODE)
 				ImDest.ImageData = getVGABaseAddr();
-#endif
 
 				bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, VGAScreenWidth, 2);
 				ghoastRect(0, 0, CurY, VGAScreenWidth - 1, CurY + 1);
@@ -860,9 +812,7 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
 					linesdone = 0;
 				}
 
-#if !defined(DOSCODE)
 				ImDest.ImageData = getVGABaseAddr();
-#endif
 
 				if (CurY == LastY)
 					bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, VGAScreenWidth, 1);
@@ -875,9 +825,7 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
 		}
 	}
 
-#if !defined(DOSCODE)
 	ungetVGABaseAddr();
-#endif
 }
 
 


Commit: 01e290e4c3cbea59690b1e0283627bd4d3242eb1
    https://github.com/scummvm/scummvm/commit/01e290e4c3cbea59690b1e0283627bd4d3242eb1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Added detection for lowres DOS version

Changed paths:
    engines/lab/detection.cpp



diff --git a/engines/lab/detection.cpp b/engines/lab/detection.cpp
index a7d70eb..5c69a1a 100644
--- a/engines/lab/detection.cpp
+++ b/engines/lab/detection.cpp
@@ -40,14 +40,18 @@ static const PlainGameDescriptor lab_setting[] = {
 	{ 0, 0 }
 };
 
+enum GameFeatures {
+        GF_LOWRES = 1 << 0
+};
+
 static const ADGameDescription labDescriptions[] = {
 	{
 		"lab",
 		"",
 		{
-			{ "doors",   0, "d77536010e7e5ae17ee066323ceb9585", 2537 },
-			{ "notes11", 0, "63e873f659f8f46f9809d16a2bf653c7", 3562 },
-			{ "inv",     0, "8c3677dba0113067619f88d301795b39", 23472 },
+			{ "doors",       0, "d77536010e7e5ae17ee066323ceb9585", 2537 },
+			{ "notes11",     0, "63e873f659f8f46f9809d16a2bf653c7", 3562 },
+			{ "noteold.fon", 0, "6c1d90ad55149556e79d3f7bfddb4bd7", 9252 },
 			{ NULL, 0, NULL, 0 }
 		},
 		Common::EN_ANY,
@@ -57,16 +61,16 @@ static const ADGameDescription labDescriptions[] = {
 	},
 	{
 		"lab",
-		"lowres",
+		"Lowres",
 		{
 			{ "doors",   0, "d77536010e7e5ae17ee066323ceb9585", 2537 },
 			{ "notes11", 0, "63e873f659f8f46f9809d16a2bf653c7", 3562 },
-			{ "inv",     0, "1633476827f614554be53d358ac2f8c0", 5076 },
+			{ "64b",     0, "3a84d41bcc6a782f22e8e954bce09721", 39916 },
 			{ NULL, 0, NULL, 0 }
 		},
 		Common::EN_ANY,
 		Common::kPlatformDOS,
-		ADGF_NO_FLAGS,
+		GF_LOWRES,
 		GUIO0()
 	},
 	{
@@ -117,6 +121,7 @@ static const char *const directoryGlobs[] = {
 		"pict",
 		"spict",
 		"rooms",
+		"h2",
         0
 };
 
@@ -125,7 +130,7 @@ public:
 	LabMetaEngine() : AdvancedMetaEngine(labDescriptions, sizeof(ADGameDescription), lab_setting) {
 		_singleid = "lab";
 
-		_maxScanDepth = 3;
+		_maxScanDepth = 4;
 		_directoryGlobs = directoryGlobs;
 	}
 


Commit: 60388893a95e8ef3044dd00dd10087967be04fdf
    https://github.com/scummvm/scummvm/commit/60388893a95e8ef3044dd00dd10087967be04fdf
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: propagate gamePlatform()

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



diff --git a/engines/lab/detection.cpp b/engines/lab/detection.cpp
index 5c69a1a..3c9174a 100644
--- a/engines/lab/detection.cpp
+++ b/engines/lab/detection.cpp
@@ -40,10 +40,6 @@ static const PlainGameDescriptor lab_setting[] = {
 	{ 0, 0 }
 };
 
-enum GameFeatures {
-        GF_LOWRES = 1 << 0
-};
-
 static const ADGameDescription labDescriptions[] = {
 	{
 		"lab",
@@ -70,7 +66,7 @@ static const ADGameDescription labDescriptions[] = {
 		},
 		Common::EN_ANY,
 		Common::kPlatformDOS,
-		GF_LOWRES,
+		Lab::GF_LOWRES,
 		GUIO0()
 	},
 	{
@@ -125,6 +121,14 @@ static const char *const directoryGlobs[] = {
         0
 };
 
+namespace Lab {
+
+Common::Platform LabEngine::getPlatform() const {
+	return _gameDescription->platform;
+}
+
+} // End of namespace Lab
+
 class LabMetaEngine : public AdvancedMetaEngine {
 public:
 	LabMetaEngine() : AdvancedMetaEngine(labDescriptions, sizeof(ADGameDescription), lab_setting) {
@@ -142,9 +146,9 @@ public:
 		return "Labytinth of Time (c) 2004 The Wyrmkeep Entertainment Co.";
 	}
 
-	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription * /* desc */) const {
+	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
 		// Instantiate Engine even if the game data is not found.
-		*engine = new Lab::LabEngine(syst);
+		*engine = new Lab::LabEngine(syst, desc);
 		return true;
 	}
 
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 971543a..911ad6d 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -39,6 +39,8 @@
 #include "lab/lab.h"
 #include "lab/labfun.h"
 
+#include "engines/advancedDetector.h"
+
 namespace Lab {
 
 bool LabEngine::hasFeature(EngineFeature f) const {
@@ -47,8 +49,8 @@ bool LabEngine::hasFeature(EngineFeature f) const {
 
 LabEngine *g_lab;
 
-LabEngine::LabEngine(OSystem *syst)
- : Engine(syst) {
+LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
+ : Engine(syst), _gameDescription(gameDesc) {
 	g_lab = this;
 }
 
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index bdb0b4d..72e359c 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -36,17 +36,26 @@
 #include "engines/engine.h"
 #include "lab/labfun.h"
 
+struct ADGameDescription;
+
 namespace Lab {
 
+enum GameFeatures {
+        GF_LOWRES = 1 << 0
+};
+
 class LabEngine : public Engine {
 public:
-	LabEngine(OSystem *syst);
+	LabEngine(OSystem *syst, const ADGameDescription *gameDesc);
 	~LabEngine();
 
 	virtual Common::Error run();
 
 	bool hasFeature(EngineFeature f) const;
 
+	const ADGameDescription *_gameDescription;
+	Common::Platform getPlatform() const;
+
 	LargeSet *_conditions, *_roomsFound;
 };
 


Commit: 60d4f0a0695f8eaf5aced2df7dfe3c191e37ae25
    https://github.com/scummvm/scummvm/commit/60d4f0a0695f8eaf5aced2df7dfe3c191e37ae25
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Initial support for lowres mode

Changed paths:
    engines/lab/detection.cpp
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/interface.cpp
    engines/lab/intro.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/mouse.cpp
    engines/lab/special.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/detection.cpp b/engines/lab/detection.cpp
index 3c9174a..1cd78a1 100644
--- a/engines/lab/detection.cpp
+++ b/engines/lab/detection.cpp
@@ -127,6 +127,10 @@ Common::Platform LabEngine::getPlatform() const {
 	return _gameDescription->platform;
 }
 
+uint32 LabEngine::getFeatures() const {
+	return _gameDescription->flags;
+}
+
 } // End of namespace Lab
 
 class LabMetaEngine : public AdvancedMetaEngine {
@@ -136,6 +140,7 @@ public:
 
 		_maxScanDepth = 4;
 		_directoryGlobs = directoryGlobs;
+		_flags = kADFlagUseExtraAsHint;
 	}
 
 	virtual const char *getName() const {
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 6104270..447a8fe 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -56,7 +56,6 @@ extern InventoryData *Inventory;
 extern uint16 NumInv, RoomNum, ManyRooms, HighestCondition, Direction;
 CloseDataPtr CPtr;
 
-#if !defined(DOSCODE)
 CrumbData BreadCrumbs[MAX_CRUMBS];
 uint16 NumCrumbs;
 bool DroppingCrumbs;
@@ -69,7 +68,6 @@ bool IsCrumbWaiting;
 int     followCrumbs();
 void    mayShowCrumbIndicator();
 void    mayShowCrumbIndicatorOff();
-#endif
 
 bool Alternate = false, ispal = false, noupdatediff = false, MainDisplay = true, QuitLab = false, DoNotReset = false;
 
@@ -131,12 +129,7 @@ static uint32 BUFFERSIZE = BIGBUFFERSIZE;
 
 static byte *MovePanelBuffer, *InvPanelBuffer;
 static uint32 MovePanelBufferSize, InvPanelBufferSize;
-static Image *MoveImages[20],
-#if defined(DOSCODE)
-		*InvImages[6];
-#else
-		*InvImages[10];
-#endif
+static Image *MoveImages[20], *InvImages[10];
 static Gadget *MoveGadgetList, *InvGadgetList;
 
 
@@ -173,14 +166,14 @@ void drawPanel(void) {
 		drawHLine(0, VGAScaleY(170) + 1, VGAScaleX(319)); /* The horizontal lines under the black one */
 		drawGadgetList(MoveGadgetList);
 	} else {
-#if defined(DOSCODE)
-		drawVLine(VGAScaleX(124), VGAScaleY(170) + 1, VGAScaleY(199)); /* Vertical Black lines */
-		drawVLine(VGAScaleX(194), VGAScaleY(170) + 1, VGAScaleY(199));
-#else
-		drawVLine(VGAScaleX(90), VGAScaleY(170) + 1, VGAScaleY(199));  /* Vertical Black lines */
-		drawVLine(VGAScaleX(160), VGAScaleY(170) + 1, VGAScaleY(199));
-		drawVLine(VGAScaleX(230), VGAScaleY(170) + 1, VGAScaleY(199));
-#endif
+		if (g_lab->getPlatform() != Common::kPlatformWindows) {
+			drawVLine(VGAScaleX(124), VGAScaleY(170) + 1, VGAScaleY(199)); /* Vertical Black lines */
+			drawVLine(VGAScaleX(194), VGAScaleY(170) + 1, VGAScaleY(199));
+		} else {
+			drawVLine(VGAScaleX(90), VGAScaleY(170) + 1, VGAScaleY(199));  /* Vertical Black lines */
+			drawVLine(VGAScaleX(160), VGAScaleY(170) + 1, VGAScaleY(199));
+			drawVLine(VGAScaleX(230), VGAScaleY(170) + 1, VGAScaleY(199));
+		}
 
 		setAPen(4);
 		drawHLine(0, VGAScaleY(170) + 1, VGAScaleX(122));   /* The horizontal lines under the black one */
@@ -188,14 +181,14 @@ void drawPanel(void) {
 		drawHLine(VGAScaleX(196), VGAScaleY(170) + 1, VGAScaleX(319));
 
 		drawVLine(VGAScaleX(1), VGAScaleY(170) + 2, VGAScaleY(198)); /* The vertical high light lines */
-#if defined(DOSCODE)
-		drawVLine(VGAScaleX(126), VGAScaleY(170) + 2, VGAScaleY(198));
-		drawVLine(VGAScaleX(196), VGAScaleY(170) + 2, VGAScaleY(198));
-#else
-		drawVLine(VGAScaleX(92), VGAScaleY(170) + 2, VGAScaleY(198));
-		drawVLine(VGAScaleX(162), VGAScaleY(170) + 2, VGAScaleY(198));
-		drawVLine(VGAScaleX(232), VGAScaleY(170) + 2, VGAScaleY(198));
-#endif
+		if (g_lab->getPlatform() != Common::kPlatformWindows) {
+			drawVLine(VGAScaleX(126), VGAScaleY(170) + 2, VGAScaleY(198));
+			drawVLine(VGAScaleX(196), VGAScaleY(170) + 2, VGAScaleY(198));
+		} else {
+			drawVLine(VGAScaleX(92), VGAScaleY(170) + 2, VGAScaleY(198));
+			drawVLine(VGAScaleX(162), VGAScaleY(170) + 2, VGAScaleY(198));
+			drawVLine(VGAScaleX(232), VGAScaleY(170) + 2, VGAScaleY(198));
+		}
 
 		drawGadgetList(InvGadgetList);
 	}
@@ -281,47 +274,48 @@ bool setUpScreens(void) {
 
 	/* Creates the gadgets for the movement control panel */
 	y = VGAScaleY(173) - SVGACord(2);
-#if !defined(DOSCODE)
-	MoveGadgetList = createButton(VGAScaleX(1), y, 0, 't', MoveImages[0], MoveImages[1]);
-	curgad = MoveGadgetList;
-	curgad->NextGadget = createButton(VGAScaleX(33), y, 1, 'm', MoveImages[2], MoveImages[3]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(65), y, 2, 'o', MoveImages[4], MoveImages[5]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(97), y, 3, 'c', MoveImages[6], MoveImages[7]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(129), y, 4, 'l', MoveImages[8], MoveImages[9]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(161), y, 5, 'i', MoveImages[12], MoveImages[13]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(193), y, 6, VKEY_LTARROW, MoveImages[14], MoveImages[15]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(225), y, 7, VKEY_UPARROW, MoveImages[16], MoveImages[17]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(257), y, 8, VKEY_RTARROW, MoveImages[18], MoveImages[19]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(289), y, 9, 'p', MoveImages[10], MoveImages[11]);
-#else
-	MoveGadgetList = createButton(VGAScaleX(1), y, 0, MoveImages[0], MoveImages[1]);
-	curgad = MoveGadgetList;
-	curgad->NextGadget = createButton(VGAScaleX(33), y, 1, MoveImages[2], MoveImages[3]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(65), y, 2, MoveImages[4], MoveImages[5]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(97), y, 3, MoveImages[6], MoveImages[7]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(129), y, 4, MoveImages[8], MoveImages[9]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(161), y, 5, MoveImages[12], MoveImages[13]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(193), y, 6, MoveImages[14], MoveImages[15]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(225), y, 7, MoveImages[16], MoveImages[17]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(257), y, 8, MoveImages[18], MoveImages[19]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(289), y, 9, MoveImages[10], MoveImages[11]);
-#endif
+
+	if (g_lab->getPlatform() != Common::kPlatformWindows) {
+		MoveGadgetList = createButton(VGAScaleX(1), y, 0, 't', MoveImages[0], MoveImages[1]);
+		curgad = MoveGadgetList;
+		curgad->NextGadget = createButton(VGAScaleX(33), y, 1, 'm', MoveImages[2], MoveImages[3]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(65), y, 2, 'o', MoveImages[4], MoveImages[5]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(97), y, 3, 'c', MoveImages[6], MoveImages[7]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(129), y, 4, 'l', MoveImages[8], MoveImages[9]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(161), y, 5, 'i', MoveImages[12], MoveImages[13]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(193), y, 6, VKEY_LTARROW, MoveImages[14], MoveImages[15]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(225), y, 7, VKEY_UPARROW, MoveImages[16], MoveImages[17]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(257), y, 8, VKEY_RTARROW, MoveImages[18], MoveImages[19]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(289), y, 9, 'p', MoveImages[10], MoveImages[11]);
+	} else {
+		MoveGadgetList = createButton(VGAScaleX(1), y, 0, 0, MoveImages[0], MoveImages[1]);
+		curgad = MoveGadgetList;
+		curgad->NextGadget = createButton(VGAScaleX(33), y, 1, 0, MoveImages[2], MoveImages[3]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(65), y, 2, 0, MoveImages[4], MoveImages[5]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(97), y, 3, 0, MoveImages[6], MoveImages[7]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(129), y, 4, 0, MoveImages[8], MoveImages[9]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(161), y, 5, 0, MoveImages[12], MoveImages[13]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(193), y, 6, 0, MoveImages[14], MoveImages[15]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(225), y, 7, 0, MoveImages[16], MoveImages[17]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(257), y, 8, 0, MoveImages[18], MoveImages[19]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(289), y, 9, 0, MoveImages[10], MoveImages[11]);
+	}
 
 	InvPanelBufferSize = sizeOfFile("P:Inv");
 
@@ -340,45 +334,44 @@ bool setUpScreens(void) {
 	file->close();
 
 	*buffer = InvPanelBuffer;
-#if !defined(DOSCODE)
-
-	for (counter = 0; counter < 10; counter++)
-		readImage(buffer, &(InvImages[counter]));
-
-	InvGadgetList = createButton(VGAScaleX(24), y, 0, 'm', InvImages[0], InvImages[1]);
-	curgad = InvGadgetList;
-	curgad->NextGadget = createButton(VGAScaleX(56), y, 1, 'g', InvImages[2], InvImages[3]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(94), y, 2, 'u', InvImages[4], InvImages[5]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(126), y, 3, 'l', MoveImages[8], MoveImages[9]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(164), y, 4, VKEY_LTARROW, MoveImages[14], MoveImages[15]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(196), y, 5, VKEY_RTARROW, MoveImages[18], MoveImages[19]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(234), y, 6, 'b', InvImages[6], InvImages[7]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(266), y, 7, 'f', InvImages[8], InvImages[9]);
-	curgad = curgad->NextGadget;
-#else
-
-	for (counter = 0; counter < 6; counter++)
-		readImage(buffer, &(InvImages[counter]));
-
-	InvGadgetList = createButton(VGAScaleX(58), y, 0, InvImages[0], InvImages[1]);
-	curgad = InvGadgetList;
-	curgad->NextGadget = createButton(VGAScaleX(90), y, 1, InvImages[2], InvImages[3]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(128), y, 2, InvImages[4], InvImages[5]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(160), y, 3, MoveImages[8], MoveImages[9]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(198), y, 4, MoveImages[14], MoveImages[15]);
-	curgad = curgad->NextGadget;
-	curgad->NextGadget = createButton(VGAScaleX(230), y, 5, MoveImages[18], MoveImages[19]);
-	curgad = curgad->NextGadget;
-#endif
+
+	if (g_lab->getPlatform() == Common::kPlatformWindows) {
+		for (counter = 0; counter < 10; counter++)
+			readImage(buffer, &(InvImages[counter]));
+
+		InvGadgetList = createButton(VGAScaleX(24), y, 0, 'm', InvImages[0], InvImages[1]);
+		curgad = InvGadgetList;
+		curgad->NextGadget = createButton(VGAScaleX(56), y, 1, 'g', InvImages[2], InvImages[3]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(94), y, 2, 'u', InvImages[4], InvImages[5]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(126), y, 3, 'l', MoveImages[8], MoveImages[9]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(164), y, 4, VKEY_LTARROW, MoveImages[14], MoveImages[15]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(196), y, 5, VKEY_RTARROW, MoveImages[18], MoveImages[19]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(234), y, 6, 'b', InvImages[6], InvImages[7]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(266), y, 7, 'f', InvImages[8], InvImages[9]);
+		curgad = curgad->NextGadget;
+	} else {
+		for (counter = 0; counter < 6; counter++)
+			readImage(buffer, &(InvImages[counter]));
+
+		InvGadgetList = createButton(VGAScaleX(58), y, 0, 0, InvImages[0], InvImages[1]);
+		curgad = InvGadgetList;
+		curgad->NextGadget = createButton(VGAScaleX(90), y, 1, 0, InvImages[2], InvImages[3]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(128), y, 2, 0, InvImages[4], InvImages[5]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(160), y, 3, 0, MoveImages[8], MoveImages[9]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(198), y, 4, 0, MoveImages[14], MoveImages[15]);
+		curgad = curgad->NextGadget;
+		curgad->NextGadget = createButton(VGAScaleX(230), y, 5, 0, MoveImages[18], MoveImages[19]);
+		curgad = curgad->NextGadget;
+	}
 
 	return true;
 }
@@ -462,19 +455,6 @@ static void checkRoomMusic(void) {
 }
 
 
-
-#if defined(DOSCODE)
-#define MONLTMARGIN     0
-#define MONRTMARGIN     319
-#define MONTOPMARGIN    0
-#define LUTERTMARGIN    124
-#else
-#define MONLTMARGIN     2
-#define MONRTMARGIN     317
-#define MONTOPMARGIN    2
-#define LUTERTMARGIN    128
-#endif
-
 /******************************************************************************/
 /* Checks whether the close up is one of the special case closeups.           */
 /******************************************************************************/
@@ -482,23 +462,37 @@ static bool doCloseUp(CloseDataPtr cptr) {
 	if (cptr == NULL)
 		return false;
 
+	int monltmargin, monrtmargin, montopmargin, lutertmargin;
+
+	if (g_lab->getPlatform() != Common::kPlatformWindows) {
+		monltmargin = 0;
+		monrtmargin = 319;
+		montopmargin = 0;
+		lutertmargin = 124;
+	} else {
+		monltmargin = 2;
+		monrtmargin = 317;
+		montopmargin = 2;
+		lutertmargin = 128;
+	}
+
 	if ((cptr->CloseUpType == MUSEUMMONITOR) || (cptr->CloseUpType == LIBRARYMONITOR) ||
 	        (cptr->CloseUpType == WINDOWMONITOR))
-		doMonitor(cptr->GraphicName, cptr->Message, false, MONLTMARGIN, MONTOPMARGIN, MONRTMARGIN, 165);
+		doMonitor(cptr->GraphicName, cptr->Message, false, monltmargin, montopmargin, monrtmargin, 165);
 	else if (cptr->CloseUpType == GRAMAPHONEMONITOR)
-		doMonitor(cptr->GraphicName, cptr->Message, false, MONLTMARGIN, MONTOPMARGIN, 171, 165);
+		doMonitor(cptr->GraphicName, cptr->Message, false, monltmargin, montopmargin, 171, 165);
 	else if (cptr->CloseUpType == UNICYCLEMONITOR)
-		doMonitor(cptr->GraphicName, cptr->Message, false, 100, MONTOPMARGIN, MONRTMARGIN, 165);
+		doMonitor(cptr->GraphicName, cptr->Message, false, 100, montopmargin, monrtmargin, 165);
 	else if (cptr->CloseUpType == STATUEMONITOR)
-		doMonitor(cptr->GraphicName, cptr->Message, false, 117, MONTOPMARGIN, MONRTMARGIN, 165);
+		doMonitor(cptr->GraphicName, cptr->Message, false, 117, montopmargin, monrtmargin, 165);
 	else if (cptr->CloseUpType == TALISMANMONITOR)
-		doMonitor(cptr->GraphicName, cptr->Message, false, MONLTMARGIN, MONTOPMARGIN, 184, 165);
+		doMonitor(cptr->GraphicName, cptr->Message, false, monltmargin, montopmargin, 184, 165);
 	else if (cptr->CloseUpType == LUTEMONITOR)
-		doMonitor(cptr->GraphicName, cptr->Message, false, MONLTMARGIN, MONTOPMARGIN, LUTERTMARGIN, 165);
+		doMonitor(cptr->GraphicName, cptr->Message, false, monltmargin, montopmargin, lutertmargin, 165);
 	else if (cptr->CloseUpType == CLOCKMONITOR)
-		doMonitor(cptr->GraphicName, cptr->Message, false, MONLTMARGIN, MONTOPMARGIN, 206, 165);
+		doMonitor(cptr->GraphicName, cptr->Message, false, monltmargin, montopmargin, 206, 165);
 	else if (cptr->CloseUpType == TERMINALMONITOR)
-		doMonitor(cptr->GraphicName, cptr->Message, true, MONLTMARGIN, MONTOPMARGIN, MONRTMARGIN, 165);
+		doMonitor(cptr->GraphicName, cptr->Message, true, monltmargin, montopmargin, monrtmargin, 165);
 	else
 		return false;
 
@@ -710,12 +704,8 @@ static void decIncInv(uint16 *CurInv, bool dec) {
 }
 
 
-#if defined(DOSCODE)
 static bool nosvgamem = false;
 static bool didintro = false;
-#else
-int didintro = false; // change to int do labw.c can access
-#endif
 static bool novesa = false, noaudio = false;
 
 /******************************************************************************/
@@ -725,19 +715,14 @@ static void process(void) {
 	IntuiMessage *Msg;
 	uint32 Class;
 
-	uint16 Code, Qualifier, MouseX, MouseY, ActionMode = 4, CurInv = MAPNUM, /* Lab: Labyrinth specific initialization */
-	                                        LastInv = MAPNUM,     /* Lab: Labyrinth specific initialization */
-	                                        Old;
+	uint16 Code, Qualifier, MouseX, MouseY, ActionMode = 4;
+	uint16 CurInv = MAPNUM, LastInv = MAPNUM, Old;
 
-	bool ForceDraw   = false, doit, GotMessage  = true;
+	bool ForceDraw = false, doit, GotMessage = true;
 
-	uint16 OldRoomNum,
-#if !defined(DOSCODE)
-	       OldDirection,
-#endif
-	       GadID, NewDir;
+	uint16 OldRoomNum, OldDirection, GadID, NewDir;
 
-	CloseDataPtr OldCPtr, TempCPtr, HCPtr    = NULL;
+	CloseDataPtr OldCPtr, TempCPtr, HCPtr = NULL;
 	ViewDataPtr VPtr;
 
 	VGASetPal(initcolors, 8);
@@ -778,10 +763,9 @@ static void process(void) {
 			/* Sees what kind of close up we're in and does the appropriate stuff, if any. */
 			if (doCloseUp(CPtr)) {
 				CPtr = NULL;
-#if !defined(DOSCODE)
+
 				mayShowCrumbIndicator();
 				WSDL_UpdateScreen();
-#endif
 			}
 
 			/* Sets the current picture properly on the screen */
@@ -816,24 +800,17 @@ static void process(void) {
 				drawRoomMessage(CurInv, CPtr);
 				ForceDraw = false;
 
-#if !defined(DOSCODE)
 				mayShowCrumbIndicator();
 				WSDL_UpdateScreen();
 
 				if (!FollowingCrumbs)
 					eatMessages();
-
-#else
-				eatMessages();
-#endif
 			}
 
 			if (ForceDraw) {
 				drawRoomMessage(CurInv, CPtr);
 				ForceDraw = false;
-#if !defined(DOSCODE)
 				WSDL_UpdateScreen();
-#endif
 			}
 		}
 
@@ -846,7 +823,6 @@ static void process(void) {
 			checkRoomMusic();
 			g_music->newCheckMusic();
 			diffNextFrame();
-#if !defined(DOSCODE)
 
 			if (FollowingCrumbs) {
 				int result = followCrumbs();
@@ -878,7 +854,6 @@ static void process(void) {
 
 			mayShowCrumbIndicator();
 			WSDL_UpdateScreen();
-#endif
 		} else {
 			GotMessage = true;
 
@@ -891,11 +866,9 @@ static void process(void) {
 
 			replyMsg((void *) Msg);
 
-#if !defined(DOSCODE)
 			FollowingCrumbs = false;
 
 from_crumbs:
-#endif
 			DoBlack = false;
 
 			if ((Class == RAWKEY) && (!LongWinInFront)) {
@@ -903,18 +876,14 @@ from_crumbs:
 					Class     = MOUSEBUTTONS;
 					Qualifier = IEQUALIFIER_LEFTBUTTON;
 					mouseXY(&MouseX, &MouseY);
-				}
-
-#if !defined(DOSCODE)
-				else if (Code == 'b' || Code == 'B') {  /* Start bread crumbs */
+				} else if (g_lab->getPlatform() == Common::kPlatformWindows && 
+						(Code == 'b' || Code == 'B')) {  /* Start bread crumbs */
 					BreadCrumbs[0].RoomNum = 0;
 					NumCrumbs = 0;
 					DroppingCrumbs = true;
 					mayShowCrumbIndicator();
 					WSDL_UpdateScreen();
-				}
-
-				else if (Code == 'f' || Code == 'F' ||
+				} else if (Code == 'f' || Code == 'F' ||
 				         Code == 'r' || Code == 'R') {  /* Follow bread crumbs */
 					if (DroppingCrumbs) {
 						if (NumCrumbs > 0) {
@@ -945,11 +914,7 @@ from_crumbs:
 							WSDL_UpdateScreen();
 						}
 					}
-				}
-
-#endif
-
-				else if ((Code == 315) || (Code == 'x') || (Code == 'X')
+				} else if ((Code == 315) || (Code == 'x') || (Code == 'X')
 				         || (Code == 'q') || (Code == 'Q')) {  /* Quit? */
 					DoNotDrawMessage = false;
 					drawMessage("Do you want to quit? (Y/N)");
@@ -968,13 +933,7 @@ from_crumbs:
 							replyMsg((void *) Msg);    /* Can't do this in non-IBM versions */
 
 							if (Msg->Class == RAWKEY) {
-#if defined(DOSCODE)
-
-								if ((Msg->Code == 'Y') || (Msg->Code == 'y'))
-#else
-								if ((Msg->Code == 'Y') || (Msg->Code == 'y') || (Msg->Code == 'Q') || (Msg->Code == 'q'))
-#endif
-								{
+								if ((Msg->Code == 'Y') || (Msg->Code == 'y') || (Msg->Code == 'Q') || (Msg->Code == 'q')) {
 									doit = true;
 									break;
 								} else if (Msg->Code < 128) {
@@ -993,58 +952,9 @@ from_crumbs:
 						ForceDraw = true;
 						interfaceOn();
 					}
-				}
-
-#ifdef undef
-				else if (Code == 324) {
-					if (BUFFERSIZE >= BIGBUFFERSIZE) { /* F10 key to switch resolutions */
-						blackAllScreen();
-						setMode((char) OldMode);
-
-						Alternate = false;
-						MainDisplay = true;
-						attachGadgetList(NULL);
-						fillUpMusic(true);
-						g_system->delayMillis(750);
-
-						IsHiRes = !IsHiRes;
-
-						free(MovePanelBuffer);
-						free(InvPanelBuffer);
-						freeButtonList(MoveGadgetList);
-						freeButtonList(InvGadgetList);
-						MoveGadgetList = NULL;
-						InvGadgetList = NULL;
-
-						if (!setUpScreens()) {
-							IsHiRes = false;
-							setUpScreens();
-						}
-
-						blackAllScreen();
-						resetBuffer();
-						CPtr = NULL;
-						DoBlack = true;
-						CurFileName = " ";
-						closeFont(MsgFont);
-						openFont("P:AvanteG.12", &MsgFont);
-						/*
-						            mouseReset();
-						 */
-						initMouse();
-						drawPanel();
-						perFlipGadget(ActionMode);
-					} else
-						drawMessage("Not enough memory to change resolutions.");
-				}
-
-#endif
-
-				else if (Code == 9) { /* TAB key */
+				} else if (Code == 9) { /* TAB key */
 					Class = DELTAMOVE;
-				}
-
-				else if (Code == 27) { /* ESC key */
+				} else if (Code == 27) { /* ESC key */
 					CPtr = NULL;
 				}
 
@@ -1060,13 +970,9 @@ from_crumbs:
 					DoNotDrawMessage = false;
 					drawPanel();
 					drawRoomMessage(CurInv, CPtr);
-#if !defined(DOSCODE)
 					WSDL_UpdateScreen();
-#endif
 				}
-			}
-
-			else if ((Class == GADGETUP) && !Alternate) {
+			} else if ((Class == GADGETUP) && !Alternate) {
 				if (GadID <= 5) {
 					if ((ActionMode == 4) && (GadID == 4) && (CPtr != NULL)) {
 						doMainView(&CPtr);
@@ -1074,13 +980,9 @@ from_crumbs:
 						DoBlack = true;
 						HCPtr = NULL;
 						CPtr = NULL;
-#if !defined(DOSCODE)
 						mayShowCrumbIndicator();
 						WSDL_UpdateScreen();
-#endif
-					}
-
-					else if (GadID == 5) {
+					} else if (GadID == 5) {
 						eatMessages();
 
 						Alternate = true;
@@ -1098,10 +1000,9 @@ from_crumbs:
 
 						drawPanel();
 						drawRoomMessage(CurInv, CPtr);
-#if !defined(DOSCODE)
+
 						mayShowCrumbIndicator();
 						WSDL_UpdateScreen();
-#endif
 					} else {
 						Old        = ActionMode;
 						ActionMode = GadID;
@@ -1122,21 +1023,14 @@ from_crumbs:
 						else if (GadID == 4)
 							drawMessage(LOOKWHAT);
 
-#if !defined(DOSCODE)
 						WSDL_UpdateScreen();
-#endif
 					}
-				}
-
-				else if (GadID == 9) {
+				} else if (GadID == 9) {
 					doUse(MAPNUM);
-#if !defined(DOSCODE)
+
 					mayShowCrumbIndicator();
 					WSDL_UpdateScreen();
-#endif
-				}
-
-				else if (GadID >= 6) { /* Arrow Gadgets */
+				} else if (GadID >= 6) { /* Arrow Gadgets */
 					CPtr = NULL;
 					HCPtr = NULL;
 
@@ -1147,19 +1041,18 @@ from_crumbs:
 							drawMessage(TURNRIGHT);
 
 						CurFileName = " ";
-#if !defined(DOSCODE)
+
 						OldDirection = Direction;
-#endif
+
 						NewDir = Direction;
 						processArrow(&NewDir, GadID - 6);
 						doTurn(Direction, NewDir, &CPtr);
 						DoBlack = true;
 						Direction = NewDir;
 						ForceDraw = true;
-#if !defined(DOSCODE)
+
 						mayShowCrumbIndicator();
 						WSDL_UpdateScreen();
-#endif
 					} else if (GadID == 7) {
 						OldRoomNum = RoomNum;
 
@@ -1181,15 +1074,6 @@ from_crumbs:
 							}
 						}
 
-#if defined(DEMODATA)
-						{
-							void writeDemoData();
-							writeDemoData();
-						}
-#endif
-
-#if !defined(DOSCODE)
-
 						if (FollowingCrumbs) {
 							if (IsCrumbTurning) {
 								if (Direction == OldDirection) {
@@ -1235,12 +1119,9 @@ from_crumbs:
 
 						mayShowCrumbIndicator();
 						WSDL_UpdateScreen();
-#endif
 					}
 				}
-			}
-
-			else if ((Class == GADGETUP) && Alternate) {
+			} else if ((Class == GADGETUP) && Alternate) {
 				DoBlack = true;
 
 				if (GadID == 0) {
@@ -1253,9 +1134,8 @@ from_crumbs:
 					interfaceOn(); /* Sets the correct gadget list */
 					drawPanel();
 					drawRoomMessage(CurInv, CPtr);
-#if !defined(DOSCODE)
+
 					WSDL_UpdateScreen();
-#endif
 				}
 
 				GadID--;
@@ -1280,21 +1160,14 @@ from_crumbs:
 					if (doit) {
 						drawMessage("Disk operation failed.");
 						VGASetPal(initcolors, 8);
-#if !defined(DOSCODE)
+
 						WSDL_UpdateScreen();
-#endif
-						g_system->delayMillis(1000);
-					}
 
-#if !defined(DOSCODE)
-					else {
+						g_system->delayMillis(1000);
+					} else {
 						WSDL_UpdateScreen();
 					}
-
-#endif
-				}
-
-				else if (GadID == 1) {
+				} else if (GadID == 1) {
 					if (!doUse(CurInv)) {
 						Old        = ActionMode;
 						ActionMode = 5;  /* Use button */
@@ -1304,13 +1177,10 @@ from_crumbs:
 
 						drawMessage(USEONWHAT);
 						MainDisplay = true;
-#if !defined(DOSCODE)
+
 						WSDL_UpdateScreen();
-#endif
 					}
-				}
-
-				else if (GadID == 2) {
+				} else if (GadID == 2) {
 					MainDisplay = !MainDisplay;
 
 					if ((CurInv == 0) || (CurInv > NumInv)) {
@@ -1324,41 +1194,28 @@ from_crumbs:
 					        Inventory[CurInv].BInvName)
 						Test = getInvName(CurInv);
 
-#if !defined(DOSCODE)
 					WSDL_UpdateScreen();
-#endif
-				}
-
-				else if (GadID == 3) { /* Left gadget */
+				} else if (GadID == 3) { /* Left gadget */
 					decIncInv(&CurInv, true);
 					LastInv = CurInv;
 					DoNotDrawMessage = false;
 					drawRoomMessage(CurInv, CPtr);
-#if !defined(DOSCODE)
-					WSDL_UpdateScreen();
-#endif
-				}
 
-				else if (GadID == 4) { /* Right gadget */
+					WSDL_UpdateScreen();
+				} else if (GadID == 4) { /* Right gadget */
 					decIncInv(&CurInv, false);
 					LastInv = CurInv;
 					DoNotDrawMessage = false;
 					drawRoomMessage(CurInv, CPtr);
-#if !defined(DOSCODE)
-					WSDL_UpdateScreen();
-#endif
-				}
 
-#if !defined(DOSCODE)
-				else if (GadID == 5) { /* bread crumbs */
+					WSDL_UpdateScreen();
+				} else if (GadID == 5) { /* bread crumbs */
 					BreadCrumbs[0].RoomNum = 0;
 					NumCrumbs = 0;
 					DroppingCrumbs = true;
 					mayShowCrumbIndicator();
 					WSDL_UpdateScreen();
-				}
-
-				else if (GadID == 6) { /* follow crumbs */
+				} else if (GadID == 6) { /* follow crumbs */
 					if (DroppingCrumbs) {
 						if (NumCrumbs > 0) {
 							FollowingCrumbs = true;
@@ -1387,11 +1244,7 @@ from_crumbs:
 						}
 					}
 				}
-			}
-
-#endif
-
-			else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier) && MainDisplay) {
+			} else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier) && MainDisplay) {
 				interfaceOff();
 				MainDisplay = true;
 
@@ -1423,9 +1276,7 @@ from_crumbs:
 							CurFileName = NewFileName;
 						else if (MouseY < (VGAScaleY(149) + SVGACord(2)))
 							drawMessage(NOTHING);
-					}
-
-					else if ((ActionMode == 1) /* Manipulate an object */  ||
+					} else if ((ActionMode == 1) /* Manipulate an object */  ||
 					         (ActionMode == 2) /* Open up a "door" */      ||
 					         (ActionMode == 3)) { /* Close a "door" */
 						if (doActionRule(MouseX, MouseY, ActionMode, RoomNum, &CPtr))
@@ -1434,9 +1285,7 @@ from_crumbs:
 							if (MouseY < (VGAScaleY(149) + SVGACord(2)))
 								drawMessage(NOTHING);
 						}
-					}
-
-					else if (ActionMode == 4) { /* Look at closeups */
+					} else if (ActionMode == 4) { /* Look at closeups */
 						TempCPtr = CPtr;
 						setCurClose(MouseX, MouseY, &TempCPtr);
 
@@ -1451,9 +1300,7 @@ from_crumbs:
 								drawMessage(NOTHING);
 						} else if (MouseY < (VGAScaleY(149) + SVGACord(2)))
 							drawMessage(NOTHING);
-					}
-
-					else if ((ActionMode == 5)  &&
+					} else if ((ActionMode == 5)  &&
 					         g_lab->_conditions->in(CurInv)) { /* Use an item on something else */
 						if (doOperateRule(MouseX, MouseY, CurInv, &CPtr)) {
 							CurFileName = NewFileName;
@@ -1465,13 +1312,9 @@ from_crumbs:
 					}
 				}
 
-#if !defined(DOSCODE)
 				mayShowCrumbIndicator();
 				WSDL_UpdateScreen();
-#endif
-			}
-
-			else if (Class == DELTAMOVE) {
+			} else if (Class == DELTAMOVE) {
 				VPtr = getViewData(RoomNum, Direction);
 				OldCPtr = VPtr->closeUps;
 
@@ -1499,9 +1342,7 @@ from_crumbs:
 
 				if (HCPtr)
 					mouseMove(scaleX((HCPtr->x1 + HCPtr->x2) / 2), scaleY((HCPtr->y1 + HCPtr->y2) / 2));
-			}
-
-			else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) {
+			} else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) {
 				eatMessages();
 				Alternate = !Alternate;
 				DoBlack = true;
@@ -1518,10 +1359,9 @@ from_crumbs:
 
 				drawPanel();
 				drawRoomMessage(CurInv, CPtr);
-#if !defined(DOSCODE)
+
 				mayShowCrumbIndicator();
 				WSDL_UpdateScreen();
-#endif
 			}
 		}
 	}
@@ -1546,36 +1386,23 @@ from_crumbs:
 }
 
 
-/*
-   void mySignalHandler(int sig)
-   {
-   signal(sig, mySignalHandler);
-   }
- */
-
-
-
-#if defined(DOSCODE)
-void (__interrupt __far *oldctrlc)(), (__interrupt __far *oldctrlcb)();
-
-uint16 iretdummy;
-void __interrupt __far myiret() {
-	iretdummy++;
-}
-#endif
-
-
-void inner_main() {
+void LabEngine::go() {
 	bool mem, dointro = false;
 	uint16 counter;
 
 	getMode(&OldMode);
 
-	IsHiRes = true;
 	DoMusic = true;
 	g_music->_turnMusicOn = true;
 	dointro = true;
 
+	IsHiRes = ((getFeatures() & GF_LOWRES) == 0);
+
+	if (IsHiRes)
+		warning("Running in HiRes mode");
+	else
+		warning("Running in LowRes mode");
+
 #if 0
 	for (counter = 1; counter < argc; counter++) {
 #if defined(DOSCODE)
@@ -1613,16 +1440,8 @@ void inner_main() {
 	if (initBuffer(BUFFERSIZE, true)) {
 		mem = true;
 	} else {
-#if defined(DOSCODE)
-		BUFFERSIZE = SMALLBUFFERSIZE;
-		mem = initBuffer(BUFFERSIZE, true);
-		IsHiRes = false;
-		nosvgamem = true;
-#else
-		// unacceptable !!!!
 		warning("initBuffer() failed");
 		return;
-#endif
 	}
 
 	if (!initAudio()) {
@@ -1641,11 +1460,7 @@ void inner_main() {
 
 	if (!initMouse()) {
 		setMode((char) OldMode);
-#if defined(DOSCODE)
-		_dos_setvect(0x23, oldctrlc);
-		_dos_setvect(0x1B, oldctrlcb);
-#endif
-		debug("\n\nMouse or mouse driver not installed!\n\n");
+
 		return;
 	}
 
@@ -1660,13 +1475,9 @@ void inner_main() {
 	openFont("P:AvanteG.12", &MsgFont);
 
 	if (dointro && mem) {
-#if defined(DOSCODE)
 		didintro = true;
-#endif
 		introSequence();
-#if !defined(DOSCODE)
 		didintro = true;
-#endif
 	} else
 		DoBlack = true;
 
@@ -1688,27 +1499,12 @@ void inner_main() {
 		readPict("P:End/L2In.9", true);
 		readPict("P:End/Lost", true);
 
-#if defined(DOSCODE)
-		counter = 600;
-
-		while (counter) {
-			newCheckMusic();
-			diffNextFrame();
-			waitTOF();
-			counter--;
-		}
-
-#else
-
 		warning("STUB: waitForPress");
 		while (!1) { // 1 means ignore SDL_ProcessInput calls
 			g_music->newCheckMusic();
 			diffNextFrame();
 			waitTOF();
 		}
-
-		// If we weren't exiting, a call to a mythical SDL_StopWaitForPress() would be in order.
-#endif
 	}
 
 	closeFont(MsgFont);
@@ -1721,25 +1517,19 @@ void inner_main() {
 	freeAudio();
 
 	mouseReset();
-	setMode((char) OldMode);
-
-#if defined(DOSCODE)
-	_dos_setvect(0x23, oldctrlc);
-	_dos_setvect(0x1B, oldctrlcb);
-#endif
+	setMode((char)OldMode);
 }
 
-#if !defined(DOSCODE)
 /*****************************************************************************/
 /* New code to allow quick(er) return navigation in game.                    */
 /*****************************************************************************/
 int followCrumbs() {
 	// NORTH, SOUTH, EAST, WEST
 	static int movement[4][4] = {
-		{ VKEY_UPARROW, VKEY_RTARROW, VKEY_RTARROW, VKEY_LTARROW }, { VKEY_RTARROW, VKEY_UPARROW, VKEY_LTARROW, VKEY_RTARROW }, { VKEY_LTARROW, VKEY_RTARROW, VKEY_UPARROW, VKEY_RTARROW }, { VKEY_RTARROW, VKEY_LTARROW, VKEY_RTARROW, VKEY_UPARROW }
-#if 0
-		{ -1, EAST, EAST, WEST }, { WEST, -1, EAST, WEST }, { NORTH, SOUTH, -1, SOUTH }, { NORTH, SOUTH, NORTH, -1 }
-#endif
+		{ VKEY_UPARROW, VKEY_RTARROW, VKEY_RTARROW, VKEY_LTARROW },
+		{ VKEY_RTARROW, VKEY_UPARROW, VKEY_LTARROW, VKEY_RTARROW },
+		{ VKEY_LTARROW, VKEY_RTARROW, VKEY_UPARROW, VKEY_RTARROW },
+		{ VKEY_RTARROW, VKEY_LTARROW, VKEY_RTARROW, VKEY_UPARROW }
 	};
 
 	int ExitDir;
@@ -1805,6 +1595,9 @@ Image DropCrumbsImage = { 24, 24, dropCrumbs };
 Image DropCrumbsOffImage = { 24, 24, dropCrumbsOff };
 
 void mayShowCrumbIndicator() {
+	if (g_lab->getPlatform() != Common::kPlatformWindows)
+		return;
+
 	if (DroppingCrumbs && MainDisplay) {
 		mouseHide();
 		drawMaskImage(&DropCrumbsImage, 612, 4);
@@ -1813,12 +1606,14 @@ void mayShowCrumbIndicator() {
 }
 
 void mayShowCrumbIndicatorOff() {
+	if (g_lab->getPlatform() != Common::kPlatformWindows)
+		return;
+
 	if (MainDisplay) {
 		mouseHide();
 		drawMaskImage(&DropCrumbsOffImage, 612, 4);
 		mouseShow();
 	}
 }
-#endif
 
 } // End of namespace Lab
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 41f4a79..3d91fd4 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -28,6 +28,7 @@
  *
  */
 
+#include "lab/lab.h"
 #include "lab/stddefines.h"
 #include "lab/diff.h"
 #include "lab/parsetypes.h"
@@ -675,23 +676,29 @@ static void doScrollWipe(char *filename) {
 /* Does the scroll bounce.  Assumes bitmap already in memory.                */
 /*****************************************************************************/
 static void doScrollBounce(void) {
-	byte *mem;
-	uint16 width, height, startline, counter,
-#if defined(DOSCODE)
-	       newby[5] = {5, 4, 3, 2, 1}, newby1[8] = {3, 3, 2, 2, 2, 1, 1, 1};
-#else
-	       newby[5] = {10, 8, 6, 4, 2}, newby1[8] = {6, 6, 4, 4, 4, 2, 2, 2};
-#endif
+	const uint16 *newby, *newby1;
+
+	const uint16 newbyd[5] = {5, 4, 3, 2, 1}, newby1d[8] = {3, 3, 2, 2, 2, 1, 1, 1};
+	const uint16 newbyw[5] = {10, 8, 6, 4, 2}, newby1w[8] = {6, 6, 4, 4, 4, 2, 2, 2};
+
+	if (g_lab->getPlatform() != Common::kPlatformWindows) {
+		newby = newbyd;
+		newby1 = newby1d;
+	} else {
+		newby = newbyw;
+		newby1 = newby1w;
+	}
+
 
 	mouseHide();
-	width = VGAScaleX(320);
-	height = VGAScaleY(149) + SVGACord(2);
-	mem = RawDiffBM.Planes[0];
+	int width = VGAScaleX(320);
+	int height = VGAScaleY(149) + SVGACord(2);
+	byte *mem = RawDiffBM.Planes[0];
 
 	g_music->fillUpMusic(true);
-	startline = headerdata.y - height - 1;
+	int startline = headerdata.y - height - 1;
 
-	for (counter = 0; counter < 5; counter++) {
+	for (int counter = 0; counter < 5; counter++) {
 		g_music->newCheckMusic();
 		startline -= newby[counter];
 		copyPage(width, height, 0, startline, mem);
@@ -700,7 +707,7 @@ static void doScrollBounce(void) {
 		waitTOF();
 	}
 
-	for (counter = 8; counter > 0; counter--) {
+	for (int counter = 8; counter > 0; counter--) {
 		g_music->newCheckMusic();
 		startline += newby1[counter - 1];
 		copyPage(width, height, 0, startline, mem);
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index e843d9b..c70d19b 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -124,23 +124,12 @@ uint16 makeGadgetKeyEquiv(uint16 key) {
 /* of gadgets.                                                               */
 /*****************************************************************************/
 static Gadget *checkNumGadgetHit(Gadget *gadlist, uint16 key) {
-#if !defined(DOSCODE)
 	uint16 gkey = key - '0';
-#else
-	key = key - '0';
-#endif
 
 	while (gadlist != NULL) {
-#if !defined(DOSCODE)
-
 		if ((gkey - 1 == gadlist->GadgetID || (gkey == 0 && gadlist->GadgetID == 9) ||
 		        (gadlist->KeyEquiv != 0 && makeGadgetKeyEquiv(key) == gadlist->KeyEquiv))
-		        && !(GADGETOFF & gadlist->GadgetFlags))
-#else
-		if ((((key - 1) == gadlist->GadgetID) || ((key == 0) && (gadlist->GadgetID == 9))) &&
-		        !(GADGETOFF & gadlist->GadgetFlags))
-#endif
-		{
+		        && !(GADGETOFF & gadlist->GadgetFlags)) {
 			mouseHide();
 			drawImage(gadlist->ImAlt, gadlist->x, gadlist->y);
 			mouseShow();
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index bac197e..09f92c0 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -28,6 +28,7 @@
  *
  */
 
+#include "lab/lab.h"
 #include "lab/stddefines.h"
 #include "lab/labfun.h"
 #include "lab/timing.h"
@@ -272,15 +273,16 @@ void introSequence(void) {
 
 	DoBlack = true;
 
-#if defined(DOSCODE)
-	readPict("p:Intro/EA0", true);
-	readPict("p:Intro/EA1", true);
-	readPict("p:Intro/EA2", true);
-	readPict("p:Intro/EA3", true);
-#elif defined(ALL_LOGOS) || defined(NDEBUG)
-	readPict("p:Intro/WYRMKEEP", true);
-	microDelay(4, 0, NULL);
-#endif
+	if (g_lab->getPlatform() != Common::kPlatformWindows) {
+		readPict("p:Intro/EA0", true);
+		readPict("p:Intro/EA1", true);
+		readPict("p:Intro/EA2", true);
+		readPict("p:Intro/EA3", true);
+	} else {
+		readPict("p:Intro/WYRMKEEP", true);
+		microDelay(4, 0);
+	}
+
 	blackAllScreen();
 
 	g_music->initMusic();
@@ -292,7 +294,6 @@ void introSequence(void) {
 	noscreenchange = false;
 
 	FadePalette = Palette;
-#if defined(ALL_LOGOS) || defined(NDEBUG)
 
 	for (counter = 0; counter < 16; counter++) {
 		Palette[counter] = ((diffcmap[counter * 3] >> 2) << 8) +
@@ -300,11 +301,11 @@ void introSequence(void) {
 		                   (diffcmap[counter * 3 + 2] >> 2);
 	}
 
-	newCheckMusic();
+	g_music->newCheckMusic();
 	fade(true, 0);
 
 	for (int times = 0; times < 150; times++) {
-		newCheckMusic();
+		g_music->newCheckMusic();
 		uint16 temp = Palette[2];
 
 		for (counter = 2; counter < 15; counter++)
@@ -318,7 +319,7 @@ void introSequence(void) {
 
 	fade(false, 0);
 	blackAllScreen();
-#endif
+
 	g_music->newCheckMusic();
 
 	readPict("p:Intro/Title.A", true);
@@ -327,15 +328,17 @@ void introSequence(void) {
 	readPict("p:Intro/BA", true);
 	readPict("p:Intro/AC", true);
 	musicDelay();
-#if !defined(DOSCODE)
-	musicDelay(); // more credits on this page now
-#endif
+
+	if (g_lab->getPlatform() == Common::kPlatformWindows)
+		musicDelay(); // more credits on this page now
+
 	readPict("p:Intro/CA", true);
 	readPict("p:Intro/AD", true);
 	musicDelay();
-#if !defined(DOSCODE)
-	musicDelay(); // more credits on this page now
-#endif
+
+	if (g_lab->getPlatform() == Common::kPlatformWindows)
+		musicDelay(); // more credits on this page now
+
 	readPict("p:Intro/DA", true);
 	musicDelay();
 
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 911ad6d..16839da 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -60,12 +60,14 @@ LabEngine::~LabEngine() {
 }
 
 Common::Error LabEngine::run() {
-	// Initialize graphics using following:
-	initGraphics(640, 480, true);
+	if (getFeatures() & GF_LOWRES)
+		initGraphics(320, 200, false);
+	else
+		initGraphics(640, 480, true);
 
 	g_music = new Music();
 
-	inner_main();
+	go();
 
 	return Common::kNoError;
 }
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 72e359c..8825417 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -50,11 +50,13 @@ public:
 	~LabEngine();
 
 	virtual Common::Error run();
+	void go();
 
 	bool hasFeature(EngineFeature f) const;
 
 	const ADGameDescription *_gameDescription;
 	Common::Platform getPlatform() const;
+	uint32 getFeatures() const;
 
 	LargeSet *_conditions, *_roomsFound;
 };
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index 753e8ff..e68ce6f 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -133,10 +133,10 @@ void attachGadgetList(Gadget *GadList) {
 
 static void drawMouse(void) {
 	if (BackImage.ImageData) {
-		if (backx <= 640 - BackImage.Width && backy <= 480 - BackImage.Height)
+		if (backx <= VGAScreenWidth - BackImage.Width && backy <= VGAScreenHeight - BackImage.Height)
 			drawMaskImage(&MouseImage, backx, backy);
 	} else {
-		if (CurMouseX <= 640 - MouseImage.Width && CurMouseY <= 480 - MouseImage.Height)
+		if (CurMouseX <= VGAScreenWidth - MouseImage.Width && CurMouseY <= VGAScreenHeight - MouseImage.Height)
 			drawMaskImage(&MouseImage, CurMouseX, CurMouseY);
 	}
 }
@@ -151,13 +151,13 @@ static void getBackMouse(void) {
 	backx = CurMouseX;
 	backy = CurMouseY;
 
-	if (backx <= 640 - BackImage.Width && backy <= 480 - BackImage.Height)
+	if (backx <= VGAScreenWidth - BackImage.Width && backy <= VGAScreenHeight - BackImage.Height)
 		readScreenImage(&BackImage, backx, backy);
 }
 
 static void restoreBackMouse(void) {
 	if (BackImage.ImageData) {
-		if (backx <= 640 - BackImage.Width && backy <= 480 - BackImage.Height)
+		if (backx <= VGAScreenWidth - BackImage.Width && backy <= VGAScreenHeight - BackImage.Height)
 			drawImage(&BackImage, backx, backy);
 
 		BackImage.ImageData = NULL;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 3ab548a..038f8b8 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -187,9 +187,7 @@ static void changeCombination(uint16 number) {
 		} else
 			waitTOF();
 
-#if !defined(DOSCODE)
 		display.ImageData = getVGABaseAddr();
-#endif
 
 		scrollDisplayY(2, VGAScaleX(combx[number]), VGAScaleY(65), VGAScaleX(combx[number]) + (Images[combnum])->Width - 1, VGAScaleY(65) + (Images[combnum])->Height);
 
@@ -204,9 +202,7 @@ static void changeCombination(uint16 number) {
 	else
 		g_lab->_conditions->exclElement(COMBINATIONUNLOCKED);
 
-#if !defined(DOSCODE)
 	ungetVGABaseAddr();
-#endif
 }
 
 
@@ -248,9 +244,6 @@ void mouseCombination(uint16 x, uint16 y) {
 /*----------------------------- Tile Puzzle Rules ----------------------------*/
 /*----------------------------------------------------------------------------*/
 
-
-
-
 Image *Tiles[16];
 int16 CurTile[4] [4] = {
 	{ 1, 5,  9, 13 },
@@ -703,14 +696,12 @@ static bool loadJournalData() {
 
 	BackG.Im = JLeft;
 	BackG.ImAlt = JLeftAlt;
-#if !defined(DOSCODE)
 	BackG.KeyEquiv = VKEY_LTARROW;
-#endif
+
 	ForwardG.Im = JRight;
 	ForwardG.ImAlt = JRightAlt;
-#if !defined(DOSCODE)
 	ForwardG.KeyEquiv = VKEY_RTARROW;
-#endif
+
 	CancelG.Im = JCancel;
 	CancelG.ImAlt = JCancelAlt;
 
@@ -785,18 +776,14 @@ static void turnPage(bool FromLeft) {
 		for (counter = 0; counter < VGAScreenWidth; counter += 8) {
 			g_music->updateMusic();
 			waitTOF();
-#if !defined(DOSCODE)
 			ScreenImage.ImageData = getVGABaseAddr();
-#endif
 			bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, VGAScreenHeight);
 		}
 	} else {
 		for (counter = (VGAScreenWidth - 8); counter > 0; counter -= 8) {
 			g_music->updateMusic();
 			waitTOF();
-#if !defined(DOSCODE)
 			ScreenImage.ImageData = getVGABaseAddr();
-#endif
 			bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, VGAScreenHeight);
 		}
 	}
@@ -819,9 +806,7 @@ static void drawJournal(uint16 wipenum, bool needFade) {
 
 	drawJournalText();
 
-#if !defined(DOSCODE)
 	ScreenImage.ImageData = getVGABaseAddr();
-#endif
 
 	if (wipenum == 0)
 		bltBitMap(&JBackImage, 0, 0, &ScreenImage, 0, 0, VGAScreenWidth, VGAScreenHeight);
@@ -838,9 +823,7 @@ static void drawJournal(uint16 wipenum, bool needFade) {
 	else
 		unGhoastGadget(&ForwardG);
 
-#if !defined(DOSCODE)
 	ungetVGABaseAddr();
-#endif
 
 
 	if (needFade)
@@ -948,9 +931,7 @@ void doJournal() {
 	fade(false, 0);
 	mouseHide();
 
-#if !defined(DOSCODE)
 	ScreenImage.ImageData = getVGABaseAddr();
-#endif
 
 	setAPen(0);
 	rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1);
@@ -958,9 +939,7 @@ void doJournal() {
 
 	journalCleanUp();
 
-#if !defined(DOSCODE)
 	ungetVGABaseAddr();
-#endif
 }
 
 
@@ -996,64 +975,6 @@ static char DriveName[5] [MAXDEVNAMES];
 /* and returned the number of drives that it found.                          */
 /*****************************************************************************/
 uint16 doDisks(void) {
-#if defined(DOSCODE)
-	uint16 many = 0, counter = 2;
-	union REGS regs;
-	char str[5];
-
-	if (manydisks)
-		return manydisks;
-
-	while ((counter < 7) && (many < MAXDEVNAMES)) {
-		memset(&regs, 0, sizeof(regs));
-		/*
-		    regs.h.ah = 0x32;
-		    regs.h.dl = counter+1;
-		    int386(0x21, &regs, &regs);
-		    if (regs.h.al == 0)
-		    {
-		 */
-		regs.h.ah = 0x36;
-		regs.h.dl = counter + 1;
-		int386(0x21, &regs, &regs);
-
-		if (regs.w.ax != 0xFFFF) {
-			str[0] = counter + 'A';
-			str[1] = ':';
-			str[2] = '\\';
-			str[3] = 0;
-			strcpy(DriveName[many], str);
-			many++;
-		}
-
-		counter++;
-	}
-
-	return many;
-#elif defined(WIN32)
-	extern void winGetDriveLetters(char cdLetters[], int size);
-	char letters[28];
-	char str[5];
-	uint16 many = 0, counter = 2;
-
-	if (manydisks)
-		return manydisks;
-
-	winGetDriveLetters(letters, 28);
-
-	while ((counter < 7) && (many < MAXDEVNAMES) && letters[many] != 0) {
-		str[0] = letters[many];
-		str[1] = ':';
-		str[2] = '\\';
-		str[3] = 0;
-		strcpy(DriveName[many], str);
-		many++;
-		counter++;
-	}
-
-	return many;
-#else
-	// !!!!goofy test code
 	char str[5];
 	str[0] = 'C';
 	str[1] = ':';
@@ -1061,13 +982,8 @@ uint16 doDisks(void) {
 	str[3] = 0;
 	strcpy(DriveName[0], str);
 	return 1;
-#endif
 }
 
-
-
-
-
 /*****************************************************************************/
 /* Does the user interface to save or restore a game position                */
 /*****************************************************************************/
@@ -1222,8 +1138,8 @@ static void drawSaveLoad() {
 			thumbnail.Width = 128;
 			thumbnail.Height = 72;
 			thumbnail.ImageData = g_SaveGameInfo[j].SaveGameImage;
-			screen.Width = 640;
-			screen.Height = 480;
+			screen.Width = VGAScreenWidth;
+			screen.Height = VGAScreenHeight;
 			screen.ImageData = getVGABaseAddr();
 			bltBitMap(&thumbnail, 0, 0, &screen, 72, 67 + i * 75, 128, 72);
 			ungetVGABaseAddr();
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 10e52e1..c850f52 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -75,10 +75,16 @@ void setMode(char mode) {
 bool createScreen(bool HiRes) {
 	//VGABASEADDRESS  = (unsigned long)malloc(640 * 480);
 	VGABASEADDRESS  = 0;
-	VGAScreenWidth  = 640;
-	VGAScreenHeight = 480;
+
+	if (HiRes) {
+		VGAScreenWidth  = 640;
+		VGAScreenHeight = 480;
+	} else {
+		VGAScreenWidth  = 320;
+		VGAScreenHeight = 200;
+	}
 	VGAPages        = 1;
-	VGABytesPerPage = 640 * 480;
+	VGABytesPerPage = VGAScreenWidth * VGAScreenHeight;
 
 	g_DisplayBuffer = (byte *)malloc(VGABytesPerPage);
 	g_Pixels = (byte *)calloc(VGABytesPerPage, 4);
@@ -156,8 +162,8 @@ void WSDL_ProcessInput(bool can_delay) {
 					g_MouseX = 0;
 					g_MouseAtEdge = true;
 				}
-				if (g_MouseX > 639) {
-					g_MouseX = 640;
+				if (g_MouseX > VGAScreenWidth - 1) {
+					g_MouseX = VGAScreenWidth;
 					g_MouseAtEdge = true;
 				}
 
@@ -166,8 +172,8 @@ void WSDL_ProcessInput(bool can_delay) {
 					g_MouseY = 0;
 					g_MouseAtEdge = true;
 				}
-				if (g_MouseY > 479) {
-					g_MouseY = 480;
+				if (g_MouseY > VGAScreenHeight - 1) {
+					g_MouseY = VGAScreenHeight;
 					g_MouseAtEdge = true;
 				}
 


Commit: c62479949805780d4545876a0785d68ea4c747ba
    https://github.com/scummvm/scummvm/commit/c62479949805780d4545876a0785d68ea4c747ba
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Cleanup

Changed paths:
    engines/lab/diff.h
    engines/lab/engine.cpp
    engines/lab/readdiff.cpp



diff --git a/engines/lab/diff.h b/engines/lab/diff.h
index e46e320..e1644d4 100644
--- a/engines/lab/diff.h
+++ b/engines/lab/diff.h
@@ -50,9 +50,7 @@ struct BitMap {
 	byte *Planes[16];
 };
 
-#if !defined(DOSCODE)
 #define BITMAPF_VIDEO (1<<7)
-#endif
 
 /* unDiff.c */
 
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 447a8fe..6f4f4e5 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -1405,32 +1405,14 @@ void LabEngine::go() {
 
 #if 0
 	for (counter = 1; counter < argc; counter++) {
-#if defined(DOSCODE)
-
-		if (((argv[counter])[0] == 'v') || ((argv[counter])[0] == 'V')) {
-			IsHiRes = false;
-		} else
-#endif
 			if (((argv[counter])[0] == 'q') || ((argv[counter])[0] == 'Q')) {
 				DoMusic = false;
 				g_music->_turnMusicOn = false;
 			}
 
-#ifdef _DEBUG
-			else if (((argv[counter])[0] == 'i') || ((argv[counter])[0] == 'I')) {
-				dointro = false;
-			}
-
-#endif
 			else if (((argv[counter])[0] == '/') && ((argv[counter])[1] == '?')) {
 				debug("\n\nPlayer Version 1.0.  Copyright (c) 1993 Terra Nova Development\n");
 				debug("Player v q\n");
-#ifdef _DEBUG
-				debug("    i : Skip intro (debug only).\n");
-#endif
-#if defined(DOSCODE)
-				debug("    v : Open up on a low res VGA display.\n");
-#endif
 				debug("    q : Start in quiet mode; no sound output.\n\n");
 				return;
 			}
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index 8da94d6..b270f3b 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -197,25 +197,17 @@ void diffNextFrame(void) {
 			IsAnim = (framenumber >= 3) && (!PlayOnce);
 			CurBit = 0;
 
-#if !defined(DOSCODE)
-
 			if (DispBitMap->Flags & BITMAPF_VIDEO)
 				WSDL_UpdateScreen();
 
-#endif
-
 			return; /* done with the next frame. */
 		}
 
 		g_music->updateMusic();
 		readBlock(&header, 4L, difffile);
-#if !defined(DOSCODE)
 		swapULongPtr(&header, 1);
-#endif
 		readBlock(&size, 4L, difffile);
-#if !defined(DOSCODE)
 		swapULongPtr(&size, 1);
-#endif
 
 		processed += 8L;
 
@@ -292,9 +284,7 @@ void diffNextFrame(void) {
 
 			skip(difffile, 4L);
 			readBlock(&samplespeed, 2L, difffile);
-#if !defined(DOSCODE)
 			swapUShortPtr(&samplespeed, 1);
-#endif
 			skip(difffile, 2L);
 
 			byte *music = *difffile;
@@ -387,10 +377,10 @@ void playDiff(void) {
 	continuous = false;
 	readBlock(temp, 4L, difffile);
 	temp[4] = '\0';
+
 	readBlock(&header, 4L, difffile);
-#if !defined(DOSCODE)
 	swapULongPtr(&header, 1);
-#endif
+
 	processed += 8L;
 
 	if (!((strcmp((char *)temp, "DIFF") == 0) && (header == 1219009121L))) {
@@ -399,13 +389,10 @@ void playDiff(void) {
 	}
 
 	readBlock(&header, 4L, difffile);
-#if !defined(DOSCODE)
 	swapULongPtr(&header, 1);
-#endif
+
 	readBlock(&size, 4L, difffile);
-#if !defined(DOSCODE)
 	swapULongPtr(&size, 1);
-#endif
 
 	if (header == 0) {
 		// sizeof(headerdata) != 18, but the padding might be at the end
@@ -420,12 +407,10 @@ void playDiff(void) {
 
 		skip(difffile, size - 18);
 
-#if !defined(DOSCODE)
 		swapUShortPtr(&headerdata.Version, 3);
 		swapULongPtr(&headerdata.BufferSize, 1);
 		swapUShortPtr(&headerdata.Machine, 1);
 		swapULongPtr(&headerdata.Flags, 1);
-#endif
 
 		continuous = CONTINUOUS & headerdata.Flags;
 		diffwidth = headerdata.x;
@@ -546,22 +531,18 @@ void readSound(void) {
 	readBlock(temp_, 4L, difffile_);
 	temp_[4] = '\0';
 	readBlock(&header_, 4L, difffile_);
-#if !defined(DOSCODE)
 	swapULongPtr(&header_, 1);
-#endif
+
 	processed += 8L;
 
 	if (!((strcmp(temp_, "DIFF") == 0) && (header_ == 1219009121L)))
 		return;
 
 	readBlock(&header_, 4L, difffile_);
-#if !defined(DOSCODE)
 	swapULongPtr(&header_, 1);
-#endif
+
 	readBlock(&size_, 4L, difffile_);
-#if !defined(DOSCODE)
 	swapULongPtr(&size_, 1);
-#endif
 
 	if (header_ == 0)
 		skip(difffile_, size_);
@@ -571,13 +552,10 @@ void readSound(void) {
 	while (header_ != 65535) {
 		g_music->updateMusic();
 		readBlock(&header_, 4L, difffile_);
-#if !defined(DOSCODE)
 		swapULongPtr(&header_, 1);
-#endif
+
 		readBlock(&size_, 4L, difffile_);
-#if !defined(DOSCODE)
 		swapULongPtr(&size_, 1);
-#endif
 
 		if ((header_ == 30) || (header_ == 31)) {
 			if (mwaiteffect) {
@@ -591,9 +569,8 @@ void readSound(void) {
 
 			skip(difffile_, 4L);
 			readBlock(&samplespeed_, 2L, difffile_);
-#if !defined(DOSCODE)
 			swapUShortPtr(&samplespeed_, 1);
-#endif
+
 			skip(difffile_, 2L);
 
 			byte *music = *difffile_;


Commit: fdb4f3edf8882f8c9907aae990c3d376e68cea18
    https://github.com/scummvm/scummvm/commit/fdb4f3edf8882f8c9907aae990c3d376e68cea18
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Cleanup

Changed paths:
    engines/lab/interface.h
    engines/lab/labmusic.cpp
    engines/lab/labsets.cpp
    engines/lab/map.cpp
    engines/lab/parsetypes.h
    engines/lab/readparse.cpp
    engines/lab/stddefines.h
    engines/lab/text.cpp
    engines/lab/vga.cpp
    engines/lab/vga.h



diff --git a/engines/lab/interface.h b/engines/lab/interface.h
index b077f3b..9b8c3fb 100644
--- a/engines/lab/interface.h
+++ b/engines/lab/interface.h
@@ -45,9 +45,7 @@ struct IntuiMessage {
 
 struct Gadget {
 	uint16 x, y, GadgetID;
-#if !defined(DOSCODE)
 	uint16 KeyEquiv; // if not zero, a key that activates gadget
-#endif
 	uint32 GadgetFlags;
 	Image *Im, *ImAlt;
 	Gadget *NextGadget;
@@ -103,13 +101,10 @@ extern Common::KeyState _keyPressed;
 #define IEQUALIFIER_RBUTTON     0x2000
 #define IEQUALIFIER_LEFTBUTTON      0x4000
 
-#if !defined(DOSCODE)
-// these values come from the SDL virtual key table
 #define VKEY_UPARROW    273
 #define VKEY_DNARROW    274
 #define VKEY_RTARROW    275
 #define VKEY_LTARROW    276
-#endif
 
 
 /*---------------------------------------------------------------------------*/
diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index ac7ba70..7e91521 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -32,6 +32,7 @@
 #include "lab/labfun.h"
 #include "lab/timing.h"
 #include "lab/mouse.h"
+#include "lab/vga.h"
 
 namespace Lab {
 
@@ -73,9 +74,8 @@ Music::Music() {
 void Music::updateMusic(void) {
 	uint16 i;
 
-#if !defined(DOSCODE)
-	//SDL_ProcessInput(0);
-#endif
+	WSDL_ProcessInput(0);
+
 	updateMouse();
 
 	if (EffectPlaying)
@@ -106,9 +106,6 @@ void Music::fillbuffer(uint16 unit) {
 	warning("STUB: Music::fillbuffer");
 	uint32 Size = MUSICBUFSIZE;
 	void *ptr  = _musicBuffer[unit];
-#if defined(DOSCODE)
-	char *endptr;
-#endif
 
 	if (Size < _leftinfile) {
 		_file->read(ptr, Size);
@@ -116,14 +113,7 @@ void Music::fillbuffer(uint16 unit) {
 	} else {
 		_file->read(ptr, _leftinfile);
 
-#if defined(DOSCODE)
-		endptr = ptr;
-		endptr += _leftinfile - 2;
-
-		memset((void *)(((uint32) ptr) + _leftinfile), *endptr, Size - _leftinfile);
-#else
 		memset((char *)ptr + _leftinfile, 0, Size - _leftinfile);
-#endif
 
 		_file->seek(0);
 		_leftinfile = _filelength;
diff --git a/engines/lab/labsets.cpp b/engines/lab/labsets.cpp
index eefbc79..d68370b 100644
--- a/engines/lab/labsets.cpp
+++ b/engines/lab/labsets.cpp
@@ -69,15 +69,11 @@ bool LargeSet::readInitialConditions(const char *fileName) {
 			return false;
 
 		readBlock(&many, 2L, file);
-#if !defined(DOSCODE)
 		swapUShortPtr(&many, 1);
-#endif
 
 		for (int counter = 0; counter < many; counter++) {
 			readBlock(&set, 2L, file);
-#if !defined(DOSCODE)
 			swapUShortPtr(&set, 1);
-#endif
 			inclElement(set);
 		}
 	} else
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 5f22746..95c12bd 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -50,10 +50,8 @@ extern uint16 Direction;
 extern bool IsHiRes;
 extern uint32 VGAScreenWidth, VGAScreenHeight;
 
-#if !defined(DOSCODE)
 extern CloseDataPtr CPtr;
 extern uint16 RoomNum;
-#endif
 
 /*****************************************************************************/
 /* Converts an Amiga palette (up to 16 colors) to a VGA palette, then sets   */
@@ -172,16 +170,12 @@ extern TextFont *MsgFont;
 uint16 *FadePalette;
 
 static uint16 MapGadX[3] = {101, 55, 8}, MapGadY[3] = {105, 105, 105};
-#if !defined(DOSCODE)
+
 static Gadget downgadget = { 101, 105, 2, VKEY_DNARROW, 0L, NULL, NULL, NULL },
 			  upgadget   = {  55, 105, 1, VKEY_UPARROW, 0L, NULL, NULL, &downgadget },
-			  backgadget = {   8, 105, 0, 0, 0L, NULL, NULL, &upgadget },
-#else
-static Gadget downgadget = { 101, 105, 2, 0L, NULL, NULL, NULL },
-			  upgadget   = {  55, 105, 1, 0L, NULL, NULL, &downgadget },
-			  backgadget = {   8, 105, 0, 0L, NULL, NULL, &upgadget },
-#endif
-*MapGadgetList = &backgadget;
+			  backgadget = {   8, 105, 0, 0, 0L, NULL, NULL, &upgadget };
+
+static Gadget *MapGadgetList = &backgadget;
 
 static uint16 AmigaMapPalette[] = {
 	0x0BA8, 0x0C11, 0x0A74, 0x0076,
@@ -292,18 +286,13 @@ static bool loadMapData(void) {
 
 	if (strcmp((char *)Temp, "MAP0") == 0) {
 		readBlock(&MaxRooms, 2L, buffer);
-#if !defined(DOSCODE)
 		swapUShortPtr(&MaxRooms, 1);
-#endif
 		Maps = (MapData *)(*buffer);
-#if !defined(DOSCODE)
 
 		for (counter = 1; counter <= MaxRooms; counter++) {
 			swapUShortPtr(&Maps[counter].x, 4);
 			swapULongPtr(&Maps[counter].MapFlags, 1);
 		}
-
-#endif
 	} else
 		return false;
 
@@ -893,9 +882,7 @@ void processMap(uint16 CurRoom) {
 				}
 			}
 
-#if !defined(DOSCODE)
 			WSDL_UpdateScreen();
-#endif
 		}
 	}
 }
@@ -934,9 +921,7 @@ void doMap(uint16 CurRoom) {
 	drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true);
 	mouseShow();
 	attachGadgetList(MapGadgetList);
-#if !defined(DOSCODE)
 	WSDL_UpdateScreen();
-#endif
 	processMap(CurRoom);
 	attachGadgetList(NULL);
 	fade(false, 0);
@@ -947,9 +932,7 @@ void doMap(uint16 CurRoom) {
 	mapCleanUp();
 	blackAllScreen();
 	mouseShow();
-#if !defined(DOSCODE)
 	WSDL_UpdateScreen();
-#endif
 }
 
 } // End of namespace Lab
diff --git a/engines/lab/parsetypes.h b/engines/lab/parsetypes.h
index 5120c41..c409750 100644
--- a/engines/lab/parsetypes.h
+++ b/engines/lab/parsetypes.h
@@ -201,14 +201,12 @@ struct MapData {
 #pragma pack(pop)
 #endif
 
-#if !defined(DOSCODE)
 typedef struct {
 	uint16 RoomNum;
 	uint16 Direction;
 } CrumbData;
 
 #define MAX_CRUMBS          128
-#endif
 
 } // End of namespace Lab
 
diff --git a/engines/lab/readparse.cpp b/engines/lab/readparse.cpp
index 075c1fd..5e4bf62 100644
--- a/engines/lab/readparse.cpp
+++ b/engines/lab/readparse.cpp
@@ -77,13 +77,9 @@ bool readRoomData(const char *fileName) {
 			return false;
 
 		readBlock(&ManyRooms, 2L, file);
-#if !defined(DOSCODE)
 		swapUShortPtr(&ManyRooms, 1);
-#endif
 		readBlock(&HighestCondition, 2L, file);
-#if !defined(DOSCODE)
 		swapUShortPtr(&HighestCondition, 1);
-#endif
 
 		if ((Rooms = (RoomData *)calloc(ManyRooms + 1, sizeof(RoomData)))) {
 			for (Counter = 1; Counter <= ManyRooms; Counter++) {
@@ -91,12 +87,11 @@ bool readRoomData(const char *fileName) {
 				readBlock(&(Rooms[Counter].SouthDoor), 2L, file);
 				readBlock(&(Rooms[Counter].EastDoor),  2L, file);
 				readBlock(&(Rooms[Counter].WestDoor),  2L, file);
-#if !defined(DOSCODE)
+
 				swapUShortPtr(&(Rooms[Counter].NorthDoor), 1);
 				swapUShortPtr(&(Rooms[Counter].SouthDoor), 1);
 				swapUShortPtr(&(Rooms[Counter].EastDoor), 1);
 				swapUShortPtr(&(Rooms[Counter].WestDoor), 1);
-#endif
 
 				readBlock(&(Rooms[Counter].WipeType),  1L, file);
 			}
@@ -156,17 +151,14 @@ bool readInventory(const char *fileName) {
 			return false;
 
 		readBlock(&NumInv, 2L, file);
-#if !defined(DOSCODE)
 		swapUShortPtr(&NumInv, 1);
-#endif
+
 		UseMemory = true;
 
 		if (rallocate((void **) &Inventory, (NumInv + 1) * sizeof(InventoryData))) {
 			for (Counter = 1; Counter <= NumInv; Counter++) {
 				readBlock(&(Inventory[Counter].Many), 2L, file);
-#if !defined(DOSCODE)
 				swapUShortPtr(&(Inventory[Counter].Many), 1);
-#endif
 
 				if (!readString(&(Inventory[Counter].name), file)) {
 					UseMemory = false;
@@ -249,9 +241,7 @@ static int16 *readConditions(byte **file) {
 
 	do {
 		readBlock(&last, 2L, file);
-#if !defined(DOSCODE)
 		swapUShortPtr((uint16 *)&last, 1);
-#endif
 
 		if (Counter < 25) {
 			list[Counter] = last;
@@ -289,9 +279,7 @@ static bool readCloseUps(CloseDataPtr *CPtr, uint16 depth, byte **file) {
 				(*CPtr)->depth       = depth;
 
 				readBlock(*CPtr, 10L, file);
-#if !defined(DOSCODE)
 				swapUShortPtr((uint16 *)*CPtr, 5);
-#endif
 
 				if (!readString(&((*CPtr)->GraphicName), file))
 					return false;
@@ -366,9 +354,7 @@ static bool readAction(ActionPtr *APtr, byte **file) {
 		if (c == 1) {
 			if (rallocate((void **) APtr, sizeof(Action))) {
 				readBlock(*APtr, 8L, file);
-#if !defined(DOSCODE)
 				swapShortPtr((int16 *)*APtr, 4);
-#endif
 
 				if ((*APtr)->ActionType == SHOWMESSAGES) {
 					if (!rallocate((void **) &ptrarray, 4L * (*APtr)->Param1))
@@ -406,9 +392,8 @@ static bool readRule(RulePtr *RPtr, byte **file) {
 		if (c == 1) {
 			if (rallocate((void **) RPtr, sizeof(Rule))) {
 				readBlock(*RPtr, 6L, file);
-#if !defined(DOSCODE)
 				swapShortPtr((int16 *)*RPtr, 3);
-#endif
+
 				(*RPtr)->Condition = readConditions(file);
 
 				if (!(*RPtr)->Condition)
diff --git a/engines/lab/stddefines.h b/engines/lab/stddefines.h
index a9d685b..3729084 100644
--- a/engines/lab/stddefines.h
+++ b/engines/lab/stddefines.h
@@ -45,7 +45,6 @@ namespace Lab {
 #define delay Lab_Delay
 #endif
 
-#if !defined(DOSCODE)
 #if defined(USE_NOSWAP)
 #define swapUShort(value) (value)
 #define swapUShortPtr(ptr,count) (ptr)
@@ -59,7 +58,7 @@ namespace Lab {
 #define swapULongPtr(ptr,count) (ptr)
 #define swapLong(value) (value)
 #define swapLongPtr(ptr,count) (ptr)
-#elif defined(USE_SWAP)
+#else
 uint16 swapUShort(uint16 value);
 uint16 *swapUShortPtr(uint16 *ptr, int count);
 int16 swapShort(int16 value);
@@ -72,10 +71,6 @@ uint32 swapULong(uint32 value);
 uint32 *swapULongPtr(uint32 *ptr, int count);
 int32 swapLong(int32 value);
 int32 *swapLongPtr(int32 *ptr, int count);
-#else
-#error Please tell me about swapping bytes!
-#endif
-
 #endif
 
 } // End of namespace Lab
diff --git a/engines/lab/text.cpp b/engines/lab/text.cpp
index 92711ac..5c456c4 100644
--- a/engines/lab/text.cpp
+++ b/engines/lab/text.cpp
@@ -53,14 +53,12 @@ bool openFontMem(const char *TextFontPath, struct TextFont *tf, byte *fontbuffer
 		if (strcmp(header, "VGAF") == 0) {
 			tf->DataLength = filesize - headersize;
 			readBlock(&(tf->Height), 2L, file);
-#if !defined(DOSCODE)
 			swapUShortPtr(&(tf->Height), 1);
-#endif
+
 			readBlock(tf->Widths, 256L, file);
 			readBlock(tf->Offsets, 256L * 2L, file);
-#if !defined(DOSCODE)
 			swapUShortPtr(tf->Offsets, 256);
-#endif
+
 			skip(file, 4L);
 			tf->data = fontbuffer;
 			readBlock(tf->data, tf->DataLength, file);
@@ -91,14 +89,12 @@ bool openFont(const char *TextFontPath, struct TextFont **tf) {
 			if (strcmp(header, "VGAF") == 0) {
 				(*tf)->DataLength = filesize - headersize;
 				readBlock(&((*tf)->Height), 2L, file);
-#if !defined(DOSCODE)
 				swapUShortPtr(&((*tf)->Height), 1);
-#endif
+
 				readBlock((*tf)->Widths, 256L, file);
 				readBlock((*tf)->Offsets, 256L * 2L, file);
-#if !defined(DOSCODE)
 				swapUShortPtr((*tf)->Offsets, 256);
-#endif
+
 				skip(file, 4L);
 
 				if (((*tf)->data = (byte *)calloc((*tf)->DataLength, 1))) {
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index c850f52..d2fa002 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -92,8 +92,6 @@ bool createScreen(bool HiRes) {
 	return true;
 }
 
-
-
 /*****************************************************************************/
 /* Sets the current page on the VGA card.                                    */
 /*****************************************************************************/
@@ -102,8 +100,6 @@ void setPage(uint16 PageNum) {
 	assert(PageNum == 0);
 }
 
-
-
 void VGAStorePage(void) {
 	// does nothing in SDL
 }
@@ -228,7 +224,6 @@ void WSDL_GetMousePos(int *x, int *y) {
 	*y = g_MouseY;
 }
 
-
 void waitTOF() {
 	int untilOutOfRefresh = 1;
 
@@ -349,7 +344,6 @@ void getMode(uint16 *Mode) {
 /* Draws an image to the screen.                                             */
 /*****************************************************************************/
 void drawImage(Image *Im, uint16 x, uint16 y) {
-#if !defined(DOSCODE)
 	int sx, sy, dx, dy, w, h;
 
 	sx = 0;
@@ -389,83 +383,12 @@ void drawImage(Image *Im, uint16 x, uint16 y) {
 
 		ungetVGABaseAddr();
 	}
-
-#else
-	uint32  RealOffset,
-	         SegmentOffset,
-	         LeftInSegment;
-	char *video,
-	              *curline,
-	              *imdata = Im->ImageData;
-	uint16 counterx,
-	         countery = 0,
-	         numwholelines,
-	         numpartiallines,
-	         curpage;
-
-	while (countery < Im->Height) {
-		RealOffset = (VGAScreenWidth * (y + countery)) + x;
-		curpage    = RealOffset / VGABytesPerPage;
-		SegmentOffset = RealOffset - (curpage * VGABytesPerPage);
-		LeftInSegment = VGABytesPerPage - SegmentOffset;
-		setPage(curpage);
-		video = (char *)(((int32)(VGABASEADDRESS)) + SegmentOffset);
-
-		numwholelines = LeftInSegment / VGAScreenWidth;
-		numpartiallines = 0;
-		counterx      = LeftInSegment - (numwholelines * VGAScreenWidth);
-
-		if (counterx >= Im->Width)
-			numwholelines++;
-		else
-			numpartiallines = 1;
-
-		while (numwholelines && (countery < Im->Height)) {
-			curline = video;
-
-			for (counterx = 0; counterx < Im->Width; counterx++) {
-				*video = *imdata;
-				video++;
-				imdata++;
-			}
-
-			video = curline;
-			video += VGAScreenWidth;
-			countery ++;
-			numwholelines --;
-			LeftInSegment -= VGAScreenWidth;
-		}
-
-		if (numpartiallines && (countery < Im->Height)) {
-			countery ++;
-			curline = video;
-
-			for (counterx = 0; counterx < Im->Width; counterx++) {
-				if (LeftInSegment == 0L) {
-					setPage(curpage + 1);
-					LeftInSegment = VGABytesPerPage;
-					video = (char *)(VGABASEADDRESS);
-				}
-
-				*video = *imdata;
-				video++;
-				imdata++;
-				LeftInSegment--;
-			}
-		}
-	}
-
-#endif
 }
 
-
-
-
 /*****************************************************************************/
 /* Draws an image to the screen.                                             */
 /*****************************************************************************/
 void drawMaskImage(Image *Im, uint16 x, uint16 y) {
-#if !defined(DOSCODE)
 	int sx, sy, dx, dy, w, h;
 
 	sx = 0;
@@ -515,87 +438,12 @@ void drawMaskImage(Image *Im, uint16 x, uint16 y) {
 
 		ungetVGABaseAddr();
 	}
-
-#else
-	uint32  RealOffset,
-	         SegmentOffset,
-	         LeftInSegment;
-	char *video,
-	              *curline,
-	              *imdata = Im->ImageData;
-	uint16 counterx,
-	         countery = 0,
-	         numwholelines,
-	         numpartiallines,
-	         curpage;
-
-	while (countery < Im->Height) {
-		RealOffset = (VGAScreenWidth * (y + countery)) + x;
-		curpage    = RealOffset / VGABytesPerPage;
-		SegmentOffset = RealOffset - (curpage * VGABytesPerPage);
-		LeftInSegment = VGABytesPerPage - SegmentOffset;
-		setPage(curpage);
-		video = (char *)(((int32)(VGABASEADDRESS)) + SegmentOffset);
-
-		numwholelines = LeftInSegment / VGAScreenWidth;
-		numpartiallines = 0;
-		counterx      = LeftInSegment - (numwholelines * VGAScreenWidth);
-
-		if (counterx >= Im->Width)
-			numwholelines++;
-		else
-			numpartiallines = 1;
-
-		while (numwholelines && (countery < Im->Height)) {
-			curline = video;
-
-			for (counterx = 0; counterx < Im->Width; counterx++) {
-				if (*imdata)
-					*video = *imdata - 1;
-
-				video++;
-				imdata++;
-			}
-
-			video = curline;
-			video += VGAScreenWidth;
-			countery ++;
-			numwholelines --;
-			LeftInSegment -= VGAScreenWidth;
-		}
-
-		if (numpartiallines && (countery < Im->Height)) {
-			countery ++;
-			curline = video;
-
-			for (counterx = 0; counterx < Im->Width; counterx++) {
-				if (LeftInSegment == 0L) {
-					setPage(curpage + 1);
-					LeftInSegment = VGABytesPerPage;
-					video = (char *)(VGABASEADDRESS);
-				}
-
-				if (*imdata)
-					*video = *imdata - 1;
-
-				video++;
-				imdata++;
-				LeftInSegment--;
-			}
-		}
-	}
-
-#endif
 }
 
-
-
-
 /*****************************************************************************/
 /* Reads an image from the screen.                                           */
 /*****************************************************************************/
 void readScreenImage(Image *Im, uint16 x, uint16 y) {
-#if !defined(DOSCODE)
 	int sx, sy, dx, dy, w, h;
 
 	sx = 0;
@@ -635,73 +483,6 @@ void readScreenImage(Image *Im, uint16 x, uint16 y) {
 
 		ungetVGABaseAddr();
 	}
-
-#else
-	uint32  RealOffset,
-	         SegmentOffset,
-	         LeftInSegment;
-	char *video,
-	              *curline,
-	              *imdata = Im->ImageData;
-	uint16 counterx,
-	         countery = 0,
-	         numwholelines,
-	         numpartiallines,
-	         curpage;
-
-	while (countery < Im->Height) {
-		RealOffset = (VGAScreenWidth * (y + countery)) + x;
-		curpage    = RealOffset / VGABytesPerPage;
-		SegmentOffset = RealOffset - (curpage * VGABytesPerPage);
-		LeftInSegment = VGABytesPerPage - SegmentOffset;
-		setPage(curpage);
-		video = (char *)(((int32)(VGABASEADDRESS)) + SegmentOffset);
-
-		numwholelines = LeftInSegment / VGAScreenWidth;
-		numpartiallines = 0;
-		counterx      = LeftInSegment - (numwholelines * VGAScreenWidth);
-
-		if (counterx >= Im->Width)
-			numwholelines++;
-		else
-			numpartiallines = 1;
-
-		while (numwholelines && (countery < Im->Height)) {
-			curline = video;
-
-			for (counterx = 0; counterx < Im->Width; counterx++) {
-				*imdata = *video;
-				video++;
-				imdata++;
-			}
-
-			video = curline;
-			video += VGAScreenWidth;
-			countery ++;
-			numwholelines --;
-			LeftInSegment -= VGAScreenWidth;
-		}
-
-		if (numpartiallines && (countery < Im->Height)) {
-			countery ++;
-			curline = video;
-
-			for (counterx = 0; counterx < Im->Width; counterx++) {
-				if (LeftInSegment == 0L) {
-					setPage(curpage + 1);
-					LeftInSegment = VGABytesPerPage;
-					video = (char *)(VGABASEADDRESS);
-				}
-
-				*imdata = *video;
-				video++;
-				imdata++;
-				LeftInSegment--;
-			}
-		}
-	}
-
-#endif
 }
 
 
@@ -713,7 +494,6 @@ void readScreenImage(Image *Im, uint16 x, uint16 y) {
 /*****************************************************************************/
 void bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest,
 					uint16 xd, uint16 yd, uint16 width, uint16 height) {
-#if !defined(DOSCODE)
 	// I think the old code assumed that the source image data was valid for the given box.
 	// I will proceed on that assumption.
 	int sx, sy, dx, dy, w, h;
@@ -751,94 +531,10 @@ void bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest,
 			d += ImDest->Width;
 		}
 	}
-
-#else
-	uint32  RealOffset,
-	         SegmentOffset,
-	         LeftInSegment;
-	char *video,
-	              *curdestline,
-	              *cursourceline = ImSource->ImageData,
-	               *imdata;
-	uint16 counterx,
-	         countery = 0,
-	         numwholelines,
-	         numpartiallines,
-	         curpage;
-
-	cursourceline += (((int32) ys) * ImSource->Width) + xs;
-	imdata        = cursourceline;
-
-	while (countery < height) {
-		RealOffset = (ImDest->Width * (yd + countery)) + xd;
-		curpage    = RealOffset / VGABytesPerPage;
-		SegmentOffset = RealOffset - (curpage * VGABytesPerPage);
-		LeftInSegment = VGABytesPerPage - SegmentOffset;
-		setPage(curpage);
-
-		video = (char *)(((int32)(ImDest->ImageData)) + SegmentOffset);
-
-		numwholelines = LeftInSegment / ImDest->Width;
-		numpartiallines = 0;
-		counterx      = LeftInSegment - (numwholelines * ImDest->Width);
-
-		if (counterx >= width)
-			numwholelines++;
-		else
-			numpartiallines = 1;
-
-		while (numwholelines && (countery < height)) {
-			curdestline = video;
-			cursourceline = imdata;
-
-			for (counterx = 0; counterx < width; counterx++) {
-				*video = *imdata;
-				video++;
-				imdata++;
-			}
-
-			video = curdestline;
-			video += ImDest->Width;
-			imdata = cursourceline;
-			imdata += ImSource->Width;
-
-			countery ++;
-			numwholelines --;
-			LeftInSegment -= ImDest->Width;
-		}
-
-		if (numpartiallines && (countery < height)) {
-			countery ++;
-			curdestline = video;
-			cursourceline = imdata;
-
-			for (counterx = 0; counterx < width; counterx++) {
-				if (LeftInSegment == 0L) {
-					setPage(curpage + 1);
-					LeftInSegment = VGABytesPerPage;
-					video = ImDest->ImageData;
-				}
-
-				*video = *imdata;
-				video++;
-				imdata++;
-				LeftInSegment--;
-			}
-
-			video = curdestline;
-			video += ImDest->Width;
-			imdata = cursourceline;
-			imdata += ImSource->Width;
-		}
-	}
-
-#endif
 }
 
-
 byte *TempScrollData;
 
-
 /*****************************************************************************/
 /* Scrolls the display in the x direction by blitting.                       */
 /* The TempScrollData variable must be initialized to some memory, or this   */
@@ -883,10 +579,6 @@ void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	}
 }
 
-
-
-
-
 /*****************************************************************************/
 /* Scrolls the display in the y direction by blitting.                       */
 /*****************************************************************************/
@@ -929,8 +621,6 @@ void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	}
 }
 
-
-
 static unsigned char curapen = 0;
 
 /*****************************************************************************/
@@ -940,14 +630,10 @@ void setAPen(uint16 pennum) {
 	curapen = (unsigned char)pennum;
 }
 
-
-
-
 /*****************************************************************************/
 /* Fills in a rectangle.                                                     */
 /*****************************************************************************/
 void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-#if !defined(DOSCODE)
 	int dx, dy, w, h;
 
 	dx = x1;
@@ -987,74 +673,8 @@ void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 
 		ungetVGABaseAddr();
 	}
-
-#else
-	uint32  RealOffset,
-	         SegmentOffset,
-	         LeftInSegment;
-	char *video,
-	              *curline;
-	uint16 counterx,
-	         countery = y1,
-	         numwholelines,
-	         numpartiallines,
-	         curpage;
-
-	while (countery <= y2) {
-		RealOffset = (VGAScreenWidth * countery) + x1;
-		curpage    = RealOffset / VGABytesPerPage;
-		SegmentOffset = RealOffset - (curpage * VGABytesPerPage);
-		LeftInSegment = VGABytesPerPage - SegmentOffset;
-		setPage(curpage);
-		video = (char *)(((int32)(VGABASEADDRESS)) + SegmentOffset);
-
-		numwholelines = LeftInSegment / VGAScreenWidth;
-		numpartiallines = 0;
-		counterx      = LeftInSegment - (numwholelines * VGAScreenWidth);
-
-		if (counterx >= (x2 - x1 + 1))
-			numwholelines++;
-		else
-			numpartiallines = 1;
-
-		while (numwholelines && (countery <= y2)) {
-			curline = video;
-
-			for (counterx = x1; counterx <= x2; counterx++) {
-				*video = curapen;
-				video++;
-			}
-
-			video = curline;
-			video += VGAScreenWidth;
-			countery ++;
-			numwholelines --;
-			LeftInSegment -= VGAScreenWidth;
-		}
-
-		if (numpartiallines && (countery <= y2)) {
-			countery ++;
-			curline = video;
-
-			for (counterx = x1; counterx <= x2; counterx++) {
-				if (LeftInSegment == 0L) {
-					setPage(curpage + 1);
-					LeftInSegment = VGABytesPerPage;
-					video = (char *)(VGABASEADDRESS);
-				}
-
-				*video = curapen;
-				video++;
-				LeftInSegment--;
-			}
-		}
-	}
-
-#endif
 }
 
-
-
 /*****************************************************************************/
 /* Draws a horizontal line.                                                  */
 /*****************************************************************************/
@@ -1062,9 +682,6 @@ void drawVLine(uint16 x, uint16 y1, uint16 y2) {
 	rectFill(x, y1, x, y2);
 }
 
-
-
-
 /*****************************************************************************/
 /* Draws a vertical line.                                                    */
 /*****************************************************************************/
@@ -1072,14 +689,10 @@ void drawHLine(uint16 x1, uint16 y, uint16 x2) {
 	rectFill(x1, y, x2, y);
 }
 
-
-
-
 /*****************************************************************************/
 /* Ghoasts a region on the screen using the desired pen color.               */
 /*****************************************************************************/
 void ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-#if !defined(DOSCODE)
 	int dx, dy, w, h;
 
 	dx = x1;
@@ -1127,85 +740,6 @@ void ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 
 		ungetVGABaseAddr();
 	}
-
-#else
-	uint32  RealOffset,
-	         SegmentOffset;
-	int32           LeftInSegment;
-	char *video,
-	              *curline;
-	uint16 counterx,
-	         countery = y1,
-	         numwholelines,
-	         numpartiallines,
-	         curpage;
-
-	while (countery <= y2) {
-		RealOffset = (VGAScreenWidth * countery) + x1;
-		curpage    = RealOffset / VGABytesPerPage;
-		SegmentOffset = RealOffset - (curpage * VGABytesPerPage);
-		LeftInSegment = VGABytesPerPage - SegmentOffset;
-		setPage(curpage);
-		video = (char *)(((int32)(VGABASEADDRESS)) + SegmentOffset);
-
-		numwholelines = LeftInSegment / VGAScreenWidth;
-		numpartiallines = 0;
-		counterx      = LeftInSegment - (numwholelines * VGAScreenWidth);
-
-		if (counterx >= (x2 - x1 + 1))
-			numwholelines++;
-		else
-			numpartiallines = 1;
-
-		while (numwholelines && (countery <= y2)) {
-			curline = video;
-			counterx = x1;
-
-			if (1 & countery) {
-				video++;
-				counterx ++;
-			}
-
-			while (counterx <= x2) {
-				*video = pencolor;
-				video += 2;
-				counterx += 2;
-			}
-
-			video = curline;
-			video += VGAScreenWidth;
-			countery ++;
-			numwholelines --;
-			LeftInSegment -= VGAScreenWidth;
-		}
-
-		if (numpartiallines && (countery <= y2)) {
-			countery ++;
-			curline = video;
-			counterx = x1;
-
-			if (1 & countery) {
-				video++;
-				counterx ++;
-				LeftInSegment --;
-			}
-
-			while (counterx < x2) {
-				if (LeftInSegment <= 0L) {
-					setPage(curpage + 1);
-					video = (char *)(((int32)(VGABASEADDRESS)) - LeftInSegment);
-					LeftInSegment = VGABytesPerPage + LeftInSegment;
-				}
-
-				*video = pencolor;
-				video += 2;
-				counterx += 2;
-				LeftInSegment -= 2;
-			}
-		}
-	}
-
-#endif
 }
 
 } // End of namespace Lab
diff --git a/engines/lab/vga.h b/engines/lab/vga.h
index 8c1d372..fe6b9f0 100644
--- a/engines/lab/vga.h
+++ b/engines/lab/vga.h
@@ -59,9 +59,7 @@ void quickWaitTOF(void);
 
 byte *getVGABaseAddr(void);
 
-#if !defined(DOSCODE)
 void ungetVGABaseAddr();
-#endif
 
 void writeColorReg(byte *buf, uint16 regnum);
 


Commit: b8da3f2bc2fe63357a6d73a78e82dafebecc140e
    https://github.com/scummvm/scummvm/commit/b8da3f2bc2fe63357a6d73a78e82dafebecc140e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Final fix for game variant detection

Changed paths:
    engines/lab/detection.cpp



diff --git a/engines/lab/detection.cpp b/engines/lab/detection.cpp
index 1cd78a1..c6a0d74 100644
--- a/engines/lab/detection.cpp
+++ b/engines/lab/detection.cpp
@@ -45,9 +45,9 @@ static const ADGameDescription labDescriptions[] = {
 		"lab",
 		"",
 		{
-			{ "doors",       0, "d77536010e7e5ae17ee066323ceb9585", 2537 },
-			{ "notes11",     0, "63e873f659f8f46f9809d16a2bf653c7", 3562 },
-			{ "noteold.fon", 0, "6c1d90ad55149556e79d3f7bfddb4bd7", 9252 },
+			{ "doors",       0, "d77536010e7e5ae17ee066323ceb9585", 2537 }, // game/doors
+			{ "notes11",     0, "63e873f659f8f46f9809d16a2bf653c7", 3562 }, // fonts/notes11
+			{ "noteold.fon", 0, "6c1d90ad55149556e79d3f7bfddb4bd7", 9252 }, // game/spict/noteold.fon
 			{ NULL, 0, NULL, 0 }
 		},
 		Common::EN_ANY,
@@ -59,9 +59,9 @@ static const ADGameDescription labDescriptions[] = {
 		"lab",
 		"Lowres",
 		{
-			{ "doors",   0, "d77536010e7e5ae17ee066323ceb9585", 2537 },
-			{ "notes11", 0, "63e873f659f8f46f9809d16a2bf653c7", 3562 },
-			{ "64b",     0, "3a84d41bcc6a782f22e8e954bce09721", 39916 },
+			{ "doors",   0, "d77536010e7e5ae17ee066323ceb9585", 2537 }, // game/doors
+			{ "notes11", 0, "63e873f659f8f46f9809d16a2bf653c7", 3562 }, // fonts/notes11
+			{ "64b",     0, "3a84d41bcc6a782f22e8e954bce09721", 39916 }, // game/pict/h2/64b
 			{ NULL, 0, NULL, 0 }
 		},
 		Common::EN_ANY,
@@ -73,10 +73,10 @@ static const ADGameDescription labDescriptions[] = {
 		"lab",
 		"Rerelease",
 		{
-			{ "doors",   0, "d77536010e7e5ae17ee066323ceb9585", 2537 },
-			{ "notes11", 0, "63e873f659f8f46f9809d16a2bf653c7", 3562 },
-			{ "inv",     0, "0a5377f0673454b1743322471892ad43", 39120 },
-			{ "48",      0, "fb2d990c5fb5dd36a618e5ca8136b740", 892 },
+			{ "doors",   0, "d77536010e7e5ae17ee066323ceb9585", 2537 }, // game/doors
+			{ "notes11", 0, "63e873f659f8f46f9809d16a2bf653c7", 3562 }, // fonts/notes11
+			{ "noteold.fon", 0, "6c1d90ad55149556e79d3f7bfddb4bd7", 9252 }, // game/spict/noteold.fon
+			{ "wyrmkeep",0, "97c7064c54c28b952d37c4ebff6efa50", 52286 }, // game/spict/intro
 			{ NULL, 0, NULL, 0 }
 		},
 		Common::EN_ANY,
@@ -86,23 +86,8 @@ static const ADGameDescription labDescriptions[] = {
 	},
 	{
 		"lab",
-		"Trial",
-		{
-			{ "doors",   0, "d77536010e7e5ae17ee066323ceb9585", 2537 },
-			{ "notes11", 0, "63e873f659f8f46f9809d16a2bf653c7", 3562 },
-			{ "inv",     0, "0a5377f0673454b1743322471892ad43", 39120 },
-			{ "48",      0, "a319ba9bab20b24200257e826b5494e1", 892 },
-			{ NULL, 0, NULL, 0 }
-		},
-		Common::EN_ANY,
-		Common::kPlatformWindows,
-		ADGF_DEMO,
-		GUIO0()
-	},
-	{
-		"lab",
 		"",
-		AD_ENTRY1s("doors", "7bf458df6ec30cc8ef4665e4d7c77f59", 2537),
+		AD_ENTRY1s("doors", "7bf458df6ec30cc8ef4665e4d7c77f59", 2537), // game/doors
 		Common::EN_ANY,
 		Common::kPlatformAmiga,
 		ADGF_NO_FLAGS,
@@ -118,6 +103,7 @@ static const char *const directoryGlobs[] = {
 		"spict",
 		"rooms",
 		"h2",
+		"intro",
         0
 };
 


Commit: 500bb493f6011ef2a5ee26711600c952d1f46583
    https://github.com/scummvm/scummvm/commit/500bb493f6011ef2a5ee26711600c952d1f46583
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Fix regression

Changed paths:
    engines/lab/engine.cpp
    engines/lab/labfile.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 6f4f4e5..01fd7b9 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -275,7 +275,7 @@ bool setUpScreens(void) {
 	/* Creates the gadgets for the movement control panel */
 	y = VGAScaleY(173) - SVGACord(2);
 
-	if (g_lab->getPlatform() != Common::kPlatformWindows) {
+	if (g_lab->getPlatform() == Common::kPlatformWindows) {
 		MoveGadgetList = createButton(VGAScaleX(1), y, 0, 't', MoveImages[0], MoveImages[1]);
 		curgad = MoveGadgetList;
 		curgad->NextGadget = createButton(VGAScaleX(33), y, 1, 'm', MoveImages[2], MoveImages[3]);
diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
index 01f1ffa..63cc626 100644
--- a/engines/lab/labfile.cpp
+++ b/engines/lab/labfile.cpp
@@ -48,11 +48,6 @@ static uint32 buffersize, realbuffersize;
 uint32 ReadSoFar;
 bool ReadIsError, ReadIsDone;
 
-
-#if defined(WIN32)
-#define stat _stat
-#endif
-
 /*****************************************************************************/
 /* Returns the size of a file.                                               */
 /*****************************************************************************/


Commit: 9a116c57e1b7a04d2f48c685847c4e8629ffc3c6
    https://github.com/scummvm/scummvm/commit/9a116c57e1b7a04d2f48c685847c4e8629ffc3c6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Use OSystem for mouse drawing

Changed paths:
    engines/lab/mouse.cpp



diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index e68ce6f..fcb8882 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -69,10 +69,6 @@ static byte MouseData[] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
 						   0, 0, 0, 0, 0, 0, 1, 1, 0, 0};
 
 
-static Image MouseImage, BackImage;
-static byte BackImageBuffer[256];
-static uint16 backx, backy;
-
 static bool drawmouse = false, gadhit    = false;
 static Gadget *hitgad = NULL;
 
@@ -128,43 +124,6 @@ void attachGadgetList(Gadget *GadList) {
 	ScreenGadgetList = GadList;
 }
 
-
-
-
-static void drawMouse(void) {
-	if (BackImage.ImageData) {
-		if (backx <= VGAScreenWidth - BackImage.Width && backy <= VGAScreenHeight - BackImage.Height)
-			drawMaskImage(&MouseImage, backx, backy);
-	} else {
-		if (CurMouseX <= VGAScreenWidth - MouseImage.Width && CurMouseY <= VGAScreenHeight - MouseImage.Height)
-			drawMaskImage(&MouseImage, CurMouseX, CurMouseY);
-	}
-}
-
-
-
-static void getBackMouse(void) {
-	BackImage.Width = MouseImage.Width;
-	BackImage.Height = MouseImage.Height;
-	BackImage.ImageData = BackImageBuffer;
-
-	backx = CurMouseX;
-	backy = CurMouseY;
-
-	if (backx <= VGAScreenWidth - BackImage.Width && backy <= VGAScreenHeight - BackImage.Height)
-		readScreenImage(&BackImage, backx, backy);
-}
-
-static void restoreBackMouse(void) {
-	if (BackImage.ImageData) {
-		if (backx <= VGAScreenWidth - BackImage.Width && backy <= VGAScreenHeight - BackImage.Height)
-			drawImage(&BackImage, backx, backy);
-
-		BackImage.ImageData = NULL;
-	}
-}
-
-
 static Gadget *TempGad;
 
 
@@ -179,12 +138,6 @@ void mouse_handler(int32 max, int32 mcx, int32 mdx) {
 
 			if (IsHiRes && !QuitMouseHandler) {
 				drawmouse = true;
-			} else if (!MouseHidden && !QuitMouseHandler) {
-				VGAStorePage();
-				restoreBackMouse();
-				getBackMouse();
-				drawMouse();
-				VGARestorePage();
 			}
 		}
 	}
@@ -221,9 +174,6 @@ void updateMouse(void) {
 	if (drawmouse && !MouseHidden) {
 		QuitMouseHandler = true;
 		drawmouse = false;
-		restoreBackMouse();
-		getBackMouse();
-		drawMouse();
 		QuitMouseHandler = false;
 		doUpdateDisplay = true;
 	}
@@ -256,10 +206,8 @@ void updateMouse(void) {
 /* Initializes the mouse.                                                    */
 /*****************************************************************************/
 bool initMouse(void) {
-	BackImage.ImageData = NULL;
-	MouseImage.ImageData = MouseData;
-	MouseImage.Width = MouseImageWidth;
-	MouseImage.Height = MouseImageHeight;
+	g_system->setMouseCursor(MouseData, MouseImageWidth, MouseImageHeight, 0, 0, 0);
+	g_system->showMouse(false);
 
 	mouseMove(0, 0);
 
@@ -281,11 +229,7 @@ bool mouseReset(void) {
 /* Shows the mouse.                                                          */
 /*****************************************************************************/
 void mouseShow(void) {
-	QuitMouseHandler = true;
-	VGAStorePage();
-	mouseShowXY(CurMouseX, CurMouseY);
-	VGARestorePage();
-	QuitMouseHandler = false;
+	g_system->showMouse(true);
 }
 
 
@@ -304,9 +248,6 @@ void mouseShowXY(uint16 MouseX, uint16 MouseY) {
 	if ((NumHidden == 0) && MouseHidden) {
 		CurMouseX = MouseX;
 		CurMouseY = MouseY;
-		getBackMouse();
-		drawMouse();
-		WSDL_UpdateScreen();
 		MouseHidden = false;
 	}
 
@@ -325,9 +266,8 @@ void mouseHide(void) {
 
 	if (NumHidden && !MouseHidden) {
 		MouseHidden = true;
-		VGAStorePage();
-		restoreBackMouse();
-		VGARestorePage();
+
+		g_system->showMouse(false);
 	}
 
 	QuitMouseHandler = false;
@@ -346,7 +286,8 @@ void mouseHideXY(void) {
 
 	if (NumHidden && !MouseHidden) {
 		MouseHidden = true;
-		restoreBackMouse();
+
+		g_system->showMouse(false);
 	}
 
 	QuitMouseHandler = false;
@@ -354,18 +295,16 @@ void mouseHideXY(void) {
 
 
 
-
+extern int g_MouseX;
+extern int g_MouseY;
 
 /*****************************************************************************/
 /* Gets the current mouse co-ordinates.  NOTE: On IBM version, will scale    */
 /* from virtual to screen co-ordinates automatically.                        */
 /*****************************************************************************/
 void mouseXY(uint16 *x, uint16 *y) {
-	int xx = 0, yy = 0;
-	//SDL_GetMousePos(&xx, &yy);
-	warning("STUB: mouseXY");
-	*x = (uint16)xx;
-	*y = (uint16)yy;
+	*x = (uint16)g_MouseX;
+	*y = (uint16)g_MouseY;
 
 	if (!IsHiRes)
 		(*x) /= 2;
@@ -386,12 +325,6 @@ void mouseMove(uint16 x, uint16 y) {
 	if (!MouseHidden) {
 		QuitMouseHandler = true;
 		mouseXY(&CurMouseX, &CurMouseY);
-		VGAStorePage();
-		restoreBackMouse();
-		getBackMouse();
-		drawMouse();
-		VGARestorePage();
-		WSDL_UpdateScreen();
 		QuitMouseHandler = false;
 	}
 }


Commit: 80e00c1f54a0d5747156ada22b6daafbf252e833
    https://github.com/scummvm/scummvm/commit/80e00c1f54a0d5747156ada22b6daafbf252e833
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Fix regression

Changed paths:
    engines/lab/mouse.cpp



diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index fcb8882..21f0f3d 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -229,6 +229,8 @@ bool mouseReset(void) {
 /* Shows the mouse.                                                          */
 /*****************************************************************************/
 void mouseShow(void) {
+	mouseShowXY(CurMouseX, CurMouseY);
+
 	g_system->showMouse(true);
 }
 
@@ -248,6 +250,7 @@ void mouseShowXY(uint16 MouseX, uint16 MouseY) {
 	if ((NumHidden == 0) && MouseHidden) {
 		CurMouseX = MouseX;
 		CurMouseY = MouseY;
+		WSDL_ProcessInput(0);
 		MouseHidden = false;
 	}
 
@@ -325,6 +328,7 @@ void mouseMove(uint16 x, uint16 y) {
 	if (!MouseHidden) {
 		QuitMouseHandler = true;
 		mouseXY(&CurMouseX, &CurMouseY);
+		WSDL_ProcessInput(0);
 		QuitMouseHandler = false;
 	}
 }


Commit: f9d90934f6e281f40b52ad561d339f26d7d9c0e9
    https://github.com/scummvm/scummvm/commit/f9d90934f6e281f40b52ad561d339f26d7d9c0e9
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Fix signed/unsigned comparison warnings

Changed paths:
    engines/lab/graphics.cpp
    engines/lab/labfile.cpp
    engines/lab/labfun.h
    engines/lab/mouse.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 3d91fd4..2a43dfe 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -242,7 +242,7 @@ static void getLine(TextFont *tf, char *LineBuffer, const char **MainBuffer, uin
 /* each line less than 255 characters.                                        */
 /******************************************************************************/
 uint32 flowText(void *font,      /* the TextAttr pointer */
-                uint16 spacing,          /* How much vertical spacing between the lines */
+                int16 spacing,          /* How much vertical spacing between the lines */
                 uint16 pencolor,         /* pen number to use for text */
                 uint16 backpen,          /* the background color */
                 bool fillback,                /* Whether to fill the background */
@@ -314,7 +314,7 @@ extern byte *VGABASEADDRESS;
 /* Calls flowText, but flows it to memory.  Same restrictions as flowText.    */
 /******************************************************************************/
 uint32 flowTextToMem(Image *DestIm, void *font,     /* the TextAttr pointer */
-                     uint16 spacing,          /* How much vertical spacing between the lines */
+                     int16 spacing,          /* How much vertical spacing between the lines */
                      uint16 pencolor,         /* pen number to use for text */
                      uint16 backpen,          /* the background color */
                      bool fillback,                /* Whether to fill the background */
diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
index 63cc626..2f93554 100644
--- a/engines/lab/labfile.cpp
+++ b/engines/lab/labfile.cpp
@@ -45,7 +45,7 @@ static byte *buffer = NULL, *realbufferstart = NULL, *startoffilestorage = NULL;
 byte **startoffile = &startoffilestorage;
 static uint32 buffersize, realbuffersize;
 
-uint32 ReadSoFar;
+int32 ReadSoFar;
 bool ReadIsError, ReadIsDone;
 
 /*****************************************************************************/
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 6f304d0..bb2ddf8 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -92,7 +92,7 @@ byte *readPictToMem(const char *filename, uint16 x, uint16 y);
 /* Window text stuff */
 
 uint32 flowText(void *font,  /* the TextAttr pointer */
-                uint16 spacing,          /* How much vertical spacing between the lines */
+                int16 spacing,          /* How much vertical spacing between the lines */
                 uint16 pencolor,         /* pen number to use for text */
                 uint16 backpen,          /* the background color */
                 bool fillback,                /* Whether to fill the background */
@@ -103,7 +103,7 @@ uint32 flowText(void *font,  /* the TextAttr pointer */
                 uint16 y1, uint16 x2, uint16 y2, const char *text); /* The text itself */
 
 uint32 flowTextToMem(Image *DestIm, void *font,     /* the TextAttr pointer */
-                     uint16 spacing,          /* How much vertical spacing between the lines */
+                     int16 spacing,          /* How much vertical spacing between the lines */
                      uint16 pencolor,         /* pen number to use for text */
                      uint16 backpen,          /* the background color */
                      bool fillback,                /* Whether to fill the background */
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index 21f0f3d..1b00c15 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -298,8 +298,8 @@ void mouseHideXY(void) {
 
 
 
-extern int g_MouseX;
-extern int g_MouseY;
+extern uint32 g_MouseX;
+extern uint32 g_MouseY;
 
 /*****************************************************************************/
 /* Gets the current mouse co-ordinates.  NOTE: On IBM version, will scale    */
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index d2fa002..11713da 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -54,8 +54,8 @@ int g_ScreenWasLocked = 0;
 int g_IgnoreUpdateDisplay = 0;
 int g_LastWaitTOFTicks = 0;
 
-int g_MouseX = 0;
-int g_MouseY = 0;
+uint32 g_MouseX = 0;
+uint32 g_MouseY = 0;
 
 uint16 g_NextKeyIn = 0;
 uint16 g_KeyBuf[64];


Commit: 28bbcf5641d8d505b07bcc121c8b129f9fb1de43
    https://github.com/scummvm/scummvm/commit/28bbcf5641d8d505b07bcc121c8b129f9fb1de43
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Add missing const qualifiers

Changed paths:
    engines/lab/engine.cpp
    engines/lab/map.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 01fd7b9..06ac219 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -71,8 +71,8 @@ void    mayShowCrumbIndicatorOff();
 
 bool Alternate = false, ispal = false, noupdatediff = false, MainDisplay = true, QuitLab = false, DoNotReset = false;
 
-extern char *NewFileName;  /* When ProcessRoom.c decides to change the filename
-                              of the current picture. */
+extern const char *NewFileName;  /* When ProcessRoom.c decides to change the filename
+                                    of the current picture. */
 
 extern char *LAMPONMSG, *TURNLEFT, *TURNRIGHT;
 extern char *GOFORWARDDIR, *NOPATH, *TAKEITEM, *USEONWHAT, *TAKEWHAT, *MOVEWHAT, *OPENWHAT, *CLOSEWHAT, *LOOKWHAT, *NOTHING, *USEMAP, *USEJOURNAL, *TURNLAMPON, *TURNLAMPOFF, *USEWHISKEY, *USEPITH, *USEHELMET;
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 95c12bd..77d520d 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -153,7 +153,7 @@ void readImage(byte **buffer, Image **im) {
 
 
 extern RoomData *Rooms;
-extern char *ViewPath;
+extern const char *ViewPath;
 
 static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge,
 			 *HRoom, *VRoom, *Maze, *HugeMaze, *Path, *MapNorth,


Commit: d70819fa6751ad37170b4cbc13cc6106ad1bb8d4
    https://github.com/scummvm/scummvm/commit/d70819fa6751ad37170b4cbc13cc6106ad1bb8d4
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Silence false positives about uninitialized variables

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 06ac219..ec9ae28 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -715,12 +715,12 @@ static void process(void) {
 	IntuiMessage *Msg;
 	uint32 Class;
 
-	uint16 Code, Qualifier, MouseX, MouseY, ActionMode = 4;
+	uint16 Code = 0, Qualifier, MouseX, MouseY, ActionMode = 4;
 	uint16 CurInv = MAPNUM, LastInv = MAPNUM, Old;
 
 	bool ForceDraw = false, doit, GotMessage = true;
 
-	uint16 OldRoomNum, OldDirection, GadID, NewDir;
+	uint16 OldRoomNum, OldDirection = 0, GadID = 0, NewDir;
 
 	CloseDataPtr OldCPtr, TempCPtr, HCPtr = NULL;
 	ViewDataPtr VPtr;


Commit: 7f80a4ff63f5314d3f9b13d124c279e18ca06d73
    https://github.com/scummvm/scummvm/commit/7f80a4ff63f5314d3f9b13d124c279e18ca06d73
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Change the "action" parameter of doActionRule to lowercase

This avoids a name clash with the Action struct

Changed paths:
    engines/lab/parsefun.h
    engines/lab/processroom.cpp



diff --git a/engines/lab/parsefun.h b/engines/lab/parsefun.h
index e6794ee..2c48311 100644
--- a/engines/lab/parsefun.h
+++ b/engines/lab/parsefun.h
@@ -77,7 +77,7 @@ void setCurClose(uint16 x, uint16 y, CloseDataPtr *cptr);
 
 bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr);
 
-bool doActionRule(int16 x, int16 y, int16 Action, int16 RoomNum, CloseDataPtr *LCPtr);
+bool doActionRule(int16 x, int16 y, int16 action, int16 RoomNum, CloseDataPtr *LCPtr);
 
 bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *LCPtr);
 
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 5699c63..70eac05 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -716,10 +716,10 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
 /*****************************************************************************/
 /* Does the work for doActionRule.                                           */
 /*****************************************************************************/
-static bool doActionRuleSub(int16 Action, int16 roomNum, CloseDataPtr LCPtr, CloseDataPtr *Set, bool AllowDefaults) {
+static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr LCPtr, CloseDataPtr *Set, bool AllowDefaults) {
 	RulePtr RPtr;
 
-	Action++;
+	action++;
 
 	if (LCPtr) {
 		RPtr = Rooms[roomNum].RuleList;
@@ -732,11 +732,11 @@ static bool doActionRuleSub(int16 Action, int16 roomNum, CloseDataPtr LCPtr, Clo
 
 		while (RPtr) {
 			if ((RPtr->RuleType == ACTION) &&
-			        ((RPtr->Param1 == Action) || ((RPtr->Param1 == 0) && AllowDefaults))) {
+			        ((RPtr->Param1 == action) || ((RPtr->Param1 == 0) && AllowDefaults))) {
 				if (((RPtr->Param2 == LCPtr->CloseUpType) ||
 				        ((RPtr->Param2 == 0) && AllowDefaults))
 				        ||
-				        ((Action == 1) && (RPtr->Param2 == (-LCPtr->CloseUpType)))) {
+				        ((action == 1) && (RPtr->Param2 == (-LCPtr->CloseUpType)))) {
 					if (checkConditions(RPtr->Condition)) {
 						doActions(RPtr->ActionList, Set);
 						return true;
@@ -754,7 +754,7 @@ static bool doActionRuleSub(int16 Action, int16 roomNum, CloseDataPtr LCPtr, Clo
 /*****************************************************************************/
 /* Goes through the rules if an action is taken.                             */
 /*****************************************************************************/
-bool doActionRule(int16 x, int16 y, int16 Action, int16 roomNum, CloseDataPtr *LCPtr) {
+bool doActionRule(int16 x, int16 y, int16 action, int16 roomNum, CloseDataPtr *LCPtr) {
 	CloseDataPtr TLCPtr;
 
 	if (roomNum)
@@ -764,13 +764,13 @@ bool doActionRule(int16 x, int16 y, int16 Action, int16 roomNum, CloseDataPtr *L
 
 	TLCPtr = getObject(x, y, *LCPtr);
 
-	if (doActionRuleSub(Action, roomNum, TLCPtr, LCPtr, false))
+	if (doActionRuleSub(action, roomNum, TLCPtr, LCPtr, false))
 		return true;
-	else if (doActionRuleSub(Action, roomNum, *LCPtr, LCPtr, false))
+	else if (doActionRuleSub(action, roomNum, *LCPtr, LCPtr, false))
 		return true;
-	else if (doActionRuleSub(Action, roomNum, TLCPtr, LCPtr, true))
+	else if (doActionRuleSub(action, roomNum, TLCPtr, LCPtr, true))
 		return true;
-	else if (doActionRuleSub(Action, roomNum, *LCPtr, LCPtr, true))
+	else if (doActionRuleSub(action, roomNum, *LCPtr, LCPtr, true))
 		return true;
 
 	return false;


Commit: 4f185f7dd6f82c86ab9b66fc10209fa966654806
    https://github.com/scummvm/scummvm/commit/4f185f7dd6f82c86ab9b66fc10209fa966654806
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Further fixes to signed/unsigned comparisons and bool assignments

Changed paths:
    engines/lab/special.cpp



diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 038f8b8..abdbc73 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -126,7 +126,7 @@ static void doCombination(void) {
 }
 
 
-extern char *TempScrollData;
+extern byte *TempScrollData;
 
 /*****************************************************************************/
 /* Reads in a backdrop picture.                                              */
@@ -245,7 +245,7 @@ void mouseCombination(uint16 x, uint16 y) {
 /*----------------------------------------------------------------------------*/
 
 Image *Tiles[16];
-int16 CurTile[4] [4] = {
+uint16 CurTile[4] [4] = {
 	{ 1, 5,  9, 13 },
 	{ 2, 6, 10, 14 },
 	{ 3, 7, 11, 15 },
@@ -1338,7 +1338,7 @@ static bool processSaveLoad() {
 
 			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) ||
 			        ((Class == RAWKEY) && (Code == 27)))
-				return -1;
+				return true;
 
 			if (Class == RAWKEY) {
 				if (Code == 'l' || Code == 'L') {
@@ -1422,7 +1422,7 @@ static bool processSaveLoad() {
 							break;
 
 						case ID_CANCEL:
-							return -1;
+							return true;
 						}
 					}
 				}


Commit: f9b4b43e9087e485d51c4be0972b911792fcd2ee
    https://github.com/scummvm/scummvm/commit/f9b4b43e9087e485d51c4be0972b911792fcd2ee
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Remove multiple mouse coordinate variables

There is no real point in holding multiple location variables
for the mouse cursor. One set of coordinates should be enough

Changed paths:
    engines/lab/mouse.cpp
    engines/lab/mouse.h



diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index 1b00c15..30c0658 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -42,14 +42,11 @@ extern uint32 VGAScreenWidth, VGAScreenHeight;
 void mouseHideXY(void);
 
 static bool LeftClick = false;
-static uint16 leftx = 0, lefty = 0;
 static bool RightClick = false;
-static uint16 rightx = 0, righty = 0;
 
 static bool MouseHidden = true, QuitMouseHandler = false;
 static int32 NumHidden   = 1;
 static uint16 CurMouseX, CurMouseY;
-static uint16 MouseImageWidth = 10, MouseImageHeight = 15;
 static Gadget *LastGadgetHit = NULL;
 Gadget *ScreenGadgetList = NULL;
 static byte MouseData[] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -68,6 +65,8 @@ static byte MouseData[] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
 						   0, 0, 0, 0, 0, 1, 7, 7, 1, 0,
 						   0, 0, 0, 0, 0, 0, 1, 1, 0, 0};
 
+#define MOUSE_WIDTH 10
+#define MOUSE_HEIGHT 15
 
 static bool drawmouse = false, gadhit    = false;
 static Gadget *hitgad = NULL;
@@ -127,14 +126,14 @@ void attachGadgetList(Gadget *GadList) {
 static Gadget *TempGad;
 
 
-void mouse_handler(int32 max, int32 mcx, int32 mdx) {
+void mouse_handler(int32 flag, int32 mouseX, int32 mouseY) {
 	if (!IsHiRes)
-		mcx /= 2;
+		mouseX /= 2;
 
-	if (max & 0x01) { /* mouse Move */
-		if ((CurMouseX != mcx) || (CurMouseY != mdx)) {
-			CurMouseX = mcx;
-			CurMouseY = mdx;
+	if (flag & 0x01) { /* mouse Move */
+		if ((CurMouseX != mouseX) || (CurMouseY != mouseY)) {
+			CurMouseX = mouseX;
+			CurMouseY = mouseY;
 
 			if (IsHiRes && !QuitMouseHandler) {
 				drawmouse = true;
@@ -142,9 +141,9 @@ void mouse_handler(int32 max, int32 mcx, int32 mdx) {
 		}
 	}
 
-	if ((max & 0x02) && (NumHidden < 2)) { /* Left mouse button click */
+	if ((flag & 0x02) && (NumHidden < 2)) { /* Left mouse button click */
 		if (ScreenGadgetList)
-			TempGad = checkGadgetHit(ScreenGadgetList, mcx, mdx);
+			TempGad = checkGadgetHit(ScreenGadgetList, mouseX, mouseY);
 		else
 			TempGad = NULL;
 
@@ -152,15 +151,15 @@ void mouse_handler(int32 max, int32 mcx, int32 mdx) {
 			LastGadgetHit = TempGad;
 		} else {
 			LeftClick = true;
-			leftx     = mcx;
-			lefty     = mdx;
+			CurMouseX     = mouseX;
+			CurMouseY     = mouseY;
 		}
 	}
 
-	if ((max & 0x08) && (NumHidden < 2)) { /* Right mouse button click */
+	if ((flag & 0x08) && (NumHidden < 2)) { /* Right mouse button click */
 		RightClick = true;
-		rightx     = mcx;
-		righty     = mdx;
+		CurMouseX     = mouseX;
+		CurMouseY     = mouseY;
 	}
 }
 
@@ -206,7 +205,7 @@ void updateMouse(void) {
 /* Initializes the mouse.                                                    */
 /*****************************************************************************/
 bool initMouse(void) {
-	g_system->setMouseCursor(MouseData, MouseImageWidth, MouseImageHeight, 0, 0, 0);
+	g_system->setMouseCursor(MouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0);
 	g_system->showMouse(false);
 
 	mouseMove(0, 0);
@@ -344,15 +343,15 @@ void mouseMove(uint16 x, uint16 y) {
 bool mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
 	if (leftbutton) {
 		if (LeftClick) {
-			*x = leftx;
-			*y = lefty;
+			*x = CurMouseX;
+			*y = CurMouseY;
 			LeftClick = false;
 			return true;
 		}
 	} else {
 		if (RightClick) {
-			*x = rightx;
-			*y = righty;
+			*x = CurMouseX;
+			*y = CurMouseY;
 			RightClick = false;
 			return true;
 		}
diff --git a/engines/lab/mouse.h b/engines/lab/mouse.h
index 8a9a3b7..8ea9056 100644
--- a/engines/lab/mouse.h
+++ b/engines/lab/mouse.h
@@ -57,7 +57,7 @@ Gadget *mouseGadget(void);
 
 void attachGadgetList(Gadget *GadList);
 
-void mouse_handler(int32 max, int32 mcx, int32 mdx);
+void mouse_handler(int32 flag, int32 mouseX, int32 mouseY);
 
 } // End of namespace Lab
 


Commit: 7ddbc55251380cee95d25ce7a25788af069d4cab
    https://github.com/scummvm/scummvm/commit/7ddbc55251380cee95d25ce7a25788af069d4cab
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Remove unused mouse reset call

Changed paths:
    engines/lab/engine.cpp
    engines/lab/mouse.cpp
    engines/lab/mouse.h



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index ec9ae28..d242fbe 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -1498,7 +1498,6 @@ void LabEngine::go() {
 	g_music->freeMusic();
 	freeAudio();
 
-	mouseReset();
 	setMode((char)OldMode);
 }
 
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index 30c0658..a75a92c 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -215,14 +215,6 @@ bool initMouse(void) {
 
 
 
-/*****************************************************************************/
-/* Resets the mouse.                                                         */
-/*****************************************************************************/
-bool mouseReset(void) {
-	return true;
-}
-
-
 
 /*****************************************************************************/
 /* Shows the mouse.                                                          */
diff --git a/engines/lab/mouse.h b/engines/lab/mouse.h
index 8ea9056..5af5821 100644
--- a/engines/lab/mouse.h
+++ b/engines/lab/mouse.h
@@ -39,8 +39,6 @@ struct Gadget;
 
 bool initMouse(void);
 
-bool mouseReset(void);
-
 void updateMouse(void);
 
 void mouseShow(void);


Commit: 35751e0f123338927ea4bfdf6f6311229a25f054
    https://github.com/scummvm/scummvm/commit/35751e0f123338927ea4bfdf6f6311229a25f054
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Implement getCurMemLabFile()

Changed paths:
    engines/lab/labfile.cpp



diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
index 2f93554..4cbbd54 100644
--- a/engines/lab/labfile.cpp
+++ b/engines/lab/labfile.cpp
@@ -112,18 +112,15 @@ static void freeFile(uint16 RMarker) {
 /*****************************************************************************/
 /* Gets a chunk of memory from the buffer.                                   */
 /*****************************************************************************/
-static void *getCurMem(uint32 size) {
+static void *getCurMemLabFile(uint32 size) {
 	void *ptr = 0;
 
-	warning ("STUB: getCurMem(%d)", size);
-
-#if 0
 	if ((((char *) MemPlace) + size - 1) >=
 	        (((char *) buffer) + buffersize))
 		MemPlace = buffer;
 
 	ptr = MemPlace;
-	((char *)MemPlace) += size;
+	MemPlace = (char *)MemPlace + size;
 
 	for (int counter = 0; counter < MAXMARKERS; counter++) {
 		if (FileMarkers[counter].name[0]) {
@@ -137,7 +134,7 @@ static void *getCurMem(uint32 size) {
 				freeFile(counter);
 		}
 	}
-#endif
+
 	return ptr;
 }
 
@@ -198,7 +195,7 @@ bool allocFile(void **Ptr, uint32 Size, const char *fileName) {
 	freeFile(RMarker);
 	strcpy(FileMarkers[RMarker].name, fileName);
 
-	*Ptr = getCurMem(Size);
+	*Ptr = getCurMemLabFile(Size);
 	FileMarkers[RMarker].Start = *Ptr;
 	FileMarkers[RMarker].End   = (void *)(((char *)(*Ptr)) + Size - 1);
 


Commit: 31ef4866a70857d107338e8c462d8456b2dcb643
    https://github.com/scummvm/scummvm/commit/31ef4866a70857d107338e8c462d8456b2dcb643
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Implement generateSaveFileName()

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



diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 16839da..1d7c827 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -72,4 +72,8 @@ Common::Error LabEngine::run() {
 	return Common::kNoError;
 }
 
+Common::String LabEngine::generateSaveFileName(uint slot) {
+	return Common::String::format("%s.%03u", _targetName.c_str(), slot);
+}
+
 } // End of namespace Lab
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 8825417..fa5edd6 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -52,12 +52,13 @@ public:
 	virtual Common::Error run();
 	void go();
 
-	bool hasFeature(EngineFeature f) const;
-
 	const ADGameDescription *_gameDescription;
 	Common::Platform getPlatform() const;
 	uint32 getFeatures() const;
 
+	bool hasFeature(EngineFeature f) const;
+	Common::String generateSaveFileName(uint slot);
+
 	LargeSet *_conditions, *_roomsFound;
 };
 


Commit: ccb3390f09268cf1ee360c74bcaac7dbebe1ae42
    https://github.com/scummvm/scummvm/commit/ccb3390f09268cf1ee360c74bcaac7dbebe1ae42
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Disable startup warning about hi/low res mode

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index d242fbe..9d6e755 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -1398,10 +1398,12 @@ void LabEngine::go() {
 
 	IsHiRes = ((getFeatures() & GF_LOWRES) == 0);
 
+#if 0
 	if (IsHiRes)
 		warning("Running in HiRes mode");
 	else
 		warning("Running in LowRes mode");
+#endif
 
 #if 0
 	for (counter = 1; counter < argc; counter++) {


Commit: 6af7abeab242b9446a1aeb6725643b40fe078611
    https://github.com/scummvm/scummvm/commit/6af7abeab242b9446a1aeb6725643b40fe078611
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Remove unused variable

Changed paths:
    engines/lab/labmusic.cpp



diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index 7e91521..4efbd07 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -244,7 +244,6 @@ void Music::startMusic(bool startatbegin) {
 /*****************************************************************************/
 bool Music::initMusic(void) {
 	uint16 counter;
-	bool mem;
 
 	if (!_turnMusicOn)
 		return true;


Commit: 0a71969018bf773cde8092df47f58ecea99f3f79
    https://github.com/scummvm/scummvm/commit/0a71969018bf773cde8092df47f58ecea99f3f79
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Rewrite the save/load system

The two different save/load dialogs from the original have been dropped
and replaced with the ScummVM save/load dialogs. The whole save/load
code has been rewritten to be endian safe and use our common code. The
original save format has not been preserved. The current implementation
crashes when loading, but it's a good start

Changed paths:
  R engines/lab/modernsavegame.cpp
  R engines/lab/modernsavegame.h
  R engines/lab/savegamepalmap.cpp
    engines/lab/detection.cpp
    engines/lab/engine.cpp
    engines/lab/lab.cpp
    engines/lab/labfun.h
    engines/lab/module.mk
    engines/lab/savegame.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/detection.cpp b/engines/lab/detection.cpp
index c6a0d74..2b1bb21 100644
--- a/engines/lab/detection.cpp
+++ b/engines/lab/detection.cpp
@@ -29,11 +29,17 @@
  */
 
 #include "engines/advancedDetector.h"
+
 #include "common/system.h"
+#include "common/str-array.h"
+#include "common/savefile.h"
 
 #include "base/plugins.h"
 
+#include "graphics/surface.h"
+
 #include "lab/lab.h"
+#include "lab/labfun.h"
 
 static const PlainGameDescriptor lab_setting[] = {
 	{ "lab", "Labyrith of Time" },
@@ -143,8 +149,112 @@ public:
 		return true;
 	}
 
+	virtual bool hasFeature(MetaEngineFeature f) const;
+	SaveStateList listSaves(const char *target) const;
+	virtual int getMaximumSaveSlot() const;
+	void removeSaveState(const char *target, int slot) const;
+	SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
 };
 
+bool LabMetaEngine::hasFeature(MetaEngineFeature f) const {
+	return
+	(f == kSupportsListSaves) ||
+	//(f == kSupportsLoadingDuringStartup) ||
+	(f == kSupportsDeleteSave) ||
+	(f == kSavesSupportMetaInfo) ||
+	(f == kSavesSupportThumbnail) ||
+	(f == kSavesSupportCreationDate) ||
+	(f == kSavesSupportPlayTime);
+}
+
+bool Lab::LabEngine::hasFeature(EngineFeature f) const {
+    return
+        (f == kSupportsRTL);
+        //(f == kSupportsLoadingDuringRuntime) ||
+        //(f == kSupportsSavingDuringRuntime);
+}
+
+SaveStateList LabMetaEngine::listSaves(const char *target) const {
+	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+	Lab::SaveGameHeader header;
+	Common::String pattern = target;
+	pattern += ".???";
+
+	Common::StringArray filenames;
+	filenames = saveFileMan->listSavefiles(pattern.c_str());
+	Common::sort(filenames.begin(), filenames.end());   // Sort (hopefully ensuring we are sorted numerically..)*/
+
+	SaveStateList saveList;
+
+	for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); file++) {
+	        // Obtain the last 3 digits of the filename, since they correspond to the save slot
+	        int slotNum = atoi(file->c_str() + file->size() - 3);
+
+	        if (slotNum >= 0 && slotNum <= 999) {
+	            Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
+	            if (in) {
+					if (Lab::readSaveGameHeader(in, header))
+	                    saveList.push_back(SaveStateDescriptor(slotNum, header.desc.getDescription()));
+	                delete in;
+	            }
+	        }
+	}
+
+	return saveList;
+}
+
+int LabMetaEngine::getMaximumSaveSlot() const {
+	return 999;
+}
+
+void LabMetaEngine::removeSaveState(const char *target, int slot) const {
+	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+	Common::String filename = Common::String::format("%s.%03u", target, slot);
+
+	saveFileMan->removeSavefile(filename.c_str());
+
+	Common::StringArray filenames;
+	Common::String pattern = target;
+	pattern += ".???";
+	filenames = saveFileMan->listSavefiles(pattern.c_str());
+	Common::sort(filenames.begin(), filenames.end());   // Sort (hopefully ensuring we are sorted numerically..)
+
+	for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+	    // Obtain the last 3 digits of the filename, since they correspond to the save slot
+	    int slotNum = atoi(file->c_str() + file->size() - 3);
+
+	    // Rename every slot greater than the deleted slot,
+	    if (slotNum > slot) {
+	        saveFileMan->renameSavefile(file->c_str(), filename.c_str());
+	        filename = Common::String::format("%s.%03u", target, ++slot);
+	    }
+	}
+}
+
+SaveStateDescriptor LabMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
+	Common::String filename = Common::String::format("%s.%03u", target, slot);
+	Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename.c_str());
+
+	if (in) {
+	    Lab::SaveGameHeader header;
+
+		bool successfulRead = Lab::readSaveGameHeader(in, header);
+	    delete in;
+
+	    if (successfulRead) {
+	        SaveStateDescriptor desc(slot, header.desc.getDescription());
+			// Do not allow save slot 0 (used for auto-saving) to be deleted or
+			// overwritten.
+			//desc.setDeletableFlag(slot != 0);
+			//desc.setWriteProtectedFlag(slot == 0);
+
+	        return header.desc;
+	    }
+	}
+
+	return SaveStateDescriptor();
+}
+
 #if PLUGIN_ENABLED_DYNAMIC(LAB)
 	REGISTER_PLUGIN_DYNAMIC(LAB, PLUGIN_TYPE_ENGINE, LabMetaEngine);
 #else
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 9d6e755..ef3850b 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -1451,8 +1451,6 @@ void LabEngine::go() {
 	mem = mem && initRoomBuffer() &&
 	      initLabText();
 
-	doDisks();
-
 	if (!dointro)
 		g_music->initMusic();
 
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 1d7c827..563ccef 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -43,10 +43,6 @@
 
 namespace Lab {
 
-bool LabEngine::hasFeature(EngineFeature f) const {
-	return (f == kSupportsRTL) ? true : false;
-}
-
 LabEngine *g_lab;
 
 LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index bb2ddf8..69dc39d 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -34,6 +34,9 @@
 #include "lab/stddefines.h"
 #include "lab/parsetypes.h"
 #include "common/file.h"
+#include "common/savefile.h"
+
+#include "engines/savestate.h"
 
 namespace Lab {
 
@@ -54,6 +57,13 @@ struct Image;
 struct TextFont;
 struct Gadget;
 
+struct SaveGameHeader {
+	byte version;
+	SaveStateDescriptor desc;
+	uint16 roomNumber;
+	uint16 direction;
+};
+
 /*----------------------------*/
 /*------ From Audioi.c -------*/
 /*----------------------------*/
@@ -345,8 +355,6 @@ void doWestPaper(void);
 
 void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 
-uint16 doDisks(void);
-
 bool saveRestoreGame(void);
 
 
@@ -355,11 +363,10 @@ bool saveRestoreGame(void);
 /*----- From saveGame.c ----*/
 /*--------------------------*/
 
-bool saveFloppy(char *path, uint16 RoomNum, uint16 Direction, uint16 NumQuarters, uint16 filenum, uint16 type);
-
-bool readFloppy(char *path, uint16 *RoomNum, uint16 *Direction, uint16 *NumQuarters, uint16 filenum, uint16 type);
-
+bool saveGame(uint16 RoomNum, uint16 Direction, uint16 Quarters, int slot, Common::String desc);
+bool loadGame(uint16 *RoomNum, uint16 *Direction, uint16 *Quarters, int slot);
 
+bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header);
 
 /*--------------------------*/
 /*----- From Special.c -----*/
diff --git a/engines/lab/modernsavegame.cpp b/engines/lab/modernsavegame.cpp
deleted file mode 100644
index f9f558b..0000000
--- a/engines/lab/modernsavegame.cpp
+++ /dev/null
@@ -1,124 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "lab/stddefines.h"
-#include "lab/labfun.h"
-#include "lab/modernsavegame.h"
-
-namespace Lab {
-
-byte g_SaveGameImage[SAVED_IMAGE_SIZE]; // 640 x 358
-
-char g_SaveGamePath[512];
-char g_PathSeperator[4];
-
-#define SAVEVERSION         "LBS3"
-
-int getSaveGameList(SaveGameInfo *info, int maxNum) {
-	warning("STUB: getSaveGameList");
-
-	return 0;
-
-#if 0
-	char path[512];
-	struct stat statb;
-	int total = 0;
-	int i;
-
-	for (i = 0; i < maxNum; i++) {
-		checkMusic();
-
-		sprintf(path, "%s%s%d", g_SaveGamePath, g_PathSeperator, i);
-		statb.st_size = 0;
-		stat(path, &statb);
-
-		if (statb.st_size > 0) {
-			struct tm *create_date;
-			FILE *fh;
-
-			create_date = localtime(&statb.st_ctime);
-			strcpy(info->SaveGameDate, asctime(create_date));
-
-			fh = fopen(path, "rb");
-
-			if (fh != NULL) {
-				char temp[5];
-				unsigned short t;
-				int toSeek;
-
-				info->Index = i;
-
-				fread(temp, 1, 4, fh);
-				temp[4] = 0;
-
-				fread(&t, 1, 2, fh);
-				info->RoomNumber = swapUShort(t);
-				fread(&t, 1, 2, fh);
-				info->Direction = swapUShort(t);
-
-				toSeek = 2 + Conditions->lastElement / 8 + g_lab->_roomsFound->_lastElement / 8 + 6 + 2 * 16;
-				fseek(fh, toSeek, SEEK_CUR);
-
-				info->SaveGameImage = NULL;
-
-				if (strcmp(temp, SAVEVERSION) == 0) {
-					info->SaveGameImage = malloc(SAVED_IMAGE_SIZE);
-
-					if (info->SaveGameImage != NULL)
-						fread(info->SaveGameImage, 1, SAVED_IMAGE_SIZE, fh);
-				} else {
-					info->SaveGameImage = malloc(SAVED_IMAGE_SIZE);
-
-					if (info->SaveGameImage != NULL)
-						memset(info->SaveGameImage, 0, SAVED_IMAGE_SIZE);
-				}
-
-				fclose(fh);
-
-				info++;
-				total++;
-			}
-		}
-	}
-
-	return total;
-#endif
-}
-
-void freeSaveGameList(SaveGameInfo *info, int count) {
-	int i;
-
-	for (i = 0; i < count; i++) {
-		free(info->SaveGameImage);
-		++info;
-	}
-}
-
-} // End of namespace Lab
diff --git a/engines/lab/modernsavegame.h b/engines/lab/modernsavegame.h
deleted file mode 100644
index ee53cd0..0000000
--- a/engines/lab/modernsavegame.h
+++ /dev/null
@@ -1,55 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#ifndef LAB_MODERNGAMESAVE_H
-#define LAB_MODERNGAMESAVE_H
-
-namespace Lab {
-
-#define MAX_SAVED_GAMES 15
-#define SAVED_IMAGE_SIZE (128 * 72)
-
-extern byte g_SaveGameImage[SAVED_IMAGE_SIZE]; // 640 x 358
-
-struct SaveGameInfo {
-	unsigned short Index;
-	unsigned short RoomNumber;
-	unsigned short Direction;
-	byte *SaveGameImage;
-	char SaveGameDate[128];
-};
-
-int getSaveGameList(SaveGameInfo *info, int maxNum);
-void freeSaveGameList(SaveGameInfo *info, int count);
-
-} // End of namespace Lab
-
-#endif /* LAB_MODERNGAMESAVE_H */
-
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index 09156a7..8057fad 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -15,13 +15,11 @@ MODULE_OBJS := \
 	labtext.o \
 	machine.o \
 	map.o \
-	modernsavegame.o \
 	mouse.o \
 	processroom.o \
 	readdiff.o \
 	readparse.o \
 	savegame.o \
-	savegamepalmap.o \
 	special.o \
 	text.o \
 	timing.o \
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index c5d3499..5cf0674 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -28,297 +28,215 @@
  *
  */
 
+#include "common/savefile.h"
+
+#include "graphics/surface.h"
+#include "graphics/thumbnail.h"
+
 #include "lab/lab.h"
 #include "lab/stddefines.h"
 #include "lab/labfun.h"
-#include "lab/modernsavegame.h"
 
 namespace Lab {
 
-/* The version string */
-#if defined(DOSCODE)
-#define SAVEVERSION         "LBS2"
-#else
-#define SAVEVERSION         "LBS3"
-#define SAVEVERSION_COMPAT  "LBS2"
-#endif
+// Labyrinth of Time ScummVM
+#define SAVEGAME_ID       MKTAG('L', 'O', 'T', 'S')
+#define SAVEGAME_VERSION  1
 
 #define BOOKMARK  0
 #define CARDMARK  1
 #define FLOPPY    2
 
-typedef void *LABFH;
-#define INVALID_LABFH   NULL
 
-uint16 FileType, FileNum;
+/*----- The machine independent section of saveGame.c -----*/
 
 
+/* Lab: Labyrinth specific */
+extern byte combination[6];
+extern uint16 CurTile[4] [4];
+extern CrumbData BreadCrumbs[MAX_CRUMBS];
+extern uint16 NumCrumbs;
+extern bool DroppingCrumbs;
+extern bool FollowingCrumbs;
 
-/*----- The Amiga specific area of saveGame.c -----*/
+void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName) {
+	out->writeUint32BE(SAVEGAME_ID);
 
+	// Write version
+	out->writeByte(SAVEGAME_VERSION);
 
-/*****************************************************************************/
-/* Opens a file to write to from disk.                                       */
-/*****************************************************************************/
-static LABFH saveGameOpen(char *filename, bool iswrite) {
-	warning("STUB: saveGameOpen");
-	return 0;
-
-#if 0
-	if (iswrite) {
-		unlink(filename);
-		return fopen(filename, "wb");
-	} else
-		return fopen(filename, "rb");
-#endif
-}
+	// Write savegame name
+	out->writeString(saveName);
+	out->writeByte(0);
 
+	// Save the game thumbnail
+	Graphics::saveThumbnail(*out);
 
+	// Creation date/time
+	TimeDate curTime;
+	g_system->getTimeAndDate(curTime);
 
+	uint32 saveDate = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF);
+	uint16 saveTime = ((curTime.tm_hour & 0xFF) << 8) | ((curTime.tm_min) & 0xFF);
+	uint32 playTime = g_engine->getTotalPlayTime() / 1000;
 
-/*****************************************************************************/
-/* Closes a file.                                                            */
-/*****************************************************************************/
-static void saveGameClose(LABFH file, bool iswrite) {
-	warning("STUB: saveGameClose");
-	return;
-
-#if 0
-	if (file != INVALID_LABFH)
-		fclose(file);
-#endif
+	out->writeUint32BE(saveDate);
+	out->writeUint16BE(saveTime);
+	out->writeUint32BE(playTime);
 }
 
+bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
+	uint32 id = in->readUint32BE();
+	
+	// Check if it's a valid ScummVM savegame
+	if (id != SAVEGAME_ID)
+		return false;
 
+	// Read in the version
+	header.version = in->readByte();
 
+	// Check that the save version isn't newer than this binary
+	if (header.version > SAVEGAME_VERSION)
+		return false;
 
-/*****************************************************************************/
-/* Writes a block of memory to whatever it is that we're writing to.         */
-/*****************************************************************************/
-static void saveGameWriteBlock(LABFH file, void *data, uint32 size) {
-	warning("STUB: saveGameWriteBlock");
-	return;
-
-	//fwrite(data, 1, size, file);
-}
-
-
+	// Read in the save name
+	Common::String saveName;
+	char ch;
+	while ((ch = (char)in->readByte()) != '\0')
+		saveName += ch;
+	header.desc.setDescription(saveName);
 
-/*****************************************************************************/
-/* Writes a block of memory to whatever it is that we're writing to.         */
-/*****************************************************************************/
-static void saveGameReadBlock(LABFH file, void *data, uint32 size) {
-	warning("STUB: saveGameReadBlock");
-	return;
+	// Get the thumbnail
+	header.desc.setThumbnail(Graphics::loadThumbnail(*in));
 
-	//fread(data, 1, size, file);
-}
+	uint32 saveDate = in->readUint32BE();
+	uint16 saveTime = in->readUint16BE();
+	uint32 playTime = in->readUint32BE();
 
+	int day = (saveDate >> 24) & 0xFF;
+	int month = (saveDate >> 16) & 0xFF;
+	int year = saveDate & 0xFFFF;
+	header.desc.setSaveDate(year, month, day);
 
+	int hour = (saveTime >> 8) & 0xFF;
+	int minutes = saveTime & 0xFF;
+	header.desc.setSaveTime(hour, minutes);
 
+	header.desc.setPlayTime(playTime * 1000);
+	g_engine->setTotalPlayTime(playTime * 1000);
 
-/*----- The machine independent section of saveGame.c -----*/
-
+	return true;
+}
 
-/* Lab: Labyrinth specific */
-extern uint16 combination[6];
-extern uint16 CurTile[4] [4];
-
-#if !defined(DOSCODE)
-extern CrumbData BreadCrumbs[MAX_CRUMBS];
-extern uint16 NumCrumbs;
-extern bool DroppingCrumbs;
-extern bool FollowingCrumbs;
-#endif
+extern char *getPictName(CloseDataPtr *LCPtr);
 
 /*****************************************************************************/
 /* Writes the game out to disk.                                              */
-/* Assumes that the file has already been openned and is there.              */
 /*****************************************************************************/
-static bool saveGame(uint16 RoomNum, uint16 Direction, uint16 Quarters, LABFH file) {
-#if !defined(DOSCODE)
-	uint16 temp;
-	CrumbData crumbs[sizeof(BreadCrumbs) / sizeof(CrumbData)];
-#endif
-	uint16 last, counter, counter1;
-	char c;
-
-	saveGameWriteBlock(file, (void *)SAVEVERSION, 4L);
-#if defined(DOSCODE)
-	saveGameWriteBlock(file, &RoomNum, 2L);
-	saveGameWriteBlock(file, &Direction, 2L);
-	saveGameWriteBlock(file, &Quarters, 2L);
-#else
-	temp = swapUShort(RoomNum);
-	saveGameWriteBlock(file, &temp, 2L);
-	temp = swapUShort(Direction);
-	saveGameWriteBlock(file, &temp, 2L);
-	temp = swapUShort(Quarters);
-	saveGameWriteBlock(file, &temp, 2L);
-#endif
-
-	last = g_lab->_conditions->_lastElement / 8;
-	saveGameWriteBlock(file, g_lab->_conditions->_array, (uint32) last);
-
-	last = g_lab->_roomsFound->_lastElement / 8;
-	saveGameWriteBlock(file, g_lab->_roomsFound->_array, (uint32) last);
-
-	/* LAB: the combination lock and tile stuff */
-	for (counter = 0; counter < 6; counter++) {
-		c = (char)combination[counter];
-		saveGameWriteBlock(file, &c, 1L);
-	}
-
-	for (counter = 0; counter < 4; counter++)
-		for (counter1 = 0; counter1 < 4; counter1++)
-#if defined(DOSCODE)
-			saveGameWriteBlock(file, &(CurTile[counter] [counter1]), 2L);
-
-#else
-		{
-			temp = swapUShort(CurTile[counter] [counter1]);
-			saveGameWriteBlock(file, &temp, 2L);
-		}
-#endif
-
-#if !defined(DOSCODE)
-	saveGameWriteBlock(file, g_SaveGameImage, SAVED_IMAGE_SIZE);
-	memcpy(crumbs, BreadCrumbs, sizeof BreadCrumbs);
-	swapUShortPtr(&crumbs[0].RoomNum, sizeof(BreadCrumbs) / sizeof(uint16));
-	saveGameWriteBlock(file, crumbs, sizeof BreadCrumbs);
-#endif
-
-	saveGameClose(file, true);
-
-	return true;
-}
-
+bool saveGame(uint16 RoomNum, uint16 Direction, uint16 Quarters, int slot, Common::String desc) {
+	uint16 i, j;
+	Common::String fileName = g_lab->generateSaveFileName(slot);
+	Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
+	Common::OutSaveFile *file = saveFileManager->openForSaving(fileName);
 
+	if (!file)
+		return false;
 
-/*****************************************************************************/
-/* Reads the game from disk.                                                 */
-/* Assumes that the file has already been openned and is there.              */
-/*****************************************************************************/
-static bool loadGame(uint16 *RoomNum, uint16 *Direction, uint16 *Quarters, LABFH file) {
-#if !defined(DOSCODE)
-	uint16 t;
-	CrumbData crumbs[sizeof(BreadCrumbs) / sizeof(CrumbData)];
-#endif
-	char temp[5], c;
-	uint16 last, counter, counter1;
-
-	saveGameReadBlock(file, temp, 4L);
-	temp[4] = 0;
-
-	/*
-	   if (strcmp(temp, SAVEVERSION) != 0)
-	   {
-	    saveGameClose(file, false);
-	    return false;
-	   }
-	 */
-
-#if defined(DOSCODE)
-	saveGameReadBlock(file, RoomNum, 2L);
-	saveGameReadBlock(file, Direction, 2L);
-	saveGameReadBlock(file, Quarters, 2L);
-#else
-	saveGameReadBlock(file, &t, 2L);
-	*RoomNum = swapUShort(t);
-	saveGameReadBlock(file, &t, 2L);
-	*Direction = swapUShort(t);
-	saveGameReadBlock(file, &t, 2L);
-	*Quarters = swapUShort(t);
-#endif
-
-	last = g_lab->_conditions->_lastElement / 8;
-	saveGameReadBlock(file, g_lab->_conditions->_array, (uint32) last);
-
-	last = g_lab->_roomsFound->_lastElement / 8;
-	saveGameReadBlock(file, g_lab->_roomsFound->_array, (uint32) last);
-
-	/* LAB: the combination lock and tile stuff */
-	for (counter = 0; counter < 6; counter++) {
-		saveGameReadBlock(file, &c, 1L);
-		combination[counter] = c;
-	}
+	// Load scene pic
+	CloseDataPtr CPtr = NULL;
+	readPict(getPictName(&CPtr), true);
 
-	for (counter = 0; counter < 4; counter++)
-		for (counter1 = 0; counter1 < 4; counter1++)
-#if defined(DOSCODE)
-			saveGameReadBlock(file, &(CurTile[counter] [counter1]), 2L);
+	writeSaveGameHeader(file, desc);
+	file->writeUint16LE(RoomNum);
+	file->writeUint16LE(Direction);
+	file->writeUint16LE(Quarters);
 
-#else
-		{
-			saveGameReadBlock(file, &t, 2L);
-			CurTile[counter] [counter1] = swapUShort(t);
-		}
-#endif
+	// Conditions
+	for (i = 0; i < g_lab->_conditions->_lastElement / (8 * 2); i++)
+		file->writeUint16LE(g_lab->_conditions->_array[i]);
 
-	if (strcmp(temp, SAVEVERSION) == 0) {
-		saveGameReadBlock(file, g_SaveGameImage, SAVED_IMAGE_SIZE);
+	// Rooms found
+	for (i = 0; i < g_lab->_roomsFound->_lastElement / (8 * 2); i++)
+		file->writeUint16LE(g_lab->_roomsFound->_array[i]);
 
-		memset(crumbs, 0, sizeof BreadCrumbs);
-		saveGameReadBlock(file, crumbs, sizeof BreadCrumbs);
-		swapUShortPtr(&crumbs[0].RoomNum, sizeof(BreadCrumbs) / sizeof(uint16));
-		memcpy(BreadCrumbs, crumbs, sizeof BreadCrumbs);
-		DroppingCrumbs = (BreadCrumbs[0].RoomNum != 0);
-		FollowingCrumbs = false;
+	// Combination lock and tile stuff
+	for (i = 0; i < 6; i++)
+		file->writeByte(combination[i]);
 
-		for (counter = 0; counter < MAX_CRUMBS; counter++)
-			if (BreadCrumbs[counter].RoomNum == 0) break;
+	// Tiles
+	for (i = 0; i < 4; i++)
+		for (j = 0; j < 4; j++)
+			file->writeUint16LE(CurTile[i][j]);
 
-		NumCrumbs = counter;
+	// Breadcrumbs
+	for (i = 0; i < sizeof(BreadCrumbs); i++) {
+		file->writeUint16LE(BreadCrumbs[i].RoomNum);
+		file->writeUint16LE(BreadCrumbs[i].Direction);
 	}
 
-	saveGameClose(file, false);
+	file->flush();
+	file->finalize();
+	delete file;
 
 	return true;
 }
 
 
 
-
 /*****************************************************************************/
-/* Saves the game to the floppy disk.                                        */
+/* Reads the game from disk.                                                 */
 /*****************************************************************************/
-bool saveFloppy(char *path, uint16 RoomNum, uint16 Direction, uint16 NumQuarters, uint16 filenum, uint16 type) {
-	LABFH FPtr;
-
-	g_music->checkMusic();
-
-	FileType = type;
-	FileNum  = filenum;
-
-	if ((FPtr = saveGameOpen(path, true)) != INVALID_LABFH)
-		saveGame(RoomNum, Direction, NumQuarters, FPtr);
-	else
+bool loadGame(uint16 *RoomNum, uint16 *Direction, uint16 *Quarters, int slot) {
+	uint16 i, j;
+	Common::String fileName = g_lab->generateSaveFileName(slot);
+	Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
+	Common::InSaveFile *file = saveFileManager->openForLoading(fileName);
+	
+	if (!file)
 		return false;
 
-	return true;
-}
-
-
-
-
-/*****************************************************************************/
-/* Reads the game from the floppy disk.                                      */
-/*****************************************************************************/
-bool readFloppy(char *path, uint16 *RoomNum, uint16 *Direction, uint16 *NumQuarters, uint16 filenum, uint16 type) {
-	LABFH FPtr;
+	SaveGameHeader header;
+	readSaveGameHeader(file, header);
+	*RoomNum = file->readUint16LE();
+	*Direction = file->readUint16LE();
+	*Quarters = file->readUint16LE();
+
+	// Conditions
+	for (i = 0; i < g_lab->_conditions->_lastElement / (8 * 2); i++)
+		g_lab->_conditions->_array[i] = file->readUint16LE();
+
+	// Rooms found
+	for (i = 0; i < g_lab->_roomsFound->_lastElement / (8 * 2); i++)
+		g_lab->_roomsFound->_array[i] = file->readUint16LE();
+
+	// Combination lock and tile stuff
+	for (i = 0; i < 6; i++)
+		combination[i] = file->readByte();
+
+	// Tiles
+	for (i = 0; i < 4; i++)
+		for (j = 0; j < 4; j++)
+			CurTile[i][j] = file->readUint16LE();
+
+	// Breadcrumbs
+	for (i = 0; i < sizeof(BreadCrumbs); i++) {
+		BreadCrumbs[i].RoomNum = file->readUint16LE();
+		BreadCrumbs[i].Direction = file->readUint16LE();
+	}
 
-	g_music->checkMusic();
+	DroppingCrumbs = (BreadCrumbs[0].RoomNum != 0);
+	FollowingCrumbs = false;
 
-	FileType = type;
-	FileNum  = filenum;
+	for (i = 0; i < sizeof(BreadCrumbs); i++) {
+		if (BreadCrumbs[i].RoomNum == 0)
+			break;
+		NumCrumbs++;
+	}
 
-	if ((FPtr = saveGameOpen(path, false)) != INVALID_LABFH) {
-		if (!loadGame(RoomNum, Direction, NumQuarters, FPtr))
-			return false;
-	} else
-		return false;
+	delete file;
 
 	return true;
 }
 
+
 } // End of namespace Lab
diff --git a/engines/lab/savegamepalmap.cpp b/engines/lab/savegamepalmap.cpp
deleted file mode 100644
index 0678b78..0000000
--- a/engines/lab/savegamepalmap.cpp
+++ /dev/null
@@ -1,3316 +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.
- *
- */
-
- /*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "lab/lab.h"
-
- namespace Lab {
-
- extern const byte ThePalMap[] = {
- 0x73, 0x73, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
- 0x20, 0x20, 0x20, 0x23, 0x23, 0x23, 0x1E, 0xE3, 0xE3, 0xE3,
- 0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE1,
- 0xE1, 0xE1, 0x73, 0x2F, 0x68, 0x68, 0x68, 0x68, 0x68, 0x68,
- 0x68, 0x20, 0x20, 0x20, 0x23, 0x23, 0x23, 0x1E, 0x1E, 0x1E,
- 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2,
- 0xE2, 0xE1, 0xE1, 0xE1, 0x67, 0x67, 0x2F, 0x68, 0x68, 0x68,
- 0x37, 0x37, 0x37, 0x20, 0x23, 0x23, 0x23, 0x23, 0x1E, 0x1E,
- 0x1E, 0x1E, 0x1E, 0xE3, 0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2,
- 0xE2, 0xE2, 0xF7, 0xF7, 0xF7, 0xF7, 0x67, 0x67, 0x67, 0x72,
- 0x72, 0x37, 0x37, 0x37, 0x37, 0x23, 0x23, 0x23, 0x23, 0x23,
- 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xE3, 0xE3, 0xE3, 0xE3, 0xE2,
- 0xE2, 0xE2, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0x67, 0x67,
- 0x67, 0x72, 0x37, 0x37, 0x37, 0x37, 0x71, 0x23, 0x23, 0x23,
- 0x23, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xDF, 0xDF, 0xDF,
- 0xDF, 0xDE, 0xDE, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0x67, 0x67, 0x67, 0x37, 0x37, 0x37, 0x37, 0x71, 0x23, 0x23,
- 0x23, 0x23, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xDF,
- 0xDF, 0xDF, 0xDF, 0xDE, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0x67, 0x67, 0x67, 0x37, 0x37, 0x37, 0x71, 0x71,
- 0x23, 0x23, 0x23, 0x23, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
- 0x1E, 0x1E, 0xDF, 0xDF, 0xDF, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0x67, 0x67, 0x37, 0x37, 0x71, 0x71,
- 0x71, 0x23, 0x23, 0x23, 0x23, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
- 0x1E, 0x1E, 0x1E, 0x1E, 0xDF, 0xDF, 0xDF, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0x67, 0x67, 0x37, 0x71,
- 0x71, 0x71, 0x71, 0x23, 0x23, 0x23, 0x1E, 0x1E, 0x1E, 0x1E,
- 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xF3, 0xF3, 0xF7, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0x67, 0x67,
- 0x71, 0x71, 0x71, 0x71, 0x23, 0x23, 0x23, 0x23, 0x1E, 0x1E,
- 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0x60, 0x60, 0x71, 0x71, 0x71, 0x71, 0x23, 0x23, 0x23, 0x1E,
- 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0x60, 0x60, 0x60, 0x71, 0x71, 0x23, 0x5F, 0x5F,
- 0x5F, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x3D, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF7, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60, 0x60, 0x71, 0x5F, 0x5F,
- 0x5F, 0x5F, 0x5F, 0x1E, 0x1E, 0x1E, 0x1E, 0xF4, 0xF4, 0xF4,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF6, 0xF6, 0xF6, 0xF6,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2,
- 0xF2, 0xF2, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF6, 0xF6,
- 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF7, 0xF7,
- 0xF7, 0xF7, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2,
- 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2,
- 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2,
- 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6,
- 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1,
- 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1,
- 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2,
- 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2,
- 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1, 0xF0, 0xF0, 0xF0, 0xF0,
- 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE,
- 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC,
- 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB, 0xF0, 0xF0,
- 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE,
- 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED,
- 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB,
- 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF,
- 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED,
- 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB,
- 0xEB, 0xEB, 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF,
- 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED,
- 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC,
- 0xEC, 0xEB, 0xEB, 0xEB, 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF,
- 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE,
- 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC,
- 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB, 0xF0, 0xF0, 0xF0, 0xF0,
- 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE,
- 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC,
- 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB, 0xEA, 0xEA,
- 0xEA, 0xEA, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE8, 0xE8,
- 0xE8, 0xE8, 0xE8, 0xE8, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7,
- 0xE7, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE5, 0xE5, 0xE5,
- 0xEA, 0xEA, 0xEA, 0xEA, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9,
- 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE7, 0xE7, 0xE7, 0xE7,
- 0xE7, 0xE7, 0xE7, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE5,
- 0xE5, 0xE5, 0xEA, 0xEA, 0xEA, 0xEA, 0xE9, 0xE9, 0xE9, 0xE9,
- 0xE9, 0xE9, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE7, 0xE7,
- 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6,
- 0xE6, 0xE5, 0xE5, 0xE5, 0x73, 0x2F, 0x68, 0x68, 0x68, 0x68,
- 0x68, 0x68, 0x20, 0x20, 0x20, 0x20, 0x23, 0x23, 0x23, 0x1E,
- 0x1E, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2,
- 0xE2, 0xE2, 0xE2, 0xE1, 0xE1, 0xE1, 0x2F, 0x2F, 0x2F, 0x2E,
- 0x68, 0x68, 0x37, 0x20, 0x20, 0x20, 0x20, 0x23, 0x23, 0x23,
- 0x1E, 0x1E, 0x1E, 0x1E, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE2,
- 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE1, 0xE1, 0xE1, 0x67, 0x2F,
- 0x72, 0x72, 0x72, 0x37, 0x37, 0x20, 0x20, 0x20, 0x23, 0x23,
- 0x23, 0x23, 0x1E, 0x1E, 0x1E, 0x1E, 0xE3, 0xE3, 0xE3, 0xE3,
- 0xE3, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE1, 0xE1, 0xE1,
- 0x67, 0x24, 0x72, 0x72, 0x37, 0x37, 0x37, 0x20, 0x20, 0x23,
- 0x23, 0x23, 0x23, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xE3,
- 0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2, 0xE2, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0x67, 0x67, 0x72, 0x37, 0x37, 0x37, 0x37, 0x71,
- 0x23, 0x23, 0x23, 0x23, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
- 0x1E, 0xDF, 0xDF, 0xDF, 0xDF, 0xDE, 0xDE, 0xDE, 0xF7, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0x67, 0x67, 0x37, 0x37, 0x37, 0x37,
- 0x71, 0x23, 0x23, 0x23, 0x23, 0x23, 0x1E, 0x1E, 0x1E, 0x1E,
- 0x1E, 0x1E, 0x1E, 0xDF, 0xDF, 0xDF, 0xDF, 0xDE, 0xDE, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0x67, 0x67, 0x37, 0x37,
- 0x71, 0x71, 0x71, 0x23, 0x23, 0x23, 0x23, 0x1E, 0x1E, 0x1E,
- 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xDF, 0xDF, 0xDF, 0xDF, 0xDE,
- 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0x67, 0x37,
- 0x37, 0x71, 0x71, 0x71, 0x23, 0x23, 0x23, 0x23, 0x1E, 0x1E,
- 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xDF, 0xDF, 0xDF,
- 0xDF, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0x60, 0x60, 0x71, 0x71, 0x71, 0x71, 0x23, 0x23, 0x23, 0x23,
- 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xDF,
- 0xDF, 0xDF, 0xDF, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0x60, 0x60, 0x71, 0x71, 0x71, 0x23, 0x23, 0x23,
- 0x23, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x3D,
- 0x3D, 0xF3, 0xF3, 0xF3, 0xF3, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60, 0x60, 0x71, 0x71, 0x23,
- 0x23, 0x5F, 0x5F, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x3D,
- 0x3D, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60, 0x60, 0x71,
- 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x1E, 0x1E, 0x1E, 0x1E, 0x3D,
- 0x3D, 0x3D, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2,
- 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60,
- 0x60, 0x60, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x1E, 0x1E, 0x3D,
- 0x3D, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF2, 0xF2, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF7, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2,
- 0xF2, 0xF2, 0xF7, 0xF7, 0xF7, 0xF7, 0xF6, 0xF6, 0xF6, 0xF6,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2,
- 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6,
- 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1,
- 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1,
- 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2,
- 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2,
- 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2,
- 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6,
- 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1,
- 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF,
- 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED,
- 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB,
- 0xEB, 0xEB, 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF,
- 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED,
- 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC,
- 0xEC, 0xEB, 0xEB, 0xEB, 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF,
- 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE,
- 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC,
- 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB, 0xF0, 0xF0, 0xF0, 0xF0,
- 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE,
- 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC,
- 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB, 0xF0, 0xF0,
- 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE,
- 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED,
- 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB,
- 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF,
- 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED,
- 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB,
- 0xEB, 0xEB, 0xEA, 0xEA, 0xEA, 0xEA, 0xE9, 0xE9, 0xE9, 0xE9,
- 0xE9, 0xE9, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE7, 0xE7,
- 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6,
- 0xE6, 0xE5, 0xE5, 0xE5, 0xEA, 0xEA, 0xEA, 0xEA, 0xE9, 0xE9,
- 0xE9, 0xE9, 0xE9, 0xE9, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8,
- 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE6, 0xE6, 0xE6,
- 0xE6, 0xE6, 0xE6, 0xE5, 0xE5, 0xE5, 0xEA, 0xEA, 0xEA, 0xEA,
- 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE8, 0xE8, 0xE8, 0xE8,
- 0xE8, 0xE8, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE6,
- 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE5, 0xE5, 0xE5, 0x66, 0x22,
- 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x23, 0x23, 0x1E, 0x1E, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3,
- 0xE3, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE1, 0xE1, 0xE1,
- 0x22, 0x22, 0x2E, 0x2E, 0x2E, 0x37, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x23, 0x23, 0x23, 0x1E, 0x1E, 0x1E, 0xE3, 0xE3, 0xE3,
- 0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE1,
- 0xE1, 0xE1, 0x24, 0x24, 0x72, 0x72, 0x37, 0x37, 0x20, 0x20,
- 0x20, 0x23, 0x23, 0x23, 0x23, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
- 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2,
- 0xE2, 0xE1, 0xE1, 0xE1, 0x24, 0x24, 0x72, 0x37, 0x37, 0x37,
- 0x20, 0x20, 0x23, 0x23, 0x23, 0x23, 0x1E, 0x1E, 0x1E, 0x1E,
- 0x1E, 0x1E, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2,
- 0xE2, 0xE2, 0xF7, 0xF7, 0xF7, 0xF7, 0x24, 0x24, 0x37, 0x37,
- 0x37, 0x37, 0x71, 0x23, 0x23, 0x23, 0x23, 0x23, 0x1E, 0x1E,
- 0x1E, 0x1E, 0x1E, 0x1E, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDE,
- 0xDE, 0xDE, 0xDE, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0x24, 0x24,
- 0x37, 0x37, 0x71, 0x71, 0x71, 0x23, 0x23, 0x23, 0x23, 0x1E,
- 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xDF, 0xDF, 0xDF, 0xDF,
- 0xDF, 0xDE, 0xDE, 0xDE, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0x24, 0x37, 0x37, 0x71, 0x71, 0x71, 0x23, 0x23, 0x23, 0x23,
- 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xDF, 0xDF,
- 0xDF, 0xDF, 0xDF, 0xDE, 0xDE, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0x60, 0x60, 0x71, 0x71, 0x71, 0x71, 0x23, 0x23,
- 0x23, 0x23, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
- 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDE, 0xF7, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60, 0x71, 0x71, 0x71, 0x23,
- 0x23, 0x23, 0x23, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
- 0x1E, 0x1E, 0x3D, 0xDF, 0xDF, 0xDF, 0xDF, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60, 0x60, 0x71,
- 0x71, 0x23, 0x23, 0x5F, 0x5F, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
- 0x1E, 0x1E, 0x3D, 0x3D, 0x29, 0xF3, 0xF3, 0xF3, 0xF3, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60,
- 0x60, 0x71, 0x23, 0x5F, 0x5F, 0x5F, 0x5F, 0x1E, 0x1E, 0x1E,
- 0x1E, 0x1E, 0x3D, 0x3D, 0x3D, 0x29, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0x60, 0x60, 0x60, 0x60, 0x5F, 0x5F, 0x5F, 0x5F, 0x5F, 0x1E,
- 0x1E, 0x1E, 0x3D, 0x3D, 0x3D, 0x3D, 0x29, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF2, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0x60, 0x60, 0x60, 0x60, 0x5F, 0x5F, 0x5F, 0x5F,
- 0x1E, 0x1E, 0x3D, 0x3D, 0x3D, 0x3D, 0xF4, 0xF4, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF5, 0x3D, 0x3D, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2,
- 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF6, 0xF6, 0xF6, 0xF6,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2,
- 0xF2, 0xF2, 0xF2, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF6, 0xF6,
- 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF7, 0xF7, 0xF7, 0xF7,
- 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1,
- 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2,
- 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2,
- 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2,
- 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6,
- 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1,
- 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1,
- 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2,
- 0xF2, 0xF1, 0xF1, 0xF1, 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF,
- 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE,
- 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC,
- 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB, 0xF0, 0xF0, 0xF0, 0xF0,
- 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE,
- 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC,
- 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB, 0xF0, 0xF0,
- 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE,
- 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED,
- 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB,
- 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF,
- 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED,
- 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB,
- 0xEB, 0xEB, 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF,
- 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED,
- 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC,
- 0xEC, 0xEB, 0xEB, 0xEB, 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF,
- 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE,
- 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC,
- 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB, 0xEA, 0xEA, 0xEA, 0xEA,
- 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE8, 0xE8, 0xE8, 0xE8,
- 0xE8, 0xE8, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE6,
- 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE5, 0xE5, 0xE5, 0xEA, 0xEA,
- 0xEA, 0xEA, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE8, 0xE8,
- 0xE8, 0xE8, 0xE8, 0xE8, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7,
- 0xE7, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE5, 0xE5, 0xE5,
- 0xEA, 0xEA, 0xEA, 0xEA, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9,
- 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE7, 0xE7, 0xE7, 0xE7,
- 0xE7, 0xE7, 0xE7, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE5,
- 0xE5, 0xE5, 0x66, 0x22, 0x2E, 0x2E, 0x2E, 0x2E, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x23, 0x23, 0x23, 0x1E, 0xE4, 0xE3, 0xE3,
- 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2,
- 0xE2, 0xE1, 0xE1, 0xE1, 0x22, 0x22, 0x2E, 0x2E, 0x2E, 0x20,
- 0x20, 0x20, 0x20, 0x20, 0x23, 0x23, 0x23, 0x1E, 0x1E, 0x1E,
- 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2,
- 0xE2, 0xE2, 0xE2, 0xE1, 0xE1, 0xE1, 0x24, 0x24, 0x01, 0x01,
- 0x37, 0x20, 0x20, 0x20, 0x20, 0x23, 0x23, 0x23, 0x1E, 0x1E,
- 0x1E, 0x1E, 0x1E, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE2,
- 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE1, 0xE1, 0xE1, 0x24, 0x24,
- 0x01, 0x37, 0x37, 0x20, 0x20, 0x20, 0x23, 0x23, 0x23, 0x23,
- 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xE3, 0xE3, 0xE3, 0xE3,
- 0xE3, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE1, 0xE1, 0xE1,
- 0x24, 0x24, 0x37, 0x37, 0x71, 0x71, 0x71, 0x23, 0x23, 0x23,
- 0x23, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xDF, 0xDF,
- 0xDF, 0xDF, 0xDF, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xF7, 0xF7,
- 0xF7, 0xF7, 0x24, 0x37, 0x37, 0x71, 0x71, 0x71, 0x23, 0x23,
- 0x23, 0x23, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
- 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDE, 0xDE, 0xDE, 0xDE, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60, 0x71, 0x71, 0x71, 0x71,
- 0x23, 0x23, 0x23, 0x23, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
- 0x1E, 0x1E, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDE, 0xDE, 0xDE,
- 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60, 0x71, 0x71,
- 0x71, 0x23, 0x23, 0x23, 0x23, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
- 0x1E, 0x1E, 0x1E, 0x1E, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDE,
- 0xDE, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60,
- 0x60, 0x71, 0x71, 0x23, 0x23, 0x5F, 0x5F, 0x1E, 0x1E, 0x1E,
- 0x1E, 0x1E, 0x1E, 0x1E, 0x3D, 0x3D, 0xDF, 0xDF, 0xDF, 0xDF,
- 0xDF, 0xDE, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0x60, 0x60, 0x60, 0x71, 0x23, 0x5F, 0x5F, 0x5F, 0x5F, 0x1E,
- 0x1E, 0x1E, 0x1E, 0x1E, 0x3D, 0x3D, 0x3D, 0x29, 0x29, 0xDF,
- 0xDF, 0xDF, 0xDF, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0x60, 0x60, 0x60, 0x60, 0x5F, 0x5F, 0x5F, 0x5F,
- 0x1E, 0x1E, 0x1E, 0x1E, 0x3D, 0x3D, 0x3D, 0x3D, 0x29, 0x29,
- 0x29, 0xF3, 0xF3, 0xF3, 0xF3, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60, 0x60, 0x60, 0x5F, 0x5F,
- 0x5F, 0x5F, 0x1E, 0x1E, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x29,
- 0x29, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF7, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60, 0x60, 0x60,
- 0x5F, 0x5F, 0x5F, 0x5F, 0x70, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D,
- 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2,
- 0xF2, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF6, 0xF6,
- 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0x70, 0x3D, 0x3D, 0xF4,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF2, 0xF2, 0xF2, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2,
- 0xF7, 0xF7, 0xF7, 0xF7, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2,
- 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2,
- 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6,
- 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1,
- 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1,
- 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2,
- 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2,
- 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2,
- 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1, 0xF0, 0xF0,
- 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE,
- 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED,
- 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB,
- 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF,
- 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED,
- 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB,
- 0xEB, 0xEB, 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF,
- 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED,
- 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC,
- 0xEC, 0xEB, 0xEB, 0xEB, 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF,
- 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE,
- 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC,
- 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB, 0xF0, 0xF0, 0xF0, 0xF0,
- 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE,
- 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC,
- 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB, 0xF0, 0xF0,
- 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE,
- 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED,
- 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB,
- 0xEA, 0xEA, 0xEA, 0xEA, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9,
- 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE7, 0xE7, 0xE7, 0xE7,
- 0xE7, 0xE7, 0xE7, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE5,
- 0xE5, 0xE5, 0xEA, 0xEA, 0xEA, 0xEA, 0xE9, 0xE9, 0xE9, 0xE9,
- 0xE9, 0xE9, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE7, 0xE7,
- 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6,
- 0xE6, 0xE5, 0xE5, 0xE5, 0xEA, 0xEA, 0xEA, 0xEA, 0xE9, 0xE9,
- 0xE9, 0xE9, 0xE9, 0xE9, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8,
- 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE6, 0xE6, 0xE6,
- 0xE6, 0xE6, 0xE6, 0xE5, 0xE5, 0xE5, 0x65, 0x65, 0x2E, 0x2E,
- 0x2E, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23, 0x23, 0x1E,
- 0xE4, 0xE4, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE2,
- 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE1, 0xE1, 0xE1, 0x65, 0x65,
- 0x01, 0x01, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x23, 0x23,
- 0x1E, 0x1E, 0x1E, 0xE4, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3,
- 0xE3, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE1, 0xE1, 0xE1,
- 0x24, 0x01, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x23, 0x23,
- 0x23, 0x23, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xE3, 0xE3, 0xE3,
- 0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE1,
- 0xE1, 0xE1, 0x24, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x23,
- 0x23, 0x23, 0x23, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xE3,
- 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2,
- 0xE2, 0xE1, 0xE1, 0xE1, 0x00, 0x00, 0x00, 0x00, 0x71, 0x71,
- 0x23, 0x23, 0x23, 0x23, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
- 0x1E, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDE, 0xDE, 0xDE,
- 0xDE, 0xDE, 0xDE, 0xDD, 0xDD, 0xDD, 0x60, 0x12, 0x12, 0x71,
- 0x71, 0x71, 0x23, 0x23, 0x23, 0x23, 0x1E, 0x1E, 0x1E, 0x1E,
- 0x1E, 0x1E, 0x1E, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDE,
- 0xDE, 0xDE, 0xDE, 0xDE, 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60,
- 0x12, 0x71, 0x71, 0x23, 0x23, 0x23, 0x23, 0x1E, 0x1E, 0x1E,
- 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF,
- 0xDF, 0xDE, 0xDE, 0xDE, 0xDE, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0x60, 0x60, 0x60, 0x71, 0x71, 0x23, 0x23, 0x5F, 0x5F, 0x1E,
- 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x3D, 0xDF, 0xDF, 0xDF,
- 0xDF, 0xDF, 0xDF, 0xDE, 0xDE, 0xDE, 0xF7, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0x60, 0x60, 0x60, 0x71, 0x23, 0x5F, 0x5F, 0x5F,
- 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x3D, 0x3D, 0x3D, 0x29,
- 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDE, 0xDE, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60, 0x60, 0x60, 0x5F, 0x5F,
- 0x5F, 0x5F, 0x1E, 0x1E, 0x1E, 0x1E, 0x3D, 0x3D, 0x3D, 0x3D,
- 0x29, 0x29, 0x29, 0xDF, 0xDF, 0xDF, 0xDF, 0xDE, 0xF7, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60, 0x60, 0x60,
- 0x5F, 0x5F, 0x5F, 0x5F, 0x1E, 0x1E, 0x3D, 0x3D, 0x3D, 0x3D,
- 0x3D, 0x29, 0x29, 0x29, 0x29, 0xDC, 0xDC, 0xDC, 0xDC, 0xDB,
- 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60,
- 0x60, 0x60, 0x5F, 0x5F, 0x5F, 0x5F, 0x70, 0x3D, 0x3D, 0x3D,
- 0x3D, 0x3D, 0x29, 0x29, 0x29, 0x29, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF2, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0x60, 0x60, 0x60, 0x60, 0x5F, 0x5F, 0x5F, 0x70, 0x70, 0x3D,
- 0x3D, 0x3D, 0x3D, 0x3D, 0x29, 0x29, 0x29, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0x70,
- 0x70, 0x3D, 0x3D, 0x3D, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF7, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2,
- 0xF2, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF6, 0xF6, 0xF6, 0xF6,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2,
- 0xF2, 0xF2, 0xF2, 0xF2, 0xF7, 0xF7, 0xF7, 0xF7, 0xF6, 0xF6,
- 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1,
- 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1,
- 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2,
- 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2,
- 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2,
- 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6,
- 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1,
- 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1,
- 0xF1, 0xF1, 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF,
- 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED,
- 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC,
- 0xEC, 0xEB, 0xEB, 0xEB, 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF,
- 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE,
- 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC,
- 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB, 0xF0, 0xF0, 0xF0, 0xF0,
- 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE,
- 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC,
- 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB, 0xF0, 0xF0,
- 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE,
- 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED,
- 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB,
- 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF,
- 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED,
- 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB,
- 0xEB, 0xEB, 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF,
- 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED,
- 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC,
- 0xEC, 0xEB, 0xEB, 0xEB, 0xEA, 0xEA, 0xEA, 0xEA, 0xE9, 0xE9,
- 0xE9, 0xE9, 0xE9, 0xE9, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8,
- 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE6, 0xE6, 0xE6,
- 0xE6, 0xE6, 0xE6, 0xE5, 0xE5, 0xE5, 0xEA, 0xEA, 0xEA, 0xEA,
- 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE8, 0xE8, 0xE8, 0xE8,
- 0xE8, 0xE8, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE6,
- 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE5, 0xE5, 0xE5, 0xEA, 0xEA,
- 0xEA, 0xEA, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE8, 0xE8,
- 0xE8, 0xE8, 0xE8, 0xE8, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7,
- 0xE7, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE5, 0xE5, 0xE5,
- 0x65, 0x65, 0x65, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
- 0x23, 0x23, 0xE4, 0xE4, 0xE4, 0xE4, 0xE3, 0xE3, 0xE3, 0xE3,
- 0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE1,
- 0xE1, 0xE1, 0x65, 0x65, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20,
- 0x20, 0x23, 0x23, 0x1C, 0x1E, 0x1E, 0xE4, 0xE4, 0xE3, 0xE3,
- 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2,
- 0xE2, 0xE1, 0xE1, 0xE1, 0x65, 0x00, 0x00, 0x00, 0x20, 0x20,
- 0x20, 0x20, 0x23, 0x23, 0x23, 0x1E, 0x1E, 0x1E, 0x1E, 0xE4,
- 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2,
- 0xE2, 0xE2, 0xE2, 0xE1, 0xE1, 0xE1, 0x00, 0x00, 0x00, 0x00,
- 0x20, 0x20, 0x09, 0x23, 0x23, 0x23, 0x1E, 0x1E, 0x1E, 0x1E,
- 0x1E, 0x1E, 0x1E, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE2,
- 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE1, 0xE1, 0xE1, 0x60, 0x12,
- 0x12, 0x12, 0x09, 0x09, 0x23, 0x23, 0x23, 0x23, 0x1E, 0x1E,
- 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF,
- 0xDF, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDD, 0xDD, 0xDD,
- 0x60, 0x60, 0x12, 0x12, 0x09, 0x23, 0x23, 0x23, 0x23, 0x1E,
- 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xDF, 0xDF, 0xDF,
- 0xDF, 0xDF, 0xDF, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDD,
- 0xDD, 0xDD, 0x60, 0x60, 0x12, 0x12, 0x71, 0x23, 0x23, 0x5F,
- 0x1A, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xDF,
- 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE,
- 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60, 0x60, 0x3A, 0x23, 0x5F,
- 0x5F, 0x5F, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x3D,
- 0x10, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDE, 0xDE, 0xDE,
- 0xDE, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60, 0x60, 0x3A,
- 0x3A, 0x5F, 0x5F, 0x5F, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x3D,
- 0x3D, 0x3D, 0x29, 0x29, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDE,
- 0xDE, 0xDE, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60,
- 0x60, 0x3A, 0x5F, 0x5F, 0x5F, 0x5F, 0x1E, 0x1E, 0x1E, 0x3D,
- 0x3D, 0x3D, 0x3D, 0x29, 0x29, 0x29, 0xDF, 0xDF, 0xDF, 0xDF,
- 0xDF, 0xDE, 0xDE, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0x60, 0x60, 0x60, 0x3A, 0x5F, 0x5F, 0x5F, 0x5F, 0x1E, 0x3D,
- 0x3D, 0x3D, 0x3D, 0x3D, 0x29, 0x29, 0x29, 0x29, 0xDC, 0xDC,
- 0xDC, 0xDC, 0xDC, 0xDB, 0xDB, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0x60, 0x60, 0x60, 0x3A, 0x5F, 0x5F, 0x5F, 0x70,
- 0x70, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x29, 0x29, 0x29, 0x29,
- 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDB, 0xDB, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60, 0x60, 0x60, 0x5F, 0x5F,
- 0x70, 0x70, 0x70, 0x3D, 0x3D, 0x3D, 0x3D, 0x29, 0x29, 0x29,
- 0x29, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF6, 0xF6, 0xF6, 0xF6,
- 0xF5, 0xF5, 0x70, 0x70, 0x70, 0x70, 0x3D, 0x3D, 0x29, 0x29,
- 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2,
- 0xF2, 0xF2, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF6, 0xF6,
- 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF7, 0xF7,
- 0xF7, 0xF7, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2,
- 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2,
- 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2,
- 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6,
- 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1,
- 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1,
- 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2,
- 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2,
- 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1, 0xF0, 0xF0, 0xF0, 0xF0,
- 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE,
- 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC,
- 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB, 0xF0, 0xF0,
- 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE,
- 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED,
- 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB,
- 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF,
- 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED,
- 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB,
- 0xEB, 0xEB, 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF,
- 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED,
- 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC,
- 0xEC, 0xEB, 0xEB, 0xEB, 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF,
- 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE,
- 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC,
- 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB, 0xF0, 0xF0, 0xF0, 0xF0,
- 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE,
- 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC,
- 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB, 0xEA, 0xEA,
- 0xEA, 0xEA, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE8, 0xE8,
- 0xE8, 0xE8, 0xE8, 0xE8, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7,
- 0xE7, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE5, 0xE5, 0xE5,
- 0xEA, 0xEA, 0xEA, 0xEA, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9,
- 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE7, 0xE7, 0xE7, 0xE7,
- 0xE7, 0xE7, 0xE7, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE5,
- 0xE5, 0xE5, 0xEA, 0xEA, 0xEA, 0xEA, 0xE9, 0xE9, 0xE9, 0xE9,
- 0xE9, 0xE9, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE7, 0xE7,
- 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6,
- 0xE6, 0xE5, 0xE5, 0xE5, 0x61, 0x61, 0x61, 0x61, 0x20, 0x20,
- 0x20, 0x20, 0x20, 0x1C, 0x1C, 0xE4, 0xE4, 0xE4, 0xE4, 0xE4,
- 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2,
- 0xE2, 0xE2, 0xE2, 0xE1, 0xE1, 0xE1, 0x61, 0x61, 0x61, 0x00,
- 0x20, 0x20, 0x20, 0x20, 0x1C, 0x1C, 0x1C, 0x1E, 0xE4, 0xE4,
- 0xE4, 0xE4, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE2,
- 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE1, 0xE1, 0xE1, 0x61, 0x61,
- 0x00, 0x00, 0x20, 0x20, 0x20, 0x1C, 0x1C, 0x1C, 0x1C, 0x1E,
- 0x1E, 0x1E, 0xE4, 0xE4, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3,
- 0xE3, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE1, 0xE1, 0xE1,
- 0x00, 0x12, 0x12, 0x12, 0x17, 0x17, 0x1C, 0x1C, 0x1C, 0x1C,
- 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xE3, 0xE3, 0xE3, 0xE3,
- 0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE1,
- 0xE1, 0xE1, 0x60, 0x12, 0x12, 0x12, 0x17, 0x17, 0x1C, 0x1C,
- 0x1C, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0xDF, 0xDF,
- 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE,
- 0xDE, 0xDD, 0xDD, 0xDD, 0x60, 0x60, 0x12, 0x12, 0x17, 0x1C,
- 0x1C, 0x1C, 0x1A, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
- 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDE, 0xDE, 0xDE,
- 0xDE, 0xDE, 0xDE, 0xDD, 0xDD, 0xDD, 0x60, 0x60, 0x60, 0x17,
- 0x3A, 0x1C, 0x5F, 0x1A, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
- 0x1E, 0x10, 0x10, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDE,
- 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDD, 0xDD, 0xDD, 0x60, 0x60,
- 0x60, 0x3A, 0x3A, 0x5F, 0x5F, 0x5F, 0x1E, 0x1E, 0x1E, 0x1E,
- 0x1E, 0x3D, 0x3D, 0x10, 0x29, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF,
- 0xDF, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xF7, 0xF7, 0xF7, 0xF7,
- 0x60, 0x60, 0x60, 0x3A, 0x3A, 0x5F, 0x5F, 0x5F, 0x1E, 0x1E,
- 0x1E, 0x3D, 0x3D, 0x3D, 0x10, 0x29, 0x29, 0xDF, 0xDF, 0xDF,
- 0xDF, 0xDF, 0xDF, 0xDE, 0xDE, 0xDE, 0xDE, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0x60, 0x60, 0x60, 0x3A, 0x3A, 0x5F, 0x5F, 0x5F,
- 0x1E, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x29, 0x29, 0x29, 0x29,
- 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDE, 0xDE, 0xDE, 0xF7, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60, 0x60, 0x3A, 0x3A, 0x5F,
- 0x5F, 0x70, 0x70, 0x3D, 0x3D, 0x3D, 0x3D, 0x29, 0x29, 0x29,
- 0x29, 0x29, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDB, 0xDB, 0xDB,
- 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60, 0x60, 0x3A,
- 0x3A, 0x5F, 0x70, 0x70, 0x70, 0x3D, 0x3D, 0x3D, 0x3D, 0x29,
- 0x29, 0x29, 0x29, 0x29, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDB,
- 0xDB, 0xDB, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60,
- 0x60, 0x3A, 0x3A, 0x70, 0x70, 0x70, 0x70, 0x70, 0x3D, 0x3D,
- 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0xDC, 0xDC, 0xDC, 0xDC,
- 0xDC, 0xDB, 0xDB, 0xDB, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7,
- 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0x70, 0x70, 0x70, 0x70, 0x70,
- 0x6F, 0x6F, 0x29, 0x29, 0x29, 0x29, 0x29, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF7, 0xF7, 0xF7, 0xF7,
- 0xF7, 0xF7, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF5, 0xF5, 0x6F, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF7,
- 0xF7, 0xF7, 0xF7, 0xF7, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2,
- 0xF2, 0xF2, 0xF7, 0xF7, 0xF7, 0xF7, 0xF6, 0xF6, 0xF6, 0xF6,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2,
- 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6,
- 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1,
- 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1,
- 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2,
- 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6, 0xF5, 0xF5,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2, 0xF2, 0xF2,
- 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6, 0xF6, 0xF6,
- 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF2,
- 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1, 0xF6, 0xF6,
- 0xF6, 0xF6, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF5, 0xF4, 0xF4,
- 0xF4, 0xF4, 0xF4, 0xF4, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3, 0xF3,
- 0xF3, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF2, 0xF1, 0xF1, 0xF1,
- 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF,
- 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED,
- 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB,
- 0xEB, 0xEB, 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF,
- 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED,
- 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC,
- 0xEC, 0xEB, 0xEB, 0xEB, 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF,
- 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE,
- 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC,
- 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB, 0xF0, 0xF0, 0xF0, 0xF0,
- 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE, 0xEE, 0xEE,
- 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED, 0xEC,
- 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB, 0xF0, 0xF0,
- 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEE, 0xEE,
- 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED, 0xED, 0xED,
- 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB, 0xEB, 0xEB,
- 0xF0, 0xF0, 0xF0, 0xF0, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF, 0xEF,
- 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xEE, 0xED, 0xED, 0xED, 0xED,
- 0xED, 0xED, 0xED, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEC, 0xEB,
- 0xEB, 0xEB, 0xEA, 0xEA, 0xEA, 0xEA, 0xE9, 0xE9, 0xE9, 0xE9,
- 0xE9, 0xE9, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE7, 0xE7,
- 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE6, 0xE6, 0xE6, 0xE6, 0xE6,
- 0xE6, 0xE5, 0xE5, 0xE5, 0xEA, 0xEA, 0xEA, 0xEA, 0xE9, 0xE9,
- 0xE9, 0xE9, 0xE9, 0xE9, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8, 0xE8,
- 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE6, 0xE6, 0xE6,
- 0xE6, 0xE6, 0xE6, 0xE5, 0xE5, 0xE5, 0xEA, 0xEA, 0xEA, 0xEA,
- 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE9, 0xE8, 0xE8, 0xE8, 0xE8,
- 0xE8, 0xE8, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7, 0xE6,
- 0xE6, 0xE6, 0xE6, 0xE6, 0xE6, 0xE5, 0xE5, 0xE5, 0x61, 0x61,
- 0x61, 0x61, 0x61, 0x20, 0x20, 0x20, 0x1C, 0x1C, 0xE4, 0xE4,
- 0xE4, 0xE4, 0xE4, 0xE4, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3,
- 0xE3, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE1, 0xE1, 0xE1,
- 0x61, 0x61, 0x61, 0x0B, 0x31, 0x17, 0x17, 0x1C, 0x1C, 0x1C,
- 0x1C, 0xE4, 0xE4, 0xE4, 0xE4, 0xE4, 0xE3, 0xE3, 0xE3, 0xE3,
- 0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2, 0xE1,
- 0xE1, 0xE1, 0x61, 0x61, 0x0B, 0x12, 0x17, 0x17, 0x17, 0x1C,
- 0x1C, 0x1C, 0x1E, 0x1E, 0x1E, 0xE4, 0xE4, 0xE4, 0xE3, 0xE3,
- 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2, 0xE2, 0xE2,
- 0xE2, 0xE1, 0xE1, 0xE1, 0x0B, 0x12, 0x12, 0x17, 0x17, 0x17,
- 0x1C, 0x1C, 0x1C, 0x1C, 0x1E, 0x1E, 0x1E, 0x1E, 0xE4, 0xE4,
- 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE3, 0xE2, 0xE2, 0xE2,
- 0xE2, 0xE2, 0xE2, 0xE1, 0xE1, 0xE1, 0x60, 0x12, 0x12, 0x17,
- 0x17, 0x17, 0x1C, 0x1C, 0x1C, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
- 0x1E, 0xE0, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDE,
- 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDD, 0xDD, 0xDD, 0x60, 0x60,
- 0x12, 0x17, 0x17, 0x17, 0x1C, 0x1A, 0x1A, 0x1E, 0x1E, 0x1E,
- 0x1E, 0x1E, 0x1E, 0xE0, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF,
- 0xDF, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDD, 0xDD, 0xDD,
- 0x60, 0x60, 0x60, 0x3A, 0x3A, 0x3A, 0x5F, 0x1A, 0x1E, 0x1E,
- 0x1E, 0x1E, 0x1E, 0x3D, 0x10, 0x10, 0xDF, 0xDF, 0xDF, 0xDF,
- 0xDF, 0xDF, 0xDF, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE, 0xDD,
- 0xDD, 0xDD, 0x60, 0x60, 0x60, 0x3A, 0x3A, 0x3A, 0x5F, 0x1A,
- 0x1E, 0x1E, 0x1E, 0x3D, 0x3D, 0x10, 0x10, 0x10, 0x29, 0xDF,
- 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDE, 0xDE, 0xDE, 0xDE, 0xDE,
- 0xDE, 0xDD, 0xDD, 0xDD, 0x60, 0x60, 0x60, 0x3A, 0x3A, 0x3A,
- 0x5F, 0x5F, 0x1E, 0x3D, 0x3D, 0x3D, 0x3D, 0x10, 0x10, 0x29,
- 0x29, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDE, 0xDE, 0xDE,
- 0xDE, 0xDE, 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60, 0x60, 0x3A,
- 0x3A, 0x3A, 0x5F, 0x70, 0x70, 0x3D, 0x3D, 0x3D, 0x10, 0x10,
- 0x29, 0x29, 0x29, 0x29, 0xDF, 0xDF, 0xDF, 0xDF, 0xDF, 0xDE,
- 0xDE, 0xDE, 0xDE, 0xF7, 0xF7, 0xF7, 0xF7, 0xF7, 0x60, 0x60,
- 0x60, 0x3A, 0x3A, 0x5F, 0x70, 0x70, 0x70, 0x3D, 0x3D, 0x3D,
- 0x10, 0x29, 0x29, 0x29, 0x29, 0x29, 0xDC, 0xDC, 0xDC, 0xDC,
- 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XF7, 0XF7, 0XF7, 0XF7, 0XF7,
- 0X60, 0X60, 0X60, 0X3A, 0X3A, 0X70, 0X70, 0X70, 0X70, 0X70,
- 0X3D, 0X3D, 0X29, 0X29, 0X29, 0X29, 0X29, 0X29, 0XDC, 0XDC,
- 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XF7, 0XF7, 0XF7,
- 0XF7, 0XF7, 0X60, 0X60, 0X60, 0X3A, 0X70, 0X70, 0X70, 0X70,
- 0X70, 0X70, 0X6F, 0X6F, 0X29, 0X29, 0X29, 0X29, 0X29, 0XDC,
- 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XF7,
- 0XF7, 0XF7, 0XF7, 0XF7, 0X5A, 0X5A, 0X5A, 0X5A, 0X59, 0X70,
- 0X70, 0X70, 0X70, 0X6F, 0X6F, 0X6F, 0X29, 0X29, 0X29, 0X29,
- 0X3E, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB,
- 0XDB, 0XF7, 0XF7, 0XF7, 0XF7, 0XF7, 0XF6, 0XF6, 0XF6, 0XF6,
- 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0X6F, 0X6F, 0X6F, 0X29, 0X29,
- 0XF4, 0XF4, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF2,
- 0XF2, 0XF2, 0XF2, 0XF7, 0XF7, 0XF7, 0XF7, 0XF7, 0XF6, 0XF6,
- 0XF6, 0XF6, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0XF4, 0XF4,
- 0XF4, 0XF4, 0XF4, 0XF4, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3,
- 0XF3, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF7, 0XF7, 0XF7, 0XF7,
- 0XF6, 0XF6, 0XF6, 0XF6, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5,
- 0XF4, 0XF4, 0XF4, 0XF4, 0XF4, 0XF4, 0XF3, 0XF3, 0XF3, 0XF3,
- 0XF3, 0XF3, 0XF3, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF1,
- 0XF1, 0XF1, 0XF6, 0XF6, 0XF6, 0XF6, 0XF5, 0XF5, 0XF5, 0XF5,
- 0XF5, 0XF5, 0XF4, 0XF4, 0XF4, 0XF4, 0XF4, 0XF4, 0XF3, 0XF3,
- 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2,
- 0XF2, 0XF1, 0XF1, 0XF1, 0XF6, 0XF6, 0XF6, 0XF6, 0XF5, 0XF5,
- 0XF5, 0XF5, 0XF5, 0XF5, 0XF4, 0XF4, 0XF4, 0XF4, 0XF4, 0XF4,
- 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF2, 0XF2, 0XF2,
- 0XF2, 0XF2, 0XF2, 0XF1, 0XF1, 0XF1, 0XF6, 0XF6, 0XF6, 0XF6,
- 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0XF4, 0XF4, 0XF4, 0XF4,
- 0XF4, 0XF4, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF2,
- 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF1, 0XF1, 0XF1, 0XF6, 0XF6,
- 0XF6, 0XF6, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0XF4, 0XF4,
- 0XF4, 0XF4, 0XF4, 0XF4, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3,
- 0XF3, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF1, 0XF1, 0XF1,
- 0XF6, 0XF6, 0XF6, 0XF6, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5,
- 0XF4, 0XF4, 0XF4, 0XF4, 0XF4, 0XF4, 0XF3, 0XF3, 0XF3, 0XF3,
- 0XF3, 0XF3, 0XF3, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF1,
- 0XF1, 0XF1, 0XF6, 0XF6, 0XF6, 0XF6, 0XF5, 0XF5, 0XF5, 0XF5,
- 0XF5, 0XF5, 0XF4, 0XF4, 0XF4, 0XF4, 0XF4, 0XF4, 0XF3, 0XF3,
- 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2,
- 0XF2, 0XF1, 0XF1, 0XF1, 0XF0, 0XF0, 0XF0, 0XF0, 0XEF, 0XEF,
- 0XEF, 0XEF, 0XEF, 0XEF, 0XEE, 0XEE, 0XEE, 0XEE, 0XEE, 0XEE,
- 0XED, 0XED, 0XED, 0XED, 0XED, 0XED, 0XED, 0XEC, 0XEC, 0XEC,
- 0XEC, 0XEC, 0XEC, 0XEB, 0XEB, 0XEB, 0XF0, 0XF0, 0XF0, 0XF0,
- 0XEF, 0XEF, 0XEF, 0XEF, 0XEF, 0XEF, 0XEE, 0XEE, 0XEE, 0XEE,
- 0XEE, 0XEE, 0XED, 0XED, 0XED, 0XED, 0XED, 0XED, 0XED, 0XEC,
- 0XEC, 0XEC, 0XEC, 0XEC, 0XEC, 0XEB, 0XEB, 0XEB, 0XF0, 0XF0,
- 0XF0, 0XF0, 0XEF, 0XEF, 0XEF, 0XEF, 0XEF, 0XEF, 0XEE, 0XEE,
- 0XEE, 0XEE, 0XEE, 0XEE, 0XED, 0XED, 0XED, 0XED, 0XED, 0XED,
- 0XED, 0XEC, 0XEC, 0XEC, 0XEC, 0XEC, 0XEC, 0XEB, 0XEB, 0XEB,
- 0XF0, 0XF0, 0XF0, 0XF0, 0XEF, 0XEF, 0XEF, 0XEF, 0XEF, 0XEF,
- 0XEE, 0XEE, 0XEE, 0XEE, 0XEE, 0XEE, 0XED, 0XED, 0XED, 0XED,
- 0XED, 0XED, 0XED, 0XEC, 0XEC, 0XEC, 0XEC, 0XEC, 0XEC, 0XEB,
- 0XEB, 0XEB, 0XF0, 0XF0, 0XF0, 0XF0, 0XEF, 0XEF, 0XEF, 0XEF,
- 0XEF, 0XEF, 0XEE, 0XEE, 0XEE, 0XEE, 0XEE, 0XEE, 0XED, 0XED,
- 0XED, 0XED, 0XED, 0XED, 0XED, 0XEC, 0XEC, 0XEC, 0XEC, 0XEC,
- 0XEC, 0XEB, 0XEB, 0XEB, 0XF0, 0XF0, 0XF0, 0XF0, 0XEF, 0XEF,
- 0XEF, 0XEF, 0XEF, 0XEF, 0XEE, 0XEE, 0XEE, 0XEE, 0XEE, 0XEE,
- 0XED, 0XED, 0XED, 0XED, 0XED, 0XED, 0XED, 0XEC, 0XEC, 0XEC,
- 0XEC, 0XEC, 0XEC, 0XEB, 0XEB, 0XEB, 0XEA, 0XEA, 0XEA, 0XEA,
- 0XE9, 0XE9, 0XE9, 0XE9, 0XE9, 0XE9, 0XE8, 0XE8, 0XE8, 0XE8,
- 0XE8, 0XE8, 0XE7, 0XE7, 0XE7, 0XE7, 0XE7, 0XE7, 0XE7, 0XE6,
- 0XE6, 0XE6, 0XE6, 0XE6, 0XE6, 0XE5, 0XE5, 0XE5, 0XEA, 0XEA,
- 0XEA, 0XEA, 0XE9, 0XE9, 0XE9, 0XE9, 0XE9, 0XE9, 0XE8, 0XE8,
- 0XE8, 0XE8, 0XE8, 0XE8, 0XE7, 0XE7, 0XE7, 0XE7, 0XE7, 0XE7,
- 0XE7, 0XE6, 0XE6, 0XE6, 0XE6, 0XE6, 0XE6, 0XE5, 0XE5, 0XE5,
- 0XEA, 0XEA, 0XEA, 0XEA, 0XE9, 0XE9, 0XE9, 0XE9, 0XE9, 0XE9,
- 0XE8, 0XE8, 0XE8, 0XE8, 0XE8, 0XE8, 0XE7, 0XE7, 0XE7, 0XE7,
- 0XE7, 0XE7, 0XE7, 0XE6, 0XE6, 0XE6, 0XE6, 0XE6, 0XE6, 0XE5,
- 0XE5, 0XE5, 0X64, 0X64, 0X64, 0X0B, 0X31, 0X31, 0X31, 0X5D,
- 0X5D, 0X5D, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE3, 0XE3,
- 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2,
- 0XE2, 0XE1, 0XE1, 0XE1, 0X64, 0X64, 0X0B, 0X0B, 0X31, 0X31,
- 0X31, 0X1C, 0X1C, 0X1C, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4,
- 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE2, 0XE2, 0XE2,
- 0XE2, 0XE2, 0XE2, 0XE1, 0XE1, 0XE1, 0X0B, 0X0B, 0X0B, 0X31,
- 0X31, 0X31, 0X17, 0X1C, 0X1C, 0X1C, 0X1E, 0XE4, 0XE4, 0XE4,
- 0XE4, 0XE4, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE2,
- 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE1, 0XE1, 0XE1, 0X0B, 0X0B,
- 0X31, 0X31, 0X31, 0X17, 0X17, 0X1C, 0X1C, 0X1E, 0X1E, 0X1E,
- 0X1E, 0XE4, 0XE4, 0XE4, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3,
- 0XE3, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE1, 0XE1, 0XE1,
- 0X0B, 0X0B, 0X31, 0X31, 0X17, 0X17, 0X1C, 0X1C, 0X1A, 0X1E,
- 0X1E, 0X1E, 0X1E, 0XE0, 0XE0, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF,
- 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD,
- 0XDD, 0XDD, 0X60, 0X0F, 0X0F, 0X17, 0X3A, 0X3A, 0X1C, 0X1A,
- 0X1A, 0X1E, 0X1E, 0X1E, 0X1E, 0X10, 0XE0, 0XE0, 0XDF, 0XDF,
- 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE,
- 0XDE, 0XDD, 0XDD, 0XDD, 0X60, 0X60, 0X0F, 0X3A, 0X3A, 0X3A,
- 0X1A, 0X1A, 0X1E, 0X1E, 0X1E, 0X1E, 0X10, 0X10, 0XE0, 0XE0,
- 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE,
- 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD, 0X60, 0X60, 0X60, 0X3A,
- 0X3A, 0X3A, 0X1A, 0X1F, 0X1F, 0X1F, 0X3D, 0X3D, 0X10, 0X10,
- 0X10, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE,
- 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD, 0X60, 0X60,
- 0X60, 0X3A, 0X3A, 0X3A, 0X5F, 0X70, 0X70, 0X3D, 0X3D, 0X10,
- 0X10, 0X10, 0X29, 0X29, 0X29, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF,
- 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD,
- 0X60, 0X60, 0X60, 0X3A, 0X3A, 0X3A, 0X70, 0X70, 0X70, 0X3D,
- 0X3D, 0X10, 0X10, 0X29, 0X29, 0X29, 0X29, 0XDF, 0XDF, 0XDF,
- 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XF7, 0XF7,
- 0XF7, 0XF7, 0X60, 0X60, 0X60, 0X3A, 0X3A, 0X70, 0X70, 0X70,
- 0X70, 0X70, 0X3D, 0X10, 0X29, 0X29, 0X29, 0X29, 0X29, 0X29,
- 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB,
- 0XF7, 0XF7, 0XF7, 0XF7, 0X60, 0X60, 0X60, 0X3A, 0X3A, 0X70,
- 0X70, 0X70, 0X70, 0X70, 0X6F, 0X6F, 0X29, 0X29, 0X29, 0X29,
- 0X29, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB,
- 0XDB, 0XDB, 0XF7, 0XF7, 0XF7, 0XF7, 0X5A, 0X5A, 0X5A, 0X5A,
- 0X59, 0X70, 0X70, 0X70, 0X70, 0X6F, 0X6F, 0X6F, 0X29, 0X29,
- 0X29, 0X29, 0X29, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB,
- 0XDB, 0XDB, 0XDB, 0XDB, 0XF7, 0XF7, 0XF7, 0XF7, 0X5A, 0X5A,
- 0X5A, 0X5A, 0X59, 0X59, 0X59, 0X70, 0X6F, 0X6F, 0X6F, 0X6F,
- 0X29, 0X29, 0X29, 0X3E, 0X3E, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC,
- 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XF7, 0XF7, 0XF7, 0XF7,
- 0X5A, 0X5A, 0X5A, 0X5A, 0X59, 0X59, 0X59, 0X59, 0X6F, 0X6F,
- 0X6F, 0X6F, 0X29, 0X29, 0X3E, 0X3E, 0X3E, 0XDC, 0XDC, 0XDC,
- 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XF7, 0XF7,
- 0XF7, 0XF7, 0XF6, 0XF6, 0XF6, 0XF6, 0XF5, 0XF5, 0XF5, 0XF5,
- 0XF5, 0XF5, 0X6F, 0XF4, 0XF4, 0XF4, 0XF4, 0XF4, 0XF3, 0XF3,
- 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2,
- 0XF7, 0XF7, 0XF7, 0XF7, 0XF6, 0XF6, 0XF6, 0XF6, 0XF5, 0XF5,
- 0XF5, 0XF5, 0XF5, 0XF5, 0XF4, 0XF4, 0XF4, 0XF4, 0XF4, 0XF4,
- 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF2, 0XF2, 0XF2,
- 0XF2, 0XF2, 0XF2, 0XF1, 0XF1, 0XF1, 0XF6, 0XF6, 0XF6, 0XF6,
- 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0XF4, 0XF4, 0XF4, 0XF4,
- 0XF4, 0XF4, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF2,
- 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF1, 0XF1, 0XF1, 0XF6, 0XF6,
- 0XF6, 0XF6, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0XF4, 0XF4,
- 0XF4, 0XF4, 0XF4, 0XF4, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3,
- 0XF3, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF1, 0XF1, 0XF1,
- 0XF6, 0XF6, 0XF6, 0XF6, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5,
- 0XF4, 0XF4, 0XF4, 0XF4, 0XF4, 0XF4, 0XF3, 0XF3, 0XF3, 0XF3,
- 0XF3, 0XF3, 0XF3, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF1,
- 0XF1, 0XF1, 0XF6, 0XF6, 0XF6, 0XF6, 0XF5, 0XF5, 0XF5, 0XF5,
- 0XF5, 0XF5, 0XF4, 0XF4, 0XF4, 0XF4, 0XF4, 0XF4, 0XF3, 0XF3,
- 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2,
- 0XF2, 0XF1, 0XF1, 0XF1, 0XF6, 0XF6, 0XF6, 0XF6, 0XF5, 0XF5,
- 0XF5, 0XF5, 0XF5, 0XF5, 0XF4, 0XF4, 0XF4, 0XF4, 0XF4, 0XF4,
- 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF2, 0XF2, 0XF2,
- 0XF2, 0XF2, 0XF2, 0XF1, 0XF1, 0XF1, 0XF6, 0XF6, 0XF6, 0XF6,
- 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0XF4, 0XF4, 0XF4, 0XF4,
- 0XF4, 0XF4, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF2,
- 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF1, 0XF1, 0XF1, 0XF0, 0XF0,
- 0XF0, 0XF0, 0XEF, 0XEF, 0XEF, 0XEF, 0XEF, 0XEF, 0XEE, 0XEE,
- 0XEE, 0XEE, 0XEE, 0XEE, 0XED, 0XED, 0XED, 0XED, 0XED, 0XED,
- 0XED, 0XEC, 0XEC, 0XEC, 0XEC, 0XEC, 0XEC, 0XEB, 0XEB, 0XEB,
- 0XF0, 0XF0, 0XF0, 0XF0, 0XEF, 0XEF, 0XEF, 0XEF, 0XEF, 0XEF,
- 0XEE, 0XEE, 0XEE, 0XEE, 0XEE, 0XEE, 0XED, 0XED, 0XED, 0XED,
- 0XED, 0XED, 0XED, 0XEC, 0XEC, 0XEC, 0XEC, 0XEC, 0XEC, 0XEB,
- 0XEB, 0XEB, 0XF0, 0XF0, 0XF0, 0XF0, 0XEF, 0XEF, 0XEF, 0XEF,
- 0XEF, 0XEF, 0XEE, 0XEE, 0XEE, 0XEE, 0XEE, 0XEE, 0XED, 0XED,
- 0XED, 0XED, 0XED, 0XED, 0XED, 0XEC, 0XEC, 0XEC, 0XEC, 0XEC,
- 0XEC, 0XEB, 0XEB, 0XEB, 0XF0, 0XF0, 0XF0, 0XF0, 0XEF, 0XEF,
- 0XEF, 0XEF, 0XEF, 0XEF, 0XEE, 0XEE, 0XEE, 0XEE, 0XEE, 0XEE,
- 0XED, 0XED, 0XED, 0XED, 0XED, 0XED, 0XED, 0XEC, 0XEC, 0XEC,
- 0XEC, 0XEC, 0XEC, 0XEB, 0XEB, 0XEB, 0XF0, 0XF0, 0XF0, 0XF0,
- 0XEF, 0XEF, 0XEF, 0XEF, 0XEF, 0XEF, 0XEE, 0XEE, 0XEE, 0XEE,
- 0XEE, 0XEE, 0XED, 0XED, 0XED, 0XED, 0XED, 0XED, 0XED, 0XEC,
- 0XEC, 0XEC, 0XEC, 0XEC, 0XEC, 0XEB, 0XEB, 0XEB, 0XF0, 0XF0,
- 0XF0, 0XF0, 0XEF, 0XEF, 0XEF, 0XEF, 0XEF, 0XEF, 0XEE, 0XEE,
- 0XEE, 0XEE, 0XEE, 0XEE, 0XED, 0XED, 0XED, 0XED, 0XED, 0XED,
- 0XED, 0XEC, 0XEC, 0XEC, 0XEC, 0XEC, 0XEC, 0XEB, 0XEB, 0XEB,
- 0XEA, 0XEA, 0XEA, 0XEA, 0XE9, 0XE9, 0XE9, 0XE9, 0XE9, 0XE9,
- 0XE8, 0XE8, 0XE8, 0XE8, 0XE8, 0XE8, 0XE7, 0XE7, 0XE7, 0XE7,
- 0XE7, 0XE7, 0XE7, 0XE6, 0XE6, 0XE6, 0XE6, 0XE6, 0XE6, 0XE5,
- 0XE5, 0XE5, 0XEA, 0XEA, 0XEA, 0XEA, 0XE9, 0XE9, 0XE9, 0XE9,
- 0XE9, 0XE9, 0XE8, 0XE8, 0XE8, 0XE8, 0XE8, 0XE8, 0XE7, 0XE7,
- 0XE7, 0XE7, 0XE7, 0XE7, 0XE7, 0XE6, 0XE6, 0XE6, 0XE6, 0XE6,
- 0XE6, 0XE5, 0XE5, 0XE5, 0XEA, 0XEA, 0XEA, 0XEA, 0XE9, 0XE9,
- 0XE9, 0XE9, 0XE9, 0XE9, 0XE8, 0XE8, 0XE8, 0XE8, 0XE8, 0XE8,
- 0XE7, 0XE7, 0XE7, 0XE7, 0XE7, 0XE7, 0XE7, 0XE6, 0XE6, 0XE6,
- 0XE6, 0XE6, 0XE6, 0XE5, 0XE5, 0XE5, 0X64, 0X64, 0X64, 0X0B,
- 0X31, 0X31, 0X5D, 0X5D, 0X5D, 0X5D, 0XE4, 0XE4, 0XE4, 0XE4,
- 0XE4, 0XE4, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE2,
- 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE1, 0XE1, 0XE1, 0X64, 0X0B,
- 0X0B, 0X0B, 0X31, 0X31, 0X31, 0X5D, 0X5D, 0X5D, 0XE4, 0XE4,
- 0XE4, 0XE4, 0XE4, 0XE4, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3,
- 0XE3, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE1, 0XE1, 0XE1,
- 0X0B, 0X0B, 0X0B, 0X31, 0X31, 0X31, 0X31, 0X16, 0X5D, 0X5D,
- 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE3, 0XE3, 0XE3, 0XE3,
- 0XE3, 0XE3, 0XE3, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE1,
- 0XE1, 0XE1, 0X0B, 0X0B, 0X31, 0X31, 0X31, 0X31, 0X16, 0X16,
- 0X16, 0X1F, 0X1F, 0X1F, 0XE4, 0XE4, 0XE4, 0XE4, 0XE3, 0XE3,
- 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2,
- 0XE2, 0XE1, 0XE1, 0XE1, 0X0B, 0X0F, 0X0F, 0X31, 0X16, 0X16,
- 0X16, 0X16, 0X1F, 0X1F, 0X1F, 0X1F, 0XE0, 0XE0, 0XE0, 0XE0,
- 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE,
- 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD, 0X0F, 0X0F, 0X0F, 0X0F,
- 0X16, 0X16, 0X16, 0X16, 0X1F, 0X1F, 0X1F, 0X1F, 0XE0, 0XE0,
- 0XE0, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE,
- 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD, 0X60, 0X0F,
- 0X0F, 0X0F, 0X16, 0X16, 0X16, 0X1F, 0X1F, 0X1F, 0X1F, 0X10,
- 0X10, 0XE0, 0XE0, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF,
- 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD,
- 0X60, 0X0F, 0X0F, 0X0F, 0X3A, 0X3A, 0X1F, 0X1F, 0X1F, 0X1F,
- 0X10, 0X10, 0X10, 0X10, 0XE0, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF,
- 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD,
- 0XDD, 0XDD, 0X60, 0X60, 0X0F, 0X3A, 0X3A, 0X3A, 0X1F, 0X1F,
- 0X70, 0X3D, 0X10, 0X10, 0X10, 0X10, 0X29, 0X29, 0X29, 0XDF,
- 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE,
- 0XDE, 0XDD, 0XDD, 0XDD, 0X60, 0X60, 0X3A, 0X3A, 0X3A, 0X3A,
- 0X70, 0X70, 0X70, 0X70, 0X10, 0X10, 0X10, 0X29, 0X29, 0X29,
- 0X29, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE,
- 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD, 0X60, 0X07, 0X07, 0X07,
- 0X3A, 0X70, 0X70, 0X70, 0X70, 0X70, 0X10, 0X10, 0X29, 0X29,
- 0X29, 0X29, 0X29, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB,
- 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XF7, 0XF7, 0XF7, 0X5A, 0X5A,
- 0X5A, 0X07, 0X59, 0X70, 0X70, 0X70, 0X70, 0X6F, 0X6F, 0X6F,
- 0X29, 0X29, 0X29, 0X29, 0X29, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC,
- 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XF7, 0XF7, 0XF7,
- 0X5A, 0X5A, 0X5A, 0X5A, 0X59, 0X59, 0X59, 0X70, 0X6F, 0X6F,
- 0X6F, 0X6F, 0X29, 0X29, 0X29, 0X3E, 0X3E, 0XDC, 0XDC, 0XDC,
- 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XF7,
- 0XF7, 0XF7, 0X5A, 0X5A, 0X5A, 0X5A, 0X59, 0X59, 0X59, 0X59,
- 0X6F, 0X6F, 0X6F, 0X6F, 0X29, 0X29, 0X3E, 0X3E, 0X3E, 0XDC,
- 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB,
- 0XDB, 0XF7, 0XF7, 0XF7, 0X5A, 0X5A, 0X5A, 0X5A, 0X59, 0X59,
- 0X59, 0X59, 0X59, 0X6F, 0X6F, 0X6F, 0X3E, 0X3E, 0X3E, 0X3E,
- 0X3E, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB,
- 0XDB, 0XDB, 0XDB, 0XF7, 0XF7, 0XF7, 0X5A, 0X5A, 0X5A, 0X5A,
- 0X59, 0X59, 0X59, 0X59, 0X59, 0X6F, 0X6F, 0X6F, 0X3E, 0X3E,
- 0X3E, 0X3E, 0X3E, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB,
- 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XF7, 0XF7, 0XF7, 0XF6, 0XF6,
- 0XF6, 0XF6, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0XF4, 0XF4,
- 0XF4, 0XF4, 0XF4, 0XF4, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3,
- 0XF3, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF1, 0XF1, 0XF1,
- 0XF6, 0XF6, 0XF6, 0XF6, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5,
- 0XF4, 0XF4, 0XF4, 0XF4, 0XF4, 0XF4, 0XF3, 0XF3, 0XF3, 0XF3,
- 0XF3, 0XF3, 0XF3, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF1,
- 0XF1, 0XF1, 0XF6, 0XF6, 0XF6, 0XF6, 0XF5, 0XF5, 0XF5, 0XF5,
- 0XF5, 0XF5, 0XF4, 0XF4, 0XF4, 0XF4, 0XF4, 0XF4, 0XF3, 0XF3,
- 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2,
- 0XF2, 0XF1, 0XF1, 0XF1, 0XF6, 0XF6, 0XF6, 0XF6, 0XF5, 0XF5,
- 0XF5, 0XF5, 0XF5, 0XF5, 0XF4, 0XF4, 0XF4, 0XF4, 0XF4, 0XF4,
- 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF2, 0XF2, 0XF2,
- 0XF2, 0XF2, 0XF2, 0XF1, 0XF1, 0XF1, 0XF6, 0XF6, 0XF6, 0XF6,
- 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0XF4, 0XF4, 0XF4, 0XF4,
- 0XF4, 0XF4, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF2,
- 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF1, 0XF1, 0XF1, 0XF6, 0XF6,
- 0XF6, 0XF6, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0XF4, 0XF4,
- 0XF4, 0XF4, 0XF4, 0XF4, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3, 0XF3,
- 0XF3, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF1, 0XF1, 0XF1,
- 0XF6, 0XF6, 0XF6, 0XF6, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5, 0XF5,
- 0XF4, 0XF4, 0XF4, 0XF4, 0XF4, 0XF4, 0XF3, 0XF3, 0XF3, 0XF3,
- 0XF3, 0XF3, 0XF3, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF2, 0XF1,
- 0XF1, 0XF1, 0XF0, 0XF0, 0XF0, 0XF0, 0XEF, 0XEF, 0XEF, 0XEF,
- 0XEF, 0XEF, 0XEE, 0XEE, 0XEE, 0XEE, 0XEE, 0XEE, 0XED, 0XED,
- 0XED, 0XED, 0XED, 0XED, 0XED, 0XEC, 0XEC, 0XEC, 0XEC, 0XEC,
- 0XEC, 0XEB, 0XEB, 0XEB, 0XF0, 0XF0, 0XF0, 0XF0, 0XEF, 0XEF,
- 0XEF, 0XEF, 0XEF, 0XEF, 0XEE, 0XEE, 0XEE, 0XEE, 0XEE, 0XEE,
- 0XED, 0XED, 0XED, 0XED, 0XED, 0XED, 0XED, 0XEC, 0XEC, 0XEC,
- 0XEC, 0XEC, 0XEC, 0XEB, 0XEB, 0XEB, 0XF0, 0XF0, 0XF0, 0XF0,
- 0XEF, 0XEF, 0XEF, 0XEF, 0XEF, 0XEF, 0XEE, 0XEE, 0XEE, 0XEE,
- 0XEE, 0XEE, 0XED, 0XED, 0XED, 0XED, 0XED, 0XED, 0XED, 0XEC,
- 0XEC, 0XEC, 0XEC, 0XEC, 0XEC, 0XEB, 0XEB, 0XEB, 0XF0, 0XF0,
- 0XF0, 0XF0, 0XEF, 0XEF, 0XEF, 0XEF, 0XEF, 0XEF, 0XEE, 0XEE,
- 0XEE, 0XEE, 0XEE, 0XEE, 0XED, 0XED, 0XED, 0XED, 0XED, 0XED,
- 0XED, 0XEC, 0XEC, 0XEC, 0XEC, 0XEC, 0XEC, 0XEB, 0XEB, 0XEB,
- 0XF0, 0XF0, 0XF0, 0XF0, 0XEF, 0XEF, 0XEF, 0XEF, 0XEF, 0XEF,
- 0XEE, 0XEE, 0XEE, 0XEE, 0XEE, 0XEE, 0XED, 0XED, 0XED, 0XED,
- 0XED, 0XED, 0XED, 0XEC, 0XEC, 0XEC, 0XEC, 0XEC, 0XEC, 0XEB,
- 0XEB, 0XEB, 0XF0, 0XF0, 0XF0, 0XF0, 0XEF, 0XEF, 0XEF, 0XEF,
- 0XEF, 0XEF, 0XEE, 0XEE, 0XEE, 0XEE, 0XEE, 0XEE, 0XED, 0XED,
- 0XED, 0XED, 0XED, 0XED, 0XED, 0XEC, 0XEC, 0XEC, 0XEC, 0XEC,
- 0XEC, 0XEB, 0XEB, 0XEB, 0XEA, 0XEA, 0XEA, 0XEA, 0XE9, 0XE9,
- 0XE9, 0XE9, 0XE9, 0XE9, 0XE8, 0XE8, 0XE8, 0XE8, 0XE8, 0XE8,
- 0XE7, 0XE7, 0XE7, 0XE7, 0XE7, 0XE7, 0XE7, 0XE6, 0XE6, 0XE6,
- 0XE6, 0XE6, 0XE6, 0XE5, 0XE5, 0XE5, 0XEA, 0XEA, 0XEA, 0XEA,
- 0XE9, 0XE9, 0XE9, 0XE9, 0XE9, 0XE9, 0XE8, 0XE8, 0XE8, 0XE8,
- 0XE8, 0XE8, 0XE7, 0XE7, 0XE7, 0XE7, 0XE7, 0XE7, 0XE7, 0XE6,
- 0XE6, 0XE6, 0XE6, 0XE6, 0XE6, 0XE5, 0XE5, 0XE5, 0XEA, 0XEA,
- 0XEA, 0XEA, 0XE9, 0XE9, 0XE9, 0XE9, 0XE9, 0XE9, 0XE8, 0XE8,
- 0XE8, 0XE8, 0XE8, 0XE8, 0XE7, 0XE7, 0XE7, 0XE7, 0XE7, 0XE7,
- 0XE7, 0XE6, 0XE6, 0XE6, 0XE6, 0XE6, 0XE6, 0XE5, 0XE5, 0XE5,
- 0X63, 0X63, 0X63, 0X0B, 0X31, 0X5D, 0X5D, 0X5D, 0X5D, 0X5D,
- 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE3, 0XE3, 0XE3, 0XE3,
- 0XE3, 0XE3, 0XE3, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE1,
- 0XE1, 0XE1, 0X63, 0X0B, 0X0B, 0X0B, 0X31, 0X31, 0X5D, 0X5D,
- 0X5D, 0X5D, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE3, 0XE3,
- 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2,
- 0XE2, 0XE1, 0XE1, 0XE1, 0X0B, 0X0B, 0X0B, 0X31, 0X31, 0X31,
- 0X31, 0X5D, 0X5D, 0X5D, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4,
- 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE2, 0XE2, 0XE2,
- 0XE2, 0XE2, 0XE2, 0XE1, 0XE1, 0XE1, 0X0B, 0X0B, 0X31, 0X31,
- 0X31, 0X31, 0X16, 0X16, 0X16, 0X1F, 0X1F, 0XE4, 0XE4, 0XE4,
- 0XE4, 0XE4, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE2,
- 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE1, 0XE1, 0XE1, 0X0B, 0X0F,
- 0X0F, 0X31, 0X16, 0X16, 0X16, 0X16, 0X1F, 0X1F, 0X1F, 0XE0,
- 0XE0, 0XE0, 0XE0, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF,
- 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD,
- 0X0F, 0X0F, 0X0F, 0X0F, 0X16, 0X16, 0X16, 0X16, 0X1F, 0X1F,
- 0X1F, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF,
- 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD,
- 0XDD, 0XDD, 0X0F, 0X0F, 0X0F, 0X0F, 0X16, 0X16, 0X16, 0X1F,
- 0X1F, 0X1F, 0X1F, 0X10, 0XE0, 0XE0, 0XE0, 0XE0, 0XDF, 0XDF,
- 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE,
- 0XDE, 0XDD, 0XDD, 0XDD, 0X5C, 0X0F, 0X0F, 0X0F, 0X16, 0X16,
- 0X16, 0X1F, 0X1F, 0X1F, 0X10, 0X10, 0X10, 0XE0, 0XE0, 0XE0,
- 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE,
- 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD, 0X5C, 0X0F, 0X0F, 0X0F,
- 0X16, 0X14, 0X1F, 0X1F, 0X1F, 0X10, 0X10, 0X10, 0X10, 0X29,
- 0X29, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE,
- 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD, 0X5C, 0X07,
- 0X07, 0X07, 0X07, 0X14, 0X70, 0X70, 0X70, 0X10, 0X10, 0X10,
- 0X29, 0X29, 0X29, 0X29, 0X29, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF,
- 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD,
- 0X5A, 0X07, 0X07, 0X07, 0X07, 0X70, 0X70, 0X70, 0X70, 0X10,
- 0X6F, 0X6F, 0X29, 0X29, 0X29, 0X29, 0X29, 0XDC, 0XDC, 0XDC,
- 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDA,
- 0XDA, 0XDA, 0X5A, 0X5A, 0X07, 0X07, 0X07, 0X59, 0X59, 0X70,
- 0X6F, 0X6F, 0X6F, 0X6F, 0X29, 0X29, 0X29, 0X29, 0X3E, 0XDC,
- 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB,
- 0XDB, 0XDA, 0XDA, 0XDA, 0X5A, 0X5A, 0X5A, 0X5A, 0X59, 0X59,
- 0X59, 0X59, 0X6F, 0X6F, 0X6F, 0X6F, 0X29, 0X29, 0X3E, 0X3E,
- 0X3E, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB,
- 0XDB, 0XDB, 0XDB, 0XDA, 0XDA, 0XDA, 0X5A, 0X5A, 0X5A, 0X5A,
- 0X59, 0X59, 0X59, 0X59, 0X59, 0X6F, 0X6F, 0X6F, 0X29, 0X3E,
- 0X3E, 0X3E, 0X3E, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB,
- 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDA, 0XDA, 0XDA, 0X5A, 0X5A,
- 0X5A, 0X5A, 0X59, 0X59, 0X59, 0X59, 0X59, 0X6F, 0X6F, 0X6F,
- 0X3E, 0X3E, 0X3E, 0X3E, 0X3E, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC,
- 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDA, 0XDA, 0XDA,
- 0X5A, 0X5A, 0X5A, 0X5A, 0X59, 0X59, 0X59, 0X59, 0X59, 0X59,
- 0X6F, 0X58, 0X58, 0X3E, 0X3E, 0X3E, 0X3E, 0XDC, 0XDC, 0XDC,
- 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDA,
- 0XDA, 0XDA, 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8,
- 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0X3E, 0X6E, 0XD6,
- 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5,
- 0XD5, 0XD4, 0XD4, 0XD4, 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8,
- 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7,
- 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5,
- 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4, 0XD9, 0XD9, 0XD9, 0XD9,
- 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0XD7,
- 0XD7, 0XD7, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD5,
- 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4, 0XD9, 0XD9,
- 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7,
- 0XD7, 0XD7, 0XD7, 0XD7, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6,
- 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4,
- 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8,
- 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD6, 0XD6, 0XD6, 0XD6,
- 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4,
- 0XD4, 0XD4, 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8,
- 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD6, 0XD6,
- 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5,
- 0XD5, 0XD4, 0XD4, 0XD4, 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8,
- 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7,
- 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5,
- 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4, 0XD3, 0XD3, 0XD3, 0XD3,
- 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD1, 0XD1, 0XD1, 0XD1,
- 0XD1, 0XD1, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XCF,
- 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCE, 0XCE, 0XCE, 0XD3, 0XD3,
- 0XD3, 0XD3, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD1, 0XD1,
- 0XD1, 0XD1, 0XD1, 0XD1, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0,
- 0XD0, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCE, 0XCE, 0XCE,
- 0XD3, 0XD3, 0XD3, 0XD3, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2,
- 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD0, 0XD0, 0XD0, 0XD0,
- 0XD0, 0XD0, 0XD0, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCE,
- 0XCE, 0XCE, 0XD3, 0XD3, 0XD3, 0XD3, 0XD2, 0XD2, 0XD2, 0XD2,
- 0XD2, 0XD2, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD0, 0XD0,
- 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF,
- 0XCF, 0XCE, 0XCE, 0XCE, 0XD3, 0XD3, 0XD3, 0XD3, 0XD2, 0XD2,
- 0XD2, 0XD2, 0XD2, 0XD2, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1,
- 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XCF, 0XCF, 0XCF,
- 0XCF, 0XCF, 0XCF, 0XCE, 0XCE, 0XCE, 0XD3, 0XD3, 0XD3, 0XD3,
- 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD1, 0XD1, 0XD1, 0XD1,
- 0XD1, 0XD1, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XCF,
- 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCE, 0XCE, 0XCE, 0XCD, 0XCD,
- 0XCD, 0XCD, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCB, 0XCB,
- 0XCB, 0XCB, 0XCB, 0XCB, 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XCA,
- 0XCA, 0XC9, 0XC9, 0XC9, 0XC9, 0XC9, 0XC9, 0XC8, 0XC8, 0XC8,
- 0XCD, 0XCD, 0XCD, 0XCD, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC,
- 0XCB, 0XCB, 0XCB, 0XCB, 0XCB, 0XCB, 0XCA, 0XCA, 0XCA, 0XCA,
- 0XCA, 0XCA, 0XCA, 0XC9, 0XC9, 0XC9, 0XC9, 0XC9, 0XC9, 0XC8,
- 0XC8, 0XC8, 0XCD, 0XCD, 0XCD, 0XCD, 0XCC, 0XCC, 0XCC, 0XCC,
- 0XCC, 0XCC, 0XCB, 0XCB, 0XCB, 0XCB, 0XCB, 0XCB, 0XCA, 0XCA,
- 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XC9, 0XC9, 0XC9, 0XC9, 0XC9,
- 0XC9, 0XC8, 0XC8, 0XC8, 0X63, 0X63, 0X63, 0X0B, 0X5D, 0X5D,
- 0X5D, 0X5D, 0X5D, 0X5D, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4,
- 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE2, 0XE2, 0XE2,
- 0XE2, 0XE2, 0XE2, 0XE1, 0XE1, 0XE1, 0X63, 0X63, 0X0B, 0X0B,
- 0X31, 0X5D, 0X5D, 0X5D, 0X5D, 0X5D, 0XE4, 0XE4, 0XE4, 0XE4,
- 0XE4, 0XE4, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE2,
- 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE1, 0XE1, 0XE1, 0X0B, 0X0B,
- 0X0B, 0X31, 0X31, 0X35, 0X5D, 0X5D, 0X5D, 0X5D, 0XE4, 0XE4,
- 0XE4, 0XE4, 0XE4, 0XE4, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3,
- 0XE3, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE1, 0XE1, 0XE1,
- 0X0B, 0X0B, 0X31, 0X31, 0X31, 0X35, 0X16, 0X16, 0X5D, 0X5D,
- 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE3, 0XE3, 0XE3, 0XE3,
- 0XE3, 0XE3, 0XE3, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE1,
- 0XE1, 0XE1, 0X0F, 0X0F, 0X0F, 0X0F, 0X16, 0X16, 0X16, 0X16,
- 0X5B, 0X1F, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0, 0XDF, 0XDF,
- 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE,
- 0XDE, 0XDD, 0XDD, 0XDD, 0X5C, 0X0F, 0X0F, 0X0F, 0X16, 0X16,
- 0X16, 0X5B, 0X5B, 0X1F, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0,
- 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE,
- 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD, 0X5C, 0X0F, 0X0F, 0X0F,
- 0X16, 0X14, 0X14, 0X5B, 0X5B, 0X1F, 0X10, 0XE0, 0XE0, 0XE0,
- 0XE0, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE,
- 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD, 0X5C, 0X5C,
- 0X0F, 0X0F, 0X14, 0X14, 0X14, 0X5B, 0X1F, 0X1F, 0X10, 0X10,
- 0XE0, 0XE0, 0XE0, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF,
- 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD,
- 0X5C, 0X5C, 0X07, 0X07, 0X14, 0X14, 0X14, 0X5B, 0X1F, 0X10,
- 0X10, 0X10, 0XE0, 0XE0, 0XE0, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF,
- 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD,
- 0XDD, 0XDD, 0X5C, 0X07, 0X07, 0X07, 0X07, 0X14, 0X14, 0X11,
- 0X11, 0X10, 0X10, 0X6F, 0X29, 0X29, 0X29, 0X29, 0X29, 0XDF,
- 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE,
- 0XDE, 0XDD, 0XDD, 0XDD, 0X5A, 0X07, 0X07, 0X07, 0X07, 0X07,
- 0X59, 0X11, 0X11, 0X6F, 0X6F, 0X6F, 0X29, 0X29, 0X29, 0X29,
- 0X3E, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB,
- 0XDB, 0XDB, 0XDB, 0XDA, 0XDA, 0XDA, 0X5A, 0X5A, 0X07, 0X07,
- 0X07, 0X59, 0X59, 0X59, 0X6F, 0X6F, 0X6F, 0X6F, 0X29, 0X29,
- 0X3E, 0X3E, 0X3E, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB,
- 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDA, 0XDA, 0XDA, 0X5A, 0X5A,
- 0X5A, 0X5A, 0X59, 0X59, 0X59, 0X59, 0X59, 0X6F, 0X6F, 0X6F,
- 0X29, 0X3E, 0X3E, 0X3E, 0X3E, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC,
- 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDA, 0XDA, 0XDA,
- 0X5A, 0X5A, 0X5A, 0X5A, 0X59, 0X59, 0X59, 0X59, 0X59, 0X6F,
- 0X6F, 0X6F, 0X3E, 0X3E, 0X3E, 0X3E, 0X3E, 0XDC, 0XDC, 0XDC,
- 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDA,
- 0XDA, 0XDA, 0X5A, 0X5A, 0X5A, 0X5A, 0X59, 0X59, 0X59, 0X59,
- 0X59, 0X59, 0X6F, 0X58, 0X58, 0X3E, 0X3E, 0X3E, 0X3E, 0XDC,
- 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB,
- 0XDB, 0XDA, 0XDA, 0XDA, 0X5A, 0X5A, 0X5A, 0X5A, 0X59, 0X59,
- 0X59, 0X59, 0X59, 0X59, 0X58, 0X58, 0X58, 0X58, 0X3E, 0X3E,
- 0X6E, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB,
- 0XDB, 0XDB, 0XDB, 0XDA, 0XDA, 0XDA, 0XD9, 0XD9, 0XD9, 0XD9,
- 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0XD7,
- 0XD7, 0X6E, 0X6E, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD5,
- 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4, 0XD9, 0XD9,
- 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7,
- 0XD7, 0XD7, 0XD7, 0XD7, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6,
- 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4,
- 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8,
- 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD6, 0XD6, 0XD6, 0XD6,
- 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4,
- 0XD4, 0XD4, 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8,
- 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD6, 0XD6,
- 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5,
- 0XD5, 0XD4, 0XD4, 0XD4, 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8,
- 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7,
- 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5,
- 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4, 0XD9, 0XD9, 0XD9, 0XD9,
- 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0XD7,
- 0XD7, 0XD7, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD5,
- 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4, 0XD9, 0XD9,
- 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7,
- 0XD7, 0XD7, 0XD7, 0XD7, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6,
- 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4,
- 0XD3, 0XD3, 0XD3, 0XD3, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2,
- 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD0, 0XD0, 0XD0, 0XD0,
- 0XD0, 0XD0, 0XD0, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCE,
- 0XCE, 0XCE, 0XD3, 0XD3, 0XD3, 0XD3, 0XD2, 0XD2, 0XD2, 0XD2,
- 0XD2, 0XD2, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD0, 0XD0,
- 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF,
- 0XCF, 0XCE, 0XCE, 0XCE, 0XD3, 0XD3, 0XD3, 0XD3, 0XD2, 0XD2,
- 0XD2, 0XD2, 0XD2, 0XD2, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1,
- 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XCF, 0XCF, 0XCF,
- 0XCF, 0XCF, 0XCF, 0XCE, 0XCE, 0XCE, 0XD3, 0XD3, 0XD3, 0XD3,
- 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD1, 0XD1, 0XD1, 0XD1,
- 0XD1, 0XD1, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XCF,
- 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCE, 0XCE, 0XCE, 0XD3, 0XD3,
- 0XD3, 0XD3, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD1, 0XD1,
- 0XD1, 0XD1, 0XD1, 0XD1, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0,
- 0XD0, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCE, 0XCE, 0XCE,
- 0XD3, 0XD3, 0XD3, 0XD3, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2,
- 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD0, 0XD0, 0XD0, 0XD0,
- 0XD0, 0XD0, 0XD0, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCE,
- 0XCE, 0XCE, 0XCD, 0XCD, 0XCD, 0XCD, 0XCC, 0XCC, 0XCC, 0XCC,
- 0XCC, 0XCC, 0XCB, 0XCB, 0XCB, 0XCB, 0XCB, 0XCB, 0XCA, 0XCA,
- 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XC9, 0XC9, 0XC9, 0XC9, 0XC9,
- 0XC9, 0XC8, 0XC8, 0XC8, 0XCD, 0XCD, 0XCD, 0XCD, 0XCC, 0XCC,
- 0XCC, 0XCC, 0XCC, 0XCC, 0XCB, 0XCB, 0XCB, 0XCB, 0XCB, 0XCB,
- 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XC9, 0XC9, 0XC9,
- 0XC9, 0XC9, 0XC9, 0XC8, 0XC8, 0XC8, 0XCD, 0XCD, 0XCD, 0XCD,
- 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCB, 0XCB, 0XCB, 0XCB,
- 0XCB, 0XCB, 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XC9,
- 0XC9, 0XC9, 0XC9, 0XC9, 0XC9, 0XC8, 0XC8, 0XC8, 0X5E, 0X5E,
- 0X5E, 0X5E, 0X5D, 0X5D, 0X5D, 0X5D, 0X5D, 0X5D, 0XE4, 0XE4,
- 0XE4, 0XE4, 0XE4, 0XE4, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3,
- 0XE3, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE1, 0XE1, 0XE1,
- 0X5E, 0X5E, 0X5E, 0X35, 0X35, 0X5D, 0X5D, 0X5D, 0X5D, 0X5D,
- 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE3, 0XE3, 0XE3, 0XE3,
- 0XE3, 0XE3, 0XE3, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE1,
- 0XE1, 0XE1, 0X5E, 0X5E, 0X35, 0X35, 0X35, 0X35, 0X5D, 0X5D,
- 0X5D, 0X5D, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE3, 0XE3,
- 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2,
- 0XE2, 0XE1, 0XE1, 0XE1, 0X0B, 0X35, 0X35, 0X35, 0X35, 0X35,
- 0X35, 0X5D, 0X5D, 0X5D, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4,
- 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE2, 0XE2, 0XE2,
- 0XE2, 0XE2, 0XE2, 0XE1, 0XE1, 0XE1, 0X5C, 0X35, 0X35, 0X35,
- 0X35, 0X35, 0X14, 0X5B, 0X5B, 0X5B, 0XE0, 0XE0, 0XE0, 0XE0,
- 0XE0, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE,
- 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD, 0X5C, 0X5C,
- 0X0F, 0X35, 0X14, 0X14, 0X14, 0X5B, 0X5B, 0X5B, 0XE0, 0XE0,
- 0XE0, 0XE0, 0XE0, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF,
- 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD,
- 0X5C, 0X5C, 0X5C, 0X0F, 0X14, 0X14, 0X14, 0X5B, 0X5B, 0X5B,
- 0XE0, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF,
- 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD,
- 0XDD, 0XDD, 0X5C, 0X5C, 0X5C, 0X07, 0X14, 0X14, 0X14, 0X5B,
- 0X5B, 0X11, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0, 0XDF, 0XDF,
- 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE,
- 0XDE, 0XDD, 0XDD, 0XDD, 0X5C, 0X5C, 0X07, 0X07, 0X07, 0X14,
- 0X14, 0X5B, 0X11, 0X11, 0X11, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0,
- 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE,
- 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD, 0X5C, 0X07, 0X07, 0X07,
- 0X07, 0X14, 0X14, 0X11, 0X11, 0X11, 0X11, 0X6F, 0X29, 0X29,
- 0X29, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE,
- 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD, 0X5A, 0X07,
- 0X07, 0X07, 0X07, 0X07, 0X59, 0X11, 0X11, 0X11, 0X6F, 0X6F,
- 0X29, 0X29, 0X3E, 0X3E, 0X3E, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC,
- 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDA, 0XDA, 0XDA,
- 0X5A, 0X5A, 0X07, 0X07, 0X07, 0X59, 0X59, 0X59, 0X11, 0X11,
- 0X6F, 0X32, 0X32, 0X3E, 0X3E, 0X3E, 0X3E, 0XDC, 0XDC, 0XDC,
- 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDA,
- 0XDA, 0XDA, 0X5A, 0X5A, 0X5A, 0X5A, 0X59, 0X59, 0X59, 0X59,
- 0X59, 0X6F, 0X6F, 0X32, 0X32, 0X3E, 0X3E, 0X3E, 0X3E, 0XDC,
- 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB,
- 0XDB, 0XDA, 0XDA, 0XDA, 0X5A, 0X5A, 0X5A, 0X5A, 0X59, 0X59,
- 0X59, 0X59, 0X59, 0X59, 0X32, 0X58, 0X58, 0X3E, 0X3E, 0X3E,
- 0X3E, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB,
- 0XDB, 0XDB, 0XDB, 0XDA, 0XDA, 0XDA, 0X5A, 0X5A, 0X5A, 0X5A,
- 0X59, 0X59, 0X59, 0X59, 0X59, 0X59, 0X58, 0X58, 0X58, 0X58,
- 0X3E, 0X3E, 0X6E, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB,
- 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDA, 0XDA, 0XDA, 0X5A, 0X5A,
- 0X5A, 0X5A, 0X59, 0X59, 0X59, 0X59, 0X59, 0X59, 0X58, 0X58,
- 0X58, 0X58, 0X58, 0X6E, 0X6E, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC,
- 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDA, 0XDA, 0XDA,
- 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8,
- 0XD7, 0XD7, 0XD7, 0XD7, 0X6E, 0X6E, 0X6E, 0X6E, 0XD6, 0XD6,
- 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4,
- 0XD4, 0XD4, 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8,
- 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0X6E, 0XD6,
- 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5,
- 0XD5, 0XD4, 0XD4, 0XD4, 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8,
- 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7,
- 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5,
- 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4, 0XD9, 0XD9, 0XD9, 0XD9,
- 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0XD7,
- 0XD7, 0XD7, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD5,
- 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4, 0XD9, 0XD9,
- 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7,
- 0XD7, 0XD7, 0XD7, 0XD7, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6,
- 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4,
- 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8,
- 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD6, 0XD6, 0XD6, 0XD6,
- 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4,
- 0XD4, 0XD4, 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8,
- 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD6, 0XD6,
- 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5,
- 0XD5, 0XD4, 0XD4, 0XD4, 0XD3, 0XD3, 0XD3, 0XD3, 0XD2, 0XD2,
- 0XD2, 0XD2, 0XD2, 0XD2, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1,
- 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XCF, 0XCF, 0XCF,
- 0XCF, 0XCF, 0XCF, 0XCE, 0XCE, 0XCE, 0XD3, 0XD3, 0XD3, 0XD3,
- 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD1, 0XD1, 0XD1, 0XD1,
- 0XD1, 0XD1, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XCF,
- 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCE, 0XCE, 0XCE, 0XD3, 0XD3,
- 0XD3, 0XD3, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD1, 0XD1,
- 0XD1, 0XD1, 0XD1, 0XD1, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0,
- 0XD0, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCE, 0XCE, 0XCE,
- 0XD3, 0XD3, 0XD3, 0XD3, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2,
- 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD0, 0XD0, 0XD0, 0XD0,
- 0XD0, 0XD0, 0XD0, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCE,
- 0XCE, 0XCE, 0XD3, 0XD3, 0XD3, 0XD3, 0XD2, 0XD2, 0XD2, 0XD2,
- 0XD2, 0XD2, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD0, 0XD0,
- 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF,
- 0XCF, 0XCE, 0XCE, 0XCE, 0XD3, 0XD3, 0XD3, 0XD3, 0XD2, 0XD2,
- 0XD2, 0XD2, 0XD2, 0XD2, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1,
- 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XCF, 0XCF, 0XCF,
- 0XCF, 0XCF, 0XCF, 0XCE, 0XCE, 0XCE, 0XCD, 0XCD, 0XCD, 0XCD,
- 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCB, 0XCB, 0XCB, 0XCB,
- 0XCB, 0XCB, 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XC9,
- 0XC9, 0XC9, 0XC9, 0XC9, 0XC9, 0XC8, 0XC8, 0XC8, 0XCD, 0XCD,
- 0XCD, 0XCD, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCB, 0XCB,
- 0XCB, 0XCB, 0XCB, 0XCB, 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XCA,
- 0XCA, 0XC9, 0XC9, 0XC9, 0XC9, 0XC9, 0XC9, 0XC8, 0XC8, 0XC8,
- 0XCD, 0XCD, 0XCD, 0XCD, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC,
- 0XCB, 0XCB, 0XCB, 0XCB, 0XCB, 0XCB, 0XCA, 0XCA, 0XCA, 0XCA,
- 0XCA, 0XCA, 0XCA, 0XC9, 0XC9, 0XC9, 0XC9, 0XC9, 0XC9, 0XC8,
- 0XC8, 0XC8, 0X5E, 0X5E, 0X5E, 0X1B, 0X5D, 0X5D, 0X5D, 0X5D,
- 0X5D, 0X5D, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE3, 0XE3,
- 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2,
- 0XE2, 0XE1, 0XE1, 0XE1, 0X5E, 0X5E, 0X1B, 0X1B, 0X35, 0X5D,
- 0X5D, 0X5D, 0X5D, 0X5D, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4,
- 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE2, 0XE2, 0XE2,
- 0XE2, 0XE2, 0XE2, 0XE1, 0XE1, 0XE1, 0X5E, 0X1B, 0X1B, 0X35,
- 0X35, 0X35, 0X5D, 0X5D, 0X5D, 0X5D, 0XE4, 0XE4, 0XE4, 0XE4,
- 0XE4, 0XE4, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE2,
- 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE1, 0XE1, 0XE1, 0X1B, 0X1B,
- 0X1B, 0X35, 0X35, 0X35, 0X35, 0X5D, 0X5D, 0X5D, 0XE4, 0XE4,
- 0XE4, 0XE4, 0XE4, 0XE4, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3,
- 0XE3, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE1, 0XE1, 0XE1,
- 0X5C, 0X1B, 0X21, 0X21, 0X35, 0X35, 0X5B, 0X5B, 0X5B, 0X5B,
- 0XE0, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF,
- 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD,
- 0XDD, 0XDD, 0X5C, 0X5C, 0X21, 0X21, 0X21, 0X14, 0X5B, 0X5B,
- 0X5B, 0X5B, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0, 0XDF, 0XDF,
- 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE,
- 0XDE, 0XDD, 0XDD, 0XDD, 0X5C, 0X5C, 0X5C, 0X21, 0X14, 0X14,
- 0X5B, 0X5B, 0X5B, 0X5B, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0,
- 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE,
- 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD, 0X5C, 0X5C, 0X07, 0X07,
- 0X14, 0X14, 0X5B, 0X5B, 0X5B, 0X11, 0X11, 0XE0, 0XE0, 0XE0,
- 0XE0, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE,
- 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD, 0X5C, 0X07,
- 0X07, 0X07, 0X07, 0X14, 0X5B, 0X5B, 0X11, 0X11, 0X11, 0XE0,
- 0XE0, 0XE0, 0XE0, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF,
- 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD,
- 0X07, 0X07, 0X07, 0X07, 0X07, 0X07, 0X11, 0X11, 0X11, 0X11,
- 0X11, 0X11, 0X32, 0X32, 0XE0, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF,
- 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD,
- 0XDD, 0XDD, 0X07, 0X07, 0X07, 0X07, 0X07, 0X07, 0X11, 0X11,
- 0X11, 0X11, 0X11, 0X32, 0X32, 0X32, 0X32, 0X3E, 0X3E, 0XDC,
- 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB,
- 0XDB, 0XDA, 0XDA, 0XDA, 0X5A, 0X5A, 0X07, 0X07, 0X07, 0X59,
- 0X59, 0X59, 0X11, 0X11, 0X2B, 0X32, 0X32, 0X32, 0X3E, 0X3E,
- 0X3E, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB,
- 0XDB, 0XDB, 0XDB, 0XDA, 0XDA, 0XDA, 0X5A, 0X5A, 0X5A, 0X07,
- 0X59, 0X59, 0X59, 0X59, 0X59, 0X2B, 0X2B, 0X32, 0X32, 0X58,
- 0X3E, 0X3E, 0X3E, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB,
- 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDA, 0XDA, 0XDA, 0X5A, 0X5A,
- 0X5A, 0X5A, 0X59, 0X59, 0X59, 0X59, 0X59, 0X59, 0X2B, 0X2B,
- 0X58, 0X58, 0X58, 0X3E, 0X6E, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC,
- 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDA, 0XDA, 0XDA,
- 0X5A, 0X5A, 0X5A, 0X5A, 0X59, 0X59, 0X59, 0X59, 0X59, 0X59,
- 0X2B, 0X58, 0X58, 0X58, 0X15, 0X6E, 0X6E, 0XDC, 0XDC, 0XDC,
- 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDA,
- 0XDA, 0XDA, 0X5A, 0X5A, 0X5A, 0X5A, 0X59, 0X59, 0X59, 0X59,
- 0X59, 0X59, 0X2B, 0X58, 0X58, 0X15, 0X6E, 0X6E, 0X6E, 0X6E,
- 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB,
- 0XDB, 0XDA, 0XDA, 0XDA, 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8,
- 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7, 0X15, 0X15, 0X6E, 0X6E,
- 0X6E, 0X3B, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5,
- 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4, 0XD9, 0XD9, 0XD9, 0XD9,
- 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0XD7,
- 0XD7, 0X6E, 0X3B, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD5,
- 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4, 0XD9, 0XD9,
- 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7,
- 0XD7, 0XD7, 0XD7, 0XD7, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6,
- 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4,
- 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8,
- 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD6, 0XD6, 0XD6, 0XD6,
- 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4,
- 0XD4, 0XD4, 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8,
- 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD6, 0XD6,
- 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5,
- 0XD5, 0XD4, 0XD4, 0XD4, 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8,
- 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7,
- 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5,
- 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4, 0XD9, 0XD9, 0XD9, 0XD9,
- 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0XD7,
- 0XD7, 0XD7, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD5,
- 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4, 0XD3, 0XD3,
- 0XD3, 0XD3, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD1, 0XD1,
- 0XD1, 0XD1, 0XD1, 0XD1, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0,
- 0XD0, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCE, 0XCE, 0XCE,
- 0XD3, 0XD3, 0XD3, 0XD3, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2,
- 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD0, 0XD0, 0XD0, 0XD0,
- 0XD0, 0XD0, 0XD0, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCE,
- 0XCE, 0XCE, 0XD3, 0XD3, 0XD3, 0XD3, 0XD2, 0XD2, 0XD2, 0XD2,
- 0XD2, 0XD2, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD0, 0XD0,
- 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF,
- 0XCF, 0XCE, 0XCE, 0XCE, 0XD3, 0XD3, 0XD3, 0XD3, 0XD2, 0XD2,
- 0XD2, 0XD2, 0XD2, 0XD2, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1,
- 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XCF, 0XCF, 0XCF,
- 0XCF, 0XCF, 0XCF, 0XCE, 0XCE, 0XCE, 0XD3, 0XD3, 0XD3, 0XD3,
- 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD1, 0XD1, 0XD1, 0XD1,
- 0XD1, 0XD1, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XCF,
- 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCE, 0XCE, 0XCE, 0XD3, 0XD3,
- 0XD3, 0XD3, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD1, 0XD1,
- 0XD1, 0XD1, 0XD1, 0XD1, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0,
- 0XD0, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCE, 0XCE, 0XCE,
- 0XCD, 0XCD, 0XCD, 0XCD, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC,
- 0XCB, 0XCB, 0XCB, 0XCB, 0XCB, 0XCB, 0XCA, 0XCA, 0XCA, 0XCA,
- 0XCA, 0XCA, 0XCA, 0XC9, 0XC9, 0XC9, 0XC9, 0XC9, 0XC9, 0XC8,
- 0XC8, 0XC8, 0XCD, 0XCD, 0XCD, 0XCD, 0XCC, 0XCC, 0XCC, 0XCC,
- 0XCC, 0XCC, 0XCB, 0XCB, 0XCB, 0XCB, 0XCB, 0XCB, 0XCA, 0XCA,
- 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XC9, 0XC9, 0XC9, 0XC9, 0XC9,
- 0XC9, 0XC8, 0XC8, 0XC8, 0XCD, 0XCD, 0XCD, 0XCD, 0XCC, 0XCC,
- 0XCC, 0XCC, 0XCC, 0XCC, 0XCB, 0XCB, 0XCB, 0XCB, 0XCB, 0XCB,
- 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XC9, 0XC9, 0XC9,
- 0XC9, 0XC9, 0XC9, 0XC8, 0XC8, 0XC8, 0X5E, 0X5E, 0X5E, 0X1B,
- 0X5D, 0X5D, 0X5D, 0X5D, 0X5D, 0X5D, 0XE4, 0XE4, 0XE4, 0XE4,
- 0XE4, 0XE4, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE2,
- 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE1, 0XE1, 0XE1, 0X5E, 0X5E,
- 0X1B, 0X1B, 0X1B, 0X5D, 0X5D, 0X5D, 0X5D, 0X5D, 0XE4, 0XE4,
- 0XE4, 0XE4, 0XE4, 0XE4, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3,
- 0XE3, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE1, 0XE1, 0XE1,
- 0X1B, 0X1B, 0X1B, 0X1B, 0X1B, 0X35, 0X5D, 0X5D, 0X5D, 0X5D,
- 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE3, 0XE3, 0XE3, 0XE3,
- 0XE3, 0XE3, 0XE3, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE1,
- 0XE1, 0XE1, 0X1B, 0X1B, 0X1B, 0X1B, 0X21, 0X35, 0X35, 0X5D,
- 0X5D, 0X5D, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE3, 0XE3,
- 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2,
- 0XE2, 0XE1, 0XE1, 0XE1, 0X1B, 0X1B, 0X21, 0X21, 0X21, 0X21,
- 0X5B, 0X5B, 0X5B, 0X5B, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0,
- 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE,
- 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD, 0X5C, 0X5C, 0X21, 0X21,
- 0X21, 0X21, 0X5B, 0X5B, 0X5B, 0X5B, 0XE0, 0XE0, 0XE0, 0XE0,
- 0XE0, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE,
- 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD, 0X5C, 0X5C,
- 0X21, 0X21, 0X21, 0X14, 0X5B, 0X5B, 0X5B, 0X5B, 0XE0, 0XE0,
- 0XE0, 0XE0, 0XE0, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF,
- 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD,
- 0X5C, 0X5C, 0X07, 0X07, 0X14, 0X14, 0X5B, 0X5B, 0X5B, 0X11,
- 0X11, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF,
- 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD,
- 0XDD, 0XDD, 0X5C, 0X07, 0X07, 0X07, 0X07, 0X14, 0X5B, 0X5B,
- 0X11, 0X11, 0X11, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0, 0XDF, 0XDF,
- 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE,
- 0XDE, 0XDD, 0XDD, 0XDD, 0X07, 0X07, 0X07, 0X07, 0X07, 0X07,
- 0X11, 0X11, 0X11, 0X11, 0X11, 0X11, 0X32, 0X32, 0XE0, 0XE0,
- 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE,
- 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD, 0X07, 0X07, 0X07, 0X07,
- 0X07, 0X07, 0X11, 0X11, 0X11, 0X11, 0X11, 0X2B, 0X32, 0X32,
- 0X32, 0X3E, 0X3E, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB,
- 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDA, 0XDA, 0XDA, 0X5A, 0X5A,
- 0X07, 0X07, 0X07, 0X59, 0X59, 0X59, 0X11, 0X11, 0X2B, 0X2B,
- 0X2B, 0X32, 0X3E, 0X3E, 0X3E, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC,
- 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDA, 0XDA, 0XDA,
- 0X5A, 0X5A, 0X5A, 0X07, 0X59, 0X59, 0X59, 0X59, 0X59, 0X2B,
- 0X2B, 0X2B, 0X2B, 0X58, 0X58, 0X15, 0X15, 0XDC, 0XDC, 0XDC,
- 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDA,
- 0XDA, 0XDA, 0X5A, 0X5A, 0X5A, 0X5A, 0X59, 0X59, 0X59, 0X59,
- 0X59, 0X2B, 0X2B, 0X2B, 0X2B, 0X15, 0X15, 0X15, 0X6E, 0XDC,
- 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB,
- 0XDB, 0XDA, 0XDA, 0XDA, 0X5A, 0X5A, 0X5A, 0X5A, 0X59, 0X59,
- 0X59, 0X59, 0X59, 0X2B, 0X2B, 0X2B, 0X15, 0X15, 0X15, 0X6E,
- 0X6E, 0X6E, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB,
- 0XDB, 0XDB, 0XDB, 0XDA, 0XDA, 0XDA, 0X5A, 0X5A, 0X5A, 0X5A,
- 0X59, 0X59, 0X59, 0X59, 0X59, 0X59, 0X2B, 0X15, 0X15, 0X15,
- 0X6E, 0X6E, 0X6E, 0X3B, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB,
- 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDA, 0XDA, 0XDA, 0XD9, 0XD9,
- 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0X15, 0X15,
- 0X15, 0X6E, 0X6E, 0X6E, 0X3B, 0X3B, 0X2A, 0XD6, 0XD6, 0XD6,
- 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4,
- 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8,
- 0XD7, 0XD7, 0XD7, 0XD7, 0X39, 0X39, 0X39, 0X2A, 0XD6, 0XD6,
- 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4,
- 0XD4, 0XD4, 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8,
- 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0X39, 0X39, 0XD6,
- 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5,
- 0XD5, 0XD4, 0XD4, 0XD4, 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8,
- 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7,
- 0X39, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5,
- 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4, 0XD9, 0XD9, 0XD9, 0XD9,
- 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0XD7,
- 0XD7, 0XD7, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD5,
- 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4, 0XD9, 0XD9,
- 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7,
- 0XD7, 0XD7, 0XD7, 0XD7, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6,
- 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4,
- 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8,
- 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD6, 0XD6, 0XD6, 0XD6,
- 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4,
- 0XD4, 0XD4, 0XD3, 0XD3, 0XD3, 0XD3, 0XD2, 0XD2, 0XD2, 0XD2,
- 0XD2, 0XD2, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD0, 0XD0,
- 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF,
- 0XCF, 0XCE, 0XCE, 0XCE, 0XD3, 0XD3, 0XD3, 0XD3, 0XD2, 0XD2,
- 0XD2, 0XD2, 0XD2, 0XD2, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1,
- 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XCF, 0XCF, 0XCF,
- 0XCF, 0XCF, 0XCF, 0XCE, 0XCE, 0XCE, 0XD3, 0XD3, 0XD3, 0XD3,
- 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD1, 0XD1, 0XD1, 0XD1,
- 0XD1, 0XD1, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XCF,
- 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCE, 0XCE, 0XCE, 0XD3, 0XD3,
- 0XD3, 0XD3, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD1, 0XD1,
- 0XD1, 0XD1, 0XD1, 0XD1, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0,
- 0XD0, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCE, 0XCE, 0XCE,
- 0XD3, 0XD3, 0XD3, 0XD3, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2,
- 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD0, 0XD0, 0XD0, 0XD0,
- 0XD0, 0XD0, 0XD0, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCE,
- 0XCE, 0XCE, 0XD3, 0XD3, 0XD3, 0XD3, 0XD2, 0XD2, 0XD2, 0XD2,
- 0XD2, 0XD2, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD0, 0XD0,
- 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF,
- 0XCF, 0XCE, 0XCE, 0XCE, 0XCD, 0XCD, 0XCD, 0XCD, 0XCC, 0XCC,
- 0XCC, 0XCC, 0XCC, 0XCC, 0XCB, 0XCB, 0XCB, 0XCB, 0XCB, 0XCB,
- 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XC9, 0XC9, 0XC9,
- 0XC9, 0XC9, 0XC9, 0XC8, 0XC8, 0XC8, 0XCD, 0XCD, 0XCD, 0XCD,
- 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCB, 0XCB, 0XCB, 0XCB,
- 0XCB, 0XCB, 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XC9,
- 0XC9, 0XC9, 0XC9, 0XC9, 0XC9, 0XC8, 0XC8, 0XC8, 0XCD, 0XCD,
- 0XCD, 0XCD, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCB, 0XCB,
- 0XCB, 0XCB, 0XCB, 0XCB, 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XCA,
- 0XCA, 0XC9, 0XC9, 0XC9, 0XC9, 0XC9, 0XC9, 0XC8, 0XC8, 0XC8,
- 0X62, 0X62, 0X1B, 0X1B, 0X5D, 0X5D, 0X5D, 0X5D, 0X5D, 0X5D,
- 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE3, 0XE3, 0XE3, 0XE3,
- 0XE3, 0XE3, 0XE3, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE1,
- 0XE1, 0XE1, 0X62, 0X1B, 0X1B, 0X1B, 0X1B, 0X5D, 0X5D, 0X5D,
- 0X5D, 0X5D, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE3, 0XE3,
- 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE2, 0XE2, 0XE2, 0XE2, 0XE2,
- 0XE2, 0XE1, 0XE1, 0XE1, 0X1B, 0X1B, 0X1B, 0X1B, 0X1B, 0X1B,
- 0X5D, 0X5D, 0X5D, 0X5D, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4, 0XE4,
- 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE2, 0XE2, 0XE2,
- 0XE2, 0XE2, 0XE2, 0XE1, 0XE1, 0XE1, 0X1B, 0X1B, 0X1B, 0X1B,
- 0X21, 0X21, 0X21, 0X5D, 0X5D, 0X5D, 0XE4, 0XE4, 0XE4, 0XE4,
- 0XE4, 0XE4, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE3, 0XE2,
- 0XE2, 0XE2, 0XE2, 0XE2, 0XE2, 0XE1, 0XE1, 0XE1, 0X1B, 0X1B,
- 0X1B, 0X21, 0X21, 0X21, 0X21, 0X5B, 0X5B, 0X5B, 0XE0, 0XE0,
- 0XE0, 0XE0, 0XE0, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF,
- 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD,
- 0X5C, 0X21, 0X21, 0X21, 0X21, 0X21, 0X5B, 0X5B, 0X5B, 0X5B,
- 0XE0, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF,
- 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD,
- 0XDD, 0XDD, 0X5C, 0X5C, 0X21, 0X21, 0X21, 0X5B, 0X5B, 0X5B,
- 0X5B, 0X5B, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0, 0XDF, 0XDF,
- 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE,
- 0XDE, 0XDD, 0XDD, 0XDD, 0X5C, 0X5C, 0X07, 0X07, 0X14, 0X5B,
- 0X5B, 0X5B, 0X5B, 0X11, 0X11, 0XE0, 0XE0, 0XE0, 0XE0, 0XE0,
- 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE, 0XDE, 0XDE,
- 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD, 0X5C, 0X07, 0X07, 0X07,
- 0X07, 0X5B, 0X5B, 0X11, 0X11, 0X11, 0X11, 0XE0, 0XE0, 0XE0,
- 0XE0, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDE,
- 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD, 0X07, 0X07,
- 0X07, 0X07, 0X07, 0X07, 0X11, 0X11, 0X11, 0X11, 0X11, 0X2B,
- 0X2B, 0X32, 0XE0, 0XE0, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF, 0XDF,
- 0XDF, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDE, 0XDD, 0XDD, 0XDD,
- 0X07, 0X07, 0X07, 0X07, 0X07, 0X07, 0X11, 0X11, 0X11, 0X11,
- 0X11, 0X2B, 0X2B, 0X2B, 0X32, 0X32, 0X15, 0XDC, 0XDC, 0XDC,
- 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDA,
- 0XDA, 0XDA, 0X5A, 0X5A, 0X07, 0X07, 0X07, 0X59, 0X59, 0X59,
- 0X11, 0X11, 0X2B, 0X2B, 0X2B, 0X2B, 0X15, 0X15, 0X15, 0XDC,
- 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB,
- 0XDB, 0XDA, 0XDA, 0XDA, 0X5A, 0X5A, 0X5A, 0X07, 0X59, 0X59,
- 0X59, 0X59, 0X59, 0X2B, 0X2B, 0X2B, 0X2B, 0X15, 0X15, 0X15,
- 0X15, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB,
- 0XDB, 0XDB, 0XDB, 0XDA, 0XDA, 0XDA, 0X5A, 0X5A, 0X5A, 0X5A,
- 0X59, 0X59, 0X59, 0X59, 0X59, 0X2B, 0X2B, 0X2B, 0X2B, 0X15,
- 0X15, 0X15, 0X6E, 0X6E, 0XDC, 0XDC, 0XDC, 0XDC, 0XDC, 0XDB,
- 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDA, 0XDA, 0XDA, 0X5A, 0X5A,
- 0X5A, 0X5A, 0X59, 0X59, 0X59, 0X59, 0X59, 0X2B, 0X2B, 0X2B,
- 0X15, 0X15, 0X15, 0X6E, 0X6E, 0X3B, 0XDC, 0XDC, 0XDC, 0XDC,
- 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDA, 0XDA, 0XDA,
- 0X5A, 0X5A, 0X5A, 0X5A, 0X59, 0X59, 0X59, 0X59, 0X59, 0X2B,
- 0X2B, 0X15, 0X15, 0X15, 0X6E, 0X6E, 0X3B, 0X3B, 0X3B, 0XDC,
- 0XDC, 0XDC, 0XDC, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDB, 0XDA,
- 0XDA, 0XDA, 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8,
- 0XD8, 0XD8, 0X15, 0X15, 0X15, 0X6E, 0X6E, 0X3B, 0X3B, 0X3B,
- 0X2A, 0X2A, 0X2A, 0X2A, 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5,
- 0XD5, 0XD4, 0XD4, 0XD4, 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8,
- 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0X39, 0X39, 0X39,
- 0X39, 0X2A, 0X2A, 0X2A, 0X2A, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5,
- 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4, 0XD9, 0XD9, 0XD9, 0XD9,
- 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0XD7,
- 0X39, 0X39, 0X39, 0X2A, 0X2A, 0X2A, 0XD6, 0XD6, 0XD6, 0XD5,
- 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4, 0XD9, 0XD9,
- 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7,
- 0XD7, 0XD7, 0XD7, 0X39, 0X2A, 0X2A, 0X2A, 0XD6, 0XD6, 0XD6,
- 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4,
- 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8, 0XD8,
- 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0X2A, 0X2A, 0XD6, 0XD6,
- 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5, 0XD4,
- 0XD4, 0XD4, 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8, 0XD8, 0XD8,
- 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0X2A, 0XD6,
- 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5, 0XD5, 0XD5,
- 0XD5, 0XD4, 0XD4, 0XD4, 0XD9, 0XD9, 0XD9, 0XD9, 0XD8, 0XD8,
- 0XD8, 0XD8, 0XD8, 0XD8, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7, 0XD7,
- 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD6, 0XD5, 0XD5, 0XD5,
- 0XD5, 0XD5, 0XD5, 0XD4, 0XD4, 0XD4, 0XD3, 0XD3, 0XD3, 0XD3,
- 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD1, 0XD1, 0XD1, 0XD1,
- 0XD1, 0XD1, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XCF,
- 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCE, 0XCE, 0XCE, 0XD3, 0XD3,
- 0XD3, 0XD3, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD1, 0XD1,
- 0XD1, 0XD1, 0XD1, 0XD1, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0,
- 0XD0, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCE, 0XCE, 0XCE,
- 0XD3, 0XD3, 0XD3, 0XD3, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2,
- 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD0, 0XD0, 0XD0, 0XD0,
- 0XD0, 0XD0, 0XD0, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCE,
- 0XCE, 0XCE, 0XD3, 0XD3, 0XD3, 0XD3, 0XD2, 0XD2, 0XD2, 0XD2,
- 0XD2, 0XD2, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD0, 0XD0,
- 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XCF, 0XCF, 0XCF, 0XCF, 0XCF,
- 0XCF, 0XCE, 0XCE, 0XCE, 0XD3, 0XD3, 0XD3, 0XD3, 0XD2, 0XD2,
- 0XD2, 0XD2, 0XD2, 0XD2, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1, 0XD1,
- 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XCF, 0XCF, 0XCF,
- 0XCF, 0XCF, 0XCF, 0XCE, 0XCE, 0XCE, 0XD3, 0XD3, 0XD3, 0XD3,
- 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD2, 0XD1, 0XD1, 0XD1, 0XD1,
- 0XD1, 0XD1, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XD0, 0XCF,
- 0XCF, 0XCF, 0XCF, 0XCF, 0XCF, 0XCE, 0XCE, 0XCE, 0XCD, 0XCD,
- 0XCD, 0XCD, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCB, 0XCB,
- 0XCB, 0XCB, 0XCB, 0XCB, 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XCA,
- 0XCA, 0XC9, 0XC9, 0XC9, 0XC9, 0XC9, 0XC9, 0XC8, 0XC8, 0XC8,
- 0XCD, 0XCD, 0XCD, 0XCD, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC, 0XCC,
- 0XCB, 0XCB, 0XCB, 0XCB, 0XCB, 0XCB, 0XCA, 0XCA, 0XCA, 0XCA,
- 0XCA, 0XCA, 0XCA, 0XC9, 0XC9, 0XC9, 0XC9, 0XC9, 0XC9, 0XC8,
- 0XC8, 0XC8, 0XCD, 0XCD, 0XCD, 0XCD, 0XCC, 0XCC, 0XCC, 0XCC,
- 0XCC, 0XCC, 0XCB, 0XCB, 0XCB, 0XCB, 0XCB, 0XCB, 0XCA, 0XCA,
- 0XCA, 0XCA, 0XCA, 0XCA, 0XCA, 0XC9, 0XC9, 0XC9, 0XC9, 0XC9,
- 0XC9, 0XC8, 0XC8, 0XC8, 0X62, 0X62, 0X62, 0X62, 0X1B, 0X57,
- 0X57, 0X57, 0X57, 0X57, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6,
- 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC4, 0XC4, 0XC4,
- 0XC4, 0XC4, 0XC4, 0XC3, 0XC3, 0XC3, 0X62, 0X62, 0X62, 0X1B,
- 0X1B, 0X57, 0X57, 0X57, 0X57, 0X57, 0XC6, 0XC6, 0XC6, 0XC6,
- 0XC6, 0XC6, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC4,
- 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC3, 0XC3, 0XC3, 0X62, 0X1B,
- 0X1B, 0X1B, 0X1B, 0X0A, 0X57, 0X57, 0X57, 0X57, 0XC6, 0XC6,
- 0XC6, 0XC6, 0XC6, 0XC6, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5,
- 0XC5, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC3, 0XC3, 0XC3,
- 0X1B, 0X1B, 0X1B, 0X1B, 0X0A, 0X0A, 0X0A, 0X0A, 0X57, 0X57,
- 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC5, 0XC5, 0XC5, 0XC5,
- 0XC5, 0XC5, 0XC5, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC3,
- 0XC3, 0XC3, 0X1B, 0X1B, 0X1B, 0X0A, 0X0A, 0X0A, 0X0A, 0X0A,
- 0X55, 0X55, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1,
- 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0,
- 0XC0, 0XBF, 0XBF, 0XBF, 0X56, 0X21, 0X0A, 0X0A, 0X0A, 0X0A,
- 0X0A, 0X55, 0X55, 0X55, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2,
- 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0,
- 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF, 0X56, 0X56, 0X0A, 0X0A,
- 0X0A, 0X0A, 0X55, 0X55, 0X55, 0X55, 0XC2, 0XC2, 0XC2, 0XC2,
- 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0,
- 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF, 0X56, 0X56,
- 0X0A, 0X0A, 0X0A, 0X0A, 0X3C, 0X3C, 0X3C, 0X11, 0X11, 0XC2,
- 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1,
- 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF,
- 0X56, 0X07, 0X07, 0X07, 0X07, 0X3C, 0X3C, 0X3C, 0X11, 0X11,
- 0X11, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1,
- 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF,
- 0XBF, 0XBF, 0X07, 0X07, 0X07, 0X07, 0X07, 0X3C, 0X3C, 0X11,
- 0X11, 0X11, 0X11, 0X2B, 0X2B, 0X2B, 0XC2, 0XC2, 0XC1, 0XC1,
- 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0,
- 0XC0, 0XBF, 0XBF, 0XBF, 0X07, 0X07, 0X07, 0X07, 0X07, 0X0C,
- 0X11, 0X11, 0X11, 0X11, 0X2B, 0X2B, 0X2B, 0X2B, 0X2B, 0X15,
- 0X15, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD,
- 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC, 0X54, 0X54, 0X07, 0X0C,
- 0X0C, 0X0C, 0X53, 0X53, 0X11, 0X2B, 0X2B, 0X2B, 0X2B, 0X2B,
- 0X15, 0X15, 0X15, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD,
- 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC, 0X54, 0X54,
- 0X0C, 0X0C, 0X0C, 0X0C, 0X53, 0X53, 0X53, 0X2B, 0X2B, 0X2B,
- 0X08, 0X08, 0X15, 0X15, 0X6E, 0X3B, 0XBE, 0XBE, 0XBE, 0XBE,
- 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC,
- 0X54, 0X54, 0X0C, 0X0C, 0X0C, 0X0C, 0X53, 0X53, 0X53, 0X2B,
- 0X2B, 0X08, 0X08, 0X15, 0X15, 0X15, 0X3B, 0X3B, 0XBE, 0XBE,
- 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC,
- 0XBC, 0XBC, 0X54, 0X54, 0X0C, 0X0C, 0X0C, 0X0C, 0X53, 0X53,
- 0X53, 0X2B, 0X08, 0X08, 0X15, 0X15, 0X15, 0X3B, 0X3B, 0X3B,
- 0X3B, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD,
- 0XBD, 0XBC, 0XBC, 0XBC, 0X54, 0X54, 0X54, 0X0C, 0X0C, 0X0C,
- 0X53, 0X53, 0X53, 0X08, 0X08, 0X08, 0X15, 0X15, 0X3B, 0X3B,
- 0X3B, 0X3B, 0X6D, 0X2A, 0X2A, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD,
- 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC, 0XBB, 0XBB, 0XBB, 0X0C,
- 0X0C, 0X51, 0X51, 0X51, 0X51, 0X08, 0X08, 0X15, 0X15, 0X39,
- 0X39, 0X39, 0X39, 0X6D, 0X2A, 0X2A, 0X2A, 0X2A, 0X2A, 0XB9,
- 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB,
- 0XBB, 0XBB, 0X51, 0X51, 0X51, 0X51, 0X51, 0X51, 0XBA, 0XBA,
- 0X39, 0X39, 0X39, 0X39, 0X39, 0X2A, 0X2A, 0X2A, 0X2A, 0X2A,
- 0X50, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8,
- 0XBB, 0XBB, 0XBB, 0XBB, 0X51, 0X51, 0X51, 0X51, 0X51, 0X51,
- 0XBA, 0XBA, 0XBA, 0X39, 0X39, 0X39, 0X2A, 0X2A, 0X2A, 0X2A,
- 0X2A, 0X50, 0X02, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8,
- 0XB8, 0XB8, 0XBB, 0XBB, 0XBB, 0XBB, 0X51, 0X51, 0X51, 0X51,
- 0X51, 0X51, 0XBA, 0XBA, 0XBA, 0XBA, 0X39, 0X39, 0X2A, 0X2A,
- 0X2A, 0X2A, 0X50, 0X02, 0X02, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9,
- 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB, 0XBB, 0XBB, 0X51, 0X51,
- 0X51, 0X51, 0X51, 0X51, 0XBA, 0XBA, 0XBA, 0XBA, 0XBA, 0X2A,
- 0X2A, 0X2A, 0X2A, 0X50, 0X02, 0X02, 0X02, 0XB9, 0XB9, 0XB9,
- 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB, 0XBB, 0XBB,
- 0X51, 0X51, 0X51, 0X51, 0X51, 0X51, 0XBA, 0XBA, 0XBA, 0XBA,
- 0XBA, 0XBA, 0X2A, 0X2A, 0X50, 0X02, 0X02, 0X02, 0X02, 0XB9,
- 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB,
- 0XBB, 0XBB, 0X51, 0X51, 0X51, 0X51, 0X51, 0X51, 0XBA, 0XBA,
- 0XBA, 0XBA, 0XBA, 0XBA, 0X2A, 0X50, 0X02, 0X02, 0X02, 0X02,
- 0X02, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8,
- 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6,
- 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4,
- 0XB4, 0XB4, 0XB4, 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0XB3,
- 0XB3, 0XB3, 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6,
- 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4,
- 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0X4F, 0X4F, 0X4F, 0X4F, 0X4F,
- 0X4F, 0XB3, 0XB3, 0XB3, 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6,
- 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5,
- 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0X4F, 0X4F, 0X4F,
- 0X4F, 0X4F, 0X4F, 0XB3, 0XB3, 0XB3, 0XB7, 0XB7, 0XB7, 0XB7,
- 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5,
- 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0X4F,
- 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0XB3, 0XB3, 0XB3, 0XB7, 0XB7,
- 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5,
- 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4,
- 0XB4, 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0XB3, 0XB3, 0XB3,
- 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6,
- 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4,
- 0XB4, 0XB4, 0XB4, 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0XB3,
- 0XB3, 0XB3, 0XB2, 0XB2, 0XB2, 0XB2, 0XB1, 0XB1, 0XB1, 0XB1,
- 0XB1, 0XB1, 0XB0, 0XB0, 0XB0, 0XB0, 0XB0, 0XB0, 0XAF, 0XAF,
- 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAE, 0XAE, 0XAE, 0XAE, 0XAE,
- 0XAE, 0XAD, 0XAD, 0XAD, 0XB2, 0XB2, 0XB2, 0XB2, 0XB1, 0XB1,
- 0XB1, 0XB1, 0XB1, 0XB1, 0XB0, 0XB0, 0XB0, 0XB0, 0XB0, 0XB0,
- 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAE, 0XAE, 0XAE,
- 0XAE, 0XAE, 0XAE, 0XAD, 0XAD, 0XAD, 0XB2, 0XB2, 0XB2, 0XB2,
- 0XB1, 0XB1, 0XB1, 0XB1, 0XB1, 0XB1, 0XB0, 0XB0, 0XB0, 0XB0,
- 0XB0, 0XB0, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAE,
- 0XAE, 0XAE, 0XAE, 0XAE, 0XAE, 0XAD, 0XAD, 0XAD, 0X62, 0X62,
- 0X62, 0X62, 0X57, 0X57, 0X57, 0X57, 0X57, 0X57, 0XC6, 0XC6,
- 0XC6, 0XC6, 0XC6, 0XC6, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5,
- 0XC5, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC3, 0XC3, 0XC3,
- 0X62, 0X62, 0X62, 0X62, 0X57, 0X57, 0X57, 0X57, 0X57, 0X57,
- 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC5, 0XC5, 0XC5, 0XC5,
- 0XC5, 0XC5, 0XC5, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC3,
- 0XC3, 0XC3, 0X62, 0X62, 0X62, 0X0A, 0X0A, 0X0A, 0X57, 0X57,
- 0X57, 0X57, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC5, 0XC5,
- 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4,
- 0XC4, 0XC3, 0XC3, 0XC3, 0X62, 0X0A, 0X0A, 0X0A, 0X0A, 0X0A,
- 0X0A, 0X57, 0X57, 0X57, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6,
- 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC4, 0XC4, 0XC4,
- 0XC4, 0XC4, 0XC4, 0XC3, 0XC3, 0XC3, 0X56, 0X0A, 0X0A, 0X0A,
- 0X0A, 0X0A, 0X0A, 0X55, 0X55, 0X55, 0XC2, 0XC2, 0XC2, 0XC2,
- 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0,
- 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF, 0X56, 0X56,
- 0X0A, 0X0A, 0X0A, 0X0A, 0X0A, 0X55, 0X55, 0X55, 0XC2, 0XC2,
- 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1,
- 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF,
- 0X56, 0X56, 0X0A, 0X0A, 0X0A, 0X0A, 0X55, 0X55, 0X55, 0X55,
- 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1,
- 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF,
- 0XBF, 0XBF, 0X56, 0X56, 0X56, 0X0A, 0X0A, 0X55, 0X3C, 0X3C,
- 0X3C, 0X3C, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1,
- 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0,
- 0XC0, 0XBF, 0XBF, 0XBF, 0X56, 0X56, 0X56, 0X0A, 0X3C, 0X3C,
- 0X3C, 0X3C, 0X3C, 0X3C, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2,
- 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0,
- 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF, 0X56, 0X56, 0X07, 0X0C,
- 0X3C, 0X3C, 0X3C, 0X3C, 0X3C, 0X3C, 0X11, 0XC2, 0XC2, 0XC2,
- 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0,
- 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF, 0X54, 0X54,
- 0X0C, 0X0C, 0X0C, 0X0C, 0X3C, 0X3C, 0X3C, 0X11, 0X08, 0X08,
- 0X08, 0X08, 0X08, 0X52, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE,
- 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC,
- 0X54, 0X54, 0X0C, 0X0C, 0X0C, 0X0C, 0X53, 0X53, 0X53, 0X08,
- 0X08, 0X08, 0X08, 0X08, 0X08, 0X52, 0XBE, 0XBE, 0XBE, 0XBE,
- 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC,
- 0XBC, 0XBC, 0X54, 0X54, 0X0C, 0X0C, 0X0C, 0X0C, 0X53, 0X53,
- 0X53, 0X08, 0X08, 0X08, 0X08, 0X08, 0X08, 0X52, 0X3B, 0XBE,
- 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD,
- 0XBD, 0XBC, 0XBC, 0XBC, 0X54, 0X54, 0X0C, 0X0C, 0X0C, 0X0C,
- 0X53, 0X53, 0X53, 0X08, 0X08, 0X08, 0X08, 0X08, 0X08, 0X3B,
- 0X3B, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD,
- 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC, 0X54, 0X54, 0X54, 0X0C,
- 0X0C, 0X0C, 0X53, 0X53, 0X53, 0X08, 0X08, 0X08, 0X08, 0X08,
- 0X3B, 0X3B, 0X3B, 0X3B, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD,
- 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC, 0X54, 0X54,
- 0X54, 0X0C, 0X0C, 0X53, 0X53, 0X53, 0X53, 0X08, 0X08, 0X08,
- 0X08, 0X08, 0X3B, 0X3B, 0X3B, 0X6D, 0X6D, 0X6D, 0XBE, 0XBE,
- 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC,
- 0XBB, 0XBB, 0XBB, 0X0C, 0X0C, 0X51, 0X51, 0X51, 0X51, 0X08,
- 0X08, 0X08, 0X39, 0X39, 0X39, 0X39, 0X6D, 0X6D, 0X6D, 0X2A,
- 0X2A, 0X2A, 0X50, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8,
- 0XB8, 0XB8, 0XBB, 0XBB, 0XBB, 0XBB, 0X51, 0X51, 0X51, 0X51,
- 0X51, 0X51, 0XBA, 0XBA, 0XBA, 0X39, 0X39, 0X39, 0X6D, 0X6D,
- 0X2A, 0X2A, 0X2A, 0X50, 0X50, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9,
- 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB, 0XBB, 0XBB, 0X51, 0X51,
- 0X51, 0X51, 0X51, 0X51, 0XBA, 0XBA, 0XBA, 0XBA, 0X39, 0X39,
- 0X6D, 0X2A, 0X2A, 0X2A, 0X50, 0X50, 0X02, 0XB9, 0XB9, 0XB9,
- 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB, 0XBB, 0XBB,
- 0X51, 0X51, 0X51, 0X51, 0X51, 0X51, 0XBA, 0XBA, 0XBA, 0XBA,
- 0XBA, 0X6D, 0X2A, 0X2A, 0X2A, 0X50, 0X50, 0X02, 0X02, 0XB9,
- 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB,
- 0XBB, 0XBB, 0X51, 0X51, 0X51, 0X51, 0X51, 0X51, 0XBA, 0XBA,
- 0XBA, 0XBA, 0XBA, 0XBA, 0X2A, 0X2A, 0X50, 0X50, 0X02, 0X02,
- 0X02, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8,
- 0XBB, 0XBB, 0XBB, 0XBB, 0X51, 0X51, 0X51, 0X51, 0X51, 0X51,
- 0XBA, 0XBA, 0XBA, 0XBA, 0XBA, 0XBA, 0X2A, 0X50, 0X50, 0X02,
- 0X02, 0X02, 0X02, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8,
- 0XB8, 0XB8, 0XBB, 0XBB, 0XBB, 0XBB, 0X51, 0X51, 0X51, 0X51,
- 0X51, 0X51, 0XBA, 0XBA, 0XBA, 0XBA, 0XBA, 0XBA, 0X50, 0X50,
- 0X02, 0X02, 0X02, 0X02, 0X02, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9,
- 0XB9, 0XB8, 0XB8, 0XB8, 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6,
- 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5,
- 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0X4F, 0X4F, 0X4F,
- 0X4F, 0X4F, 0X4F, 0XB3, 0XB3, 0XB3, 0XB7, 0XB7, 0XB7, 0XB7,
- 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5,
- 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0X4F,
- 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0XB3, 0XB3, 0XB3, 0XB7, 0XB7,
- 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5,
- 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4,
- 0XB4, 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0XB3, 0XB3, 0XB3,
- 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6,
- 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4,
- 0XB4, 0XB4, 0XB4, 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0XB3,
- 0XB3, 0XB3, 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6,
- 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4,
- 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0X4F, 0X4F, 0X4F, 0X4F, 0X4F,
- 0X4F, 0XB3, 0XB3, 0XB3, 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6,
- 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5,
- 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0X4F, 0X4F, 0X4F,
- 0X4F, 0X4F, 0X4F, 0XB3, 0XB3, 0XB3, 0XB2, 0XB2, 0XB2, 0XB2,
- 0XB1, 0XB1, 0XB1, 0XB1, 0XB1, 0XB1, 0XB0, 0XB0, 0XB0, 0XB0,
- 0XB0, 0XB0, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAE,
- 0XAE, 0XAE, 0XAE, 0XAE, 0XAE, 0XAD, 0XAD, 0XAD, 0XB2, 0XB2,
- 0XB2, 0XB2, 0XB1, 0XB1, 0XB1, 0XB1, 0XB1, 0XB1, 0XB0, 0XB0,
- 0XB0, 0XB0, 0XB0, 0XB0, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF,
- 0XAF, 0XAE, 0XAE, 0XAE, 0XAE, 0XAE, 0XAE, 0XAD, 0XAD, 0XAD,
- 0XB2, 0XB2, 0XB2, 0XB2, 0XB1, 0XB1, 0XB1, 0XB1, 0XB1, 0XB1,
- 0XB0, 0XB0, 0XB0, 0XB0, 0XB0, 0XB0, 0XAF, 0XAF, 0XAF, 0XAF,
- 0XAF, 0XAF, 0XAF, 0XAE, 0XAE, 0XAE, 0XAE, 0XAE, 0XAE, 0XAD,
- 0XAD, 0XAD, 0X62, 0X62, 0X62, 0X62, 0X57, 0X57, 0X57, 0X57,
- 0X57, 0X57, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC5, 0XC5,
- 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4,
- 0XC4, 0XC3, 0XC3, 0XC3, 0X62, 0X62, 0X62, 0X62, 0X57, 0X57,
- 0X57, 0X57, 0X57, 0X57, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6,
- 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC4, 0XC4, 0XC4,
- 0XC4, 0XC4, 0XC4, 0XC3, 0XC3, 0XC3, 0X62, 0X62, 0X0A, 0X0A,
- 0X0A, 0X57, 0X57, 0X57, 0X57, 0X57, 0XC6, 0XC6, 0XC6, 0XC6,
- 0XC6, 0XC6, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC4,
- 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC3, 0XC3, 0XC3, 0X62, 0X0A,
- 0X0A, 0X0A, 0X0A, 0X0A, 0X0A, 0X57, 0X57, 0X57, 0XC6, 0XC6,
- 0XC6, 0XC6, 0XC6, 0XC6, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5,
- 0XC5, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC3, 0XC3, 0XC3,
- 0X56, 0X0A, 0X0A, 0X0A, 0X0A, 0X0A, 0X0A, 0X55, 0X55, 0X55,
- 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1,
- 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF,
- 0XBF, 0XBF, 0X56, 0X56, 0X0A, 0X0A, 0X0A, 0X0A, 0X55, 0X55,
- 0X55, 0X55, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1,
- 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0,
- 0XC0, 0XBF, 0XBF, 0XBF, 0X56, 0X56, 0X0A, 0X0A, 0X0A, 0X55,
- 0X55, 0X55, 0X55, 0X55, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2,
- 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0,
- 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF, 0X56, 0X56, 0X56, 0X0A,
- 0X0A, 0X55, 0X3C, 0X3C, 0X3C, 0X3C, 0XC2, 0XC2, 0XC2, 0XC2,
- 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0,
- 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF, 0X56, 0X56,
- 0X56, 0X0A, 0X3C, 0X3C, 0X3C, 0X3C, 0X3C, 0X3C, 0XC2, 0XC2,
- 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1,
- 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF,
- 0X56, 0X56, 0X56, 0X0C, 0X3C, 0X3C, 0X3C, 0X3C, 0X3C, 0X3C,
- 0X3C, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1,
- 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF,
- 0XBF, 0XBF, 0X54, 0X54, 0X0C, 0X0C, 0X0C, 0X0C, 0X3C, 0X3C,
- 0X3C, 0X3C, 0X08, 0X08, 0X08, 0X08, 0X52, 0X52, 0XBE, 0XBE,
- 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD,
- 0XBD, 0XBC, 0XBC, 0XBC, 0X54, 0X54, 0X0C, 0X0C, 0X0C, 0X0C,
- 0X53, 0X53, 0X53, 0X53, 0X08, 0X08, 0X08, 0X08, 0X52, 0X52,
- 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD,
- 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC, 0X54, 0X54, 0X0C, 0X0C,
- 0X0C, 0X0C, 0X53, 0X53, 0X53, 0X53, 0X08, 0X08, 0X08, 0X08,
- 0X52, 0X52, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD,
- 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC, 0X54, 0X54,
- 0X0C, 0X0C, 0X0C, 0X0C, 0X53, 0X53, 0X53, 0X53, 0X08, 0X08,
- 0X08, 0X08, 0X52, 0X52, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE,
- 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC,
- 0X54, 0X54, 0X54, 0X0C, 0X0C, 0X0C, 0X53, 0X53, 0X53, 0X53,
- 0X08, 0X08, 0X08, 0X08, 0X52, 0X34, 0X34, 0X34, 0XBE, 0XBE,
- 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC,
- 0XBC, 0XBC, 0X54, 0X54, 0X54, 0X0C, 0X0C, 0X53, 0X53, 0X53,
- 0X53, 0X53, 0X08, 0X08, 0X08, 0X08, 0X34, 0X34, 0X34, 0X34,
- 0X6D, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD,
- 0XBD, 0XBC, 0XBC, 0XBC, 0XBB, 0XBB, 0XBB, 0X0C, 0X26, 0X51,
- 0X51, 0X51, 0X51, 0X51, 0X08, 0X08, 0X08, 0X39, 0X34, 0X34,
- 0X34, 0X34, 0X6D, 0X6D, 0X6D, 0X50, 0X50, 0XB9, 0XB9, 0XB9,
- 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB, 0XBB, 0XBB,
- 0X51, 0X51, 0X51, 0X51, 0X51, 0X51, 0XBA, 0XBA, 0XBA, 0XBA,
- 0X34, 0X34, 0X34, 0X6D, 0X6D, 0X6D, 0X50, 0X50, 0X50, 0XB9,
- 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB,
- 0XBB, 0XBB, 0X51, 0X51, 0X51, 0X51, 0X51, 0X51, 0XBA, 0XBA,
- 0XBA, 0XBA, 0XBA, 0X34, 0X6D, 0X6D, 0X6D, 0X50, 0X50, 0X50,
- 0X02, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8,
- 0XBB, 0XBB, 0XBB, 0XBB, 0X51, 0X51, 0X51, 0X51, 0X51, 0X51,
- 0XBA, 0XBA, 0XBA, 0XBA, 0XBA, 0XBA, 0X6D, 0X6D, 0X50, 0X50,
- 0X50, 0X02, 0X02, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8,
- 0XB8, 0XB8, 0XBB, 0XBB, 0XBB, 0XBB, 0X51, 0X51, 0X51, 0X51,
- 0X51, 0X51, 0XBA, 0XBA, 0XBA, 0XBA, 0XBA, 0XBA, 0X6D, 0X50,
- 0X50, 0X50, 0X02, 0X02, 0X02, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9,
- 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB, 0XBB, 0XBB, 0X51, 0X51,
- 0X51, 0X51, 0X51, 0X51, 0XBA, 0XBA, 0XBA, 0XBA, 0XBA, 0XBA,
- 0X50, 0X50, 0X50, 0X02, 0X02, 0X02, 0X02, 0XB9, 0XB9, 0XB9,
- 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB, 0XBB, 0XBB,
- 0X51, 0X51, 0X51, 0X51, 0X51, 0X51, 0XBA, 0XBA, 0XBA, 0XBA,
- 0XBA, 0XBA, 0X50, 0X50, 0X02, 0X02, 0X02, 0X02, 0X02, 0X2C,
- 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8, 0XB7, 0XB7,
- 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5,
- 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4,
- 0X6C, 0X2C, 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0XB3, 0XB3, 0XB3,
- 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6,
- 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4,
- 0XB4, 0XB4, 0XB4, 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0XB3,
- 0XB3, 0XB3, 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6,
- 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4,
- 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0X4F, 0X4F, 0X4F, 0X4F, 0X4F,
- 0X4F, 0XB3, 0XB3, 0XB3, 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6,
- 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5,
- 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0X4F, 0X4F, 0X4F,
- 0X4F, 0X4F, 0X4F, 0XB3, 0XB3, 0XB3, 0XB7, 0XB7, 0XB7, 0XB7,
- 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5,
- 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0X4F,
- 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0XB3, 0XB3, 0XB3, 0XB7, 0XB7,
- 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5,
- 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4,
- 0XB4, 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0XB3, 0XB3, 0XB3,
- 0XB2, 0XB2, 0XB2, 0XB2, 0XB1, 0XB1, 0XB1, 0XB1, 0XB1, 0XB1,
- 0XB0, 0XB0, 0XB0, 0XB0, 0XB0, 0XB0, 0XAF, 0XAF, 0XAF, 0XAF,
- 0XAF, 0XAF, 0XAF, 0XAE, 0XAE, 0XAE, 0XAE, 0XAE, 0XAE, 0XAD,
- 0XAD, 0XAD, 0XB2, 0XB2, 0XB2, 0XB2, 0XB1, 0XB1, 0XB1, 0XB1,
- 0XB1, 0XB1, 0XB0, 0XB0, 0XB0, 0XB0, 0XB0, 0XB0, 0XAF, 0XAF,
- 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAE, 0XAE, 0XAE, 0XAE, 0XAE,
- 0XAE, 0XAD, 0XAD, 0XAD, 0XB2, 0XB2, 0XB2, 0XB2, 0XB1, 0XB1,
- 0XB1, 0XB1, 0XB1, 0XB1, 0XB0, 0XB0, 0XB0, 0XB0, 0XB0, 0XB0,
- 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAE, 0XAE, 0XAE,
- 0XAE, 0XAE, 0XAE, 0XAD, 0XAD, 0XAD, 0XC7, 0XC7, 0XC7, 0XC7,
- 0X57, 0X57, 0X57, 0X57, 0X57, 0X57, 0XC6, 0XC6, 0XC6, 0XC6,
- 0XC6, 0XC6, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC4,
- 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC3, 0XC3, 0XC3, 0XC7, 0XC7,
- 0XC7, 0XC7, 0X57, 0X57, 0X57, 0X57, 0X57, 0X57, 0XC6, 0XC6,
- 0XC6, 0XC6, 0XC6, 0XC6, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5,
- 0XC5, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC3, 0XC3, 0XC3,
- 0XC7, 0XC7, 0XC7, 0X0A, 0X0A, 0X57, 0X57, 0X57, 0X57, 0X57,
- 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC5, 0XC5, 0XC5, 0XC5,
- 0XC5, 0XC5, 0XC5, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC3,
- 0XC3, 0XC3, 0XC7, 0XC7, 0X0A, 0X0A, 0X0A, 0X0A, 0X57, 0X57,
- 0X57, 0X57, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC5, 0XC5,
- 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4,
- 0XC4, 0XC3, 0XC3, 0XC3, 0X56, 0X56, 0X0A, 0X0A, 0X0A, 0X0A,
- 0X55, 0X55, 0X55, 0X55, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2,
- 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0,
- 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF, 0X56, 0X56, 0X0A, 0X0A,
- 0X0A, 0X0A, 0X55, 0X55, 0X55, 0X55, 0XC2, 0XC2, 0XC2, 0XC2,
- 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0,
- 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF, 0X56, 0X56,
- 0X56, 0X0A, 0X0A, 0X55, 0X55, 0X55, 0X55, 0X55, 0XC2, 0XC2,
- 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1,
- 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF,
- 0X56, 0X56, 0X56, 0X0A, 0X55, 0X55, 0X55, 0X3C, 0X3C, 0X3C,
- 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1,
- 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF,
- 0XBF, 0XBF, 0X56, 0X56, 0X56, 0X56, 0X3C, 0X3C, 0X3C, 0X3C,
- 0X3C, 0X3C, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1,
- 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0,
- 0XC0, 0XBF, 0XBF, 0XBF, 0X56, 0X56, 0X56, 0X0C, 0X3C, 0X3C,
- 0X3C, 0X3C, 0X3C, 0X3C, 0X3C, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2,
- 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0,
- 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF, 0X54, 0X54, 0X0C, 0X0C,
- 0X0C, 0X0C, 0X3C, 0X3C, 0X3C, 0X3C, 0X08, 0X08, 0X52, 0X52,
- 0X52, 0X52, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD,
- 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC, 0X54, 0X54,
- 0X0C, 0X0C, 0X0C, 0X0C, 0X53, 0X53, 0X53, 0X53, 0X08, 0X08,
- 0X52, 0X52, 0X52, 0X52, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE,
- 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC,
- 0X54, 0X54, 0X0C, 0X0C, 0X0C, 0X0C, 0X53, 0X53, 0X53, 0X53,
- 0X08, 0X08, 0X52, 0X52, 0X52, 0X52, 0XBE, 0XBE, 0XBE, 0XBE,
- 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC,
- 0XBC, 0XBC, 0X54, 0X54, 0X54, 0X0C, 0X0C, 0X0C, 0X53, 0X53,
- 0X53, 0X53, 0X08, 0X08, 0X52, 0X52, 0X52, 0X52, 0XBE, 0XBE,
- 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD,
- 0XBD, 0XBC, 0XBC, 0XBC, 0X54, 0X54, 0X54, 0X0C, 0X0C, 0X53,
- 0X53, 0X53, 0X53, 0X53, 0X08, 0X08, 0X52, 0X52, 0X52, 0X34,
- 0X34, 0X34, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD,
- 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC, 0X54, 0X54, 0X54, 0X0C,
- 0X0C, 0X53, 0X53, 0X53, 0X53, 0X53, 0X08, 0X08, 0X52, 0X52,
- 0X34, 0X34, 0X34, 0X34, 0X34, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD,
- 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC, 0XBB, 0XBB,
- 0XBB, 0X26, 0X26, 0X26, 0X26, 0X51, 0X51, 0X51, 0X08, 0X08,
- 0XBA, 0X34, 0X34, 0X34, 0X34, 0X34, 0X34, 0X6D, 0X50, 0X50,
- 0X50, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8,
- 0XBB, 0XBB, 0XBB, 0X26, 0X26, 0X51, 0X51, 0X51, 0X51, 0X51,
- 0XBA, 0XBA, 0XBA, 0XBA, 0X34, 0X34, 0X34, 0X34, 0X34, 0X50,
- 0X50, 0X50, 0X50, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8,
- 0XB8, 0XB8, 0XBB, 0XBB, 0XBB, 0XBB, 0X51, 0X51, 0X51, 0X51,
- 0X51, 0X51, 0XBA, 0XBA, 0XBA, 0XBA, 0XBA, 0X34, 0X34, 0X34,
- 0X50, 0X50, 0X50, 0X50, 0X02, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9,
- 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB, 0XBB, 0XBB, 0X51, 0X51,
- 0X51, 0X51, 0X51, 0X51, 0XBA, 0XBA, 0XBA, 0XBA, 0XBA, 0XBA,
- 0X34, 0X50, 0X50, 0X50, 0X50, 0X02, 0X02, 0XB9, 0XB9, 0XB9,
- 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB, 0XBB, 0XBB,
- 0X51, 0X51, 0X51, 0X51, 0X51, 0X51, 0XBA, 0XBA, 0XBA, 0XBA,
- 0XBA, 0XBA, 0X50, 0X50, 0X50, 0X50, 0X02, 0X02, 0X02, 0XB9,
- 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB,
- 0XBB, 0XBB, 0X51, 0X51, 0X51, 0X51, 0X51, 0X51, 0XBA, 0XBA,
- 0XBA, 0XBA, 0XBA, 0XBA, 0X50, 0X50, 0X50, 0X02, 0X02, 0X02,
- 0X6C, 0X6C, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8,
- 0XBB, 0XBB, 0XBB, 0XBB, 0X51, 0X51, 0X51, 0X51, 0X51, 0X51,
- 0XBA, 0XBA, 0XBA, 0XBA, 0XBA, 0XBA, 0X50, 0X50, 0X02, 0X02,
- 0X02, 0X6C, 0X6C, 0X2C, 0X2C, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8,
- 0XB8, 0XB8, 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6,
- 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4,
- 0XB4, 0XB4, 0XB4, 0X6C, 0X2C, 0X2C, 0X2C, 0X4F, 0X4F, 0X4F,
- 0X4F, 0XB3, 0XB3, 0XB3, 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6,
- 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5,
- 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0X2C, 0X2C, 0X4F, 0X4F,
- 0X4F, 0X4F, 0X4F, 0XB3, 0XB3, 0XB3, 0XB7, 0XB7, 0XB7, 0XB7,
- 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5,
- 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0X4F,
- 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0XB3, 0XB3, 0XB3, 0XB7, 0XB7,
- 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5,
- 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4,
- 0XB4, 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0XB3, 0XB3, 0XB3,
- 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6,
- 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4,
- 0XB4, 0XB4, 0XB4, 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0XB3,
- 0XB3, 0XB3, 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6,
- 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4,
- 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0X4F, 0X4F, 0X4F, 0X4F, 0X4F,
- 0X4F, 0XB3, 0XB3, 0XB3, 0XB2, 0XB2, 0XB2, 0XB2, 0XB1, 0XB1,
- 0XB1, 0XB1, 0XB1, 0XB1, 0XB0, 0XB0, 0XB0, 0XB0, 0XB0, 0XB0,
- 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAE, 0XAE, 0XAE,
- 0XAE, 0XAE, 0XAE, 0XAD, 0XAD, 0XAD, 0XB2, 0XB2, 0XB2, 0XB2,
- 0XB1, 0XB1, 0XB1, 0XB1, 0XB1, 0XB1, 0XB0, 0XB0, 0XB0, 0XB0,
- 0XB0, 0XB0, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAE,
- 0XAE, 0XAE, 0XAE, 0XAE, 0XAE, 0XAD, 0XAD, 0XAD, 0XB2, 0XB2,
- 0XB2, 0XB2, 0XB1, 0XB1, 0XB1, 0XB1, 0XB1, 0XB1, 0XB0, 0XB0,
- 0XB0, 0XB0, 0XB0, 0XB0, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF,
- 0XAF, 0XAE, 0XAE, 0XAE, 0XAE, 0XAE, 0XAE, 0XAD, 0XAD, 0XAD,
- 0XC7, 0XC7, 0XC7, 0XC7, 0X57, 0X57, 0X57, 0X57, 0X57, 0X57,
- 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC5, 0XC5, 0XC5, 0XC5,
- 0XC5, 0XC5, 0XC5, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC3,
- 0XC3, 0XC3, 0XC7, 0XC7, 0XC7, 0XC7, 0X57, 0X57, 0X57, 0X57,
- 0X57, 0X57, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC5, 0XC5,
- 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4,
- 0XC4, 0XC3, 0XC3, 0XC3, 0XC7, 0XC7, 0XC7, 0X0A, 0X57, 0X57,
- 0X57, 0X57, 0X57, 0X57, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6,
- 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC4, 0XC4, 0XC4,
- 0XC4, 0XC4, 0XC4, 0XC3, 0XC3, 0XC3, 0XC7, 0XC7, 0X0A, 0X0A,
- 0X0A, 0X0A, 0X57, 0X57, 0X57, 0X57, 0XC6, 0XC6, 0XC6, 0XC6,
- 0XC6, 0XC6, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC4,
- 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC3, 0XC3, 0XC3, 0X56, 0X56,
- 0X0A, 0X0A, 0X0A, 0X0A, 0X55, 0X55, 0X55, 0X55, 0XC2, 0XC2,
- 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1,
- 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF,
- 0X56, 0X56, 0X56, 0X0A, 0X0A, 0X55, 0X55, 0X55, 0X55, 0X55,
- 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1,
- 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF,
- 0XBF, 0XBF, 0X56, 0X56, 0X56, 0X0A, 0X55, 0X55, 0X55, 0X55,
- 0X55, 0X55, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1,
- 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0,
- 0XC0, 0XBF, 0XBF, 0XBF, 0X56, 0X56, 0X56, 0X56, 0X55, 0X55,
- 0X55, 0X3C, 0X3C, 0X3C, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2,
- 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0,
- 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF, 0X56, 0X56, 0X56, 0X56,
- 0X3C, 0X3C, 0X3C, 0X3C, 0X3C, 0X3C, 0XC2, 0XC2, 0XC2, 0XC2,
- 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0,
- 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF, 0X56, 0X56,
- 0X56, 0X0C, 0X3C, 0X3C, 0X3C, 0X3C, 0X3C, 0X3C, 0X3C, 0XC2,
- 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1,
- 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF,
- 0X54, 0X54, 0X0C, 0X0C, 0X0C, 0X0C, 0X3C, 0X3C, 0X3C, 0X3C,
- 0X52, 0X52, 0X52, 0X52, 0X52, 0X52, 0XBE, 0XBE, 0XBE, 0XBE,
- 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC,
- 0XBC, 0XBC, 0X54, 0X54, 0X0C, 0X0C, 0X0C, 0X0C, 0X53, 0X53,
- 0X53, 0X53, 0X52, 0X52, 0X52, 0X52, 0X52, 0X52, 0XBE, 0XBE,
- 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD,
- 0XBD, 0XBC, 0XBC, 0XBC, 0X54, 0X54, 0X54, 0X0C, 0X0C, 0X0C,
- 0X53, 0X53, 0X53, 0X53, 0X52, 0X52, 0X52, 0X52, 0X52, 0X52,
- 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD,
- 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC, 0X54, 0X54, 0X54, 0X0C,
- 0X0C, 0X53, 0X53, 0X53, 0X53, 0X53, 0X52, 0X52, 0X52, 0X52,
- 0X52, 0X52, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD,
- 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC, 0X54, 0X54,
- 0X54, 0X0C, 0X0C, 0X53, 0X53, 0X53, 0X53, 0X53, 0X52, 0X52,
- 0X52, 0X52, 0X52, 0X34, 0X34, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE,
- 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC,
- 0X54, 0X54, 0X54, 0X26, 0X26, 0X26, 0X26, 0X53, 0X53, 0X53,
- 0X52, 0X52, 0X52, 0X52, 0X34, 0X34, 0X34, 0X34, 0X34, 0XBE,
- 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC,
- 0XBC, 0XBC, 0XBB, 0XBB, 0X26, 0X26, 0X26, 0X26, 0X26, 0X26,
- 0X26, 0X51, 0XBA, 0XBA, 0XBA, 0X34, 0X34, 0X34, 0X34, 0X34,
- 0X34, 0X34, 0X50, 0X50, 0X50, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9,
- 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB, 0XBB, 0X26, 0X26, 0X26,
- 0X26, 0X51, 0X51, 0X51, 0XBA, 0XBA, 0XBA, 0XBA, 0X34, 0X34,
- 0X34, 0X34, 0X34, 0X50, 0X50, 0X50, 0X02, 0XB9, 0XB9, 0XB9,
- 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB, 0XBB, 0X26,
- 0X26, 0X51, 0X51, 0X51, 0X51, 0X51, 0XBA, 0XBA, 0XBA, 0XBA,
- 0XBA, 0X34, 0X34, 0X34, 0X50, 0X50, 0X50, 0X02, 0X02, 0XB9,
- 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB,
- 0XBB, 0XBB, 0X51, 0X51, 0X51, 0X51, 0X51, 0X51, 0XBA, 0XBA,
- 0XBA, 0XBA, 0XBA, 0XBA, 0X34, 0X50, 0X50, 0X50, 0X02, 0X02,
- 0X02, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8,
- 0XBB, 0XBB, 0XBB, 0XBB, 0X51, 0X51, 0X51, 0X51, 0X51, 0X51,
- 0XBA, 0XBA, 0XBA, 0XBA, 0XBA, 0XBA, 0X50, 0X50, 0X50, 0X02,
- 0X02, 0X02, 0X6C, 0X6C, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8,
- 0XB8, 0XB8, 0XBB, 0XBB, 0XBB, 0XBB, 0X51, 0X51, 0X51, 0X51,
- 0X51, 0X51, 0XBA, 0XBA, 0XBA, 0XBA, 0XBA, 0XBA, 0X50, 0X50,
- 0X02, 0X02, 0X02, 0X6C, 0X6C, 0X6C, 0XB9, 0XB9, 0XB9, 0XB9,
- 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB, 0XBB, 0XBB, 0X51, 0X51,
- 0X51, 0X51, 0X51, 0X51, 0XBA, 0XBA, 0XBA, 0XBA, 0XBA, 0XBA,
- 0X50, 0X02, 0X02, 0X02, 0X6C, 0X6C, 0X6C, 0X2C, 0X2C, 0X2C,
- 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8, 0XB7, 0XB7, 0XB7, 0XB7,
- 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5,
- 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4, 0X6C, 0X6C, 0X2C, 0X2C,
- 0X2C, 0X36, 0X36, 0X4F, 0X4F, 0XB3, 0XB3, 0XB3, 0XB7, 0XB7,
- 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5,
- 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4,
- 0X2C, 0X2C, 0X36, 0X36, 0X4F, 0X4F, 0X4F, 0XB3, 0XB3, 0XB3,
- 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6,
- 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4,
- 0XB4, 0XB4, 0X2C, 0X36, 0X36, 0X4F, 0X4F, 0X4F, 0X4F, 0XB3,
- 0XB3, 0XB3, 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6,
- 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4,
- 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0X36, 0X4F, 0X4F, 0X4F, 0X4F,
- 0X4F, 0XB3, 0XB3, 0XB3, 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6,
- 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5,
- 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0X4F, 0X4F, 0X4F,
- 0X4F, 0X4F, 0X4F, 0XB3, 0XB3, 0XB3, 0XB7, 0XB7, 0XB7, 0XB7,
- 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5,
- 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0X4F,
- 0X4F, 0X4F, 0X4F, 0X4F, 0X4F, 0XB3, 0XB3, 0XB3, 0XB2, 0XB2,
- 0XB2, 0XB2, 0XB1, 0XB1, 0XB1, 0XB1, 0XB1, 0XB1, 0XB0, 0XB0,
- 0XB0, 0XB0, 0XB0, 0XB0, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF,
- 0XAF, 0XAE, 0XAE, 0XAE, 0XAE, 0XAE, 0XAE, 0XAD, 0XAD, 0XAD,
- 0XB2, 0XB2, 0XB2, 0XB2, 0XB1, 0XB1, 0XB1, 0XB1, 0XB1, 0XB1,
- 0XB0, 0XB0, 0XB0, 0XB0, 0XB0, 0XB0, 0XAF, 0XAF, 0XAF, 0XAF,
- 0XAF, 0XAF, 0XAF, 0XAE, 0XAE, 0XAE, 0XAE, 0XAE, 0XAE, 0XAD,
- 0XAD, 0XAD, 0XB2, 0XB2, 0XB2, 0XB2, 0XB1, 0XB1, 0XB1, 0XB1,
- 0XB1, 0XB1, 0XB0, 0XB0, 0XB0, 0XB0, 0XB0, 0XB0, 0XAF, 0XAF,
- 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAE, 0XAE, 0XAE, 0XAE, 0XAE,
- 0XAE, 0XAD, 0XAD, 0XAD, 0XC7, 0XC7, 0XC7, 0XC7, 0X57, 0X57,
- 0X57, 0X57, 0X57, 0X57, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6,
- 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC4, 0XC4, 0XC4,
- 0XC4, 0XC4, 0XC4, 0XC3, 0XC3, 0XC3, 0XC7, 0XC7, 0XC7, 0XC7,
- 0X57, 0X57, 0X57, 0X57, 0X57, 0X57, 0XC6, 0XC6, 0XC6, 0XC6,
- 0XC6, 0XC6, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC4,
- 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC3, 0XC3, 0XC3, 0XC7, 0XC7,
- 0XC7, 0XC7, 0X57, 0X57, 0X57, 0X57, 0X57, 0X57, 0XC6, 0XC6,
- 0XC6, 0XC6, 0XC6, 0XC6, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5,
- 0XC5, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC3, 0XC3, 0XC3,
- 0XC7, 0XC7, 0X0A, 0X0A, 0X0A, 0X57, 0X57, 0X57, 0X57, 0X57,
- 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC5, 0XC5, 0XC5, 0XC5,
- 0XC5, 0XC5, 0XC5, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC3,
- 0XC3, 0XC3, 0X56, 0X56, 0X56, 0X0A, 0X0A, 0X55, 0X55, 0X55,
- 0X55, 0X55, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1,
- 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0,
- 0XC0, 0XBF, 0XBF, 0XBF, 0X56, 0X56, 0X56, 0X0A, 0X3F, 0X55,
- 0X55, 0X55, 0X55, 0X55, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2,
- 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0,
- 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF, 0X56, 0X56, 0X56, 0X3F,
- 0X3F, 0X3F, 0X55, 0X55, 0X55, 0X55, 0XC2, 0XC2, 0XC2, 0XC2,
- 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0,
- 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF, 0X56, 0X56,
- 0X56, 0X3F, 0X3F, 0X3F, 0X3F, 0X55, 0X3C, 0X3C, 0XC2, 0XC2,
- 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1,
- 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF,
- 0X56, 0X56, 0X56, 0X3F, 0X3F, 0X3F, 0X3F, 0X3C, 0X3C, 0X3C,
- 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1,
- 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF,
- 0XBF, 0XBF, 0X56, 0X56, 0X56, 0X3F, 0X3F, 0X3F, 0X3F, 0X3C,
- 0X3C, 0X3C, 0X3C, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1,
- 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0,
- 0XC0, 0XBF, 0XBF, 0XBF, 0X54, 0X54, 0X0C, 0X0C, 0X0C, 0X3F,
- 0X3F, 0X3C, 0X3C, 0X3C, 0X52, 0X52, 0X52, 0X52, 0X52, 0X52,
- 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD,
- 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC, 0X54, 0X54, 0X54, 0X0C,
- 0X0C, 0X0C, 0X53, 0X53, 0X53, 0X53, 0X52, 0X52, 0X52, 0X52,
- 0X52, 0X52, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD,
- 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC, 0X54, 0X54,
- 0X54, 0X0C, 0X0C, 0X53, 0X53, 0X53, 0X53, 0X53, 0X52, 0X52,
- 0X52, 0X52, 0X52, 0X52, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE,
- 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC,
- 0X54, 0X54, 0X54, 0X0C, 0X0C, 0X53, 0X53, 0X53, 0X53, 0X53,
- 0X52, 0X52, 0X52, 0X52, 0X52, 0X52, 0XBE, 0XBE, 0XBE, 0XBE,
- 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC,
- 0XBC, 0XBC, 0X54, 0X54, 0X54, 0X26, 0X26, 0X26, 0X53, 0X53,
- 0X53, 0X53, 0X52, 0X52, 0X52, 0X52, 0X52, 0X52, 0X34, 0XBE,
- 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD,
- 0XBD, 0XBC, 0XBC, 0XBC, 0X54, 0X54, 0X26, 0X26, 0X26, 0X26,
- 0X26, 0X26, 0X26, 0X53, 0X52, 0X52, 0X52, 0X52, 0X34, 0X34,
- 0X34, 0X34, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD,
- 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC, 0XBB, 0XBB, 0X26, 0X26,
- 0X26, 0X26, 0X26, 0X26, 0X26, 0X19, 0X19, 0XBA, 0XBA, 0XBA,
- 0X34, 0X34, 0X34, 0X34, 0X34, 0X50, 0X50, 0X50, 0X50, 0XB9,
- 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB,
- 0X26, 0X26, 0X26, 0X26, 0X26, 0X26, 0X26, 0X19, 0X19, 0XBA,
- 0XBA, 0XBA, 0X34, 0X34, 0X34, 0X34, 0X34, 0X50, 0X50, 0X50,
- 0X02, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8,
- 0XBB, 0XBB, 0XBB, 0X26, 0X26, 0X26, 0X26, 0X51, 0X51, 0X19,
- 0XBA, 0XBA, 0XBA, 0XBA, 0XBA, 0X34, 0X34, 0X34, 0X50, 0X50,
- 0X50, 0X02, 0X02, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8,
- 0XB8, 0XB8, 0XBB, 0XBB, 0XBB, 0XBB, 0X51, 0X51, 0X51, 0X51,
- 0X51, 0X51, 0XBA, 0XBA, 0XBA, 0XBA, 0XBA, 0XBA, 0X34, 0X50,
- 0X50, 0X50, 0X02, 0X02, 0X6C, 0X6C, 0XB9, 0XB9, 0XB9, 0XB9,
- 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB, 0XBB, 0XBB, 0X51, 0X51,
- 0X51, 0X51, 0X51, 0X51, 0XBA, 0XBA, 0XBA, 0XBA, 0XBA, 0XBA,
- 0X50, 0X50, 0X50, 0X02, 0X02, 0X6C, 0X6C, 0X6C, 0XB9, 0XB9,
- 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB, 0XBB, 0XBB,
- 0X51, 0X51, 0X51, 0X51, 0X51, 0X51, 0XBA, 0XBA, 0XBA, 0XBA,
- 0XBA, 0XBA, 0X50, 0X50, 0X02, 0X02, 0X6C, 0X6C, 0X6C, 0X6C,
- 0X2C, 0X2C, 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB,
- 0XBB, 0XBB, 0X51, 0X51, 0X51, 0X51, 0X51, 0X51, 0XBA, 0XBA,
- 0XBA, 0XBA, 0XBA, 0XBA, 0X50, 0X02, 0X02, 0X6C, 0X6C, 0X6C,
- 0X6C, 0X2C, 0X2C, 0X2C, 0X2C, 0X36, 0XB9, 0XB8, 0XB8, 0XB8,
- 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6,
- 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0X6C,
- 0X6C, 0X6C, 0X2C, 0X2C, 0X2C, 0X36, 0X36, 0X36, 0X36, 0XB3,
- 0XB3, 0XB3, 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6,
- 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4,
- 0XB4, 0XB4, 0XB4, 0X2C, 0X2C, 0X2C, 0X36, 0X36, 0X36, 0X36,
- 0X18, 0XB3, 0XB3, 0XB3, 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6,
- 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5,
- 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0X2C, 0X36, 0X36, 0X36,
- 0X36, 0X36, 0X18, 0XB3, 0XB3, 0XB3, 0XB7, 0XB7, 0XB7, 0XB7,
- 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5,
- 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0X36, 0X36,
- 0X36, 0X36, 0X36, 0X18, 0X18, 0XB3, 0XB3, 0XB3, 0XB7, 0XB7,
- 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5,
- 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4,
- 0X36, 0X36, 0X36, 0X36, 0X4F, 0X18, 0X18, 0XB3, 0XB3, 0XB3,
- 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6,
- 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4,
- 0XB4, 0XB4, 0XB4, 0X36, 0X36, 0X4F, 0X4F, 0X18, 0X18, 0X38,
- 0XB3, 0XB3, 0XB2, 0XB2, 0XB2, 0XB2, 0XB1, 0XB1, 0XB1, 0XB1,
- 0XB1, 0XB1, 0XB0, 0XB0, 0XB0, 0XB0, 0XB0, 0XB0, 0XAF, 0XAF,
- 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAE, 0XAE, 0XAE, 0XAE, 0XAE,
- 0X38, 0X38, 0XAD, 0XAD, 0XB2, 0XB2, 0XB2, 0XB2, 0XB1, 0XB1,
- 0XB1, 0XB1, 0XB1, 0XB1, 0XB0, 0XB0, 0XB0, 0XB0, 0XB0, 0XB0,
- 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAE, 0XAE, 0XAE,
- 0XAE, 0XAE, 0XAE, 0XAD, 0XAD, 0XAD, 0XB2, 0XB2, 0XB2, 0XB2,
- 0XB1, 0XB1, 0XB1, 0XB1, 0XB1, 0XB1, 0XB0, 0XB0, 0XB0, 0XB0,
- 0XB0, 0XB0, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAE,
- 0XAE, 0XAE, 0XAE, 0XAE, 0XAE, 0XAD, 0XAD, 0XAD, 0XC7, 0XC7,
- 0XC7, 0XC7, 0X57, 0X57, 0X57, 0X57, 0X57, 0X57, 0XC6, 0XC6,
- 0XC6, 0XC6, 0XC6, 0XC6, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5,
- 0XC5, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC3, 0XC3, 0XC3,
- 0XC7, 0XC7, 0XC7, 0XC7, 0X57, 0X57, 0X57, 0X57, 0X57, 0X57,
- 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC5, 0XC5, 0XC5, 0XC5,
- 0XC5, 0XC5, 0XC5, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4, 0XC3,
- 0XC3, 0XC3, 0XC7, 0XC7, 0XC7, 0XC7, 0X57, 0X57, 0X57, 0X57,
- 0X57, 0X57, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC5, 0XC5,
- 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC4, 0XC4, 0XC4, 0XC4, 0XC4,
- 0XC4, 0XC3, 0XC3, 0XC3, 0XC7, 0XC7, 0XC7, 0X0A, 0X0A, 0X57,
- 0X57, 0X57, 0X57, 0X57, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6, 0XC6,
- 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC5, 0XC4, 0XC4, 0XC4,
- 0XC4, 0XC4, 0XC4, 0XC3, 0XC3, 0XC3, 0X56, 0X56, 0X56, 0X3F,
- 0X3F, 0X3F, 0X3F, 0X55, 0X55, 0X55, 0XC2, 0XC2, 0XC2, 0XC2,
- 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0,
- 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF, 0X56, 0X56,
- 0X56, 0X3F, 0X3F, 0X3F, 0X3F, 0X3F, 0X55, 0X55, 0XC2, 0XC2,
- 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1,
- 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF,
- 0X56, 0X56, 0X56, 0X3F, 0X3F, 0X3F, 0X3F, 0X3F, 0X3F, 0X55,
- 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1,
- 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF,
- 0XBF, 0XBF, 0X56, 0X56, 0X3F, 0X3F, 0X3F, 0X3F, 0X3F, 0X3F,
- 0X3F, 0X3F, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC1, 0XC1,
- 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0, 0XC0, 0XC0,
- 0XC0, 0XBF, 0XBF, 0XBF, 0X56, 0X56, 0X3F, 0X3F, 0X3F, 0X3F,
- 0X3F, 0X3F, 0X3F, 0X3F, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2, 0XC2,
- 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0, 0XC0, 0XC0,
- 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF, 0X56, 0X56, 0X3F, 0X3F,
- 0X3F, 0X3F, 0X3F, 0X3F, 0X27, 0X27, 0X27, 0XC2, 0XC2, 0XC2,
- 0XC2, 0XC2, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC1, 0XC0,
- 0XC0, 0XC0, 0XC0, 0XC0, 0XC0, 0XBF, 0XBF, 0XBF, 0X54, 0X54,
- 0X3F, 0X3F, 0X3F, 0X3F, 0X27, 0X27, 0X27, 0X27, 0X27, 0X52,
- 0X52, 0X52, 0X52, 0X52, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE,
- 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC,
- 0X54, 0X54, 0X54, 0X0C, 0X0C, 0X27, 0X27, 0X27, 0X27, 0X27,
- 0X27, 0X52, 0X52, 0X52, 0X52, 0X52, 0XBE, 0XBE, 0XBE, 0XBE,
- 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC,
- 0XBC, 0XBC, 0X54, 0X54, 0X54, 0X0C, 0X0C, 0X53, 0X53, 0X53,
- 0X27, 0X27, 0X52, 0X52, 0X52, 0X52, 0X52, 0X52, 0XBE, 0XBE,
- 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD,
- 0XBD, 0XBC, 0XBC, 0XBC, 0X54, 0X54, 0X54, 0X0C, 0X26, 0X26,
- 0X53, 0X53, 0X53, 0X53, 0X52, 0X52, 0X52, 0X52, 0X52, 0X52,
- 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD, 0XBD, 0XBD,
- 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC, 0X54, 0X54, 0X26, 0X26,
- 0X26, 0X26, 0X26, 0X26, 0X53, 0X53, 0X52, 0X52, 0X52, 0X52,
- 0X52, 0X52, 0X34, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBE, 0XBD,
- 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC, 0X54, 0X54,
- 0X26, 0X26, 0X26, 0X26, 0X26, 0X26, 0X26, 0X19, 0X19, 0X52,
- 0X52, 0X52, 0X52, 0X34, 0X34, 0X34, 0XBE, 0XBE, 0XBE, 0XBE,
- 0XBE, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBD, 0XBC, 0XBC, 0XBC,
- 0XBB, 0X26, 0X26, 0X26, 0X26, 0X26, 0X26, 0X26, 0X19, 0X19,
- 0X19, 0X03, 0X03, 0X03, 0X34, 0X34, 0X34, 0X34, 0X34, 0X50,
- 0X50, 0X50, 0X50, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8,
- 0XB8, 0XB8, 0XBB, 0XBB, 0X26, 0X26, 0X26, 0X26, 0X26, 0X26,
- 0X19, 0X19, 0X19, 0X03, 0X03, 0X03, 0X03, 0X34, 0X34, 0X34,
- 0X50, 0X50, 0X50, 0X50, 0X6C, 0XB9, 0XB9, 0XB9, 0XB9, 0XB9,
- 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB, 0X26, 0X26, 0X26, 0X26,
- 0X26, 0X19, 0X19, 0X19, 0X19, 0X03, 0X03, 0X03, 0X03, 0X03,
- 0X34, 0X34, 0X50, 0X50, 0X50, 0X6C, 0X6C, 0X6C, 0XB9, 0XB9,
- 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB, 0XBB, 0X26,
- 0X26, 0X26, 0X51, 0X19, 0X19, 0X19, 0X03, 0X03, 0X03, 0X03,
- 0X03, 0X03, 0X03, 0X50, 0X50, 0X50, 0X6C, 0X6C, 0X6C, 0X6C,
- 0XB9, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8, 0XBB, 0XBB,
- 0XBB, 0XBB, 0X51, 0X51, 0X51, 0X51, 0X19, 0X19, 0X03, 0X03,
- 0X03, 0X03, 0X03, 0X03, 0X03, 0X50, 0X50, 0X6C, 0X6C, 0X6C,
- 0X6C, 0X6C, 0X2C, 0XB9, 0XB9, 0XB9, 0XB9, 0XB8, 0XB8, 0XB8,
- 0XBB, 0XBB, 0XBB, 0XBB, 0X51, 0X51, 0X51, 0X51, 0X51, 0X19,
- 0X03, 0X03, 0X03, 0X03, 0X03, 0X03, 0X04, 0X50, 0X6C, 0X6C,
- 0X6C, 0X6C, 0X6C, 0X6C, 0X2C, 0X2C, 0X2C, 0XB9, 0XB9, 0XB8,
- 0XB8, 0XB8, 0XBB, 0XBB, 0XBB, 0XBB, 0X51, 0X51, 0X51, 0X51,
- 0X51, 0X03, 0X03, 0X03, 0X03, 0X03, 0X03, 0X04, 0X04, 0X6C,
- 0X6C, 0X6C, 0X6C, 0X6C, 0X6C, 0X2C, 0X2C, 0X2C, 0X2C, 0X36,
- 0X18, 0X18, 0XB8, 0XB8, 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6,
- 0XB6, 0XB6, 0XB6, 0XB6, 0X03, 0X03, 0XB5, 0XB5, 0XB5, 0X04,
- 0X04, 0XB4, 0X6C, 0X6C, 0X6C, 0X6C, 0X2C, 0X2C, 0X2C, 0X2C,
- 0X36, 0X18, 0X18, 0X18, 0XB3, 0XB3, 0XB7, 0XB7, 0XB7, 0XB7,
- 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5,
- 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4, 0X6C, 0X2C, 0X2C, 0X2C,
- 0X36, 0X36, 0X36, 0X18, 0X18, 0X18, 0XB3, 0XB3, 0XB7, 0XB7,
- 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5,
- 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0X2C,
- 0X2C, 0X36, 0X36, 0X36, 0X18, 0X18, 0X18, 0X18, 0XB3, 0XB3,
- 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6, 0XB6,
- 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4, 0XB4, 0XB4,
- 0XB4, 0XB4, 0X36, 0X36, 0X36, 0X36, 0X18, 0X18, 0X18, 0X18,
- 0XB3, 0XB3, 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6, 0XB6, 0XB6,
- 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB4, 0XB4,
- 0XB4, 0XB4, 0XB4, 0XB4, 0X36, 0X36, 0X36, 0X18, 0X18, 0X18,
- 0X18, 0X38, 0X38, 0XB3, 0XB7, 0XB7, 0XB7, 0XB7, 0XB6, 0XB6,
- 0XB6, 0XB6, 0XB6, 0XB6, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5, 0XB5,
- 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0XB4, 0X36, 0X36, 0X36, 0X18,
- 0X18, 0X18, 0X38, 0X38, 0X38, 0XB3, 0XB2, 0XB2, 0XB2, 0XB2,
- 0XB1, 0XB1, 0XB1, 0XB1, 0XB1, 0XB1, 0XB0, 0XB0, 0XB0, 0XB0,
- 0XB0, 0XB0, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0X36,
- 0X18, 0X18, 0X38, 0X38, 0X38, 0X38, 0X38, 0X38, 0XB2, 0XB2,
- 0XB2, 0XB2, 0XB1, 0XB1, 0XB1, 0XB1, 0XB1, 0XB1, 0XB0, 0XB0,
- 0XB0, 0XB0, 0XB0, 0XB0, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF, 0XAF,
- 0XAF, 0XAE, 0XAE, 0XAE, 0XAE, 0X38, 0X38, 0X38, 0X38, 0XAD,
- 0XB2, 0XB2, 0XB2, 0XB2, 0XB1, 0XB1, 0XB1, 0XB1, 0XB1, 0XB1,
- 0XB0, 0XB0, 0XB0, 0XB0, 0XB0, 0XB0, 0XAF, 0XAF, 0XAF, 0XAF,
- 0XAF, 0XAF, 0XAF, 0XAE, 0XAE, 0XAE, 0XAE, 0XAE, 0X38, 0X38,
- 0XAD, 0XAD, 0XAC, 0XAC, 0XAC, 0XAC, 0XAB, 0XAB, 0XAB, 0XAB,
- 0XAB, 0XAB, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XA9, 0XA9,
- 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA8, 0XA8, 0XA8, 0XA8, 0XA8,
- 0XA8, 0XA7, 0XA7, 0XA7, 0XAC, 0XAC, 0XAC, 0XAC, 0XAB, 0XAB,
- 0XAB, 0XAB, 0XAB, 0XAB, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA,
- 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA8, 0XA8, 0XA8,
- 0XA8, 0XA8, 0XA8, 0XA7, 0XA7, 0XA7, 0XAC, 0XAC, 0XAC, 0XAC,
- 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAA, 0XAA, 0XAA, 0XAA,
- 0XAA, 0XAA, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA8,
- 0XA8, 0XA8, 0XA8, 0XA8, 0XA8, 0XA7, 0XA7, 0XA7, 0XAC, 0XAC,
- 0XAC, 0XAC, 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAA, 0XAA,
- 0XAA, 0XAA, 0XAA, 0XAA, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9,
- 0XA9, 0XA8, 0XA8, 0XA8, 0XA8, 0XA8, 0XA8, 0XA7, 0XA7, 0XA7,
- 0XA6, 0XA6, 0XA6, 0X3F, 0X3F, 0X3F, 0X4E, 0X4E, 0X4E, 0X4E,
- 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA4, 0XA4, 0XA4, 0XA4,
- 0XA4, 0XA4, 0XA4, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA2,
- 0XA2, 0XA2, 0XA6, 0XA6, 0XA6, 0X3F, 0X3F, 0X3F, 0X3F, 0X4E,
- 0X4E, 0X4E, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA4, 0XA4,
- 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3,
- 0XA3, 0XA2, 0XA2, 0XA2, 0XA6, 0XA6, 0XA6, 0X3F, 0X3F, 0X3F,
- 0X3F, 0X3F, 0X4E, 0X4E, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5,
- 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA3, 0XA3, 0XA3,
- 0XA3, 0XA3, 0XA3, 0XA2, 0XA2, 0XA2, 0XA6, 0XA6, 0XA6, 0X3F,
- 0X3F, 0X3F, 0X3F, 0X3F, 0X3F, 0X4E, 0XA5, 0XA5, 0XA5, 0XA5,
- 0XA5, 0XA5, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA3,
- 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA2, 0XA2, 0XA2, 0XA6, 0XA6,
- 0X3F, 0X3F, 0X3F, 0X3F, 0X3F, 0X3F, 0X3F, 0X27, 0XA5, 0XA5,
- 0XA5, 0XA5, 0XA5, 0XA5, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4,
- 0XA4, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA2, 0XA2, 0XA2,
- 0XA6, 0XA6, 0X3F, 0X3F, 0X3F, 0X3F, 0X3F, 0X27, 0X27, 0X27,
- 0X27, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA4, 0XA4, 0XA4, 0XA4,
- 0XA4, 0XA4, 0XA4, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA2,
- 0XA2, 0XA2, 0XA1, 0XA1, 0X3F, 0X3F, 0X3F, 0X27, 0X27, 0X27,
- 0X27, 0X27, 0X27, 0X4C, 0X4C, 0X4C, 0X4C, 0X4C, 0XA0, 0XA0,
- 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F,
- 0X9F, 0X9E, 0X9E, 0X9E, 0XA1, 0XA1, 0XA1, 0X27, 0X27, 0X27,
- 0X27, 0X27, 0X27, 0X27, 0X27, 0X4C, 0X4C, 0X4C, 0X4C, 0X4C,
- 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0X9F, 0X9F, 0X9F,
- 0X9F, 0X9F, 0X9F, 0X9E, 0X9E, 0X9E, 0XA1, 0XA1, 0XA1, 0XA1,
- 0X27, 0X27, 0X27, 0X27, 0X27, 0X27, 0X4C, 0X4C, 0X4C, 0X4C,
- 0X4C, 0X4C, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0X9F,
- 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9E, 0X9E, 0X9E, 0XA1, 0XA1,
- 0XA1, 0XA1, 0X4D, 0X4D, 0X4D, 0X4D, 0X4D, 0X4D, 0X4C, 0X4C,
- 0X4C, 0X4C, 0X4C, 0X4C, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0,
- 0XA0, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9E, 0X9E, 0X9E,
- 0XA1, 0XA1, 0XA1, 0X26, 0X26, 0X26, 0X26, 0X4D, 0X4D, 0X4D,
- 0X4C, 0X4C, 0X4C, 0X4C, 0X4C, 0X4C, 0XA0, 0XA0, 0XA0, 0XA0,
- 0XA0, 0XA0, 0XA0, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9E,
- 0X9E, 0X9E, 0XA1, 0XA1, 0X26, 0X26, 0X26, 0X26, 0X26, 0X26,
- 0X19, 0X19, 0X19, 0X4C, 0X4C, 0X4C, 0X4C, 0X4C, 0X34, 0XA0,
- 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F,
- 0X9F, 0X9E, 0X9E, 0X9E, 0X9D, 0X9D, 0X26, 0X26, 0X26, 0X26,
- 0X26, 0X19, 0X19, 0X19, 0X19, 0X03, 0X03, 0X03, 0X03, 0X34,
- 0X34, 0X34, 0X49, 0X49, 0X49, 0X49, 0X49, 0X9C, 0X9C, 0X9C,
- 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B, 0X9D, 0X9D, 0X26, 0X26,
- 0X26, 0X26, 0X26, 0X19, 0X19, 0X19, 0X19, 0X03, 0X03, 0X03,
- 0X03, 0X03, 0X34, 0X49, 0X49, 0X49, 0X49, 0X49, 0X49, 0X9C,
- 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B, 0X9D, 0X9D,
- 0X9D, 0X26, 0X26, 0X26, 0X19, 0X19, 0X19, 0X19, 0X19, 0X03,
- 0X03, 0X03, 0X03, 0X03, 0X03, 0X49, 0X49, 0X49, 0X49, 0X49,
- 0X6C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B,
- 0X9D, 0X9D, 0X9D, 0X26, 0X26, 0X4B, 0X19, 0X19, 0X19, 0X19,
- 0X03, 0X03, 0X03, 0X03, 0X03, 0X03, 0X04, 0X49, 0X49, 0X49,
- 0X49, 0X6C, 0X6C, 0X6C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9B,
- 0X9B, 0X9B, 0X9D, 0X9D, 0X9D, 0X9D, 0X4B, 0X4B, 0X4B, 0X19,
- 0X19, 0X19, 0X03, 0X03, 0X03, 0X03, 0X03, 0X03, 0X04, 0X49,
- 0X49, 0X49, 0X6C, 0X6C, 0X6C, 0X6C, 0X9C, 0X9C, 0X9C, 0X9C,
- 0X9C, 0X9B, 0X9B, 0X9B, 0X9D, 0X9D, 0X9D, 0X9D, 0X4B, 0X4B,
- 0X4B, 0X4B, 0X19, 0X19, 0X03, 0X03, 0X03, 0X03, 0X03, 0X04,
- 0X04, 0X04, 0X49, 0X6C, 0X6C, 0X6C, 0X6C, 0X2C, 0X2C, 0X6B,
- 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B, 0X9D, 0X9D, 0X9D, 0X9D,
- 0X4B, 0X4B, 0X4B, 0X4B, 0X4B, 0X03, 0X03, 0X03, 0X03, 0X03,
- 0X04, 0X04, 0X04, 0X05, 0X6C, 0X6C, 0X6C, 0X6C, 0X6B, 0X6B,
- 0X6B, 0X6B, 0X6B, 0X18, 0X18, 0X18, 0X9B, 0X9B, 0XF8, 0XF8,
- 0XF8, 0XF8, 0XF9, 0XF9, 0XF9, 0XF9, 0XF9, 0XF9, 0XFA, 0XFA,
- 0XFA, 0XFA, 0X04, 0X04, 0X04, 0XFB, 0XFB, 0X6C, 0X6C, 0X6B,
- 0X6B, 0X6B, 0X6B, 0X6B, 0X18, 0X18, 0X18, 0X18, 0XFD, 0XFD,
- 0XF8, 0XF8, 0XF8, 0XF8, 0XF9, 0XF9, 0XF9, 0XF9, 0XF9, 0XF9,
- 0XFA, 0XFA, 0XFA, 0XFA, 0XFA, 0XFA, 0XFB, 0XFB, 0XFB, 0XFB,
- 0XFB, 0X6B, 0X6B, 0X6B, 0X6B, 0X36, 0X18, 0X18, 0X18, 0X18,
- 0XFD, 0XFD, 0XF8, 0XF8, 0XF8, 0XF8, 0XF9, 0XF9, 0XF9, 0XF9,
- 0XF9, 0XF9, 0XFA, 0XFA, 0XFA, 0XFA, 0XFA, 0XFA, 0XFB, 0XFB,
- 0XFB, 0XFB, 0XFB, 0X6B, 0X6B, 0X6B, 0X36, 0X18, 0X18, 0X18,
- 0X18, 0X18, 0XFD, 0XFD, 0XF8, 0XF8, 0XF8, 0XF8, 0XF9, 0XF9,
- 0XF9, 0XF9, 0XF9, 0X99, 0XFA, 0XFA, 0XFA, 0XFA, 0XFA, 0X48,
- 0XFB, 0XFB, 0XFB, 0XFB, 0XFB, 0X47, 0X6B, 0X36, 0X36, 0X18,
- 0X18, 0X18, 0X18, 0X18, 0XFD, 0XFD, 0XF8, 0XF8, 0XF8, 0XF8,
- 0XF9, 0XF9, 0XF9, 0XF9, 0X99, 0X99, 0XFA, 0XFA, 0XFA, 0XFA,
- 0X48, 0X48, 0XFB, 0XFB, 0XFB, 0XFB, 0X47, 0X47, 0X36, 0X36,
- 0X18, 0X18, 0X18, 0X18, 0X38, 0X38, 0X38, 0XFD, 0X9A, 0X9A,
- 0X9A, 0X9A, 0XF9, 0XF9, 0XF9, 0X99, 0X99, 0X99, 0XFA, 0XFA,
- 0XFA, 0X48, 0X48, 0X48, 0XFB, 0XFB, 0XFB, 0X47, 0X47, 0X47,
- 0X36, 0X36, 0X18, 0X18, 0X18, 0X38, 0X38, 0X38, 0X38, 0X38,
- 0XFE, 0XFE, 0XFE, 0XFE, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF,
- 0X95, 0X95, 0X95, 0X95, 0X95, 0X95, 0X94, 0X94, 0X94, 0X94,
- 0X94, 0X94, 0X94, 0X93, 0X93, 0X18, 0X38, 0X38, 0X38, 0X38,
- 0X38, 0X38, 0XFE, 0XFE, 0XFE, 0XFE, 0XFF, 0XFF, 0XFF, 0XFF,
- 0XFF, 0XFF, 0X95, 0X95, 0X95, 0X95, 0X95, 0X95, 0X94, 0X94,
- 0X94, 0X94, 0X94, 0X94, 0X94, 0X93, 0X93, 0X93, 0X93, 0X38,
- 0X38, 0X38, 0X38, 0X92, 0XFE, 0XFE, 0XFE, 0XFE, 0XFF, 0XFF,
- 0XFF, 0XFF, 0XFF, 0XFF, 0X95, 0X95, 0X95, 0X95, 0X95, 0X95,
- 0X94, 0X94, 0X94, 0X94, 0X94, 0X94, 0X94, 0X93, 0X93, 0X93,
- 0X93, 0X93, 0X38, 0X38, 0X92, 0X92, 0XAC, 0XAC, 0XAC, 0XAC,
- 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAA, 0XAA, 0XAA, 0XAA,
- 0XAA, 0XAA, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA8,
- 0XA8, 0XA8, 0XA8, 0XA8, 0XA8, 0XA7, 0XA7, 0XA7, 0XAC, 0XAC,
- 0XAC, 0XAC, 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAA, 0XAA,
- 0XAA, 0XAA, 0XAA, 0XAA, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9,
- 0XA9, 0XA8, 0XA8, 0XA8, 0XA8, 0XA8, 0XA8, 0XA7, 0XA7, 0XA7,
- 0XAC, 0XAC, 0XAC, 0XAC, 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAB,
- 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XA9, 0XA9, 0XA9, 0XA9,
- 0XA9, 0XA9, 0XA9, 0XA8, 0XA8, 0XA8, 0XA8, 0XA8, 0XA8, 0XA7,
- 0XA7, 0XA7, 0XAC, 0XAC, 0XAC, 0XAC, 0XAB, 0XAB, 0XAB, 0XAB,
- 0XAB, 0XAB, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XA9, 0XA9,
- 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA8, 0XA8, 0XA8, 0XA8, 0XA8,
- 0XA8, 0XA7, 0XA7, 0XA7, 0XA6, 0XA6, 0XA6, 0XA6, 0X4E, 0X4E,
- 0X4E, 0X4E, 0X4E, 0X4E, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5,
- 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA3, 0XA3, 0XA3,
- 0XA3, 0XA3, 0XA3, 0XA2, 0XA2, 0XA2, 0XA6, 0XA6, 0XA6, 0X3F,
- 0X3F, 0X4E, 0X4E, 0X4E, 0X4E, 0X4E, 0XA5, 0XA5, 0XA5, 0XA5,
- 0XA5, 0XA5, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA3,
- 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA2, 0XA2, 0XA2, 0XA6, 0XA6,
- 0XA6, 0X3F, 0X3F, 0X3F, 0X4E, 0X4E, 0X4E, 0X4E, 0XA5, 0XA5,
- 0XA5, 0XA5, 0XA5, 0XA5, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4,
- 0XA4, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA2, 0XA2, 0XA2,
- 0XA6, 0XA6, 0XA6, 0X3F, 0X3F, 0X3F, 0X3F, 0X4E, 0X4E, 0X4E,
- 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA4, 0XA4, 0XA4, 0XA4,
- 0XA4, 0XA4, 0XA4, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA2,
- 0XA2, 0XA2, 0XA6, 0XA6, 0XA6, 0X3F, 0X3F, 0X3F, 0X3F, 0X3F,
- 0X27, 0X27, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA4, 0XA4,
- 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3,
- 0XA3, 0XA2, 0XA2, 0XA2, 0XA6, 0XA6, 0XA6, 0X3F, 0X3F, 0X27,
- 0X27, 0X27, 0X27, 0X27, 0X27, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5,
- 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA3, 0XA3, 0XA3,
- 0XA3, 0XA3, 0XA3, 0XA2, 0XA2, 0XA2, 0XA1, 0XA1, 0XA1, 0X27,
- 0X27, 0X27, 0X27, 0X27, 0X27, 0X27, 0X27, 0X4C, 0X4C, 0X4C,
- 0X4C, 0X4C, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0X9F,
- 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9E, 0X9E, 0X9E, 0XA1, 0XA1,
- 0XA1, 0X27, 0X27, 0X27, 0X27, 0X27, 0X27, 0X27, 0X4C, 0X4C,
- 0X4C, 0X4C, 0X4C, 0X4C, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0,
- 0XA0, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9E, 0X9E, 0X9E,
- 0XA1, 0XA1, 0XA1, 0XA1, 0X4D, 0X4D, 0X4D, 0X4D, 0X4D, 0X4D,
- 0X4C, 0X4C, 0X4C, 0X4C, 0X4C, 0X4C, 0XA0, 0XA0, 0XA0, 0XA0,
- 0XA0, 0XA0, 0XA0, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9E,
- 0X9E, 0X9E, 0XA1, 0XA1, 0XA1, 0XA1, 0X4D, 0X4D, 0X4D, 0X4D,
- 0X4D, 0X4D, 0X4C, 0X4C, 0X4C, 0X4C, 0X4C, 0X4C, 0XA0, 0XA0,
- 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F,
- 0X9F, 0X9E, 0X9E, 0X9E, 0XA1, 0XA1, 0XA1, 0XA1, 0X4D, 0X4D,
- 0X4D, 0X4D, 0X4D, 0X4D, 0X4C, 0X4C, 0X4C, 0X4C, 0X4C, 0X4C,
- 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0X9F, 0X9F, 0X9F,
- 0X9F, 0X9F, 0X9F, 0X9E, 0X9E, 0X9E, 0XA1, 0XA1, 0XA1, 0X26,
- 0X26, 0X26, 0X4D, 0X4D, 0X19, 0X19, 0X19, 0X4C, 0X4C, 0X4C,
- 0X4C, 0X4C, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0X9F,
- 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9E, 0X9E, 0X9E, 0X9D, 0X9D,
- 0X26, 0X26, 0X26, 0X26, 0X19, 0X19, 0X19, 0X19, 0X19, 0X19,
- 0X4A, 0X4A, 0X4A, 0X4A, 0X49, 0X49, 0X49, 0X49, 0X49, 0X49,
- 0X49, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B,
- 0X9D, 0X9D, 0X9D, 0X26, 0X26, 0X26, 0X19, 0X19, 0X19, 0X19,
- 0X19, 0X03, 0X03, 0X03, 0X4A, 0X4A, 0X49, 0X49, 0X49, 0X49,
- 0X49, 0X49, 0X49, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9B,
- 0X9B, 0X9B, 0X9D, 0X9D, 0X9D, 0X9D, 0X4B, 0X4B, 0X19, 0X19,
- 0X19, 0X19, 0X19, 0X03, 0X03, 0X03, 0X03, 0X4A, 0X04, 0X49,
- 0X49, 0X49, 0X49, 0X49, 0X49, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C,
- 0X9C, 0X9B, 0X9B, 0X9B, 0X9D, 0X9D, 0X9D, 0X9D, 0X4B, 0X4B,
- 0X4B, 0X19, 0X19, 0X19, 0X03, 0X03, 0X03, 0X03, 0X03, 0X04,
- 0X04, 0X49, 0X49, 0X49, 0X49, 0X49, 0X49, 0X9C, 0X9C, 0X9C,
- 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B, 0X9D, 0X9D, 0X9D, 0X9D,
- 0X4B, 0X4B, 0X4B, 0X4B, 0X19, 0X19, 0X03, 0X03, 0X03, 0X03,
- 0X04, 0X04, 0X04, 0X49, 0X49, 0X49, 0X49, 0X49, 0X6C, 0X9C,
- 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B, 0X9D, 0X9D,
- 0X9D, 0X9D, 0X4B, 0X4B, 0X4B, 0X4B, 0X4B, 0X19, 0X03, 0X03,
- 0X03, 0X03, 0X04, 0X04, 0X04, 0X05, 0X49, 0X49, 0X49, 0X6C,
- 0X6B, 0X6B, 0X6B, 0X9C, 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B,
- 0X9D, 0X9D, 0X9D, 0X9D, 0X4B, 0X4B, 0X4B, 0X4B, 0X4B, 0X4B,
- 0X03, 0X03, 0X03, 0X04, 0X04, 0X04, 0X04, 0X05, 0X05, 0X49,
- 0X6C, 0X6B, 0X6B, 0X6B, 0X6B, 0X6B, 0X6B, 0X9C, 0X18, 0X9B,
- 0X9B, 0X9B, 0XF8, 0XF8, 0XF8, 0XF8, 0XF9, 0XF9, 0XF9, 0XF9,
- 0XF9, 0XF9, 0XFA, 0XFA, 0XFA, 0XFA, 0X04, 0X04, 0X05, 0X05,
- 0XFB, 0XFB, 0XFB, 0X6B, 0X6B, 0X6B, 0X6B, 0X6B, 0X18, 0X18,
- 0X18, 0XFD, 0XFD, 0XFD, 0XF8, 0XF8, 0XF8, 0XF8, 0XF9, 0XF9,
- 0XF9, 0XF9, 0XF9, 0XF9, 0XFA, 0XFA, 0XFA, 0XFA, 0XFA, 0XFA,
- 0X05, 0XFB, 0XFB, 0XFB, 0XFB, 0X6B, 0X6B, 0X6B, 0X6B, 0X6B,
- 0X18, 0X18, 0X18, 0X18, 0XFD, 0XFD, 0XF8, 0XF8, 0XF8, 0XF8,
- 0XF9, 0XF9, 0XF9, 0XF9, 0XF9, 0X99, 0XFA, 0XFA, 0XFA, 0XFA,
- 0XFA, 0X48, 0XFB, 0XFB, 0XFB, 0XFB, 0XFB, 0X47, 0X6B, 0X6B,
- 0X6B, 0XFC, 0X18, 0X18, 0X18, 0X06, 0XFD, 0XFD, 0XF8, 0XF8,
- 0XF8, 0XF8, 0XF9, 0XF9, 0XF9, 0XF9, 0X99, 0X99, 0XFA, 0XFA,
- 0XFA, 0XFA, 0X48, 0X48, 0XFB, 0XFB, 0XFB, 0XFB, 0X47, 0X47,
- 0X6B, 0X6B, 0XFC, 0X18, 0X18, 0X18, 0X06, 0X38, 0XFD, 0XFD,
- 0X9A, 0X9A, 0X9A, 0X9A, 0XF9, 0XF9, 0XF9, 0X99, 0X99, 0X99,
- 0XFA, 0XFA, 0XFA, 0X48, 0X48, 0X48, 0XFB, 0XFB, 0XFB, 0X47,
- 0X47, 0X47, 0X47, 0XFC, 0XFC, 0X18, 0X18, 0X06, 0X38, 0X38,
- 0X38, 0XFD, 0X9A, 0X9A, 0X9A, 0X9A, 0XF9, 0XF9, 0X99, 0X99,
- 0X99, 0X99, 0XFA, 0XFA, 0X48, 0X48, 0X48, 0X48, 0XFB, 0XFB,
- 0X47, 0X47, 0X47, 0X47, 0X47, 0XFC, 0XFC, 0X18, 0X38, 0X38,
- 0X38, 0X38, 0X38, 0X38, 0XFE, 0XFE, 0XFE, 0XFE, 0XFF, 0XFF,
- 0XFF, 0XFF, 0XFF, 0XFF, 0X95, 0X95, 0X95, 0X95, 0X95, 0X95,
- 0X94, 0X94, 0X94, 0X94, 0X94, 0X94, 0X94, 0X93, 0X93, 0X93,
- 0X38, 0X38, 0X38, 0X38, 0X38, 0X38, 0XFE, 0XFE, 0XFE, 0XFE,
- 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X95, 0X95, 0X95, 0X95,
- 0X95, 0X95, 0X94, 0X94, 0X94, 0X94, 0X94, 0X94, 0X94, 0X93,
- 0X93, 0X93, 0X93, 0X38, 0X38, 0X38, 0X38, 0X92, 0XFE, 0XFE,
- 0XFE, 0XFE, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X96, 0X95, 0X95,
- 0X95, 0X95, 0X95, 0X95, 0X94, 0X94, 0X94, 0X94, 0X94, 0X94,
- 0X94, 0X93, 0X93, 0X93, 0X93, 0X93, 0X38, 0X38, 0X92, 0X92,
- 0XAC, 0XAC, 0XAC, 0XAC, 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAB,
- 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XA9, 0XA9, 0XA9, 0XA9,
- 0XA9, 0XA9, 0XA9, 0XA8, 0XA8, 0XA8, 0XA8, 0XA8, 0XA8, 0XA7,
- 0XA7, 0XA7, 0XAC, 0XAC, 0XAC, 0XAC, 0XAB, 0XAB, 0XAB, 0XAB,
- 0XAB, 0XAB, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XA9, 0XA9,
- 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA8, 0XA8, 0XA8, 0XA8, 0XA8,
- 0XA8, 0XA7, 0XA7, 0XA7, 0XAC, 0XAC, 0XAC, 0XAC, 0XAB, 0XAB,
- 0XAB, 0XAB, 0XAB, 0XAB, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA,
- 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA8, 0XA8, 0XA8,
- 0XA8, 0XA8, 0XA8, 0XA7, 0XA7, 0XA7, 0XAC, 0XAC, 0XAC, 0XAC,
- 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAA, 0XAA, 0XAA, 0XAA,
- 0XAA, 0XAA, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA8,
- 0XA8, 0XA8, 0XA8, 0XA8, 0XA8, 0XA7, 0XA7, 0XA7, 0XA6, 0XA6,
- 0XA6, 0XA6, 0X4E, 0X4E, 0X4E, 0X4E, 0X4E, 0X4E, 0XA5, 0XA5,
- 0XA5, 0XA5, 0XA5, 0XA5, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4,
- 0XA4, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA2, 0XA2, 0XA2,
- 0XA6, 0XA6, 0XA6, 0XA6, 0X4E, 0X4E, 0X4E, 0X4E, 0X4E, 0X4E,
- 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA4, 0XA4, 0XA4, 0XA4,
- 0XA4, 0XA4, 0XA4, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA2,
- 0XA2, 0XA2, 0XA6, 0XA6, 0XA6, 0XA6, 0X4E, 0X4E, 0X4E, 0X4E,
- 0X4E, 0X4E, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA4, 0XA4,
- 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3,
- 0XA3, 0XA2, 0XA2, 0XA2, 0XA6, 0XA6, 0XA6, 0XA6, 0X4E, 0X4E,
- 0X4E, 0X4E, 0X4E, 0X4E, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5,
- 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA3, 0XA3, 0XA3,
- 0XA3, 0XA3, 0XA3, 0XA2, 0XA2, 0XA2, 0XA6, 0XA6, 0XA6, 0X3F,
- 0X3F, 0X4E, 0X4E, 0X4E, 0X4E, 0X4E, 0XA5, 0XA5, 0XA5, 0XA5,
- 0XA5, 0XA5, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA3,
- 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA2, 0XA2, 0XA2, 0XA6, 0XA6,
- 0XA6, 0X3F, 0X27, 0X27, 0X27, 0X27, 0X27, 0X27, 0X27, 0XA5,
- 0XA5, 0XA5, 0XA5, 0XA5, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4,
- 0XA4, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA2, 0XA2, 0XA2,
- 0XA1, 0XA1, 0XA1, 0X27, 0X27, 0X27, 0X27, 0X27, 0X27, 0X27,
- 0X27, 0X4C, 0X4C, 0X4C, 0X4C, 0X4C, 0XA0, 0XA0, 0XA0, 0XA0,
- 0XA0, 0XA0, 0XA0, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9E,
- 0X9E, 0X9E, 0XA1, 0XA1, 0XA1, 0XA1, 0X27, 0X27, 0X27, 0X27,
- 0X27, 0X27, 0X4C, 0X4C, 0X4C, 0X4C, 0X4C, 0X4C, 0XA0, 0XA0,
- 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F,
- 0X9F, 0X9E, 0X9E, 0X9E, 0XA1, 0XA1, 0XA1, 0XA1, 0X4D, 0X4D,
- 0X4D, 0X4D, 0X4D, 0X4D, 0X4C, 0X4C, 0X4C, 0X4C, 0X4C, 0X4C,
- 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0X9F, 0X9F, 0X9F,
- 0X9F, 0X9F, 0X9F, 0X9E, 0X9E, 0X9E, 0XA1, 0XA1, 0XA1, 0XA1,
- 0X4D, 0X4D, 0X4D, 0X4D, 0X4D, 0X4D, 0X4C, 0X4C, 0X4C, 0X4C,
- 0X4C, 0X4C, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0X9F,
- 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9E, 0X9E, 0X9E, 0XA1, 0XA1,
- 0XA1, 0XA1, 0X4D, 0X4D, 0X4D, 0X4D, 0X4D, 0X4D, 0X4C, 0X4C,
- 0X4C, 0X4C, 0X4C, 0X4C, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0,
- 0XA0, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9E, 0X9E, 0X9E,
- 0XA1, 0XA1, 0XA1, 0XA1, 0X4D, 0X4D, 0X4D, 0X4D, 0X4D, 0X19,
- 0X4C, 0X4C, 0X4C, 0X4C, 0X4C, 0X4C, 0XA0, 0XA0, 0XA0, 0XA0,
- 0XA0, 0XA0, 0XA0, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9E,
- 0X9E, 0X9E, 0X9D, 0X9D, 0X9D, 0X26, 0X26, 0X19, 0X19, 0X19,
- 0X19, 0X19, 0X19, 0X4A, 0X4A, 0X4A, 0X4A, 0X4A, 0X49, 0X49,
- 0X49, 0X49, 0X49, 0X49, 0X49, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C,
- 0X9C, 0X9B, 0X9B, 0X9B, 0X9D, 0X9D, 0X9D, 0X9D, 0X4B, 0X4B,
- 0X19, 0X19, 0X19, 0X19, 0X19, 0X4A, 0X4A, 0X4A, 0X4A, 0X4A,
- 0X49, 0X49, 0X49, 0X49, 0X49, 0X49, 0X49, 0X9C, 0X9C, 0X9C,
- 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B, 0X9D, 0X9D, 0X9D, 0X9D,
- 0X4B, 0X4B, 0X4B, 0X19, 0X19, 0X19, 0X19, 0X4A, 0X4A, 0X4A,
- 0X4A, 0X4A, 0X04, 0X49, 0X49, 0X49, 0X49, 0X49, 0X49, 0X9C,
- 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B, 0X9D, 0X9D,
- 0X9D, 0X9D, 0X4B, 0X4B, 0X4B, 0X4B, 0X19, 0X19, 0X19, 0X4A,
- 0X4A, 0X4A, 0X4A, 0X04, 0X04, 0X49, 0X49, 0X49, 0X49, 0X49,
- 0X49, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B,
- 0X9D, 0X9D, 0X9D, 0X9D, 0X4B, 0X4B, 0X4B, 0X4B, 0X4B, 0X19,
- 0X03, 0X4A, 0X4A, 0X4A, 0X04, 0X04, 0X04, 0X49, 0X49, 0X49,
- 0X49, 0X49, 0X49, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9B,
- 0X9B, 0X9B, 0X9D, 0X9D, 0X9D, 0X9D, 0X4B, 0X4B, 0X4B, 0X4B,
- 0X4B, 0X4B, 0X03, 0X03, 0X4A, 0X04, 0X04, 0X04, 0X04, 0X05,
- 0X49, 0X49, 0X49, 0X49, 0X6B, 0X6B, 0X9C, 0X9C, 0X9C, 0X9C,
- 0X9C, 0X9B, 0X9B, 0X9B, 0X9D, 0X9D, 0X9D, 0X9D, 0X4B, 0X4B,
- 0X4B, 0X4B, 0X4B, 0X4B, 0X03, 0X03, 0X04, 0X04, 0X04, 0X04,
- 0X05, 0X05, 0X05, 0X49, 0X49, 0X6B, 0X6B, 0X6B, 0X6B, 0X6B,
- 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B, 0XF8, 0XF8, 0XF8, 0XF8,
- 0XF9, 0XF9, 0XF9, 0XF9, 0XF9, 0XF9, 0XFA, 0XFA, 0XFA, 0XFA,
- 0X04, 0X04, 0X05, 0X05, 0XFB, 0XFB, 0XFB, 0X6B, 0X6B, 0X6B,
- 0X6B, 0X6B, 0XFC, 0XFC, 0X06, 0XFD, 0XFD, 0XFD, 0XF8, 0XF8,
- 0XF8, 0XF8, 0XF9, 0XF9, 0XF9, 0XF9, 0XF9, 0X99, 0XFA, 0XFA,
- 0XFA, 0XFA, 0XFA, 0X48, 0X05, 0XFB, 0XFB, 0XFB, 0XFB, 0X47,
- 0X6B, 0X6B, 0X6B, 0XFC, 0XFC, 0XFC, 0X06, 0XFD, 0XFD, 0XFD,
- 0XF8, 0XF8, 0XF8, 0XF8, 0XF9, 0XF9, 0XF9, 0XF9, 0X99, 0X99,
- 0XFA, 0XFA, 0XFA, 0XFA, 0X48, 0X48, 0XFB, 0XFB, 0XFB, 0XFB,
- 0X47, 0X47, 0X6B, 0X6B, 0XFC, 0XFC, 0XFC, 0X06, 0X06, 0X06,
- 0XFD, 0XFD, 0X9A, 0X9A, 0X9A, 0X9A, 0XF9, 0XF9, 0XF9, 0X99,
- 0X99, 0X99, 0XFA, 0XFA, 0XFA, 0X48, 0X48, 0X48, 0XFB, 0XFB,
- 0XFB, 0X47, 0X47, 0X47, 0X47, 0XFC, 0XFC, 0XFC, 0X46, 0X06,
- 0X06, 0X06, 0XFD, 0XFD, 0X9A, 0X9A, 0X9A, 0X9A, 0XF9, 0XF9,
- 0X99, 0X99, 0X99, 0X99, 0XFA, 0XFA, 0X48, 0X48, 0X48, 0X48,
- 0XFB, 0XFB, 0X47, 0X47, 0X47, 0X47, 0X47, 0XFC, 0XFC, 0X46,
- 0X06, 0X06, 0X38, 0X38, 0X25, 0X98, 0X9A, 0X9A, 0X9A, 0X9A,
- 0XF9, 0X99, 0X99, 0X99, 0X99, 0X99, 0XFA, 0X48, 0X48, 0X48,
- 0X48, 0X48, 0XFB, 0X47, 0X47, 0X47, 0X47, 0X47, 0X47, 0XFC,
- 0X46, 0X46, 0X06, 0X38, 0X38, 0X38, 0X38, 0X98, 0XFE, 0XFE,
- 0XFE, 0XFE, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X95, 0X95,
- 0X95, 0X95, 0X95, 0X95, 0X94, 0X94, 0X94, 0X94, 0X94, 0X94,
- 0X94, 0X93, 0X93, 0X93, 0X38, 0X38, 0X38, 0X38, 0X38, 0X1D,
- 0XFE, 0XFE, 0XFE, 0XFE, 0XFF, 0XFF, 0XFF, 0XFF, 0XFF, 0X96,
- 0X95, 0X95, 0X95, 0X95, 0X95, 0X95, 0X94, 0X94, 0X94, 0X94,
- 0X94, 0X94, 0X94, 0X93, 0X93, 0X93, 0X93, 0X38, 0X38, 0X38,
- 0X1D, 0X92, 0XFE, 0XFE, 0XFE, 0XFE, 0XFF, 0XFF, 0XFF, 0XFF,
- 0X96, 0X96, 0X95, 0X95, 0X95, 0X95, 0X95, 0X95, 0X94, 0X94,
- 0X94, 0X94, 0X94, 0X94, 0X94, 0X93, 0X93, 0X93, 0X93, 0X93,
- 0X38, 0X38, 0X92, 0X92, 0XAC, 0XAC, 0XAC, 0XAC, 0XAB, 0XAB,
- 0XAB, 0XAB, 0XAB, 0XAB, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA,
- 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA8, 0XA8, 0XA8,
- 0XA8, 0XA8, 0XA8, 0XA7, 0XA7, 0XA7, 0XAC, 0XAC, 0XAC, 0XAC,
- 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAA, 0XAA, 0XAA, 0XAA,
- 0XAA, 0XAA, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA8,
- 0XA8, 0XA8, 0XA8, 0XA8, 0XA8, 0XA7, 0XA7, 0XA7, 0XAC, 0XAC,
- 0XAC, 0XAC, 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAA, 0XAA,
- 0XAA, 0XAA, 0XAA, 0XAA, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9,
- 0XA9, 0XA8, 0XA8, 0XA8, 0XA8, 0XA8, 0XA8, 0XA7, 0XA7, 0XA7,
- 0XAC, 0XAC, 0XAC, 0XAC, 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAB,
- 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XA9, 0XA9, 0XA9, 0XA9,
- 0XA9, 0XA9, 0XA9, 0XA8, 0XA8, 0XA8, 0XA8, 0XA8, 0XA8, 0XA7,
- 0XA7, 0XA7, 0XA6, 0XA6, 0XA6, 0XA6, 0X4E, 0X4E, 0X4E, 0X4E,
- 0X4E, 0X4E, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA4, 0XA4,
- 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3,
- 0XA3, 0XA2, 0XA2, 0XA2, 0XA6, 0XA6, 0XA6, 0XA6, 0X4E, 0X4E,
- 0X4E, 0X4E, 0X4E, 0X4E, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5,
- 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA3, 0XA3, 0XA3,
- 0XA3, 0XA3, 0XA3, 0XA2, 0XA2, 0XA2, 0XA6, 0XA6, 0XA6, 0XA6,
- 0X4E, 0X4E, 0X4E, 0X4E, 0X4E, 0X4E, 0XA5, 0XA5, 0XA5, 0XA5,
- 0XA5, 0XA5, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA3,
- 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA2, 0XA2, 0XA2, 0XA6, 0XA6,
- 0XA6, 0XA6, 0X4E, 0X4E, 0X4E, 0X4E, 0X4E, 0X4E, 0XA5, 0XA5,
- 0XA5, 0XA5, 0XA5, 0XA5, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4,
- 0XA4, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA2, 0XA2, 0XA2,
- 0XA6, 0XA6, 0XA6, 0XA6, 0X4E, 0X4E, 0X4E, 0X4E, 0X4E, 0X4E,
- 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA4, 0XA4, 0XA4, 0XA4,
- 0XA4, 0XA4, 0XA4, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA2,
- 0XA2, 0XA2, 0XA6, 0XA6, 0XA6, 0XA6, 0X27, 0X27, 0X27, 0X27,
- 0X27, 0X27, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA4, 0XA4,
- 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3,
- 0XA3, 0XA2, 0XA2, 0XA2, 0XA1, 0XA1, 0XA1, 0X27, 0X27, 0X27,
- 0X27, 0X27, 0X27, 0X27, 0X27, 0X4C, 0X4C, 0X4C, 0X4C, 0X4C,
- 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0X9F, 0X9F, 0X9F,
- 0X9F, 0X9F, 0X9F, 0X9E, 0X9E, 0X9E, 0XA1, 0XA1, 0XA1, 0XA1,
- 0X4D, 0X4D, 0X4D, 0X27, 0X27, 0X27, 0X4C, 0X4C, 0X4C, 0X4C,
- 0X4C, 0X4C, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0X9F,
- 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9E, 0X9E, 0X9E, 0XA1, 0XA1,
- 0XA1, 0XA1, 0X4D, 0X4D, 0X4D, 0X4D, 0X4D, 0X4D, 0X4C, 0X4C,
- 0X4C, 0X4C, 0X4C, 0X4C, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0,
- 0XA0, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9E, 0X9E, 0X9E,
- 0XA1, 0XA1, 0XA1, 0XA1, 0X4D, 0X4D, 0X4D, 0X4D, 0X4D, 0X4D,
- 0X13, 0X4C, 0X4C, 0X4C, 0X4C, 0X4C, 0XA0, 0XA0, 0XA0, 0XA0,
- 0XA0, 0XA0, 0XA0, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9E,
- 0X9E, 0X9E, 0XA1, 0XA1, 0XA1, 0XA1, 0X4D, 0X4D, 0X4D, 0X4D,
- 0X4D, 0X4D, 0X13, 0X13, 0X4C, 0X4C, 0X4C, 0X4C, 0XA0, 0XA0,
- 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F,
- 0X9F, 0X9E, 0X9E, 0X9E, 0XA1, 0XA1, 0XA1, 0XA1, 0X4D, 0X4D,
- 0X4D, 0X4D, 0X4D, 0X4D, 0X13, 0X13, 0X13, 0X4C, 0X4C, 0X4C,
- 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0X9F, 0X9F, 0X9F,
- 0X9F, 0X9F, 0X9F, 0X9E, 0X9E, 0X9E, 0X9D, 0X9D, 0X9D, 0X9D,
- 0X4B, 0X4B, 0X19, 0X19, 0X19, 0X19, 0X13, 0X13, 0X13, 0X13,
- 0X4A, 0X4A, 0X49, 0X49, 0X49, 0X49, 0X49, 0X49, 0X49, 0X9C,
- 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B, 0X9D, 0X9D,
- 0X9D, 0X9D, 0X4B, 0X4B, 0X4B, 0X19, 0X19, 0X19, 0X19, 0X4A,
- 0X4A, 0X4A, 0X4A, 0X4A, 0X49, 0X49, 0X49, 0X49, 0X49, 0X49,
- 0X49, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B,
- 0X9D, 0X9D, 0X9D, 0X9D, 0X4B, 0X4B, 0X4B, 0X4B, 0X19, 0X19,
- 0X19, 0X4A, 0X4A, 0X4A, 0X4A, 0X4A, 0X49, 0X49, 0X49, 0X49,
- 0X49, 0X49, 0X49, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9B,
- 0X9B, 0X9B, 0X9D, 0X9D, 0X9D, 0X9D, 0X4B, 0X4B, 0X4B, 0X4B,
- 0X4B, 0X19, 0X4A, 0X4A, 0X4A, 0X4A, 0X4A, 0X04, 0X04, 0X49,
- 0X49, 0X49, 0X49, 0X49, 0X49, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C,
- 0X9C, 0X9B, 0X9B, 0X9B, 0X9D, 0X9D, 0X9D, 0X9D, 0X4B, 0X4B,
- 0X4B, 0X4B, 0X4B, 0X4B, 0X4A, 0X4A, 0X4A, 0X4A, 0X04, 0X04,
- 0X05, 0X05, 0X49, 0X49, 0X49, 0X49, 0X49, 0X9C, 0X9C, 0X9C,
- 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B, 0X9D, 0X9D, 0X9D, 0X9D,
- 0X4B, 0X4B, 0X4B, 0X4B, 0X4B, 0X4B, 0X4A, 0X4A, 0X4A, 0X04,
- 0X04, 0X04, 0X05, 0X05, 0X05, 0X49, 0X49, 0X49, 0X30, 0X30,
- 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B, 0X9D, 0X9D,
- 0X9D, 0X9D, 0X4B, 0X4B, 0X4B, 0X4B, 0X4B, 0X4B, 0X4A, 0X4A,
- 0X04, 0X04, 0X04, 0X05, 0X05, 0X05, 0X05, 0X05, 0X49, 0X30,
- 0X30, 0X30, 0X30, 0X30, 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B,
- 0XF8, 0XF8, 0XF8, 0XF8, 0XF9, 0XF9, 0XF9, 0XF9, 0XF9, 0X99,
- 0XFA, 0XFA, 0XFA, 0XFA, 0X04, 0X05, 0X05, 0X05, 0X05, 0XFB,
- 0XFB, 0X30, 0X30, 0X30, 0X30, 0X30, 0XFC, 0XFC, 0X06, 0XFD,
- 0XFD, 0XFD, 0XF8, 0XF8, 0XF8, 0XF8, 0XF9, 0XF9, 0XF9, 0XF9,
- 0X99, 0X99, 0XFA, 0XFA, 0XFA, 0XFA, 0X48, 0X05, 0X05, 0X05,
- 0XFB, 0XFB, 0X47, 0X47, 0X30, 0X30, 0X30, 0XFC, 0XFC, 0X46,
- 0X06, 0X06, 0XFD, 0XFD, 0X9A, 0X9A, 0X9A, 0X9A, 0XF9, 0XF9,
- 0XF9, 0X99, 0X99, 0X99, 0XFA, 0XFA, 0XFA, 0X48, 0X48, 0X48,
- 0XFB, 0XFB, 0XFB, 0X47, 0X47, 0X47, 0X30, 0X30, 0XFC, 0XFC,
- 0X46, 0X06, 0X06, 0X06, 0XFD, 0XFD, 0X9A, 0X9A, 0X9A, 0X9A,
- 0XF9, 0XF9, 0X99, 0X99, 0X99, 0X99, 0XFA, 0XFA, 0X48, 0X48,
- 0X48, 0X48, 0XFB, 0XFB, 0X47, 0X47, 0X47, 0X47, 0X47, 0XFC,
- 0XFC, 0X46, 0X46, 0X06, 0X06, 0X25, 0XFD, 0X98, 0X9A, 0X9A,
- 0X9A, 0X9A, 0XF9, 0X99, 0X99, 0X99, 0X99, 0X99, 0XFA, 0X48,
- 0X48, 0X48, 0X48, 0X48, 0XFB, 0X47, 0X47, 0X47, 0X47, 0X47,
- 0X47, 0XFC, 0X46, 0X46, 0X06, 0X06, 0X25, 0X25, 0X25, 0X98,
- 0X9A, 0X9A, 0X9A, 0X9A, 0X99, 0X99, 0X99, 0X99, 0X99, 0X99,
- 0X48, 0X48, 0X48, 0X48, 0X48, 0X48, 0X47, 0X47, 0X47, 0X47,
- 0X47, 0X47, 0X47, 0X46, 0X46, 0X06, 0X06, 0X38, 0X25, 0X25,
- 0X25, 0X1D, 0XFE, 0XFE, 0XFE, 0XFE, 0XFF, 0XFF, 0XFF, 0XFF,
- 0XFF, 0X96, 0X95, 0X95, 0X95, 0X95, 0X95, 0X95, 0X94, 0X94,
- 0X94, 0X94, 0X94, 0X94, 0X94, 0X93, 0X93, 0X93, 0X38, 0X38,
- 0X38, 0X25, 0X1D, 0X1D, 0XFE, 0XFE, 0XFE, 0XFE, 0XFF, 0XFF,
- 0XFF, 0XFF, 0X96, 0X96, 0X95, 0X95, 0X95, 0X95, 0X95, 0X95,
- 0X94, 0X94, 0X94, 0X94, 0X94, 0X94, 0X94, 0X93, 0X93, 0X93,
- 0X93, 0X38, 0X38, 0X1D, 0X1D, 0X1D, 0XFE, 0XFE, 0XFE, 0XFE,
- 0XFF, 0XFF, 0XFF, 0X96, 0X96, 0X96, 0X95, 0X95, 0X95, 0X95,
- 0X95, 0X95, 0X94, 0X94, 0X94, 0X94, 0X94, 0X94, 0X94, 0X93,
- 0X93, 0X93, 0X93, 0X93, 0X93, 0X1D, 0X1D, 0X92, 0XAC, 0XAC,
- 0XAC, 0XAC, 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAA, 0XAA,
- 0XAA, 0XAA, 0XAA, 0XAA, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9,
- 0XA9, 0XA8, 0XA8, 0XA8, 0XA8, 0XA8, 0XA8, 0XA7, 0XA7, 0XA7,
- 0XAC, 0XAC, 0XAC, 0XAC, 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAB,
- 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XA9, 0XA9, 0XA9, 0XA9,
- 0XA9, 0XA9, 0XA9, 0XA8, 0XA8, 0XA8, 0XA8, 0XA8, 0XA8, 0XA7,
- 0XA7, 0XA7, 0XAC, 0XAC, 0XAC, 0XAC, 0XAB, 0XAB, 0XAB, 0XAB,
- 0XAB, 0XAB, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XA9, 0XA9,
- 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA8, 0XA8, 0XA8, 0XA8, 0XA8,
- 0XA8, 0XA7, 0XA7, 0XA7, 0XAC, 0XAC, 0XAC, 0XAC, 0XAB, 0XAB,
- 0XAB, 0XAB, 0XAB, 0XAB, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA,
- 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA8, 0XA8, 0XA8,
- 0XA8, 0XA8, 0XA8, 0XA7, 0XA7, 0XA7, 0XA6, 0XA6, 0XA6, 0XA6,
- 0X4E, 0X4E, 0X4E, 0X4E, 0X4E, 0X4E, 0XA5, 0XA5, 0XA5, 0XA5,
- 0XA5, 0XA5, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA3,
- 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA2, 0XA2, 0XA2, 0XA6, 0XA6,
- 0XA6, 0XA6, 0X4E, 0X4E, 0X4E, 0X4E, 0X4E, 0X4E, 0XA5, 0XA5,
- 0XA5, 0XA5, 0XA5, 0XA5, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4,
- 0XA4, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA2, 0XA2, 0XA2,
- 0XA6, 0XA6, 0XA6, 0XA6, 0X4E, 0X4E, 0X4E, 0X4E, 0X4E, 0X4E,
- 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA4, 0XA4, 0XA4, 0XA4,
- 0XA4, 0XA4, 0XA4, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA2,
- 0XA2, 0XA2, 0XA6, 0XA6, 0XA6, 0XA6, 0X4E, 0X4E, 0X4E, 0X4E,
- 0X4E, 0X4E, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA4, 0XA4,
- 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3,
- 0XA3, 0XA2, 0XA2, 0XA2, 0XA6, 0XA6, 0XA6, 0XA6, 0X4E, 0X4E,
- 0X4E, 0X4E, 0X4E, 0X4E, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5,
- 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA3, 0XA3, 0XA3,
- 0XA3, 0XA3, 0XA3, 0XA2, 0XA2, 0XA2, 0XA6, 0XA6, 0XA6, 0XA6,
- 0X27, 0X27, 0X27, 0X27, 0X27, 0X27, 0XA5, 0XA5, 0XA5, 0XA5,
- 0XA5, 0XA5, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA3,
- 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA2, 0XA2, 0XA2, 0XA1, 0XA1,
- 0XA1, 0XA1, 0X27, 0X27, 0X27, 0X27, 0X27, 0X27, 0X4C, 0X4C,
- 0X4C, 0X4C, 0X4C, 0X4C, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0,
- 0XA0, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9E, 0X9E, 0X9E,
- 0XA1, 0XA1, 0XA1, 0XA1, 0X4D, 0X4D, 0X4D, 0X4D, 0X4D, 0X4D,
- 0X13, 0X4C, 0X4C, 0X4C, 0X4C, 0X4C, 0XA0, 0XA0, 0XA0, 0XA0,
- 0XA0, 0XA0, 0XA0, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9E,
- 0X9E, 0X9E, 0XA1, 0XA1, 0XA1, 0XA1, 0X4D, 0X4D, 0X4D, 0X4D,
- 0X4D, 0X4D, 0X13, 0X13, 0X4C, 0X4C, 0X4C, 0X4C, 0XA0, 0XA0,
- 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F,
- 0X9F, 0X9E, 0X9E, 0X9E, 0XA1, 0XA1, 0XA1, 0XA1, 0X4D, 0X4D,
- 0X4D, 0X4D, 0X4D, 0X4D, 0X13, 0X13, 0X13, 0X4C, 0X4C, 0X4C,
- 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0X9F, 0X9F, 0X9F,
- 0X9F, 0X9F, 0X9F, 0X9E, 0X9E, 0X9E, 0XA1, 0XA1, 0XA1, 0XA1,
- 0X4D, 0X4D, 0X4D, 0X4D, 0X4D, 0X13, 0X13, 0X13, 0X13, 0X13,
- 0X13, 0X4C, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0X9F,
- 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9E, 0X9E, 0X9E, 0XA1, 0XA1,
- 0XA1, 0XA1, 0X4D, 0X4D, 0X4D, 0X4D, 0X4D, 0X13, 0X13, 0X13,
- 0X13, 0X13, 0X13, 0X13, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0,
- 0XA0, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9E, 0X9E, 0X9E,
- 0X9D, 0X9D, 0X9D, 0X9D, 0X4B, 0X4B, 0X4B, 0X19, 0X19, 0X19,
- 0X13, 0X13, 0X13, 0X13, 0X13, 0X13, 0X49, 0X49, 0X49, 0X49,
- 0X49, 0X49, 0X49, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9B,
- 0X9B, 0X9B, 0X9D, 0X9D, 0X9D, 0X9D, 0X4B, 0X4B, 0X4B, 0X4B,
- 0X19, 0X19, 0X19, 0X4A, 0X4A, 0X4A, 0X4A, 0X4A, 0X49, 0X49,
- 0X49, 0X49, 0X49, 0X49, 0X49, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C,
- 0X9C, 0X9B, 0X9B, 0X9B, 0X9D, 0X9D, 0X9D, 0X9D, 0X4B, 0X4B,
- 0X4B, 0X4B, 0X4B, 0X19, 0X4A, 0X4A, 0X4A, 0X4A, 0X4A, 0X4A,
- 0X49, 0X49, 0X49, 0X49, 0X49, 0X49, 0X49, 0X9C, 0X9C, 0X9C,
- 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B, 0X9D, 0X9D, 0X9D, 0X9D,
- 0X4B, 0X4B, 0X4B, 0X4B, 0X4B, 0X4B, 0X4A, 0X4A, 0X4A, 0X4A,
- 0X4A, 0X04, 0X05, 0X49, 0X49, 0X49, 0X49, 0X49, 0X49, 0X9C,
- 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B, 0X9D, 0X9D,
- 0X9D, 0X9D, 0X4B, 0X4B, 0X4B, 0X4B, 0X4B, 0X4B, 0X4A, 0X4A,
- 0X4A, 0X4A, 0X04, 0X04, 0X05, 0X05, 0X49, 0X49, 0X49, 0X49,
- 0X49, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B,
- 0X9D, 0X9D, 0X9D, 0X9D, 0X4B, 0X4B, 0X4B, 0X4B, 0X4B, 0X4B,
- 0X4A, 0X4A, 0X4A, 0X04, 0X04, 0X05, 0X05, 0X05, 0X05, 0X49,
- 0X49, 0X49, 0X30, 0X30, 0X30, 0X9C, 0X9C, 0X9C, 0X9C, 0X9B,
- 0X9B, 0X9B, 0X9D, 0X9D, 0X9D, 0X9D, 0X4B, 0X4B, 0X4B, 0X4B,
- 0X4B, 0X4B, 0X4A, 0X4A, 0X04, 0X04, 0X04, 0X05, 0X05, 0X05,
- 0X05, 0X05, 0X49, 0X30, 0X30, 0X30, 0X30, 0X30, 0X30, 0X9C,
- 0X9C, 0X9B, 0X9B, 0X9B, 0XF8, 0XF8, 0XF8, 0XF8, 0XF9, 0XF9,
- 0XF9, 0XF9, 0X99, 0X99, 0XFA, 0XFA, 0XFA, 0XFA, 0X05, 0X05,
- 0X05, 0X05, 0X05, 0X0E, 0X0E, 0X30, 0X30, 0X30, 0X30, 0X30,
- 0X30, 0X46, 0X06, 0XFD, 0XFD, 0XFD, 0X9A, 0X9A, 0X9A, 0X9A,
- 0XF9, 0XF9, 0XF9, 0X99, 0X99, 0X99, 0XFA, 0XFA, 0XFA, 0X48,
- 0X48, 0X05, 0X05, 0X05, 0X0E, 0X0E, 0X47, 0X30, 0X30, 0X30,
- 0X30, 0X30, 0X46, 0X46, 0X06, 0X06, 0XFD, 0XFD, 0X9A, 0X9A,
- 0X9A, 0X9A, 0XF9, 0XF9, 0X99, 0X99, 0X99, 0X99, 0XFA, 0XFA,
- 0X48, 0X48, 0X48, 0X48, 0X05, 0XFB, 0X47, 0X47, 0X47, 0X47,
- 0X30, 0X30, 0X30, 0X46, 0X46, 0X06, 0X06, 0X25, 0XFD, 0X98,
- 0X9A, 0X9A, 0X9A, 0X9A, 0XF9, 0X99, 0X99, 0X99, 0X99, 0X99,
- 0XFA, 0X48, 0X48, 0X48, 0X48, 0X48, 0XFB, 0X47, 0X47, 0X47,
- 0X47, 0X47, 0X30, 0X30, 0X46, 0X46, 0X06, 0X06, 0X25, 0X25,
- 0X25, 0X98, 0X9A, 0X9A, 0X9A, 0X9A, 0X99, 0X99, 0X99, 0X99,
- 0X99, 0X99, 0X48, 0X48, 0X48, 0X48, 0X48, 0X48, 0X47, 0X47,
- 0X47, 0X47, 0X47, 0X47, 0X47, 0X46, 0X46, 0X46, 0X06, 0X6A,
- 0X25, 0X25, 0X25, 0X98, 0X9A, 0X9A, 0X9A, 0X9A, 0X99, 0X99,
- 0X99, 0X99, 0X99, 0X99, 0X48, 0X48, 0X48, 0X48, 0X48, 0X48,
- 0X47, 0X47, 0X47, 0X47, 0X47, 0X47, 0X47, 0X46, 0X46, 0X6A,
- 0X6A, 0X6A, 0X25, 0X25, 0X25, 0X1D, 0XFE, 0XFE, 0XFE, 0XFE,
- 0XFF, 0XFF, 0XFF, 0XFF, 0X96, 0X96, 0X95, 0X95, 0X95, 0X95,
- 0X95, 0X95, 0X94, 0X94, 0X94, 0X94, 0X94, 0X94, 0X94, 0X93,
- 0X93, 0X6A, 0X6A, 0X6A, 0X25, 0X1D, 0X1D, 0X1D, 0XFE, 0XFE,
- 0XFE, 0XFE, 0XFF, 0XFF, 0XFF, 0X96, 0X96, 0X96, 0X95, 0X95,
- 0X95, 0X95, 0X95, 0X95, 0X94, 0X94, 0X94, 0X94, 0X94, 0X94,
- 0X94, 0X93, 0X93, 0X93, 0X93, 0X6A, 0X1D, 0X1D, 0X1D, 0X1D,
- 0X97, 0X97, 0X97, 0X97, 0XFF, 0XFF, 0X96, 0X96, 0X96, 0X96,
- 0X95, 0X95, 0X95, 0X95, 0X95, 0X95, 0X94, 0X94, 0X94, 0X94,
- 0X94, 0X94, 0X94, 0X93, 0X93, 0X93, 0X93, 0X93, 0X1D, 0X1D,
- 0X1D, 0X1D, 0XAC, 0XAC, 0XAC, 0XAC, 0XAB, 0XAB, 0XAB, 0XAB,
- 0XAB, 0XAB, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XA9, 0XA9,
- 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA8, 0XA8, 0XA8, 0XA8, 0XA8,
- 0XA8, 0XA7, 0XA7, 0XA7, 0XAC, 0XAC, 0XAC, 0XAC, 0XAB, 0XAB,
- 0XAB, 0XAB, 0XAB, 0XAB, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA, 0XAA,
- 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA8, 0XA8, 0XA8,
- 0XA8, 0XA8, 0XA8, 0XA7, 0XA7, 0XA7, 0XAC, 0XAC, 0XAC, 0XAC,
- 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAA, 0XAA, 0XAA, 0XAA,
- 0XAA, 0XAA, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA8,
- 0XA8, 0XA8, 0XA8, 0XA8, 0XA8, 0XA7, 0XA7, 0XA7, 0XAC, 0XAC,
- 0XAC, 0XAC, 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAB, 0XAA, 0XAA,
- 0XAA, 0XAA, 0XAA, 0XAA, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9, 0XA9,
- 0XA9, 0XA8, 0XA8, 0XA8, 0XA8, 0XA8, 0XA8, 0XA7, 0XA7, 0XA7,
- 0XA6, 0XA6, 0XA6, 0XA6, 0X4E, 0X4E, 0X4E, 0X4E, 0X4E, 0X4E,
- 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA4, 0XA4, 0XA4, 0XA4,
- 0XA4, 0XA4, 0XA4, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA2,
- 0XA2, 0XA2, 0XA6, 0XA6, 0XA6, 0XA6, 0X4E, 0X4E, 0X4E, 0X4E,
- 0X4E, 0X4E, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA4, 0XA4,
- 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3,
- 0XA3, 0XA2, 0XA2, 0XA2, 0XA6, 0XA6, 0XA6, 0XA6, 0X4E, 0X4E,
- 0X4E, 0X4E, 0X4E, 0X4E, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5,
- 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA3, 0XA3, 0XA3,
- 0XA3, 0XA3, 0XA3, 0XA2, 0XA2, 0XA2, 0XA6, 0XA6, 0XA6, 0XA6,
- 0X4E, 0X4E, 0X4E, 0X4E, 0X4E, 0X4E, 0XA5, 0XA5, 0XA5, 0XA5,
- 0XA5, 0XA5, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA3,
- 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA2, 0XA2, 0XA2, 0XA6, 0XA6,
- 0XA6, 0XA6, 0X4E, 0X4E, 0X4E, 0X4E, 0X4E, 0X4E, 0XA5, 0XA5,
- 0XA5, 0XA5, 0XA5, 0XA5, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4, 0XA4,
- 0XA4, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA2, 0XA2, 0XA2,
- 0XA6, 0XA6, 0XA6, 0XA6, 0X4E, 0X4E, 0X4E, 0X4E, 0X4E, 0X4E,
- 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA5, 0XA4, 0XA4, 0XA4, 0XA4,
- 0XA4, 0XA4, 0XA4, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA3, 0XA2,
- 0XA2, 0XA2, 0XA1, 0XA1, 0XA1, 0XA1, 0X27, 0X27, 0X27, 0X27,
- 0X27, 0X27, 0X13, 0X13, 0X4C, 0X4C, 0X4C, 0X4C, 0XA0, 0XA0,
- 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F,
- 0X9F, 0X9E, 0X9E, 0X9E, 0XA1, 0XA1, 0XA1, 0XA1, 0X4D, 0X4D,
- 0X4D, 0X4D, 0X4D, 0X4D, 0X13, 0X13, 0X13, 0X4C, 0X4C, 0X4C,
- 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0X9F, 0X9F, 0X9F,
- 0X9F, 0X9F, 0X9F, 0X9E, 0X9E, 0X9E, 0XA1, 0XA1, 0XA1, 0XA1,
- 0X4D, 0X4D, 0X4D, 0X4D, 0X4D, 0X13, 0X13, 0X13, 0X13, 0X13,
- 0X13, 0X4C, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0X9F,
- 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9E, 0X9E, 0X9E, 0XA1, 0XA1,
- 0XA1, 0XA1, 0X4D, 0X4D, 0X4D, 0X4D, 0X4D, 0X13, 0X13, 0X13,
- 0X13, 0X13, 0X13, 0X13, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0XA0,
- 0XA0, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9E, 0X9E, 0X9E,
- 0XA1, 0XA1, 0XA1, 0XA1, 0X4D, 0X4D, 0X4D, 0X4D, 0X4D, 0X13,
- 0X13, 0X13, 0X13, 0X13, 0X13, 0X13, 0X13, 0XA0, 0XA0, 0XA0,
- 0XA0, 0XA0, 0XA0, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F, 0X9E,
- 0X9E, 0X9E, 0XA1, 0XA1, 0XA1, 0XA1, 0X4D, 0X4D, 0X4D, 0X4D,
- 0X4D, 0X13, 0X13, 0X13, 0X13, 0X13, 0X13, 0X13, 0X13, 0XA0,
- 0XA0, 0XA0, 0XA0, 0XA0, 0XA0, 0X9F, 0X9F, 0X9F, 0X9F, 0X9F,
- 0X9F, 0X9E, 0X9E, 0X9E, 0X9D, 0X9D, 0X9D, 0X9D, 0X4B, 0X4B,
- 0X4B, 0X4B, 0X19, 0X13, 0X13, 0X13, 0X13, 0X13, 0X13, 0X13,
- 0X13, 0X49, 0X49, 0X49, 0X49, 0X49, 0X49, 0X9C, 0X9C, 0X9C,
- 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B, 0X9D, 0X9D, 0X9D, 0X9D,
- 0X4B, 0X4B, 0X4B, 0X4B, 0X4B, 0X19, 0X13, 0X13, 0X13, 0X4A,
- 0X4A, 0X4A, 0X49, 0X49, 0X49, 0X49, 0X49, 0X49, 0X49, 0X9C,
- 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B, 0X9D, 0X9D,
- 0X9D, 0X9D, 0X4B, 0X4B, 0X4B, 0X4B, 0X4B, 0X4B, 0X4A, 0X4A,
- 0X4A, 0X4A, 0X4A, 0X4A, 0X05, 0X49, 0X49, 0X49, 0X49, 0X49,
- 0X49, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B,
- 0X9D, 0X9D, 0X9D, 0X9D, 0X4B, 0X4B, 0X4B, 0X4B, 0X4B, 0X4B,
- 0X4A, 0X4A, 0X4A, 0X4A, 0X4A, 0X04, 0X05, 0X05, 0X49, 0X49,
- 0X49, 0X49, 0X49, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9C, 0X9B,
- 0X9B, 0X9B, 0X9D, 0X9D, 0X9D, 0X9D, 0X4B, 0X4B, 0X4B, 0X4B,
- 0X4B, 0X4B, 0X4A, 0X4A, 0X4A, 0X4A, 0X04, 0X05, 0X05, 0X05,
- 0X05, 0X49, 0X49, 0X49, 0X30, 0X30, 0X9C, 0X9C, 0X9C, 0X9C,
- 0X9C, 0X9B, 0X9B, 0X9B, 0X9D, 0X9D, 0X9D, 0X9D, 0X4B, 0X4B,
- 0X4B, 0X4B, 0X4B, 0X4B, 0X4A, 0X4A, 0X4A, 0X04, 0X04, 0X05,
- 0X05, 0X05, 0X05, 0X05, 0X49, 0X30, 0X30, 0X30, 0X30, 0X30,
- 0X9C, 0X9C, 0X9C, 0X9B, 0X9B, 0X9B, 0X9D, 0X9D, 0X9D, 0X9D,
- 0X4B, 0X4B, 0X4B, 0X4B, 0X4B, 0X4B, 0X4A, 0X4A, 0X04, 0X04,
- 0X05, 0X05, 0X05, 0X05, 0X05, 0X05, 0X0E, 0X30, 0X30, 0X30,
- 0X30, 0X30, 0X30, 0X30, 0X9C, 0X9B, 0X9B, 0X9B, 0X9A, 0X9A,
- 0X9A, 0X9A, 0XF9, 0XF9, 0XF9, 0X99, 0X99, 0X99, 0XFA, 0XFA,
- 0XFA, 0X48, 0X05, 0X05, 0X05, 0X05, 0X0E, 0X0E, 0X0E, 0X30,
- 0X30, 0X30, 0X30, 0X30, 0X30, 0X30, 0X06, 0XFD, 0XFD, 0XFD,
- 0X9A, 0X9A, 0X9A, 0X9A, 0XF9, 0XF9, 0X99, 0X99, 0X99, 0X99,
- 0XFA, 0XFA, 0X48, 0X48, 0X48, 0X05, 0X05, 0X0E, 0X0E, 0X0E,
- 0X0E, 0X0E, 0X30, 0X30, 0X30, 0X30, 0X30, 0X06, 0X06, 0X25,
- 0XFD, 0X98, 0X9A, 0X9A, 0X9A, 0X9A, 0XF9, 0X99, 0X99, 0X99,
- 0X99, 0X99, 0XFA, 0X48, 0X48, 0X48, 0X48, 0X48, 0X0E, 0X0E,
- 0X0E, 0X0E, 0X0E, 0X0E, 0X30, 0X30, 0X30, 0X30, 0X46, 0X06,
- 0X6A, 0X25, 0X98, 0X98, 0X9A, 0X9A, 0X9A, 0X9A, 0X99, 0X99,
- 0X99, 0X99, 0X99, 0X99, 0X48, 0X48, 0X48, 0X48, 0X48, 0X48,
- 0X0E, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E, 0X30, 0X30, 0X28, 0X46,
- 0X6A, 0X6A, 0X6A, 0X25, 0X25, 0X98, 0X9A, 0X9A, 0X9A, 0X9A,
- 0X99, 0X99, 0X99, 0X99, 0X99, 0X99, 0X48, 0X48, 0X48, 0X48,
- 0X48, 0X48, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E, 0X28, 0X28,
- 0X28, 0X28, 0X6A, 0X6A, 0X6A, 0X25, 0X33, 0X33, 0X9A, 0X9A,
- 0X9A, 0X9A, 0X99, 0X99, 0X99, 0X99, 0X99, 0X99, 0X48, 0X48,
- 0X48, 0X48, 0X48, 0X48, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E,
- 0X28, 0X28, 0X28, 0X6A, 0X6A, 0X6A, 0X6A, 0X33, 0X33, 0X1D,
- 0XFE, 0XFE, 0XFE, 0XFE, 0XFF, 0XFF, 0XFF, 0X96, 0X96, 0X96,
- 0X95, 0X95, 0X95, 0X95, 0X95, 0X95, 0X94, 0X94, 0X94, 0X94,
- 0X94, 0X94, 0X28, 0X28, 0X28, 0X6A, 0X6A, 0X6A, 0X6A, 0X33,
- 0X1D, 0X1D, 0X97, 0X97, 0X97, 0X97, 0XFF, 0XFF, 0X96, 0X96,
- 0X96, 0X96, 0X95, 0X95, 0X95, 0X95, 0X95, 0X95, 0X94, 0X94,
- 0X94, 0X94, 0X94, 0X94, 0X94, 0X93, 0X93, 0X93, 0X6A, 0X6A,
- 0X33, 0X1D, 0X1D, 0X1D, 0X97, 0X97, 0X97, 0X97, 0XFF, 0X96,
- 0X96, 0X96, 0X96, 0X96, 0X95, 0X95, 0X95, 0X95, 0X95, 0X95,
- 0X94, 0X94, 0X94, 0X94, 0X94, 0X94, 0X94, 0X93, 0X93, 0X93,
- 0X93, 0X93, 0X1D, 0X1D, 0X1D, 0X1D, 0X91, 0X91, 0X91, 0X91,
- 0X90, 0X90, 0X90, 0X90, 0X90, 0X90, 0X8F, 0X8F, 0X8F, 0X8F,
- 0X8F, 0X8F, 0X8E, 0X8E, 0X8E, 0X8E, 0X8E, 0X8E, 0X8E, 0X8D,
- 0X8D, 0X8D, 0X8D, 0X8D, 0X8D, 0X8C, 0X8C, 0X8C, 0X91, 0X91,
- 0X91, 0X91, 0X90, 0X90, 0X90, 0X90, 0X90, 0X90, 0X8F, 0X8F,
- 0X8F, 0X8F, 0X8F, 0X8F, 0X8E, 0X8E, 0X8E, 0X8E, 0X8E, 0X8E,
- 0X8E, 0X8D, 0X8D, 0X8D, 0X8D, 0X8D, 0X8D, 0X8C, 0X8C, 0X8C,
- 0X91, 0X91, 0X91, 0X91, 0X90, 0X90, 0X90, 0X90, 0X90, 0X90,
- 0X8F, 0X8F, 0X8F, 0X8F, 0X8F, 0X8F, 0X8E, 0X8E, 0X8E, 0X8E,
- 0X8E, 0X8E, 0X8E, 0X8D, 0X8D, 0X8D, 0X8D, 0X8D, 0X8D, 0X8C,
- 0X8C, 0X8C, 0X91, 0X91, 0X91, 0X91, 0X90, 0X90, 0X90, 0X90,
- 0X90, 0X90, 0X8F, 0X8F, 0X8F, 0X8F, 0X8F, 0X8F, 0X8E, 0X8E,
- 0X8E, 0X8E, 0X8E, 0X8E, 0X8E, 0X8D, 0X8D, 0X8D, 0X8D, 0X8D,
- 0X8D, 0X8C, 0X8C, 0X8C, 0X8B, 0X8B, 0X8B, 0X8B, 0X8A, 0X8A,
- 0X8A, 0X8A, 0X8A, 0X8A, 0X89, 0X89, 0X89, 0X89, 0X89, 0X89,
- 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X87, 0X87, 0X87,
- 0X87, 0X87, 0X87, 0X86, 0X86, 0X86, 0X8B, 0X8B, 0X8B, 0X8B,
- 0X8A, 0X8A, 0X8A, 0X8A, 0X8A, 0X8A, 0X89, 0X89, 0X89, 0X89,
- 0X89, 0X89, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X87,
- 0X87, 0X87, 0X87, 0X87, 0X87, 0X86, 0X86, 0X86, 0X8B, 0X8B,
- 0X8B, 0X8B, 0X8A, 0X8A, 0X8A, 0X8A, 0X8A, 0X8A, 0X89, 0X89,
- 0X89, 0X89, 0X89, 0X89, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88,
- 0X88, 0X87, 0X87, 0X87, 0X87, 0X87, 0X87, 0X86, 0X86, 0X86,
- 0X8B, 0X8B, 0X8B, 0X8B, 0X8A, 0X8A, 0X8A, 0X8A, 0X8A, 0X8A,
- 0X89, 0X89, 0X89, 0X89, 0X89, 0X89, 0X88, 0X88, 0X88, 0X88,
- 0X88, 0X88, 0X88, 0X87, 0X87, 0X87, 0X87, 0X87, 0X87, 0X86,
- 0X86, 0X86, 0X8B, 0X8B, 0X8B, 0X8B, 0X8A, 0X8A, 0X8A, 0X8A,
- 0X8A, 0X8A, 0X89, 0X89, 0X89, 0X89, 0X89, 0X89, 0X88, 0X88,
- 0X88, 0X88, 0X88, 0X88, 0X88, 0X87, 0X87, 0X87, 0X87, 0X87,
- 0X87, 0X86, 0X86, 0X86, 0X8B, 0X8B, 0X8B, 0X8B, 0X8A, 0X8A,
- 0X8A, 0X8A, 0X8A, 0X8A, 0X89, 0X89, 0X89, 0X89, 0X89, 0X89,
- 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X87, 0X87, 0X87,
- 0X87, 0X87, 0X87, 0X86, 0X86, 0X86, 0X85, 0X85, 0X85, 0X85,
- 0X84, 0X84, 0X84, 0X84, 0X84, 0X84, 0X13, 0X13, 0X13, 0X83,
- 0X83, 0X83, 0X82, 0X82, 0X82, 0X82, 0X82, 0X82, 0X82, 0X81,
- 0X81, 0X81, 0X81, 0X81, 0X81, 0X80, 0X80, 0X80, 0X85, 0X85,
- 0X85, 0X85, 0X84, 0X84, 0X84, 0X84, 0X84, 0X13, 0X13, 0X13,
- 0X13, 0X13, 0X83, 0X83, 0X82, 0X82, 0X82, 0X82, 0X82, 0X82,
- 0X82, 0X81, 0X81, 0X81, 0X81, 0X81, 0X81, 0X80, 0X80, 0X80,
- 0X85, 0X85, 0X85, 0X85, 0X84, 0X84, 0X84, 0X84, 0X84, 0X13,
- 0X13, 0X13, 0X13, 0X13, 0X13, 0X83, 0X82, 0X82, 0X82, 0X82,
- 0X82, 0X82, 0X82, 0X81, 0X81, 0X81, 0X81, 0X81, 0X81, 0X80,
- 0X80, 0X80, 0X85, 0X85, 0X85, 0X85, 0X84, 0X84, 0X84, 0X84,
- 0X84, 0X13, 0X13, 0X13, 0X13, 0X13, 0X13, 0X13, 0X82, 0X82,
- 0X82, 0X82, 0X82, 0X82, 0X82, 0X81, 0X81, 0X81, 0X81, 0X81,
- 0X81, 0X80, 0X80, 0X80, 0X85, 0X85, 0X85, 0X85, 0X84, 0X84,
- 0X84, 0X84, 0X84, 0X13, 0X13, 0X13, 0X13, 0X13, 0X13, 0X13,
- 0X13, 0X82, 0X82, 0X82, 0X82, 0X82, 0X82, 0X81, 0X81, 0X81,
- 0X81, 0X81, 0X81, 0X80, 0X80, 0X80, 0X85, 0X85, 0X85, 0X85,
- 0X84, 0X84, 0X84, 0X84, 0X84, 0X13, 0X13, 0X13, 0X13, 0X13,
- 0X13, 0X13, 0X13, 0X82, 0X82, 0X82, 0X82, 0X82, 0X82, 0X81,
- 0X81, 0X81, 0X81, 0X81, 0X81, 0X80, 0X80, 0X80, 0X7F, 0X7F,
- 0X7F, 0X7F, 0X7E, 0X7E, 0X7E, 0X7E, 0X7E, 0X13, 0X13, 0X13,
- 0X13, 0X13, 0X13, 0X13, 0X13, 0X44, 0X44, 0X44, 0X44, 0X44,
- 0X44, 0X7D, 0X7D, 0X7D, 0X7D, 0X7D, 0X7D, 0X7C, 0X7C, 0X7C,
- 0X7F, 0X7F, 0X7F, 0X7F, 0X7E, 0X7E, 0X7E, 0X7E, 0X7E, 0X13,
- 0X13, 0X13, 0X13, 0X13, 0X45, 0X45, 0X44, 0X44, 0X44, 0X44,
- 0X44, 0X44, 0X44, 0X7D, 0X7D, 0X7D, 0X7D, 0X7D, 0X7D, 0X7C,
- 0X7C, 0X7C, 0X7F, 0X7F, 0X7F, 0X7F, 0X7E, 0X7E, 0X7E, 0X7E,
- 0X7E, 0X7E, 0X45, 0X45, 0X45, 0X45, 0X45, 0X45, 0X44, 0X44,
- 0X44, 0X44, 0X44, 0X44, 0X44, 0X7D, 0X7D, 0X7D, 0X7D, 0X7D,
- 0X7D, 0X7C, 0X7C, 0X7C, 0X7F, 0X7F, 0X7F, 0X7F, 0X7E, 0X7E,
- 0X7E, 0X7E, 0X7E, 0X7E, 0X45, 0X45, 0X45, 0X45, 0X45, 0X45,
- 0X05, 0X44, 0X44, 0X44, 0X44, 0X44, 0X44, 0X7D, 0X7D, 0X7D,
- 0X7D, 0X7D, 0X7D, 0X7C, 0X7C, 0X7C, 0X7F, 0X7F, 0X7F, 0X7F,
- 0X7E, 0X7E, 0X7E, 0X7E, 0X7E, 0X7E, 0X45, 0X45, 0X45, 0X45,
- 0X45, 0X05, 0X05, 0X05, 0X44, 0X44, 0X44, 0X44, 0X30, 0X30,
- 0X7D, 0X7D, 0X7D, 0X7D, 0X7D, 0X7C, 0X7C, 0X7C, 0X7F, 0X7F,
- 0X7F, 0X7F, 0X7E, 0X7E, 0X7E, 0X7E, 0X7E, 0X7E, 0X45, 0X45,
- 0X45, 0X45, 0X05, 0X05, 0X05, 0X05, 0X05, 0X44, 0X44, 0X30,
- 0X30, 0X30, 0X30, 0X30, 0X7D, 0X7D, 0X7D, 0X7C, 0X7C, 0X7C,
- 0X7F, 0X7F, 0X7F, 0X7F, 0X7E, 0X7E, 0X7E, 0X7E, 0X7E, 0X7E,
- 0X45, 0X45, 0X45, 0X04, 0X05, 0X05, 0X05, 0X05, 0X05, 0X0E,
- 0X0E, 0X30, 0X30, 0X30, 0X30, 0X30, 0X30, 0X30, 0X7D, 0X7C,
- 0X7C, 0X7C, 0X7B, 0X7B, 0X7B, 0X7B, 0X7A, 0X7A, 0X7A, 0X7A,
- 0X7A, 0X7A, 0X79, 0X79, 0X79, 0X79, 0X05, 0X05, 0X05, 0X05,
- 0X0E, 0X0E, 0X0E, 0X0E, 0X30, 0X30, 0X30, 0X30, 0X30, 0X30,
- 0X42, 0X78, 0X78, 0X78, 0X7B, 0X7B, 0X7B, 0X7B, 0X7A, 0X7A,
- 0X7A, 0X7A, 0X7A, 0X7A, 0X79, 0X79, 0X79, 0X79, 0X79, 0X05,
- 0X05, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E, 0X30, 0X30, 0X30, 0X30,
- 0X30, 0X42, 0X6A, 0X6A, 0X78, 0X78, 0X7B, 0X7B, 0X7B, 0X7B,
- 0X7A, 0X7A, 0X7A, 0X7A, 0X7A, 0X7A, 0X79, 0X79, 0X79, 0X79,
- 0X79, 0X79, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E, 0X30, 0X30,
- 0X30, 0X28, 0X28, 0X6A, 0X6A, 0X6A, 0X78, 0X78, 0X7B, 0X7B,
- 0X7B, 0X7B, 0X7A, 0X7A, 0X7A, 0X7A, 0X7A, 0X7A, 0X79, 0X79,
- 0X79, 0X79, 0X79, 0X79, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E,
- 0X28, 0X28, 0X28, 0X28, 0X28, 0X6A, 0X6A, 0X33, 0X33, 0X78,
- 0X7B, 0X7B, 0X7B, 0X7B, 0X7A, 0X7A, 0X7A, 0X7A, 0X7A, 0X7A,
- 0X79, 0X79, 0X79, 0X79, 0X79, 0X79, 0X0E, 0X0E, 0X0E, 0X0E,
- 0X0E, 0X0E, 0X28, 0X28, 0X28, 0X28, 0X6A, 0X6A, 0X6A, 0X33,
- 0X33, 0X33, 0X7B, 0X7B, 0X7B, 0X7B, 0X7A, 0X7A, 0X7A, 0X7A,
- 0X7A, 0X7A, 0X79, 0X79, 0X79, 0X79, 0X79, 0X79, 0X0E, 0X0E,
- 0X0E, 0X0E, 0X0E, 0X0E, 0X28, 0X28, 0X28, 0X28, 0X6A, 0X6A,
- 0X33, 0X33, 0X33, 0X33, 0X77, 0X77, 0X77, 0X77, 0X76, 0X76,
- 0X76, 0X76, 0X76, 0X76, 0X75, 0X75, 0X75, 0X75, 0X75, 0X75,
- 0X0E, 0X0E, 0X74, 0X74, 0X74, 0X28, 0X28, 0X28, 0X28, 0X28,
- 0X2D, 0X6A, 0X33, 0X33, 0X33, 0X69, 0X77, 0X77, 0X77, 0X77,
- 0X76, 0X76, 0X76, 0X76, 0X76, 0X76, 0X75, 0X75, 0X75, 0X75,
- 0X75, 0X75, 0X74, 0X74, 0X74, 0X74, 0X74, 0X74, 0X28, 0X28,
- 0X28, 0X2D, 0X2D, 0X2D, 0X69, 0X69, 0X69, 0X69, 0X77, 0X77,
- 0X77, 0X77, 0X76, 0X76, 0X76, 0X76, 0X76, 0X76, 0X75, 0X75,
- 0X75, 0X75, 0X75, 0X75, 0X74, 0X74, 0X74, 0X74, 0X74, 0X74,
- 0X74, 0X41, 0X41, 0X41, 0X41, 0X2D, 0X69, 0X69, 0X69, 0X69,
- 0X91, 0X91, 0X91, 0X91, 0X90, 0X90, 0X90, 0X90, 0X90, 0X90,
- 0X8F, 0X8F, 0X8F, 0X8F, 0X8F, 0X8F, 0X8E, 0X8E, 0X8E, 0X8E,
- 0X8E, 0X8E, 0X8E, 0X8D, 0X8D, 0X8D, 0X8D, 0X8D, 0X8D, 0X8C,
- 0X8C, 0X8C, 0X91, 0X91, 0X91, 0X91, 0X90, 0X90, 0X90, 0X90,
- 0X90, 0X90, 0X8F, 0X8F, 0X8F, 0X8F, 0X8F, 0X8F, 0X8E, 0X8E,
- 0X8E, 0X8E, 0X8E, 0X8E, 0X8E, 0X8D, 0X8D, 0X8D, 0X8D, 0X8D,
- 0X8D, 0X8C, 0X8C, 0X8C, 0X91, 0X91, 0X91, 0X91, 0X90, 0X90,
- 0X90, 0X90, 0X90, 0X90, 0X8F, 0X8F, 0X8F, 0X8F, 0X8F, 0X8F,
- 0X8E, 0X8E, 0X8E, 0X8E, 0X8E, 0X8E, 0X8E, 0X8D, 0X8D, 0X8D,
- 0X8D, 0X8D, 0X8D, 0X8C, 0X8C, 0X8C, 0X91, 0X91, 0X91, 0X91,
- 0X90, 0X90, 0X90, 0X90, 0X90, 0X90, 0X8F, 0X8F, 0X8F, 0X8F,
- 0X8F, 0X8F, 0X8E, 0X8E, 0X8E, 0X8E, 0X8E, 0X8E, 0X8E, 0X8D,
- 0X8D, 0X8D, 0X8D, 0X8D, 0X8D, 0X8C, 0X8C, 0X8C, 0X8B, 0X8B,
- 0X8B, 0X8B, 0X8A, 0X8A, 0X8A, 0X8A, 0X8A, 0X8A, 0X89, 0X89,
- 0X89, 0X89, 0X89, 0X89, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88,
- 0X88, 0X87, 0X87, 0X87, 0X87, 0X87, 0X87, 0X86, 0X86, 0X86,
- 0X8B, 0X8B, 0X8B, 0X8B, 0X8A, 0X8A, 0X8A, 0X8A, 0X8A, 0X8A,
- 0X89, 0X89, 0X89, 0X89, 0X89, 0X89, 0X88, 0X88, 0X88, 0X88,
- 0X88, 0X88, 0X88, 0X87, 0X87, 0X87, 0X87, 0X87, 0X87, 0X86,
- 0X86, 0X86, 0X8B, 0X8B, 0X8B, 0X8B, 0X8A, 0X8A, 0X8A, 0X8A,
- 0X8A, 0X8A, 0X89, 0X89, 0X89, 0X89, 0X89, 0X89, 0X88, 0X88,
- 0X88, 0X88, 0X88, 0X88, 0X88, 0X87, 0X87, 0X87, 0X87, 0X87,
- 0X87, 0X86, 0X86, 0X86, 0X8B, 0X8B, 0X8B, 0X8B, 0X8A, 0X8A,
- 0X8A, 0X8A, 0X8A, 0X8A, 0X89, 0X89, 0X89, 0X89, 0X89, 0X89,
- 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X87, 0X87, 0X87,
- 0X87, 0X87, 0X87, 0X86, 0X86, 0X86, 0X8B, 0X8B, 0X8B, 0X8B,
- 0X8A, 0X8A, 0X8A, 0X8A, 0X8A, 0X8A, 0X89, 0X89, 0X89, 0X89,
- 0X89, 0X89, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X87,
- 0X87, 0X87, 0X87, 0X87, 0X87, 0X86, 0X86, 0X86, 0X8B, 0X8B,
- 0X8B, 0X8B, 0X8A, 0X8A, 0X8A, 0X8A, 0X8A, 0X8A, 0X89, 0X89,
- 0X89, 0X89, 0X89, 0X89, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88,
- 0X88, 0X87, 0X87, 0X87, 0X87, 0X87, 0X87, 0X86, 0X86, 0X86,
- 0X85, 0X85, 0X85, 0X85, 0X84, 0X84, 0X84, 0X84, 0X84, 0X84,
- 0X83, 0X83, 0X83, 0X83, 0X83, 0X83, 0X82, 0X82, 0X82, 0X82,
- 0X82, 0X82, 0X82, 0X81, 0X81, 0X81, 0X81, 0X81, 0X81, 0X80,
- 0X80, 0X80, 0X85, 0X85, 0X85, 0X85, 0X84, 0X84, 0X84, 0X84,
- 0X84, 0X84, 0X83, 0X83, 0X83, 0X83, 0X83, 0X83, 0X82, 0X82,
- 0X82, 0X82, 0X82, 0X82, 0X82, 0X81, 0X81, 0X81, 0X81, 0X81,
- 0X81, 0X80, 0X80, 0X80, 0X85, 0X85, 0X85, 0X85, 0X84, 0X84,
- 0X84, 0X84, 0X84, 0X84, 0X13, 0X83, 0X83, 0X83, 0X83, 0X83,
- 0X82, 0X82, 0X82, 0X82, 0X82, 0X82, 0X82, 0X81, 0X81, 0X81,
- 0X81, 0X81, 0X81, 0X80, 0X80, 0X80, 0X85, 0X85, 0X85, 0X85,
- 0X84, 0X84, 0X84, 0X84, 0X84, 0X84, 0X13, 0X13, 0X83, 0X83,
- 0X83, 0X83, 0X82, 0X82, 0X82, 0X82, 0X82, 0X82, 0X82, 0X81,
- 0X81, 0X81, 0X81, 0X81, 0X81, 0X80, 0X80, 0X80, 0X85, 0X85,
- 0X85, 0X85, 0X84, 0X84, 0X84, 0X84, 0X84, 0X84, 0X13, 0X13,
- 0X13, 0X83, 0X83, 0X83, 0X82, 0X82, 0X82, 0X82, 0X82, 0X82,
- 0X82, 0X81, 0X81, 0X81, 0X81, 0X81, 0X81, 0X80, 0X80, 0X80,
- 0X85, 0X85, 0X85, 0X85, 0X84, 0X84, 0X84, 0X84, 0X84, 0X13,
- 0X13, 0X13, 0X13, 0X13, 0X83, 0X83, 0X82, 0X82, 0X82, 0X82,
- 0X82, 0X82, 0X82, 0X81, 0X81, 0X81, 0X81, 0X81, 0X81, 0X80,
- 0X80, 0X80, 0X7F, 0X7F, 0X7F, 0X7F, 0X7E, 0X7E, 0X7E, 0X7E,
- 0X7E, 0X13, 0X13, 0X13, 0X13, 0X13, 0X13, 0X45, 0X44, 0X44,
- 0X44, 0X44, 0X44, 0X44, 0X44, 0X7D, 0X7D, 0X7D, 0X7D, 0X7D,
- 0X7D, 0X7C, 0X7C, 0X7C, 0X7F, 0X7F, 0X7F, 0X7F, 0X7E, 0X7E,
- 0X7E, 0X7E, 0X7E, 0X7E, 0X45, 0X45, 0X45, 0X45, 0X45, 0X45,
- 0X44, 0X44, 0X44, 0X44, 0X44, 0X44, 0X44, 0X7D, 0X7D, 0X7D,
- 0X7D, 0X7D, 0X7D, 0X7C, 0X7C, 0X7C, 0X7F, 0X7F, 0X7F, 0X7F,
- 0X7E, 0X7E, 0X7E, 0X7E, 0X7E, 0X7E, 0X45, 0X45, 0X45, 0X45,
- 0X45, 0X45, 0X44, 0X44, 0X44, 0X44, 0X44, 0X44, 0X44, 0X7D,
- 0X7D, 0X7D, 0X7D, 0X7D, 0X7D, 0X7C, 0X7C, 0X7C, 0X7F, 0X7F,
- 0X7F, 0X7F, 0X7E, 0X7E, 0X7E, 0X7E, 0X7E, 0X7E, 0X45, 0X45,
- 0X45, 0X45, 0X45, 0X45, 0X44, 0X44, 0X44, 0X44, 0X44, 0X44,
- 0X44, 0X7D, 0X7D, 0X7D, 0X7D, 0X7D, 0X7D, 0X7C, 0X7C, 0X7C,
- 0X7F, 0X7F, 0X7F, 0X7F, 0X7E, 0X7E, 0X7E, 0X7E, 0X7E, 0X7E,
- 0X45, 0X45, 0X45, 0X45, 0X45, 0X45, 0X44, 0X44, 0X44, 0X44,
- 0X44, 0X44, 0X44, 0X7D, 0X7D, 0X7D, 0X7D, 0X7D, 0X7D, 0X7C,
- 0X7C, 0X7C, 0X7F, 0X7F, 0X7F, 0X7F, 0X7E, 0X7E, 0X7E, 0X7E,
- 0X7E, 0X7E, 0X45, 0X45, 0X45, 0X45, 0X45, 0X45, 0X05, 0X44,
- 0X44, 0X44, 0X44, 0X44, 0X30, 0X30, 0X7D, 0X7D, 0X7D, 0X7D,
- 0X7D, 0X7C, 0X7C, 0X7C, 0X7F, 0X7F, 0X7F, 0X7F, 0X7E, 0X7E,
- 0X7E, 0X7E, 0X7E, 0X7E, 0X45, 0X45, 0X45, 0X45, 0X45, 0X05,
- 0X05, 0X05, 0X0E, 0X0E, 0X0E, 0X0E, 0X30, 0X30, 0X30, 0X30,
- 0X7D, 0X7D, 0X7D, 0X7C, 0X7C, 0X7C, 0X7B, 0X7B, 0X7B, 0X7B,
- 0X7A, 0X7A, 0X7A, 0X7A, 0X7A, 0X7A, 0X79, 0X79, 0X79, 0X79,
- 0X79, 0X05, 0X05, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E, 0X30, 0X30,
- 0X30, 0X30, 0X42, 0X42, 0X42, 0X78, 0X78, 0X78, 0X7B, 0X7B,
- 0X7B, 0X7B, 0X7A, 0X7A, 0X7A, 0X7A, 0X7A, 0X7A, 0X79, 0X79,
- 0X79, 0X79, 0X79, 0X79, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E, 0X0E,
- 0X30, 0X30, 0X30, 0X42, 0X42, 0X42, 0X42, 0X78, 0X78, 0X78,
- 0X7B, 0X7B, 0X7B, 0X7B, 0X7A, 0X7A, 0X7A, 0X7A, 0X7A, 0X7A,
- 0X79, 0X79, 0X79, 0X79, 0X79, 0X79, 0X0E, 0X0E, 0X0E, 0X0E,
- 0X0E, 0X0E, 0X28, 0X28, 0X28, 0X28, 0X42, 0X42, 0X42, 0X78,
- 0X78, 0X78, 0X7B, 0X7B, 0X7B, 0X7B, 0X7A, 0X7A, 0X7A, 0X7A,
- 0X7A, 0X7A, 0X79, 0X79, 0X79, 0X79, 0X79, 0X79, 0X0E, 0X0E,
- 0X0E, 0X0E, 0X0E, 0X0E, 0X28, 0X28, 0X28, 0X28, 0X28, 0X42,
- 0X6A, 0X33, 0X78, 0X78, 0X7B, 0X7B, 0X7B, 0X7B, 0X7A, 0X7A,
- 0X7A, 0X7A, 0X7A, 0X7A, 0X79, 0X79, 0X79, 0X79, 0X79, 0X79,
- 0X0E, 0X0E, 0X0E, 0X0E, 0X43, 0X43, 0X28, 0X28, 0X28, 0X28,
- 0X28, 0X6A, 0X33, 0X33, 0X33, 0X33, 0X7B, 0X7B, 0X7B, 0X7B,
- 0X7A, 0X7A, 0X7A, 0X7A, 0X7A, 0X7A, 0X79, 0X79, 0X79, 0X79,
- 0X79, 0X79, 0X43, 0X43, 0X43, 0X43, 0X43, 0X28, 0X28, 0X28,
- 0X28, 0X28, 0X2D, 0X2D, 0X33, 0X33, 0X33, 0X33, 0X77, 0X77,
- 0X77, 0X77, 0X76, 0X76, 0X76, 0X76, 0X76, 0X76, 0X75, 0X75,
- 0X75, 0X75, 0X75, 0X75, 0X74, 0X74, 0X74, 0X74, 0X74, 0X74,
- 0X28, 0X28, 0X28, 0X28, 0X2D, 0X2D, 0X2D, 0X33, 0X69, 0X69,
- 0X77, 0X77, 0X77, 0X77, 0X76, 0X76, 0X76, 0X76, 0X76, 0X76,
- 0X75, 0X75, 0X75, 0X75, 0X75, 0X75, 0X74, 0X74, 0X74, 0X74,
- 0X74, 0X74, 0X74, 0X28, 0X41, 0X2D, 0X2D, 0X2D, 0X2D, 0X69,
- 0X69, 0X69, 0X77, 0X77, 0X77, 0X77, 0X76, 0X76, 0X76, 0X76,
- 0X76, 0X76, 0X75, 0X75, 0X75, 0X75, 0X75, 0X75, 0X74, 0X74,
- 0X74, 0X74, 0X74, 0X74, 0X74, 0X41, 0X41, 0X41, 0X41, 0X2D,
- 0X69, 0X69, 0X69, 0X0D, 0X91, 0X91, 0X91, 0X91, 0X90, 0X90,
- 0X90, 0X90, 0X90, 0X90, 0X8F, 0X8F, 0X8F, 0X8F, 0X8F, 0X8F,
- 0X8E, 0X8E, 0X8E, 0X8E, 0X8E, 0X8E, 0X8E, 0X8D, 0X8D, 0X8D,
- 0X8D, 0X8D, 0X8D, 0X8C, 0X8C, 0X8C, 0X91, 0X91, 0X91, 0X91,
- 0X90, 0X90, 0X90, 0X90, 0X90, 0X90, 0X8F, 0X8F, 0X8F, 0X8F,
- 0X8F, 0X8F, 0X8E, 0X8E, 0X8E, 0X8E, 0X8E, 0X8E, 0X8E, 0X8D,
- 0X8D, 0X8D, 0X8D, 0X8D, 0X8D, 0X8C, 0X8C, 0X8C, 0X91, 0X91,
- 0X91, 0X91, 0X90, 0X90, 0X90, 0X90, 0X90, 0X90, 0X8F, 0X8F,
- 0X8F, 0X8F, 0X8F, 0X8F, 0X8E, 0X8E, 0X8E, 0X8E, 0X8E, 0X8E,
- 0X8E, 0X8D, 0X8D, 0X8D, 0X8D, 0X8D, 0X8D, 0X8C, 0X8C, 0X8C,
- 0X91, 0X91, 0X91, 0X91, 0X90, 0X90, 0X90, 0X90, 0X90, 0X90,
- 0X8F, 0X8F, 0X8F, 0X8F, 0X8F, 0X8F, 0X8E, 0X8E, 0X8E, 0X8E,
- 0X8E, 0X8E, 0X8E, 0X8D, 0X8D, 0X8D, 0X8D, 0X8D, 0X8D, 0X8C,
- 0X8C, 0X8C, 0X8B, 0X8B, 0X8B, 0X8B, 0X8A, 0X8A, 0X8A, 0X8A,
- 0X8A, 0X8A, 0X89, 0X89, 0X89, 0X89, 0X89, 0X89, 0X88, 0X88,
- 0X88, 0X88, 0X88, 0X88, 0X88, 0X87, 0X87, 0X87, 0X87, 0X87,
- 0X87, 0X86, 0X86, 0X86, 0X8B, 0X8B, 0X8B, 0X8B, 0X8A, 0X8A,
- 0X8A, 0X8A, 0X8A, 0X8A, 0X89, 0X89, 0X89, 0X89, 0X89, 0X89,
- 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X87, 0X87, 0X87,
- 0X87, 0X87, 0X87, 0X86, 0X86, 0X86, 0X8B, 0X8B, 0X8B, 0X8B,
- 0X8A, 0X8A, 0X8A, 0X8A, 0X8A, 0X8A, 0X89, 0X89, 0X89, 0X89,
- 0X89, 0X89, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88, 0X87,
- 0X87, 0X87, 0X87, 0X87, 0X87, 0X86, 0X86, 0X86, 0X8B, 0X8B,
- 0X8B, 0X8B, 0X8A, 0X8A, 0X8A, 0X8A, 0X8A, 0X8A, 0X89, 0X89,
- 0X89, 0X89, 0X89, 0X89, 0X88, 0X88, 0X88, 0X88, 0X88, 0X88,
- 0X88, 0X87, 0X87, 0X87, 0X87, 0X87, 0X87, 0X86, 0X86, 0X86,
- 0X8B, 0X8B, 0X8B, 0X8B, 0X8A, 0X8A, 0X8A, 0X8A, 0X8A, 0X8A,
- 0X89, 0X89, 0X89, 0X89, 0X89, 0X89, 0X88, 0X88, 0X88, 0X88,
- 0X88, 0X88, 0X88, 0X87, 0X87, 0X87, 0X87, 0X87, 0X87, 0X86,
- 0X86, 0X86, 0X8B, 0X8B, 0X8B, 0X8B, 0X8A, 0X8A, 0X8A, 0X8A,
- 0X8A, 0X8A, 0X89, 0X89, 0X89, 0X89, 0X89, 0X89, 0X88, 0X88,
- 0X88, 0X88, 0X88, 0X88, 0X88, 0X87, 0X87, 0X87, 0X87, 0X87,
- 0X87, 0X86, 0X86, 0X86, 0X85, 0X85, 0X85, 0X85, 0X84, 0X84,
- 0X84, 0X84, 0X84, 0X84, 0X83, 0X83, 0X83, 0X83, 0X83, 0X83,
- 0X82, 0X82, 0X82, 0X82, 0X82, 0X82, 0X82, 0X81, 0X81, 0X81,
- 0X81, 0X81, 0X81, 0X80, 0X80, 0X80, 0X85, 0X85, 0X85, 0X85,
- 0X84, 0X84, 0X84, 0X84, 0X84, 0X84, 0X83, 0X83, 0X83, 0X83,
- 0X83, 0X83, 0X82, 0X82, 0X82, 0X82, 0X82, 0X82, 0X82, 0X81,
- 0X81, 0X81, 0X81, 0X81, 0X81, 0X80, 0X80, 0X80, 0X85, 0X85,
- 0X85, 0X85, 0X84, 0X84, 0X84, 0X84, 0X84, 0X84, 0X83, 0X83,
- 0X83, 0X83, 0X83, 0X83, 0X82, 0X82, 0X82, 0X82, 0X82, 0X82,
- 0X82, 0X81, 0X81, 0X81, 0X81, 0X81, 0X81, 0X80, 0X80, 0X80,
- 0X85, 0X85, 0X85, 0X85, 0X84, 0X84, 0X84, 0X84, 0X84, 0X84,
- 0X83, 0X83, 0X83, 0X83, 0X83, 0X83, 0X82, 0X82, 0X82, 0X82,
- 0X82, 0X82, 0X82, 0X81, 0X81, 0X81, 0X81, 0X81, 0X81, 0X80,
- 0X80, 0X80, 0X85, 0X85, 0X85, 0X85, 0X84, 0X84, 0X84, 0X84,
- 0X84, 0X84, 0X83, 0X83, 0X83, 0X83, 0X83, 0X83, 0X82, 0X82,
- 0X82, 0X82, 0X82, 0X82, 0X82, 0X81, 0X81, 0X81, 0X81, 0X81,
- 0X81, 0X80, 0X80, 0X80, 0X85, 0X85, 0X85, 0X85, 0X84, 0X84,
- 0X84, 0X84, 0X84, 0X84, 0X83, 0X83, 0X83, 0X83, 0X83, 0X83,
- 0X82, 0X82, 0X82, 0X82, 0X82, 0X82, 0X82, 0X81, 0X81, 0X81,
- 0X81, 0X81, 0X81, 0X80, 0X80, 0X80, 0X7F, 0X7F, 0X7F, 0X7F,
- 0X7E, 0X7E, 0X7E, 0X7E, 0X7E, 0X7E, 0X13, 0X45, 0X45, 0X45,
- 0X45, 0X45, 0X44, 0X44, 0X44, 0X44, 0X44, 0X44, 0X44, 0X7D,
- 0X7D, 0X7D, 0X7D, 0X7D, 0X7D, 0X7C, 0X7C, 0X7C, 0X7F, 0X7F,
- 0X7F, 0X7F, 0X7E, 0X7E, 0X7E, 0X7E, 0X7E, 0X7E, 0X45, 0X45,
- 0X45, 0X45, 0X45, 0X45, 0X44, 0X44, 0X44, 0X44, 0X44, 0X44,
- 0X44, 0X7D, 0X7D, 0X7D, 0X7D, 0X7D, 0X7D, 0X7C, 0X7C, 0X7C,
- 0X7F, 0X7F, 0X7F, 0X7F, 0X7E, 0X7E, 0X7E, 0X7E, 0X7E, 0X7E,
- 0X45, 0X45, 0X45, 0X45, 0X45, 0X45, 0X44, 0X44, 0X44, 0X44,
- 0X44, 0X44, 0X44, 0X7D, 0X7D, 0X7D, 0X7D, 0X7D, 0X7D, 0X7C,
- 0X7C, 0X7C, 0X7F, 0X7F, 0X7F, 0X7F, 0X7E, 0X7E, 0X7E, 0X7E,
- 0X7E, 0X7E, 0X45, 0X45, 0X45, 0X45, 0X45, 0X45, 0X44, 0X44,
- 0X44, 0X44, 0X44, 0X44, 0X44, 0X7D, 0X7D, 0X7D, 0X7D, 0X7D,
- 0X7D, 0X7C, 0X7C, 0X7C, 0X7F, 0X7F, 0X7F, 0X7F, 0X7E, 0X7E,
- 0X7E, 0X7E, 0X7E, 0X7E, 0X45, 0X45, 0X45, 0X45, 0X45, 0X45,
- 0X44, 0X44, 0X44, 0X44, 0X44, 0X44, 0X44, 0X7D, 0X7D, 0X7D,
- 0X7D, 0X7D, 0X7D, 0X7C, 0X7C, 0X7C, 0X7F, 0X7F, 0X7F, 0X7F,
- 0X7E, 0X7E, 0X7E, 0X7E, 0X7E, 0X7E, 0X45, 0X45, 0X45, 0X45,
- 0X45, 0X45, 0X44, 0X44, 0X44, 0X44, 0X44, 0X44, 0X44, 0X7D,
- 0X7D, 0X7D, 0X7D, 0X7D, 0X7D, 0X7C, 0X7C, 0X7C, 0X7F, 0X7F,
- 0X7F, 0X7F, 0X7E, 0X7E, 0X7E, 0X7E, 0X7E, 0X7E, 0X45, 0X45,
- 0X45, 0X45, 0X45, 0X45, 0X05, 0X44, 0X44, 0X44, 0X44, 0X44,
- 0X30, 0X30, 0X7D, 0X7D, 0X7D, 0X7D, 0X7D, 0X7C, 0X7C, 0X7C,
- 0X7B, 0X7B, 0X7B, 0X7B, 0X7A, 0X7A, 0X7A, 0X7A, 0X7A, 0X7A,
- 0X79, 0X79, 0X79, 0X79, 0X79, 0X79, 0X43, 0X43, 0X43, 0X43,
- 0X43, 0X43, 0X30, 0X30, 0X42, 0X42, 0X42, 0X42, 0X42, 0X78,
- 0X78, 0X78, 0X7B, 0X7B, 0X7B, 0X7B, 0X7A, 0X7A, 0X7A, 0X7A,
- 0X7A, 0X7A, 0X79, 0X79, 0X79, 0X79, 0X79, 0X79, 0X43, 0X43,
- 0X43, 0X43, 0X43, 0X43, 0X43, 0X42, 0X42, 0X42, 0X42, 0X42,
- 0X42, 0X78, 0X78, 0X78, 0X7B, 0X7B, 0X7B, 0X7B, 0X7A, 0X7A,
- 0X7A, 0X7A, 0X7A, 0X7A, 0X79, 0X79, 0X79, 0X79, 0X79, 0X79,
- 0X43, 0X43, 0X43, 0X43, 0X43, 0X43, 0X28, 0X28, 0X42, 0X42,
- 0X42, 0X42, 0X42, 0X78, 0X78, 0X78, 0X7B, 0X7B, 0X7B, 0X7B,
- 0X7A, 0X7A, 0X7A, 0X7A, 0X7A, 0X7A, 0X79, 0X79, 0X79, 0X79,
- 0X79, 0X79, 0X43, 0X43, 0X43, 0X43, 0X43, 0X43, 0X28, 0X28,
- 0X28, 0X28, 0X42, 0X42, 0X42, 0X78, 0X78, 0X78, 0X7B, 0X7B,
- 0X7B, 0X7B, 0X7A, 0X7A, 0X7A, 0X7A, 0X7A, 0X7A, 0X79, 0X79,
- 0X79, 0X79, 0X79, 0X79, 0X43, 0X43, 0X43, 0X43, 0X43, 0X43,
- 0X28, 0X28, 0X28, 0X28, 0X28, 0X2D, 0X2D, 0X33, 0X33, 0X78,
- 0X7B, 0X7B, 0X7B, 0X7B, 0X7A, 0X7A, 0X7A, 0X7A, 0X7A, 0X7A,
- 0X79, 0X79, 0X79, 0X79, 0X79, 0X79, 0X43, 0X43, 0X43, 0X43,
- 0X43, 0X43, 0X28, 0X28, 0X28, 0X28, 0X2D, 0X2D, 0X2D, 0X33,
- 0X33, 0X69, 0X77, 0X77, 0X77, 0X77, 0X76, 0X76, 0X76, 0X76,
- 0X76, 0X76, 0X75, 0X75, 0X75, 0X75, 0X75, 0X75, 0X74, 0X74,
- 0X74, 0X74, 0X74, 0X74, 0X28, 0X28, 0X28, 0X2D, 0X2D, 0X2D,
- 0X2D, 0X69, 0X69, 0X69, 0X77, 0X77, 0X77, 0X77, 0X76, 0X76,
- 0X76, 0X76, 0X76, 0X76, 0X75, 0X75, 0X75, 0X75, 0X75, 0X75,
- 0X74, 0X74, 0X74, 0X74, 0X74, 0X74, 0X74, 0X41, 0X41, 0X41,
- 0X2D, 0X2D, 0X2D, 0X69, 0X69, 0X0D, 0X77, 0X77, 0X77, 0X77,
- 0X76, 0X76, 0X76, 0X76, 0X76, 0X76, 0X75, 0X75, 0X75, 0X75,
- 0X75, 0X75, 0X74, 0X74, 0X74, 0X74, 0X74, 0X74, 0X74, 0X41,
- 0X41, 0X41, 0X41, 0X2D, 0X2D, 0X69, 0X0D, 0X0D
-};
-
-
-} // End of namespace Lab
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index abdbc73..495fe45 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -28,6 +28,11 @@
  *
  */
 
+#include "common/translation.h"
+
+#include "gui/message.h"
+#include "gui/saveload.h"
+
 #include "lab/lab.h"
 #include "lab/labfun.h"
 #include "lab/parsefun.h"
@@ -40,12 +45,6 @@
 #include "lab/stddefines.h"
 #include "lab/parsetypes.h"
 
-#define MODERNGAMESAVE  1
-
-#if defined(MODERNGAMESAVE)
-#include "lab/modernsavegame.h"
-#endif
-
 namespace Lab {
 
 #ifdef GAME_TRIAL
@@ -109,7 +108,7 @@ static byte *loadBackPict(const char *fileName, bool tomem) {
 static Image *Images[10];
 
 
-uint16 combination[6] = {0, 0, 0, 0, 0, 0}, solution[] = {0, 4, 0, 8, 7, 2};
+byte combination[6] = {0, 0, 0, 0, 0, 0}, solution[] = {0, 4, 0, 8, 7, 2};
 
 static uint16 combx[] = {45, 83, 129, 166, 211, 248};
 
@@ -942,528 +941,57 @@ void doJournal() {
 	ungetVGABaseAddr();
 }
 
+/*
+struct SaveGameInfo {
+	unsigned short RoomNumber;
+	unsigned short Direction;
+	byte *SaveGameImage;
+	char SaveGameDate[128];
+};
 
+int getSaveGameList(SaveGameInfo *info, int maxNum);
+*/
 
-/*---------------------------------------------------------------------------*/
-/*------------------------- The Save/Restore stuff --------------------------*/
-/*---------------------------------------------------------------------------*/
-
-
-Image *Arrow1, *NoArrow1, *DriveButton;
-
+#define QUARTERNUM           30
 
 extern InventoryData *Inventory;
 extern uint16 RoomNum, Direction;
 
-extern char *SAVETEXT, *LOADTEXT, *BOOKMARKTEXT, *PERSONALTEXT, *DISKTEXT, *SAVEBOOK, *RESTOREBOOK, *SAVEFLASH, *RESTOREFLASH, *SAVEDISK, *RESTOREDISK, *SELECTDISK, *NODISKINDRIVE, *WRITEPROTECTED, *FORMATFLOPPY, *FORMATTING;
-
-static uint16 device;
-
-#define MAXDEVNAMES  5
-
-static char DriveName[5] [MAXDEVNAMES];
-
-
-
-
-
-
-/*----- Gets the devices -----*/
-
-/*****************************************************************************/
-/* Finds all the disk drives, puts them in an array of strings, sorts them,  */
-/* and returned the number of drives that it found.                          */
-/*****************************************************************************/
-uint16 doDisks(void) {
-	char str[5];
-	str[0] = 'C';
-	str[1] = ':';
-	str[2] = '\\';
-	str[3] = 0;
-	strcpy(DriveName[0], str);
-	return 1;
-}
-
-/*****************************************************************************/
-/* Does the user interface to save or restore a game position                */
-/*****************************************************************************/
-#if defined(MODERNGAMESAVE)
-
-extern const byte ThePalMap[];
-
-void getRoomMessage(int MyRoomNum, int MyDirection, char *msg);
-
-#define QUARTERNUM           30
-
-#define NEXTEMPTYSLOTTEXT   "Next Empty Slot"
-
-extern char g_SaveGamePath[512];
-extern char g_PathSeperator[4];
-
-SaveGameInfo g_SaveGameInfo[MAX_SAVED_GAMES];
-int g_TotalSavedGames;
-char g_CommonPalette[3 * 256];
-int g_LastSaveGameNumber = 0;
-int g_CurSaveGameNumber = 0;
-int g_CurSaveSet = 0;
-int g_PendingNewSave = 0;
-
-enum UI_Ident {
-	ID_SAVE,
-	ID_LOAD,
-	ID_NEWSLOT,
-	ID_1_TO_5,
-	ID_6_TO_10,
-	ID_11_TO_15,
-	ID_SLOT_A,
-	ID_SLOT_B,
-	ID_SLOT_C,
-	ID_SLOT_D,
-	ID_SLOT_E,
-	ID_CANCEL,
-	ID_LAST
-};
-
-struct ModernUI {
-	int id;
-	int x, y, w, h;
-};
-
-ModernUI theUI[ID_LAST] = {
-	{ ID_LOAD,      491, 182, 128,  54 },
-	{ ID_SAVE,      491, 255, 128,  54 },
-	{ ID_NEWSLOT,   491, 328, 128,  54 },
-	{ ID_1_TO_5,     27,  40, 146,  25 },
-	{ ID_6_TO_10,   175,  40, 146,  25 },
-	{ ID_11_TO_15,  323,  40, 146,  25 },
-	{ ID_SLOT_A,     27,  67, 442,  72 },
-	{ ID_SLOT_B,     27, 142, 442,  72 },
-	{ ID_SLOT_C,     27, 217, 442,  72 },
-	{ ID_SLOT_D,     27, 292, 442,  72 },
-	{ ID_SLOT_E,     27, 367, 442,  72 },
-	{ ID_CANCEL,    531, 405,  52,  52 }
-};
-
-enum {
-	SG_BLACK = 1,
-	SG_TAN   = 14,
-	SG_DKTAN = 38,
-	SG_WHITE = 105,
-	SG_YELLOW = 118
-};
-
-/*****************************************************************************/
-/* Draw display                                                              */
-/*****************************************************************************/
-static void flowTextBold(void *font,      /* the TextAttr pointer */
-                         uint16 spacing,   /* How much vertical spacing between the lines */
-                         uint16 pencolor,  /* pen number to use for text */
-                         uint16 backpen,   /* the background color */
-                         bool outline,          /* Whether to outline in background color */
-                         bool centerh,          /* Whether to center the text horizontally */
-                         bool centerv,          /* Whether to center the text vertically */
-                         bool output,           /* Whether to output any text */
-                         uint16 x1,        /* Cords */
-                         uint16 y1, uint16 x2, uint16 y2,  const char *text) { /* The text itself */
-
-	if (outline) {
-		flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 - 1, y1, x2 - 1, y2, text);
-		flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 - 1, y1 - 1, x2 - 1, y2 - 1, text);
-		flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1, y1 + 2, x2, y2 + 2, text);
-		flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 - 1, y1 + 2, x2 - 1, y2 + 2, text);
-		flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 + 2, y1, x2 + 2, y2, text);
-		flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 + 2, y1 + 2, x2 + 2, y2 + 2, text);
-		flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1, y1 - 1, x2, y2 - 1, text);
-		flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 + 2, y1 - 1, x2 + 2, y2 - 1, text);
-	}
-
-	flowText(font, spacing, pencolor, 0, false, centerh, centerv, output, x1, y1, x2, y2, text);
-	flowText(font, spacing, pencolor, 0, false, centerh, centerv, output, x1 + 1, y1, x2 + 1, y2, text);
-	flowText(font, spacing, pencolor, 0, false, centerh, centerv, output, x1, y1 + 1, x2, y2 + 1, text);
-	flowText(font, spacing, pencolor, 0, false, centerh, centerv, output, x1 + 1, y1 + 1, x2 + 1, y2 + 1, text);
-}
-
-/*****************************************************************************/
-/* Draw display                                                              */
-/*****************************************************************************/
-static void flowTextShadow(void *font,      /* the TextAttr pointer */
-                           uint16 spacing,   /* How much vertical spacing between the lines */
-                           uint16 pencolor,  /* pen number to use for text */
-                           uint16 backpen,   /* the background color */
-                           bool outline,          /* Whether to outline in background color */
-                           bool centerh,          /* Whether to center the text horizontally */
-                           bool centerv,          /* Whether to center the text vertically */
-                           bool output,           /* Whether to output any text */
-                           uint16 x1,        /* Cords */
-                           uint16 y1, uint16 x2, uint16 y2, char *text) { /* The text itself */
-
-	if (outline) {
-		flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 - 1, y1 - 1, x2 - 1, y2 - 1, text);
-		flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 - 1, y1 + 1, x2 - 1, y2 + 1, text);
-		flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 + 1, y1 + 1, x2 + 1, y2 + 1, text);
-		flowText(font, spacing, backpen, 0, false, centerh, centerv, output, x1 + 1, y1 - 1, x2 + 1, y2 - 1, text);
-	}
-
-	flowText(font, spacing, pencolor, 0, false, centerh, centerv, output, x1, y1, x2, y2, text);
-}
-
-static void drawSaveLoad() {
-	int i, j;
-
-	flowTextBold(MsgFont, 0, g_CurSaveGameNumber < g_TotalSavedGames ? SG_YELLOW : SG_DKTAN, SG_BLACK, true, true, true, true, 491 + 3, 182, 619 + 3, 236, LOADTEXT);
-	flowTextBold(MsgFont, 0, g_TotalSavedGames + g_PendingNewSave > 0 ? SG_YELLOW : SG_DKTAN, SG_BLACK, true, true, true, true, 491 + 3, 255, 619 + 3, 309, SAVETEXT);
-	flowTextBold(MsgFont, 0, g_PendingNewSave ? SG_DKTAN : SG_YELLOW, SG_BLACK, true, true, true, true, 491 + 3, 328, 619 + 3, 382, NEXTEMPTYSLOTTEXT);
-
-	flowTextBold(MsgFont, 0, (g_CurSaveSet == 0 ? SG_YELLOW : SG_WHITE), SG_BLACK, true, true, true, true, 27 + 3, 40, 175 + 3, 65, "Saves 1-5");
-	flowTextBold(MsgFont, 0, (g_CurSaveSet == 1 ? SG_YELLOW : SG_WHITE), SG_BLACK, true, true, true, true, 175 + 3, 40, 321 + 3, 65, "Saves 6-10");
-	flowTextBold(MsgFont, 0, (g_CurSaveSet == 2 ? SG_YELLOW : SG_WHITE), SG_BLACK, true, true, true, true, 323 + 3, 40, 469 + 3, 65, "Saves 11-15");
-
-	for (i = 0, j = 5 * g_CurSaveSet; i < 5; i++, j++) {
-		uint16 hue, y;
-		char num_text[4];
-		Image thumbnail, screen;
-
-		if (j < g_TotalSavedGames + g_PendingNewSave) {
-			char msg[256];
-
-			getRoomMessage(g_SaveGameInfo[j].RoomNumber, g_SaveGameInfo[j].Direction, msg);
-
-			hue = (j == g_CurSaveGameNumber ? SG_YELLOW : SG_WHITE);
-			y = 67 + 2 + i * 75;
-			flowText(MsgFont, 0, hue, 0, false, false, false, true, 202 + 2, y, 469 - 2, y + 48, msg);
-			y += 46;
-			flowText(MsgFont, 0, hue, 0, false, false, false, true, 202 + 2, y, 469 - 2, y + 24, g_SaveGameInfo[j].SaveGameDate);
-
-			// blast image
-			thumbnail.Width = 128;
-			thumbnail.Height = 72;
-			thumbnail.ImageData = g_SaveGameInfo[j].SaveGameImage;
-			screen.Width = VGAScreenWidth;
-			screen.Height = VGAScreenHeight;
-			screen.ImageData = getVGABaseAddr();
-			bltBitMap(&thumbnail, 0, 0, &screen, 72, 67 + i * 75, 128, 72);
-			ungetVGABaseAddr();
-
-			hue = (j == g_CurSaveGameNumber ? SG_YELLOW : SG_WHITE);
-		} else {
-			y = 67 + 2 + i * 75;
-			flowText(MsgFont, 0, SG_TAN, 0, false, true, true, true, 202 + 2, y, 469 - 2, y + 70, "[Empty Slot]");
-
-			hue = SG_DKTAN;
-		}
-
-		y = 67 + i * 75;
-		sprintf(num_text, "%d", j + 1);
-		flowTextShadow(BigMsgFont, 0, hue, SG_BLACK, true, true, true, true, 27 + 4, y, 72 + 4, y + 72, num_text);
-	}
-
-	// Add ".1" to version number
-	setAPen(SG_WHITE);
-	rectFill(271, 454, 271, 454);
-	rectFill(275, 449, 275, 454);
-	rectFill(274, 450, 274, 450);
-	rectFill(274, 454, 276, 454);
-
-	WSDL_UpdateScreen();
-}
-
-static void makeThumbnail(SaveGameInfo *info) {
-	char *pictName;
-	CloseDataPtr CPtr = NULL;
-	byte *BitMapMem;
-	int x, y, u, v;
-
-	// load pict
-	pictName = getPictName(&CPtr);
-	nopalchange = true;
-	BitMapMem = readPictToMem(pictName, VGAScreenWidth, VGAScreenHeight);
-	nopalchange = false;
-
-	for (y = 0; y < 72; y++) {
-		for (x = 0; x < 128; x++) {
-			unsigned int r = 0, g = 0, b = 0;
-
-			for (v = 5 * y; v < 5 * y + 5; v++) {
-				for (u = 5 * x; u < 5 * x + 5; u++) {
-					byte n = (byte)BitMapMem[u + v * VGAScreenWidth];
-					// 6-bit color (VGA)
-					r += (unsigned int)diffcmap[3 * n + 0];
-					g += (unsigned int)diffcmap[3 * n + 1];
-					b += (unsigned int)diffcmap[3 * n + 2];
-				}
+bool saveRestoreGame(void) {
+	bool isOK = false;
+
+	// The original had one screen for saving/loading. We have two.
+	// Ask the user which screen to use.
+	GUI::MessageDialog saveOrLoad(_("Would you like to save or restore a game?"), _("Save"), _("Restore"));
+
+	int choice = saveOrLoad.runModal();
+	if (choice == GUI::kMessageOK) {
+		// Save
+		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
+		int slot = dialog->runModalWithCurrentTarget();
+		if (slot >= 0) {
+			Common::String desc = dialog->getResultString();
+
+			if (desc.empty()) {
+				// create our own description for the saved game, the user didn't enter it
+				desc = dialog->createDefaultSaveDescription(slot);
 			}
 
-			r = (r / 25) >> 1;
-			g = (g / 25) >> 1;
-			b = (b / 25) >> 1;
-			warning("STUB: makeThumbnail");
-			info->SaveGameImage[x + 128 * y] = ThePalMap[(r << 10) | (g << 5) | b];
+			isOK = saveGame(RoomNum, Direction, Inventory[QUARTERNUM].Many, slot, desc);
 		}
-	}
-}
-
-static void addSaveSlot() {
-	SaveGameInfo *info;
-
-	if (g_PendingNewSave || g_TotalSavedGames == MAX_SAVED_GAMES)
-		return;
-
-	g_PendingNewSave = 1;
-	g_CurSaveGameNumber = g_TotalSavedGames;
-	g_CurSaveSet = g_CurSaveGameNumber / 5;
-
-	// set-up saved game
-	info = &g_SaveGameInfo[g_CurSaveGameNumber];
-	info->RoomNumber = RoomNum;
-	info->Direction = Direction;
-
-	// not really a date yet
-	strcpy(info->SaveGameDate, "Click SAVE GAME to Confirm");
-
-	info->SaveGameImage = (byte *)malloc(SAVED_IMAGE_SIZE);
-	makeThumbnail(info);
-
-	mouseHide();
-	WSDL_IgnoreUpdateDisplay(1);
-	loadBackPict("P:ModSave", false);
-	WSDL_IgnoreUpdateDisplay(0);
-	drawSaveLoad();
-	mouseShow();
-}
-
-static void selectSave(int n) {
-	if (g_CurSaveGameNumber == n || n >= g_TotalSavedGames + g_PendingNewSave)
-		return;
-
-	g_CurSaveGameNumber = n;
-
-	mouseHide();
-	WSDL_IgnoreUpdateDisplay(1);
-	loadBackPict("P:ModSave", false);
-	WSDL_IgnoreUpdateDisplay(0);
-	drawSaveLoad();
-	mouseShow();
-}
-
-static void selectSaveSet(int n) {
-	if (g_CurSaveSet != n) {
-		g_CurSaveSet = n;
-
-		mouseHide();
-		WSDL_IgnoreUpdateDisplay(1);
-		loadBackPict("P:ModSave", false);
-		WSDL_IgnoreUpdateDisplay(0);
-		drawSaveLoad();
-		mouseShow();
-	}
-}
-
-/*****************************************************************************/
-/* Do modern save.                                                           */
-/*****************************************************************************/
-static bool doSaveGame() {
-	bool isok;
-	char DrivePath[260];
-
-	if (g_CurSaveGameNumber != g_TotalSavedGames) {
-		makeThumbnail(&g_SaveGameInfo[g_CurSaveGameNumber]);
 	} else {
-		// set time of save for new saved game
-		//struct tm *create_date;
-		//time_t ticks;
-
-		warning("STUB: doSaveGame");
-		//ticks = time(NULL);
-		//create_date = localtime(&ticks);
-		//strcpy(g_SaveGameInfo[g_CurSaveGameNumber].SaveGameDate, asctime(create_date));
+		// Restore
+		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
+		int slot = dialog->runModalWithCurrentTarget();
+		if (slot >= 0)
+			isOK = loadGame(&RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), slot);
 	}
 
-	memcpy(g_SaveGameImage, g_SaveGameInfo[g_CurSaveGameNumber].SaveGameImage, SAVED_IMAGE_SIZE);
-
-	sprintf(DrivePath, "%s%s%d", g_SaveGamePath, g_PathSeperator, g_CurSaveGameNumber);
-
-	isok = saveFloppy(DrivePath, RoomNum, Direction, Inventory[QUARTERNUM].Many, g_CurSaveGameNumber, device);
-	g_music->resetMusic();
-
-	if (isok)
-		g_LastSaveGameNumber = g_CurSaveGameNumber;
-
-	return isok;
-}
-
-/*****************************************************************************/
-/* Do modern load.                                                           */
-/*****************************************************************************/
-static bool doLoadGame() {
-	bool isok;
-	char drivePath[260];
-
-	snprintf(drivePath, 260, "%s%s%d", g_SaveGamePath, g_PathSeperator, g_CurSaveGameNumber);
-
-	isok = readFloppy(drivePath, &RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), g_CurSaveGameNumber, device);
-	g_music->resetMusic();
-
-	if (isok)
-		g_LastSaveGameNumber = g_CurSaveGameNumber;
-
-	return isok;
-}
-
-/*****************************************************************************/
-/* Processes user input.                                                     */
-/*****************************************************************************/
-static bool processSaveLoad() {
-	IntuiMessage *Msg;
-
-	uint32 Class;
-	uint16 Qualifier, MouseX, MouseY, Code;
-	int i;
-
-	drawSaveLoad();
-
-	while (1) {
-		g_music->checkMusic();  /* Make sure we check the music at least after every message */
-		Msg = getMsg();
-
-		if (Msg == NULL) {
-			g_music->newCheckMusic();
-		} else {
-			Class     = Msg->Class;
-			Qualifier = Msg->Qualifier;
-			MouseX    = Msg->MouseX;
-			MouseY    = Msg->MouseY;
-			Code      = Msg->Code;
-
-			replyMsg(Msg);
-
-			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) ||
-			        ((Class == RAWKEY) && (Code == 27)))
-				return true;
-
-			if (Class == RAWKEY) {
-				if (Code == 'l' || Code == 'L') {
-					if (g_CurSaveGameNumber < g_TotalSavedGames)
-						return doLoadGame();
-				} else if (Code == 's' || Code == 'S') {
-					if (g_TotalSavedGames + g_PendingNewSave > 0)
-						return doSaveGame();
-				} else if (Code == 'n' || Code == 'N') {
-					addSaveSlot();
-				} else if (Code == VKEY_LTARROW) {
-					i = g_CurSaveSet - 1;
-
-					if (i < 0) i = 2;
-
-					selectSaveSet(i);
-				} else if (Code == VKEY_RTARROW) {
-					i = g_CurSaveSet + 1;
-
-					if (i > 2) i = 0;
-
-					selectSaveSet(i);
-				} else if (Code == VKEY_UPARROW) {
-					if (g_TotalSavedGames + g_PendingNewSave > 0) {
-						i = g_CurSaveGameNumber - 1;
-
-						if (i < 0)
-							i = g_TotalSavedGames + g_PendingNewSave - 1;
-
-						if (i / 5 != g_CurSaveSet)
-							selectSaveSet(i / 5);
-
-						selectSave(i);
-					}
-				} else if (Code == VKEY_DNARROW) {
-					if (g_TotalSavedGames + g_PendingNewSave > 0) {
-						i = g_CurSaveGameNumber + 1;
-
-						if (i >= g_TotalSavedGames + g_PendingNewSave)
-							i = 0;
-
-						if (i / 5 != g_CurSaveSet)
-							selectSaveSet(i / 5);
-
-						selectSave(i);
-					}
-				}
-			} else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) {
-				for (i = 0; i < ID_LAST; i++) {
-					if (MouseX >= theUI[i].x && MouseY >= theUI[i].y &&
-					        MouseX < theUI[i].x + theUI[i].w && MouseY < theUI[i].y + theUI[i].h) {
-						switch (theUI[i].id) {
-						case ID_SAVE:
-							if (g_TotalSavedGames + g_PendingNewSave > 0)
-								return doSaveGame();
-
-							break;
-
-						case ID_LOAD:
-							if (g_CurSaveGameNumber < g_TotalSavedGames)
-								return doLoadGame();
-
-							break;
-
-						case ID_NEWSLOT:
-							addSaveSlot();
-							break;
-
-						case ID_1_TO_5:
-						case ID_6_TO_10:
-						case ID_11_TO_15:
-							selectSaveSet(theUI[i].id - ID_1_TO_5);
-							break;
-
-						case ID_SLOT_A:
-						case ID_SLOT_B:
-						case ID_SLOT_C:
-						case ID_SLOT_D:
-						case ID_SLOT_E:
-							selectSave(5 * g_CurSaveSet + theUI[i].id - ID_SLOT_A);
-							break;
-
-						case ID_CANCEL:
-							return true;
-						}
-					}
-				}
-			}
-		}
-	}
-}
-
-bool saveRestoreGame(void) {
-	byte **buffer;
-	bool isok = true;
-
-	blackAllScreen();
-
-	BigMsgFont = &bmfont;
-
-	if (!getFont("P:Map.fon", BigMsgFont)) {
-		BigMsgFont = NULL;
-		return false;
-	}
-
-	buffer = g_music->newOpen("P:ModSave");
-
-	if (!buffer) {
-		freeAllStolenMem();
+	if (!isOK)
 		return false;
-	}
-
-	g_TotalSavedGames = getSaveGameList(g_SaveGameInfo, MAX_SAVED_GAMES);
-	g_CurSaveGameNumber = g_LastSaveGameNumber;
-	g_CurSaveSet = g_CurSaveGameNumber / 5;
-	g_PendingNewSave = 0;
-
-	loadBackPict("P:ModSave", false);
-
-	mouseShow();
 
-	VGASetPal(diffcmap, 256);
-	memcpy(g_CommonPalette, diffcmap, 3 * 256);
+	g_music->resetMusic();
 
-	isok = processSaveLoad();
 	eatMessages();
 
 	mouseHide();
@@ -1478,373 +1006,9 @@ bool saveRestoreGame(void) {
 
 	freeAllStolenMem();
 
-	freeSaveGameList(g_SaveGameInfo, g_TotalSavedGames);
-
-	return isok;
-}
-#else
-
-static uint16 manydisks = 0;
-
-static uint16 issave, ghoast, arrow, ManyDrives, DriveInitX, DriveNum = -1, FileNum = -1;
-
-/*****************************************************************************/
-/* Draws the number arrows.                                                  */
-/*****************************************************************************/
-static void doNumArrows(void) {
-	uint16 counterx, countery, curnum, cordx[3], cordy[3];
-
-	cordx[0] = VGAScaleX(53) + SVGACord(3);
-	cordx[1] = VGAScaleX(126) + SVGACord(1);
-	cordx[2] = VGAScaleX(197) + SVGACord(3);
-
-	cordy[0] = VGAScaleY(58) + SVGACord(2);
-	cordy[1] = VGAScaleY(86) + SVGACord(3);
-	cordy[2] = VGAScaleY(114) + SVGACord(3);
-
-	mouseHide();
-
-	for (countery = 0; countery < 3; countery++) {
-		for (counterx = 0; counterx < 3; counterx++) {
-			curnum = countery + counterx * 3;
-
-			if INBIT(arrow, curnum)
-				drawImage(Arrow1, cordx[counterx], cordy[countery]);
-			else
-				drawImage(NoArrow1, cordx[counterx], (int32) cordy[countery]);
-
-			if INBIT(ghoast, curnum)
-				ghoastRect(0, cordx[counterx], cordy[countery], cordx[counterx] + VGAScaleX(69), cordy[countery] + NoArrow1->Height);
-		}
-	}
-
-	mouseShow();
-}
-
-/*****************************************************************************/
-/* Does the drive buttons for the final save/restore screen.                 */
-/*****************************************************************************/
-static void doDriveButtons(void) {
-	uint16 curx, counter;
-
-	if (ManyDrives > 5)
-		ManyDrives = 5;
-
-	DriveInitX = (VGAScreenWidth / 2) - ((ManyDrives * DriveButton->Width) / 2);
-	curx       = DriveInitX;
-
-	mouseHide();
-
-	for (counter = 0; counter < ManyDrives; counter++) {
-		drawImage(DriveButton, curx, VGAScaleY(153));
-
-		flowText(BigMsgFont, 0, 1, 0, false, true, true, true, curx + VGAScaleX(5), VGAScaleY(158), curx + DriveButton->Width - VGAScaleX(5), VGAScaleY(148) + DriveButton->Height, DriveName[counter]);
-
-		curx += DriveButton->Width;
-	}
-
-	mouseShow();
-}
-
-
-static void drawSRMessage(char *rtext) {
-	mouseHide();
-	flowText(BigMsgFont, 0, 1, 10, true, true, true, true, VGAScaleX(22), VGAScaleY(21), VGAScaleX(289), VGAScaleY(48), rtext);
-	mouseShow();
-}
-
-/*****************************************************************************/
-/* Draws the correct message to the message box.                             */
-/*****************************************************************************/
-static void doSaveRestoreText(void) {
-	char *rtext, text[100];
-
-	if (DriveNum >= ManyDrives) {
-		rtext = SELECTDISK;
-	} else if (issave) {
-		strcpy(text, SAVEDISK);
-		strcat(text, " ");
-		strcat(text, DriveName[DriveNum]);
-		rtext = text;
-	} else {
-		strcpy(text, RESTOREDISK);
-		strcat(text, " ");
-		strcat(text, DriveName[DriveNum]);
-		rtext = text;
-	}
-
-	drawSRMessage(rtext);
-}
-
-static uint16 processSaveRestore(uint16 type);
-
-static char DrivePath[50];
-
-/*****************************************************************************/
-/* Checks for the existence of previous saved game positions on disk.        */
-/*****************************************************************************/
-static void floppyCheckFiles(void) {
-	char temp[7], *name, len;
-	int fl;
-	uint16 counter;
-
-	doSaveRestoreText();
-
-	arrow = 0;
-	ghoast = 0;
-
-	strcpy(DrivePath, DriveName[DriveNum]);
-	strcat(DrivePath, "LabSaves");
-
-	warning("STUB: floppyCheckFiles");
-
-#if 0
-#if defined(WIN32)
-	mkdir(DrivePath);
-#else
-	mkdir(DrivePath, 0x644);
-#endif
-	strcat(DrivePath, "\\");
-
-	len = strlen(DrivePath);
-
-	for (counter = 0; counter < 9; counter++) {
-		name = numtostr(temp, counter);
-		strcat(DrivePath, name);
-
-		if ((fl = open(DrivePath, O_RDONLY)) != -1) {
-			close(fl);
-			SETBIT(arrow, counter);
-		} else
-			SETBIT(ghoast, counter);
-
-		DrivePath[len] = 0;
-	}
-#endif
-}
-
-/*****************************************************************************/
-/* Checks for the existence of previously saved game positions.              */
-/*****************************************************************************/
-static void checkFiles(void) {
-	ghoast = -1;
-	arrow  = 0;
-
-	g_music->fillUpMusic(true);
-
-	/* NYI: check for empty drive */
-	floppyCheckFiles();
-
-	if (issave)
-		ghoast = 0;
-}
-
-/*****************************************************************************/
-/* Processes user input.                                                     */
-/*****************************************************************************/
-static uint16 processSaveRestore(uint16 type) {
-	IntuiMessage *Msg;
-
-	uint32 Class;
-	uint16 Qualifier, MouseX, MouseY, Code, Temp;
-
-	while (1) {
-		g_music->checkMusic();  /* Make sure we check the music at least after every message */
-		Msg = getMsg();
-
-		if (Msg == NULL) {
-			g_music->newCheckMusic();
-		} else {
-			Class     = Msg->Class;
-			Qualifier = Msg->Qualifier;
-			MouseX    = Msg->MouseX;
-			MouseY    = Msg->MouseY;
-			Code      = Msg->Code;
-
-			replyMsg(Msg);
-
-			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) ||
-			        ((Class == RAWKEY) && (Code == 27)))
-				return -1;
-
-			else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) {
-				if (type == 0) { /* The save or restore screen */
-					if ((MouseX >= VGAScaleX(64)) && (MouseX <= VGAScaleX(257))) {
-						if ((MouseY >= VGAScaleY(57)) && (MouseY <= VGAScaleY(92)))
-							return true;
-						else if ((MouseY >= VGAScaleY(108)) && (MouseY <= VGAScaleY(142)))
-							return false;
-					}
-				}
-
-				else if (type == 2) { /* The files screen */
-					if ((MouseY >= VGAScaleY(153)) && (MouseY <= VGAScaleY(180))) {  /* the drive buttons */
-						Temp = ((MouseX - DriveInitX) / DriveButton->Width);
-
-						if (Temp < ManyDrives) {
-							DriveNum = Temp;
-
-							fade(false, 0);
-							checkFiles();
-
-							loadBackPict("P:Disk/Nums.pic", false);
-							doNumArrows();
-							doDriveButtons();
-							doSaveRestoreText();
-
-							fade(true, 0);
-						}
-					}
-
-					else if ((MouseX >= VGAScaleX(53)) && (MouseY >= VGAScaleY(58)) &&
-					         (MouseX <= VGAScaleX(266)) && (MouseY <= VGAScaleY(142))) {
-						MouseX = (MouseX - VGAScaleX(53)) / VGAScaleX(71);
-						MouseY = (MouseY - VGAScaleY(58)) / VGAScaleY(28);
-
-						Temp = MouseY + (MouseX * 3);
-
-						if (!(INBIT(ghoast, Temp))) {
-
-							SETBIT(arrow, Temp);
-							doNumArrows();
-
-							FileNum = Temp;
-							return FileNum;
-						}
-					}
-				}
-			}
-		}
-	}
-}
-
-
-
-
-/*****************************************************************************/
-/* Sets up the Save or Restore screen.                                       */
-/*****************************************************************************/
-static uint16 saveOrRestore(void) {
-	uint16 res;
-
-	mouseHide();
-	loadBackPict("P:Disk/Choose.pic", false);
-
-	flowText(BigMsgFont, 0, 1, 4, false, true, true, true, VGAScaleX(74), VGAScaleY(65), VGAScaleX(247), VGAScaleY(84), SAVETEXT);
-	flowText(BigMsgFont, 0, 1, 4, false, true, true, true, VGAScaleX(74), VGAScaleY(116), VGAScaleX(247), VGAScaleY(135), LOADTEXT);
-	mouseShow();
-
-	fade(true, 0);
-	res = processSaveRestore(0);
-	fade(false, 0);
-	eatMessages();
-
-	return res;
-}
-
-
-
-
-
-/*****************************************************************************/
-/* Sets up the final save/restore screen.                                    */
-/*****************************************************************************/
-static uint16 saveRestore(void) {
-	uint16 res;
-
-	loadBackPict("P:Disk/Nums.pic", false);
-
-	if ((DriveNum < ManyDrives)) {
-		checkFiles();
-	} else {
-		ghoast = -1;
-		arrow  =  0;
-	}
-
-	doNumArrows();
-	doDriveButtons();
-	doSaveRestoreText();
-	g_music->newCheckMusic();
-
-	eatMessages();
-	fade(true, 0);
-	res = processSaveRestore(2);
-	fade(false, 0);
-
-	return res;
-}
-
-
-#define QUARTERNUM           30
-
-
-bool saveRestoreGame(void) {
-	uint16 filenum;
-	byte **buffer;
-	char temp[10], *name;
-	bool isok = true;
-
-	blackAllScreen();
-
-	ManyDrives = doDisks();
-
-	FadePalette = hipal;
-	memset(&(hipal[0]), 0, 32L);
-
-	BigMsgFont = &bmfont;
-
-	if (!getFont("P:Map.fon", BigMsgFont)) {
-		BigMsgFont = NULL;
-		return false;
-	}
-
-	buffer = g_music->newOpen("P:SaveImage");
-
-	if (!buffer) {
-		freeAllStolenMem();
-		return false;
-	}
-
-	readImage(buffer, &Arrow1);
-	readImage(buffer, &NoArrow1);
-	readImage(buffer, &DriveButton);
-
-	mouseShow();
-
-	if ((issave = saveOrRestore()) != (uint16) - 1) {
-		eatMessages();
-
-		if ((filenum = saveRestore()) != (uint16) - 1) {
-			name = numtostr(temp, filenum);
-			strcat(DrivePath, name);
-
-			eatMessages();
-
-			if (issave)
-				isok = saveFloppy(DrivePath, RoomNum, Direction, Inventory[QUARTERNUM].Many, filenum, device);
-			else {
-				isok = readFloppy(DrivePath, &RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), filenum, device);
-				g_music->resetMusic();
-			}
-		}
-	}
-
-	mouseHide();
-	setAPen(0);
-	rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1);
-	blackScreen();
-
-	journalCleanUp();
-
-	freeAllStolenMem();
-
-	return isok;
+	return true;
 }
 
-#endif
-
-
-
 /*---------------------------------------------------------------------------*/
 /*--------------------------- The Monitors stuff ----------------------------*/
 /*---------------------------------------------------------------------------*/


Commit: 66486895906b18ef4c299496c7fd7e5963f7155b
    https://github.com/scummvm/scummvm/commit/66486895906b18ef4c299496c7fd7e5963f7155b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Remove the unused Cords struct

Changed paths:
    engines/lab/labfun.h



diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 69dc39d..4d1854f 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -46,13 +46,6 @@ namespace Lab {
 #define EAST    2
 #define WEST    3
 
-
-
-/* Generic co-ordinate define. */
-typedef struct {
-	uint16 x1, y1;
-} Cords;
-
 struct Image;
 struct TextFont;
 struct Gadget;


Commit: 95461c91616eda80b33cfec3597f8c3243748a89
    https://github.com/scummvm/scummvm/commit/95461c91616eda80b33cfec3597f8c3243748a89
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Remove the journalCleanUp() wrapper

Changed paths:
    engines/lab/special.cpp



diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 495fe45..3909d97 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -888,17 +888,6 @@ static void processJournal() {
 
 
 /*****************************************************************************/
-/* Cleans up behind all memory allocations.                                  */
-/*****************************************************************************/
-static void journalCleanUp(void) {
-	freeAllStolenMem();
-}
-
-
-
-
-
-/*****************************************************************************/
 /* Does the journal processing.                                              */
 /*****************************************************************************/
 void doJournal() {
@@ -936,7 +925,7 @@ void doJournal() {
 	rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1);
 	blackScreen();
 
-	journalCleanUp();
+	freeAllStolenMem();
 
 	ungetVGABaseAddr();
 }
@@ -1002,8 +991,6 @@ bool saveRestoreGame(void) {
 	blackScreen();
 	WSDL_UpdateScreen();
 
-	journalCleanUp();
-
 	freeAllStolenMem();
 
 	return true;


Commit: 5bc37fd878e89dbcf3312dedcb0b4cfcd89cda7f
    https://github.com/scummvm/scummvm/commit/5bc37fd878e89dbcf3312dedcb0b4cfcd89cda7f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Fix loading of saved games

Changed paths:
    engines/lab/savegame.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 5cf0674..4d40540 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -219,7 +219,7 @@ bool loadGame(uint16 *RoomNum, uint16 *Direction, uint16 *Quarters, int slot) {
 			CurTile[i][j] = file->readUint16LE();
 
 	// Breadcrumbs
-	for (i = 0; i < sizeof(BreadCrumbs); i++) {
+	for (i = 0; i < 128; i++) {
 		BreadCrumbs[i].RoomNum = file->readUint16LE();
 		BreadCrumbs[i].Direction = file->readUint16LE();
 	}
@@ -227,10 +227,10 @@ bool loadGame(uint16 *RoomNum, uint16 *Direction, uint16 *Quarters, int slot) {
 	DroppingCrumbs = (BreadCrumbs[0].RoomNum != 0);
 	FollowingCrumbs = false;
 
-	for (i = 0; i < sizeof(BreadCrumbs); i++) {
+	for (i = 0; i < 128; i++) {
 		if (BreadCrumbs[i].RoomNum == 0)
 			break;
-		NumCrumbs++;
+		NumCrumbs = i;
 	}
 
 	delete file;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 3909d97..ae9eb02 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -972,28 +972,16 @@ bool saveRestoreGame(void) {
 		// Restore
 		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
 		int slot = dialog->runModalWithCurrentTarget();
-		if (slot >= 0)
+		if (slot >= 0) {
 			isOK = loadGame(&RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), slot);
+			if (isOK)
+				g_music->resetMusic();
+		}
 	}
 
-	if (!isOK)
-		return false;
-
-	g_music->resetMusic();
-
-	eatMessages();
-
-	mouseHide();
-	memset(diffcmap, 0, 3 * 256);
-	VGASetPal(diffcmap, 256);
-	setAPen(0);
-	rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1);
-	blackScreen();
 	WSDL_UpdateScreen();
-
-	freeAllStolenMem();
-
-	return true;
+	
+	return isOK;
 }
 
 /*---------------------------------------------------------------------------*/


Commit: d25d74ef2033835514242584562f7433deeb52c8
    https://github.com/scummvm/scummvm/commit/d25d74ef2033835514242584562f7433deeb52c8
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Remove leftover debug code

Changed paths:
    engines/lab/special.cpp



diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index ae9eb02..f9c793c 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -930,17 +930,6 @@ void doJournal() {
 	ungetVGABaseAddr();
 }
 
-/*
-struct SaveGameInfo {
-	unsigned short RoomNumber;
-	unsigned short Direction;
-	byte *SaveGameImage;
-	char SaveGameDate[128];
-};
-
-int getSaveGameList(SaveGameInfo *info, int maxNum);
-*/
-
 #define QUARTERNUM           30
 
 extern InventoryData *Inventory;


Commit: 7e0545cf6d3f4dd3628119cf61910be5ca0fb340
    https://github.com/scummvm/scummvm/commit/7e0545cf6d3f4dd3628119cf61910be5ca0fb340
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Remove unused byte swap code

The relevant defines will be replaced with the ones from our common
code

Changed paths:
    engines/lab/machine.cpp
    engines/lab/stddefines.h
    engines/lab/undiff.cpp



diff --git a/engines/lab/machine.cpp b/engines/lab/machine.cpp
index c1bdd00..3806b5f 100644
--- a/engines/lab/machine.cpp
+++ b/engines/lab/machine.cpp
@@ -218,134 +218,4 @@ char *translateFileName(const char *filename) {
 	return NewFileName;
 }
 
-#if defined(USE_SWAP)
-
-uint16 swapUShort(uint16 value) {
-	char *b = (char *)&value;
-	char t = b[0];
-	b[0] = b[1];
-	b[1] = t;
-	return value;
-}
-uint16 *wapUShortPtsr(uint16 *ptr, int count) {
-	while (count-- > 0) {
-		char *b = (char *)ptr++;
-		char t = b[0];
-		b[0] = b[1];
-		b[1] = t;
-	}
-
-	return ptr;
-}
-int16 swapShort(int16 value) {
-	char *b = (char *)&value;
-	char t = b[0];
-	b[0] = b[1];
-	b[1] = t;
-	return value;
-}
-int16 *swapShortPtr(int16 *ptr, int count) {
-	while (count-- > 0) {
-		char *b = (char *)ptr++;
-		char t = b[0];
-		b[0] = b[1];
-		b[1] = t;
-	}
-
-	return ptr;
-}
-unsigned int swapUInt(unsigned int value) {
-	char *b = (char *)&value;
-	char t = b[0];
-	b[0] = b[3];
-	b[3] = t;
-	t = b[1];
-	b[1] = b[2];
-	b[2] = t;
-	return value;
-}
-unsigned int *swapUIntPtr(unsigned int *ptr, int count) {
-	while (count-- > 0) {
-		char *b = (char *)ptr++;
-		char t = b[0];
-		b[0] = b[3];
-		b[3] = t;
-		t = b[1];
-		b[1] = b[2];
-		b[2] = t;
-	}
-
-	return ptr;
-}
-int swapInt(int value) {
-	char *b = (char *)&value;
-	char t = b[0];
-	b[0] = b[3];
-	b[3] = t;
-	t = b[1];
-	b[1] = b[2];
-	b[2] = t;
-	return value;
-}
-int *swapIntPtr(int *ptr, int count) {
-	while (count-- > 0) {
-		char *b = (char *)ptr++;
-		char t = b[0];
-		b[0] = b[3];
-		b[3] = t;
-		t = b[1];
-		b[1] = b[2];
-		b[2] = t;
-	}
-
-	return ptr;
-}
-uint32 swapULong(uint32 value) {
-	char *b = (char *)&value;
-	char t = b[0];
-	b[0] = b[3];
-	b[3] = t;
-	t = b[1];
-	b[1] = b[2];
-	b[2] = t;
-	return value;
-}
-uint32 *swapULongPtr(uint32 *ptr, int count) {
-	while (count-- > 0) {
-		char *b = (char *)ptr++;
-		char t = b[0];
-		b[0] = b[3];
-		b[3] = t;
-		t = b[1];
-		b[1] = b[2];
-		b[2] = t;
-	}
-
-	return ptr;
-}
-int32 swapLong(int32 value) {
-	char *b = (char *)&value;
-	char t = b[0];
-	b[0] = b[3];
-	b[3] = t;
-	t = b[1];
-	b[1] = b[2];
-	b[2] = t;
-	return value;
-}
-int32 *swapLongPtr(int32 *ptr, int count) {
-	while (count-- > 0) {
-		char *b = (char *)ptr++;
-		char t = b[0];
-		b[0] = b[3];
-		b[3] = t;
-		t = b[1];
-		b[1] = b[2];
-		b[2] = t;
-	}
-
-	return ptr;
-}
-#endif
-
 } // End of namespace Lab
diff --git a/engines/lab/stddefines.h b/engines/lab/stddefines.h
index 3729084..67bd39a 100644
--- a/engines/lab/stddefines.h
+++ b/engines/lab/stddefines.h
@@ -38,14 +38,12 @@
 namespace Lab {
 
 #define IS_MACOSX 1
-#define USE_NOSWAP 1
 
 #if defined(IS_MACOSX)
 #define getTime Lab_GetTime
 #define delay Lab_Delay
 #endif
 
-#if defined(USE_NOSWAP)
 #define swapUShort(value) (value)
 #define swapUShortPtr(ptr,count) (ptr)
 #define swapShort(value) (value)
@@ -58,20 +56,6 @@ namespace Lab {
 #define swapULongPtr(ptr,count) (ptr)
 #define swapLong(value) (value)
 #define swapLongPtr(ptr,count) (ptr)
-#else
-uint16 swapUShort(uint16 value);
-uint16 *swapUShortPtr(uint16 *ptr, int count);
-int16 swapShort(int16 value);
-int16 *swapShortPtr(int16 *ptr, int count);
-unsigned int swapUInt(unsigned int value);
-unsigned int *swapUIntPtr(unsigned int *ptr, int count);
-int swapInt(int value);
-int *swapIntPtr(int *ptr, int count);
-uint32 swapULong(uint32 value);
-uint32 *swapULongPtr(uint32 *ptr, int count);
-int32 swapLong(int32 value);
-int32 *swapLongPtr(int32 *ptr, int count);
-#endif
 
 } // End of namespace Lab
 
diff --git a/engines/lab/undiff.cpp b/engines/lab/undiff.cpp
index 2218db48..bc4eacc 100644
--- a/engines/lab/undiff.cpp
+++ b/engines/lab/undiff.cpp
@@ -39,8 +39,6 @@ extern uint16 DataBytesPerRow;
 /*****************************************************************************/
 /* Copies memory.                                                            */
 /*****************************************************************************/
-#define turbocopymem(Dest, Source, Len) (memcpy(Dest, Source, Len))
-
 
 static void copytwo(byte *Dest, byte *Source) {
 #if defined(USE_SWAP)
@@ -86,7 +84,7 @@ static void unDIFFByteByte(byte *Dest, byte *diff) {
 		}
 
 		Dest += skip;
-		turbocopymem(Dest, diff, copy);
+		memcpy(Dest, diff, copy);
 		Dest += copy;
 		diff += copy;
 	}
@@ -150,42 +148,6 @@ static void unDIFFByteWord(uint16 *Dest, uint16 *diff) {
 
 
 
-#ifdef undef
-
-/*****************************************************************************/
-/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
-/* is a long word.                                                           */
-/*****************************************************************************/
-static void unDIFFByteLong(byte *Dest, byte *diff) {
-	uint16 skip, copy;
-
-	while (1) {
-		skip = *diff << 2;
-		diff++;
-		copy = *diff << 2;
-		diff++;
-
-		if (skip == (255 << 2)) {
-			if (copy == 0) {
-				skip = swapUShort(*((uint16 *) diff)) << 2;
-				diff += 2;
-				copy = swapUShort(*((uint16 *) diff) << 2;
-				                  diff += 2;
-			} else if (copy == (255 << 2))
-				       return;
-		}
-
-		Dest += skip;
-		turbocopymem(Dest, diff, copy);
-		Dest += copy;
-		diff += copy;
-	}
-}
-
-#endif
-
-
-
 /*****************************************************************************/
 /* UnDiffs a coded DIFF string onto an already initialized piece of memory.  */
 /*****************************************************************************/
@@ -197,33 +159,10 @@ bool unDIFFMemory(byte *Dest, byte *diff, uint16 HeaderSize, uint16 CopySize) {
 		else if (CopySize == 2)
 			unDIFFByteWord((uint16 *)Dest, (uint16 *)diff);
 
-#ifdef undef
-		else if (CopySize == 4)
-			unDIFFByteLong((uint32 *)Dest, (uint32 *)diff);
-
-#endif
-
 		else
 			return false;
-	}
-	/*
-	   else if (HeaderSize == 2)
-	   {
-	    if (CopySize == 1)
-	      unDIFFWordByte(Dest, diff);
-
-	    else if (CopySize == 2)
-	      unDIFFWordWord(Dest, diff);
-
-	    else if (CopySize == 4)
-	      unDIFFWordLong(Dest, diff);
-
-	    else
-	      return false;
-	   }
-	 */
-	else
-		return (false);
+	} else
+		error("unDIFFMemory: HeaderSize is %d", HeaderSize);
 
 	return true;
 }
@@ -431,7 +370,7 @@ void runLengthDecode(byte *Dest, byte *Source) {
 		if (num == 127) {
 			return;
 		} else if (num > '\0') {
-			turbocopymem(Dest, Source, num);
+			memcpy(Dest, Source, num);
 			Source += num;
 			Dest   += num;
 		} else {


Commit: 2cd1c0d3fff098f84aca5cee912ac163b200dbad
    https://github.com/scummvm/scummvm/commit/2cd1c0d3fff098f84aca5cee912ac163b200dbad
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Clean up some DOS-specific code

Changed paths:
    engines/lab/labmusic.cpp



diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index 4efbd07..2998b62 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -472,11 +472,8 @@ byte **Music::newOpen(const char *name) {
 	if (_musicOn) {
 		updateMusic();
 
-#if defined(DOSCODE)
-		LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / SAMPLESPEED;
-#else
-		LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / (2 * SAMPLESPEED);
-#endif
+		LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / (2 * SAMPLESPEED);	// Windows (16-bit)
+		//LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / SAMPLESPEED;	// DOS (8-bit) - TODO
 
 		filelength = sizeOfFile(name) * 10;
 		Time = 10 +                           /* Seek time for the music and the file */
@@ -511,11 +508,9 @@ void Music::fileCheckMusic(uint32 filelength) {
 	if (_musicOn) {
 		updateMusic();
 
-#if defined(DOSCODE)
-		LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / SAMPLESPEED;
-#else
-		LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / (2 * SAMPLESPEED);
-#endif
+		
+		LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / (2 * SAMPLESPEED);	// Windows (16-bit)
+		//LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / SAMPLESPEED;	// DOS (8-bit) - TODO
 
 		filelength *= 10;
 		Time = 5 +                            /* Seek time for the music */


Commit: af35398ad0a9eef858a4ac062b2c2bd78f02452c
    https://github.com/scummvm/scummvm/commit/af35398ad0a9eef858a4ac062b2c2bd78f02452c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Initial sound implementation

Sound effects are now played, and the engine no longer waits forever
when playing a sound. A lot of unused sound code has been removed.

Changed paths:
    engines/lab/audioi.cpp



diff --git a/engines/lab/audioi.cpp b/engines/lab/audioi.cpp
index 37aecd5..e2c5af8 100644
--- a/engines/lab/audioi.cpp
+++ b/engines/lab/audioi.cpp
@@ -28,84 +28,35 @@
  *
  */
 
-#include "lab/stddefines.h"
+#include "audio/mixer.h"
+#include "audio/audiostream.h"
+#include "audio/decoders/raw.h"
 
+#include "lab/lab.h"
+#include "lab/stddefines.h"
 #include "lab/labfun.h"
 
 namespace Lab {
 
 #define PLAYBUFSIZE     65536L
 
-#if defined(DOSCODE)
-const char VERSION[] = "1.01";
-
-char *AudioI_DriverName = "a32sbdg.dll";
-#endif
-
 extern bool MusicOn;
 
-#if defined(DOSCODE)
-static HTIMER server;
-static HDRIVER hdriver;
-static char *drvr;
-static char *dll;
-static drvr_desc *desc;
-#endif
 //static sound_buff firstblock, tempblock;
 static int bufnum;
-#if defined(DOSCODE)
-static unsigned seg1;
-static unsigned seg2;
-static union REGS inregs, outregs;
-#endif
 
 
 bool EffectPlaying = false, ContMusic = false, DoMusic = false;
 static char *CurMusic, *startMusic;
 static uint32 StartMusicLen;
-
-
-#if defined(DOSCODE)
-static uint16 *mem, *head, *tail, counter;
-
-#pragma off (check_stack)
-void cdecl timer_callback(void) {
-
-	head = (uint16 *)(0x41A);
-	tail = (uint16 *)(0x41C);
-	mem  = (uint16 *)(0x400 + *head);
-
-	if (*tail > *head)
-		counter = (*tail - *head) >> 1;
-	else
-		counter = (*head - *tail) >> 1;
-
-	if (counter > 16)
-		counter = 16;
-
-	while (counter) {
-		if ((*mem == 0x2e03) || (*mem == 0x300) || (*mem == 0x0003)) {
-			*tail = *head;
-			return;
-		}
-
-		mem++;
-		counter--;
-	}
-}
-#endif
+static Audio::SoundHandle g_musicHandle;
 
 void freeAudio(void) {
 	if (!DoMusic)
 		return;
 
-#if defined(DOSCODE)
-	AIL_release_timer_handle(server);
-
-	AIL_shutdown(NULL);
-#else
+	// TODO
 	//SDLWrapAudio();
-#endif
 }
 
 
@@ -114,114 +65,10 @@ bool initAudio(void) {
 	if (!DoMusic)
 		return true;
 
+// TODO
 #if 0
-#if defined(DOSCODE)
-
-	AudioI_DriverName = "a32sbdg.dll";
-
-	//
-	// Allocate two 16K buffers from real-mode (lower 1MB) memory
-	//
-	// *buf1, *buf2 -> protected-mode pointers to buffers (sel:0000)
-	// *seg1, *seg2 -> real-mode (physical) pointers to buffers (seg:0000)
-	//
-	// Note: DPMI calculations assume flat model near pointer offset 0 =
-	// segment 0, offset 0 (Rational DOS4GW).  The reason -- our simple
-	// file loader function can't use the far pointer formed by the selector
-	// returned by the DPMI call.
-
-	// Note that these examples do not implement out-of-memory error
-	// checking
-	//
-
-	inregs.x.eax = 0x100;
-	inregs.x.ebx = (16384 / 16);
-	int386(0x31, &inregs, &outregs);
-
-	seg1 = outregs.x.eax << 16;
-	buf1 = (char *)(outregs.x.eax * 16);
-
-	if (buf1 == NULL)
-		return false;
-
-	inregs.x.eax = 0x100;
-	inregs.x.ebx = (16384 / 16);
-	int386(0x31, &inregs, &outregs);
-
-	seg2 = outregs.x.eax << 16;
-	buf2 = (char *)(outregs.x.eax * 16);
-
-	if (buf2 == NULL)
-		return false;
-
-	//
-	// Load driver file
-	//
-
-	dll = FILE_read(AudioI_DriverName, NULL);
-
-	if (dll == NULL) {
-		return false;
-	}
-
-	drvr = DLL_load(dll, DLLMEM_ALLOC | DLLSRC_MEM, NULL);
-
-	if (drvr == NULL) {
-		return false;
-	}
-
-	free(dll);
-
-	//
-	// Initialize API before calling any Library functions
-	//
-
-	AIL_startup();
-
-	hdriver = AIL_register_driver(drvr);
-
-	if (hdriver == -1) {
-		AIL_shutdown(NULL);
-		return false;
-	}
-
-	//
-	// Get driver type and factory default I/O parameters; exit if
-	// driver is not capable of interpreting PCM sound data
-	//
-
-	desc = AIL_describe_driver(hdriver);
-
-	if (desc->drvr_type != DSP_DRVR) {
-		AIL_shutdown(NULL);
-		return false;
-	}
-
-	if (!AIL_detect_device(hdriver, desc->default_IO, desc->default_IRQ, desc->default_DMA, desc->default_DRQ)) {
-		desc->default_IRQ = 5;
-
-		if (!AIL_detect_device(hdriver, desc->default_IO, desc->default_IRQ, desc->default_DMA, desc->default_DRQ)) {
-			AIL_shutdown(NULL);
-			return false;
-		}
-	}
-
-	AIL_init_driver(hdriver, desc->default_IO, desc->default_IRQ, desc->default_DMA, desc->default_DRQ);
-
-	//
-	// Register a timer function; set up for 10-millisecond (100 Hz.)
-	// callback intervals
-	//
-
-	server = AIL_register_timer(timer_callback);
-
-	if (server != -1) {
-		AIL_set_timer_period(server, 20000L);
-		AIL_start_timer(server);
-	}
-
-#else
 	// we allocate extra mempory for 16-bit samples
+	// TODO: 8-bit mono sample for DOS
 	buf1 = malloc(PLAYBUFSIZE);
 
 	if (buf1 == NULL)
@@ -234,8 +81,6 @@ bool initAudio(void) {
 
 	if (!SDLInitAudio())
 		return false;
-
-#endif
 #endif
 
 	return true;
@@ -248,57 +93,23 @@ void initSampleRate(uint16 SampleSpeed) {
 	if (SampleSpeed < 4000)
 		SampleSpeed = 4000;
 
-#if defined(DOSCODE)
-	firstblock.sample_rate = 256 - (1000000L / SampleSpeed);
-	firstblock.pack_type = 0 | 0x80;  // 8-bit mono sample
-#else
 	//firstblock.sample_rate = SampleSpeed;
 	//firstblock.pack_type = AUDIO_S16; // SOUND_MONO | SOUND_16BIT;  // 16-bit mono sample
-#endif
+	// TODO: 8-bit mono sample for DOS
 }
 
 
 
 
 bool musicBufferEmpty(uint16 i) {
-#if defined(NEWCODE)
-	return (AIL_sound_buffer_status(hdriver, i) == DAC_DONE);
-#else
-	//return (SDLSoundBufferStatus(i) == DAC_DONE);
-	return true;
-#endif
+	// TODO: Multiple streams
+	return !g_lab->_mixer->isSoundHandleActive(g_musicHandle);
 }
 
 
 
 void playMusicBlock(void *Ptr, uint32 Size, uint16 BufferNum, uint16 SampleSpeed) {
-#if defined(DOSCODE)
-	uint32 TempPtr;
-	uint32 seg;
-	char *buf;
-
-	TempPtr = ((uint32) Ptr) / 16L;
-
-	seg = TempPtr << 16;
-	buf = (char *)(TempPtr * 16);
-
-	if (SampleSpeed < 4000)
-		SampleSpeed = 4000;
-
-	firstblock.sample_rate = 256 - (1000000L / SampleSpeed);
-	firstblock.pack_type = 0 | 0x80;  // 8-bit mono sample
-
-	tempblock = firstblock;
-	tempblock.sel_data = buf;
-	tempblock.seg_data = seg;
-	tempblock.len      = Size;
-
-	AIL_register_sound_buffer(hdriver, BufferNum, &tempblock);
-	AIL_format_sound_buffer(hdriver, &tempblock);
-
-	AIL_start_digital_playback(hdriver);
-	AIL_set_digital_playback_volume(hdriver, 127);
-#else
+	// TODO
 #if 0
 
 	if (SampleSpeed < 4000)
@@ -306,6 +117,7 @@ void playMusicBlock(void *Ptr, uint32 Size, uint16 BufferNum, uint16 SampleSpeed
 
 	firstblock.sample_rate = SampleSpeed;
 	firstblock.pack_type = SOUND_MONO | SOUND_16BIT;  // 16-bit mono sample
+	// TODO: 8-bit mono sample for DOS
 
 	tempblock = firstblock;
 	tempblock.sel_data = Ptr;
@@ -313,7 +125,6 @@ void playMusicBlock(void *Ptr, uint32 Size, uint16 BufferNum, uint16 SampleSpeed
 
 	SDLPlayBuffer(BufferNum, &tempblock);
 #endif
-#endif
 }
 
 
@@ -324,52 +135,14 @@ void updateSoundBuffers(void) {
 	if (!EffectPlaying)
 		return;
 
-#if defined(DOSCODE)
-
-	for (int i = 0; i < 2; i++) {
-		if ((AIL_sound_buffer_status(hdriver, i) == DAC_DONE) && firstblock.len) {
-			tempblock.len = MIN(16384L, firstblock.len);
-			firstblock.len -= tempblock.len;
-
-			if (!(bufnum ^= 1)) {
-				memcpy(buf1, CurMusic, (unsigned) tempblock.len);
-				tempblock.sel_data = buf1;
-				tempblock.seg_data = seg1;
-			} else {
-				memcpy(buf2, CurMusic, (unsigned) tempblock.len);
-				tempblock.sel_data = buf2;
-				tempblock.seg_data = seg2;
-			}
-
-			CurMusic += tempblock.len;
-
-			AIL_register_sound_buffer(hdriver, i, &tempblock);
-			AIL_format_sound_buffer(hdriver, &tempblock);
-
-			AIL_start_digital_playback(hdriver);
-			AIL_set_digital_playback_volume(hdriver, 127);
-		}
-	}
-
-	//
-	// Playback ends when no bytes are left in the source data and
-	// the status of both buffers equals DAC_DONE
-	//
-
-	if (!firstblock.len) {
-		if (ContMusic) {
-			CurMusic = startMusic;
-			firstblock.len = StartMusicLen;
-		} else if ((AIL_sound_buffer_status(hdriver, 0) == DAC_DONE) &&
-		           (AIL_sound_buffer_status(hdriver, 1) == DAC_DONE)) {
-			flushAudio();
-			EffectPlaying = false;
-		}
+	// TODO
+	// FIXME: Very crude implementation
+	if (musicBufferEmpty(0)) {
+		flushAudio();
+		EffectPlaying = false;
 	}
 
-#else
 #if 0
-
 	for (int i = 0; i < 2; i++) {
 		if ((SDLSoundBufferStatus(i) == DAC_DONE) && firstblock.len) {
 			// use extra memory for 16-bit samples
@@ -407,7 +180,6 @@ void updateSoundBuffers(void) {
 	}
 
 #endif
-#endif
 }
 
 
@@ -416,11 +188,7 @@ void flushAudio(void) {
 	if (!DoMusic)
 		return;
 
-#if defined(DOSCODE)
-	AIL_stop_digital_playback(hdriver);
-#else
-	//SDLStopPlayback();
-#endif
+	g_lab->_mixer->stopHandle(g_musicHandle);
 	EffectPlaying = false;
 }
 
@@ -439,13 +207,9 @@ void playMusic(uint16 SampleSpeed, uint16 Volume, uint32 Length, bool flush, voi
 	if (SampleSpeed < 4000)
 		SampleSpeed = 4000;
 
-#if defined(DOSCODE)
-	firstblock.sample_rate = 256 - (1000000L / SampleSpeed);
-	firstblock.pack_type = 0 | 0x80;  // 8-bit mono sample
-#else
 	//firstblock.sample_rate = SampleSpeed;
 	//firstblock.pack_type = SOUND_MONO | SOUND_16BIT;  // 16-bit mono sample
-#endif
+	// TODO: 8-bit mono sample for DOS
 	//firstblock.len = Length;
 	bufnum = 0;
 
@@ -455,6 +219,13 @@ void playMusic(uint16 SampleSpeed, uint16 Volume, uint32 Length, bool flush, voi
 	startMusic = CurMusic;
 	StartMusicLen = Length;
 
+	byte soundFlags = Audio::FLAG_LITTLE_ENDIAN;
+	if (g_lab->getPlatform() == Common::kPlatformWindows)
+		soundFlags |= Audio::FLAG_16BITS;
+
+	Audio::SeekableAudioStream *audStream = Audio::makeRawStream((const byte *)Data, Length, SampleSpeed, soundFlags, DisposeAfterUse::NO);
+	g_lab->_mixer->playStream(Audio::Mixer::kMusicSoundType, &g_musicHandle, audStream);
+
 	updateSoundBuffers();
 }
 


Commit: 530aa5926b8ebcca6533079950730f42e6954a09
    https://github.com/scummvm/scummvm/commit/530aa5926b8ebcca6533079950730f42e6954a09
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Remove dead code

Changed paths:
    engines/lab/audioi.cpp
    engines/lab/diff.h
    engines/lab/labfun.h
    engines/lab/labmusic.cpp
    engines/lab/readdiff.cpp



diff --git a/engines/lab/audioi.cpp b/engines/lab/audioi.cpp
index e2c5af8..ed1e32c 100644
--- a/engines/lab/audioi.cpp
+++ b/engines/lab/audioi.cpp
@@ -87,20 +87,6 @@ bool initAudio(void) {
 }
 
 
-void initSampleRate(uint16 SampleSpeed) {
-	flushAudio();
-
-	if (SampleSpeed < 4000)
-		SampleSpeed = 4000;
-
-	//firstblock.sample_rate = SampleSpeed;
-	//firstblock.pack_type = AUDIO_S16; // SOUND_MONO | SOUND_16BIT;  // 16-bit mono sample
-	// TODO: 8-bit mono sample for DOS
-}
-
-
-
-
 bool musicBufferEmpty(uint16 i) {
 	// TODO: Multiple streams
 	return !g_lab->_mixer->isSoundHandleActive(g_musicHandle);
@@ -115,10 +101,6 @@ void playMusicBlock(void *Ptr, uint32 Size, uint16 BufferNum, uint16 SampleSpeed
 	if (SampleSpeed < 4000)
 		SampleSpeed = 4000;
 
-	firstblock.sample_rate = SampleSpeed;
-	firstblock.pack_type = SOUND_MONO | SOUND_16BIT;  // 16-bit mono sample
-	// TODO: 8-bit mono sample for DOS
-
 	tempblock = firstblock;
 	tempblock.sel_data = Ptr;
 	tempblock.len      = Size;
@@ -207,8 +189,6 @@ void playMusic(uint16 SampleSpeed, uint16 Volume, uint32 Length, bool flush, voi
 	if (SampleSpeed < 4000)
 		SampleSpeed = 4000;
 
-	//firstblock.sample_rate = SampleSpeed;
-	//firstblock.pack_type = SOUND_MONO | SOUND_16BIT;  // 16-bit mono sample
 	// TODO: 8-bit mono sample for DOS
 	//firstblock.len = Length;
 	bufnum = 0;
diff --git a/engines/lab/diff.h b/engines/lab/diff.h
index e1644d4..b0725e5 100644
--- a/engines/lab/diff.h
+++ b/engines/lab/diff.h
@@ -81,8 +81,6 @@ bool readDiff(bool playonce);
 
 void diffNextFrame(void);
 
-void playCntMusic(void);
-
 void readSound(void);
 
 void stopDiff(void);
@@ -91,8 +89,6 @@ void stopDiffEnd(void);
 
 void stopSound(void);
 
-void diffSetMusic(void);
-
 } // End of namespace Lab
 
 #endif /* LAB_DIFF_H */
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 4d1854f..ea45497 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -65,8 +65,6 @@ bool initAudio(void);
 
 void freeAudio(void);
 
-void initSampleRate(uint16 SampleSpeed);
-
 bool musicBufferEmpty(uint16 i);
 
 void playMusicBlock(void *Ptr, uint32 Size, uint16 BufferNum, uint16 SampleSpeed);
diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index 2998b62..8e61c63 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -219,8 +219,6 @@ void Music::startMusic(bool startatbegin) {
 		_leftinfile  = _filelength;
 	}
 
-	initSampleRate(SAMPLESPEED);
-
 	_musicPlaying  = 0;
 	_musicOnBuffer = 0;
 	_musicFilledTo = _manyBuffers - 1;
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index b270f3b..71707dc 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -487,20 +487,6 @@ void stopSound(void) {
 
 
 /*****************************************************************************/
-/* Checks the music while a diff is playing.                                 */
-/*****************************************************************************/
-void diffSetMusic(void) {
-	return;
-
-	while (IsPlaying) {
-		waitTOF();
-		g_music->newCheckMusic();
-	}
-}
-
-
-
-/*****************************************************************************/
 /* Reads in a DIFF file.                                                     */
 /*****************************************************************************/
 bool readDiff(bool playonce) {


Commit: 6ff7c480af11939feb9546985577c092c4f7074d
    https://github.com/scummvm/scummvm/commit/6ff7c480af11939feb9546985577c092c4f7074d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Remove superfluous void function parameters

Changed paths:
    engines/lab/allocroom.cpp
    engines/lab/audioi.cpp
    engines/lab/diff.h
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/interface.cpp
    engines/lab/interface.h
    engines/lab/intro.cpp
    engines/lab/labfile.cpp
    engines/lab/labfun.h
    engines/lab/labmusic.cpp
    engines/lab/labtext.cpp
    engines/lab/map.cpp
    engines/lab/mouse.cpp
    engines/lab/mouse.h
    engines/lab/parsefun.h
    engines/lab/readdiff.cpp
    engines/lab/special.cpp
    engines/lab/vga.cpp
    engines/lab/vga.h



diff --git a/engines/lab/allocroom.cpp b/engines/lab/allocroom.cpp
index 339ae0b..3a5c7b9 100644
--- a/engines/lab/allocroom.cpp
+++ b/engines/lab/allocroom.cpp
@@ -59,7 +59,7 @@ static int32 MemLeftInBuffer = 0L;
 /*****************************************************************************/
 /* Allocates the memory for the room buffers.                                */
 /*****************************************************************************/
-bool initRoomBuffer(void) {
+bool initRoomBuffer() {
 	uint16 counter;
 
 	CurMarker = 0;
@@ -82,7 +82,7 @@ bool initRoomBuffer(void) {
 /*****************************************************************************/
 /* Frees the memory for the room buffers.                                    */
 /*****************************************************************************/
-void freeRoomBuffer(void) {
+void freeRoomBuffer() {
 	if (RoomBuffer)
 		free(RoomBuffer);
 }
diff --git a/engines/lab/audioi.cpp b/engines/lab/audioi.cpp
index ed1e32c..5b2d183 100644
--- a/engines/lab/audioi.cpp
+++ b/engines/lab/audioi.cpp
@@ -51,7 +51,7 @@ static char *CurMusic, *startMusic;
 static uint32 StartMusicLen;
 static Audio::SoundHandle g_musicHandle;
 
-void freeAudio(void) {
+void freeAudio() {
 	if (!DoMusic)
 		return;
 
@@ -61,7 +61,7 @@ void freeAudio(void) {
 
 
 
-bool initAudio(void) {
+bool initAudio() {
 	if (!DoMusic)
 		return true;
 
@@ -110,7 +110,7 @@ void playMusicBlock(void *Ptr, uint32 Size, uint16 BufferNum, uint16 SampleSpeed
 }
 
 
-void updateSoundBuffers(void) {
+void updateSoundBuffers() {
 	if (!DoMusic)
 		return;
 
@@ -166,7 +166,7 @@ void updateSoundBuffers(void) {
 
 
 
-void flushAudio(void) {
+void flushAudio() {
 	if (!DoMusic)
 		return;
 
diff --git a/engines/lab/diff.h b/engines/lab/diff.h
index b0725e5..6889bcc 100644
--- a/engines/lab/diff.h
+++ b/engines/lab/diff.h
@@ -75,19 +75,19 @@ void blackScreen();
 
 void blackAllScreen();
 
-void whiteScreen(void);
+void whiteScreen();
 
 bool readDiff(bool playonce);
 
-void diffNextFrame(void);
+void diffNextFrame();
 
-void readSound(void);
+void readSound();
 
-void stopDiff(void);
+void stopDiff();
 
-void stopDiffEnd(void);
+void stopDiffEnd();
 
-void stopSound(void);
+void stopSound();
 
 } // End of namespace Lab
 
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index ef3850b..ed90443 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -146,7 +146,7 @@ static char initcolors[] = { '\x00', '\x00', '\x00', '\x30',
 /******************************************************************************/
 /* Draws the control panel display.                                           */
 /******************************************************************************/
-void drawPanel(void) {
+void drawPanel() {
 	mouseHide();
 
 	setAPen(3);                 /* Clear Area */
@@ -241,7 +241,7 @@ static uint16 OldMode;
 /******************************************************************************/
 /* Sets up the Labyrinth screens, and opens up the initial windows.           */
 /******************************************************************************/
-bool setUpScreens(void) {
+bool setUpScreens() {
 	uint16 counter;
 	byte *bufferstorage, **buffer = &bufferstorage;
 	Gadget *curgad;
@@ -416,7 +416,7 @@ static void perFlipGadget(uint16 GadID) {
 /******************************************************************************/
 /* Eats all the available messages.                                           */
 /******************************************************************************/
-void eatMessages(void) {
+void eatMessages() {
 	IntuiMessage *Msg;
 
 	do {
@@ -440,7 +440,7 @@ static uint16 lastmusicroom = 1;
 /******************************************************************************/
 /* Checks the music that should be playing in a particular room.              */
 /******************************************************************************/
-static void checkRoomMusic(void) {
+static void checkRoomMusic() {
 	if ((lastmusicroom == RoomNum) || !g_music->_musicOn)
 		return;
 
@@ -546,7 +546,7 @@ static bool interfaceisoff = false;
 /******************************************************************************/
 /* Turns the interface off.                                                   */
 /******************************************************************************/
-static void interfaceOff(void) {
+static void interfaceOff() {
 	if (!interfaceisoff) {
 		attachGadgetList(NULL);
 		mouseHide();
@@ -560,7 +560,7 @@ static void interfaceOff(void) {
 /******************************************************************************/
 /* Turns the interface on.                                                    */
 /******************************************************************************/
-static void interfaceOn(void) {
+static void interfaceOn() {
 	if (interfaceisoff) {
 		interfaceisoff = false;
 
@@ -711,7 +711,7 @@ static bool novesa = false, noaudio = false;
 /******************************************************************************/
 /* Processes user input events.                                               */
 /******************************************************************************/
-static void process(void) {
+static void process() {
 	IntuiMessage *Msg;
 	uint32 Class;
 
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 2a43dfe..4ef132a 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -495,7 +495,7 @@ void copyLong64(uint32 *Dest, uint32 *Source, uint32 Many64) {
 /*****************************************************************************/
 /* Scrolls the display to black.                                             */
 /*****************************************************************************/
-static void doScrollBlack(void) {
+static void doScrollBlack() {
 	byte *mem, *tempmem;
 	Image Im;
 	uint16 width, height, by, nheight, CurPage;
@@ -675,7 +675,7 @@ static void doScrollWipe(char *filename) {
 /*****************************************************************************/
 /* Does the scroll bounce.  Assumes bitmap already in memory.                */
 /*****************************************************************************/
-static void doScrollBounce(void) {
+static void doScrollBounce() {
 	const uint16 *newby, *newby1;
 
 	const uint16 newbyd[5] = {5, 4, 3, 2, 1}, newby1d[8] = {3, 3, 2, 2, 2, 1, 1, 1};
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index c70d19b..62d35c1 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -165,7 +165,7 @@ static bool keyPress(uint16 *KeyCode) {
 IntuiMessage IMessage;
 extern Gadget *ScreenGadgetList;
 
-IntuiMessage *getMsg(void) {
+IntuiMessage *getMsg() {
 	Gadget *curgad;
 	int Qualifiers;
 
diff --git a/engines/lab/interface.h b/engines/lab/interface.h
index 9b8c3fb..1c0439b 100644
--- a/engines/lab/interface.h
+++ b/engines/lab/interface.h
@@ -124,7 +124,7 @@ void ghoastGadget(Gadget *curgad, uint16 pencolor);
 
 void unGhoastGadget(Gadget *curgad);
 
-IntuiMessage *getMsg(void);
+IntuiMessage *getMsg();
 
 void replyMsg(void *Msg);
 
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 09f92c0..8d508ae 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -63,7 +63,7 @@ extern int32 longcharsdrawn;
 /* Goes thru, and responds to all the intuition messages currently in the     */
 /* the message port.                                                          */
 /******************************************************************************/
-void introEatMessages(void) {
+void introEatMessages() {
 	IntuiMessage *Msg;
 
 	while (1) {
@@ -229,7 +229,7 @@ static void doPictText(const char *Filename, bool isscreen) {
 /*****************************************************************************/
 /* Does a one second delay, but checks the music while doing it.             */
 /*****************************************************************************/
-void musicDelay(void) {
+void musicDelay() {
 	int16 counter;
 
 	g_music->newCheckMusic();
@@ -268,7 +268,7 @@ static void NReadPict(const char *Filename, bool PlayOnce) {
 /*****************************************************************************/
 /* Does the introduction sequence for Labyrinth.                             */
 /*****************************************************************************/
-void introSequence(void) {
+void introSequence() {
 	uint16 counter, counter1;
 
 	DoBlack = true;
diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
index 4cbbd54..e5ff491 100644
--- a/engines/lab/labfile.cpp
+++ b/engines/lab/labfile.cpp
@@ -278,7 +278,7 @@ void skip(byte **File, uint32 skip) {
 /*****************************************************************************/
 /* Resets the internal buffers to empty.                                     */
 /*****************************************************************************/
-void resetBuffer(void) {
+void resetBuffer() {
 	uint16 RMarker;
 
 	CurMarker = 0;
@@ -314,7 +314,7 @@ bool initBuffer(uint32 BufSize, bool IsGraphicsMem) {
 /*****************************************************************************/
 /* Frees the buffer.                                                         */
 /*****************************************************************************/
-void freeBuffer(void) {
+void freeBuffer() {
 	freeAllStolenMem();
 
 	if (buffer)
@@ -335,7 +335,7 @@ void freeBuffer(void) {
 /*****************************************************************************/
 /* Clears all the buffers.                                                   */
 /*****************************************************************************/
-static void flushBuffers(void) {
+static void flushBuffers() {
 	uint16 RMarker;
 
 	RMarker = 0;
@@ -385,7 +385,7 @@ Common::File *openPartial(const char *name) {
 /*****************************************************************************/
 /* Frees all the memory stolen from the buffer.                              */
 /*****************************************************************************/
-void freeAllStolenMem(void) {
+void freeAllStolenMem() {
 	flushBuffers();
 
 	buffer = realbufferstart;
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index ea45497..a527b12 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -61,17 +61,17 @@ struct SaveGameHeader {
 /*------ From Audioi.c -------*/
 /*----------------------------*/
 
-bool initAudio(void);
+bool initAudio();
 
-void freeAudio(void);
+void freeAudio();
 
 bool musicBufferEmpty(uint16 i);
 
 void playMusicBlock(void *Ptr, uint32 Size, uint16 BufferNum, uint16 SampleSpeed);
 
-void updateSoundBuffers(void);
+void updateSoundBuffers();
 
-void flushAudio(void);
+void flushAudio();
 
 void playMusic(uint16 SampleSpeed, uint16 Volume, uint32 Length, bool flush, void *Data);
 
@@ -146,7 +146,7 @@ void gadgetsOnOff(void *gptr, void *win, int32 num, bool on);
 /*---- From Intro.c ----*/
 /*----------------------*/
 
-void introSequence(void);
+void introSequence();
 
 
 
@@ -154,13 +154,13 @@ void introSequence(void);
 /*----- From Lab.c -----*/
 /*----------------------*/
 
-void eatMessages(void);
+void eatMessages();
 
-bool setUpScreens(void);
+bool setUpScreens();
 
-void drawPanel(void);
+void drawPanel();
 
-bool quitPlaying(void);
+bool quitPlaying();
 
 
 
@@ -182,11 +182,11 @@ char readChar(char **File);
 
 void skip(byte **File, uint32 skip);
 
-void resetBuffer(void);
+void resetBuffer();
 
 bool initBuffer(uint32 BufSize, bool IsGraphicsMem);
 
-void freeBuffer(void);
+void freeBuffer();
 
 
 /* Functions that borrow memory from the buffer */
@@ -195,7 +195,7 @@ bool allocFile(void **Ptr, uint32 Size, const char *fileName);
 
 void *stealBufMem(int32 Size);
 
-void freeAllStolenMem(void);
+void freeAllStolenMem();
 
 
 /* Read chunks of a file */
@@ -210,9 +210,9 @@ void closePartial(int32 File);
 /*------ From LabText.c -----*/
 /*---------------------------*/
 
-bool initLabText(void);
+bool initLabText();
 
-void freeLabText(void);
+void freeLabText();
 
 void decrypt(byte *text);
 
@@ -231,18 +231,18 @@ public:
 	Music();
 
 	byte **newOpen(const char *name);
-	bool initMusic(void);
-	void freeMusic(void);
+	bool initMusic();
+	void freeMusic();
 	void fillUpMusic(bool doit);
-	void updateMusic(void);
-	void checkMusic(void);
-	void newCheckMusic(void);
-	void closeMusic(void);
+	void updateMusic();
+	void checkMusic();
+	void newCheckMusic();
+	void closeMusic();
 	void setMusic(bool on);
-	void restartBackMusic(void);
-	void pauseBackMusic(void);
+	void restartBackMusic();
+	void pauseBackMusic();
 	void changeMusic(const char *newmusic);
-	void resetMusic(void);
+	void resetMusic();
 	void fileCheckMusic(uint32 filelength);
 
 	bool _winmusic, _doNotFileFlushAudio;
@@ -251,7 +251,7 @@ public:
 
 private:
 	void fillbuffer(uint16 unit);
-	uint16 getManyBuffersLeft(void);
+	uint16 getManyBuffersLeft();
 	void startMusic(bool startatbegin);
 
 	Common::File *_file;
@@ -340,13 +340,13 @@ void doMap(uint16 CurRoom);
 
 void doJournal();
 
-void doNotes(void);
+void doNotes();
 
-void doWestPaper(void);
+void doWestPaper();
 
 void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 
-bool saveRestoreGame(void);
+bool saveRestoreGame();
 
 
 
diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index 8e61c63..cd08270 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -71,7 +71,7 @@ Music::Music() {
 /* Figures out which buffer is currently playing based on messages sent to   */
 /* it from the Audio device.                                                 */
 /*****************************************************************************/
-void Music::updateMusic(void) {
+void Music::updateMusic() {
 	uint16 i;
 
 	WSDL_ProcessInput(0);
@@ -125,7 +125,7 @@ void Music::fillbuffer(uint16 unit) {
 /*****************************************************************************/
 /* Figures out how many *complete* buffers of music left to play.            */
 /*****************************************************************************/
-uint16 Music::getManyBuffersLeft(void) {
+uint16 Music::getManyBuffersLeft() {
 	uint16 mp = _musicOnBuffer;
 
 	if (mp == _musicFilledTo) /* Already filled */
@@ -240,7 +240,7 @@ void Music::startMusic(bool startatbegin) {
 /*****************************************************************************/
 /* Initializes the music buffers.                                            */
 /*****************************************************************************/
-bool Music::initMusic(void) {
+bool Music::initMusic() {
 	uint16 counter;
 
 	if (!_turnMusicOn)
@@ -278,7 +278,7 @@ bool Music::initMusic(void) {
 /*****************************************************************************/
 /* Frees up the music buffers and closes the file.                           */
 /*****************************************************************************/
-void Music::freeMusic(void) {
+void Music::freeMusic() {
 	_musicOn = false;
 
 	if (_file->isOpen())
@@ -291,7 +291,7 @@ void Music::freeMusic(void) {
 /*****************************************************************************/
 /* Pauses the background music.                                              */
 /*****************************************************************************/
-void Music::pauseBackMusic(void) {
+void Music::pauseBackMusic() {
 	if (!_musicPaused && _musicOn) {
 		updateMusic();
 		_musicOn = false;
@@ -311,7 +311,7 @@ void Music::pauseBackMusic(void) {
 /*****************************************************************************/
 /* Restarts the paused background music.                                     */
 /*****************************************************************************/
-void Music::restartBackMusic(void) {
+void Music::restartBackMusic() {
 	if (_musicPaused) {
 		flushAudio();
 		_musicOn = true;
@@ -327,7 +327,7 @@ void Music::restartBackMusic(void) {
 /*****************************************************************************/
 /* Checks to see if need to fill buffers fill of music.                      */
 /*****************************************************************************/
-void Music::checkMusic(void) {
+void Music::checkMusic() {
 	updateMusic();
 
 	if (!_musicOn)
@@ -341,7 +341,7 @@ void Music::checkMusic(void) {
 /*****************************************************************************/
 /* Checks to see if need to fill buffers fill of music.                      */
 /*****************************************************************************/
-void Music::newCheckMusic(void) {
+void Music::newCheckMusic() {
 	checkMusic();
 }
 
@@ -405,7 +405,7 @@ void Music::changeMusic(const char *newmusic) {
 /*****************************************************************************/
 /* Changes the background music to the original piece playing.               */
 /*****************************************************************************/
-void Music::resetMusic(void) {
+void Music::resetMusic() {
 	if (!_tFile)
 		return;
 
diff --git a/engines/lab/labtext.cpp b/engines/lab/labtext.cpp
index 673f8d0..3c26ea7 100644
--- a/engines/lab/labtext.cpp
+++ b/engines/lab/labtext.cpp
@@ -64,7 +64,7 @@ static void setString(char **string) {
 /*****************************************************************************/
 /* Initializes everything for the Labyrinth text stuff                       */
 /*****************************************************************************/
-bool initLabText(void) {
+bool initLabText() {
 	if ((SizeOfMemChunk = sizeOfFile(LABTEXTFILE)))
 		if ((BeginOfMemChunk = (char *)calloc(SizeOfMemChunk, 1))) {
 			Common::File *file = openPartial(LABTEXTFILE);
@@ -143,7 +143,7 @@ bool initLabText(void) {
 /*****************************************************************************/
 /* Frees the memory from the Labyrinth text stuff.                           */
 /*****************************************************************************/
-void freeLabText(void) {
+void freeLabText() {
 	if (SizeOfMemChunk && BeginOfMemChunk)
 		free(BeginOfMemChunk);
 }
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 77d520d..f51bf86 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -217,7 +217,7 @@ static uint16 mapScaleY(uint16 y) {
 /*****************************************************************************/
 /* Loads in the map data.                                                    */
 /*****************************************************************************/
-static bool loadMapData(void) {
+static bool loadMapData() {
 	byte **buffer, Temp[5];
 	int32 Size;
 	Gadget *gptr;
@@ -892,7 +892,7 @@ void processMap(uint16 CurRoom) {
 /*****************************************************************************/
 /* Cleans up behind itself.                                                  */
 /*****************************************************************************/
-void mapCleanUp(void) {
+void mapCleanUp() {
 	freeAllStolenMem();
 }
 
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index a75a92c..6e6c97d 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -39,7 +39,7 @@ namespace Lab {
 extern bool IsHiRes;
 extern uint32 VGAScreenWidth, VGAScreenHeight;
 
-void mouseHideXY(void);
+void mouseHideXY();
 
 static bool LeftClick = false;
 static bool RightClick = false;
@@ -166,7 +166,7 @@ void mouse_handler(int32 flag, int32 mouseX, int32 mouseY) {
 
 
 
-void updateMouse(void) {
+void updateMouse() {
 	uint16 counter;
 	bool doUpdateDisplay = false;
 
@@ -204,7 +204,7 @@ void updateMouse(void) {
 /*****************************************************************************/
 /* Initializes the mouse.                                                    */
 /*****************************************************************************/
-bool initMouse(void) {
+bool initMouse() {
 	g_system->setMouseCursor(MouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0);
 	g_system->showMouse(false);
 
@@ -219,7 +219,7 @@ bool initMouse(void) {
 /*****************************************************************************/
 /* Shows the mouse.                                                          */
 /*****************************************************************************/
-void mouseShow(void) {
+void mouseShow() {
 	mouseShowXY(CurMouseX, CurMouseY);
 
 	g_system->showMouse(true);
@@ -253,7 +253,7 @@ void mouseShowXY(uint16 MouseX, uint16 MouseY) {
 /*****************************************************************************/
 /* Hides the mouse.                                                          */
 /*****************************************************************************/
-void mouseHide(void) {
+void mouseHide() {
 	QuitMouseHandler = true;
 
 	NumHidden++;
@@ -273,7 +273,7 @@ void mouseHide(void) {
 /*****************************************************************************/
 /* Hides the mouse.                                                          */
 /*****************************************************************************/
-void mouseHideXY(void) {
+void mouseHideXY() {
 	QuitMouseHandler = true;
 
 	NumHidden++;
@@ -355,7 +355,7 @@ bool mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
 
 
 
-Gadget *mouseGadget(void) {
+Gadget *mouseGadget() {
 	Gadget *Temp = LastGadgetHit;
 
 	LastGadgetHit = NULL;
diff --git a/engines/lab/mouse.h b/engines/lab/mouse.h
index 5af5821..18e5c2c 100644
--- a/engines/lab/mouse.h
+++ b/engines/lab/mouse.h
@@ -37,13 +37,13 @@ namespace Lab {
 
 struct Gadget;
 
-bool initMouse(void);
+bool initMouse();
 
-void updateMouse(void);
+void updateMouse();
 
-void mouseShow(void);
+void mouseShow();
 
-void mouseHide(void);
+void mouseHide();
 
 void mouseXY(uint16 *x, uint16 *y);
 
@@ -51,7 +51,7 @@ void mouseMove(uint16 x, uint16 y);
 
 bool mouseButton(uint16 *x, uint16 *y, bool leftbutton);
 
-Gadget *mouseGadget(void);
+Gadget *mouseGadget();
 
 void attachGadgetList(Gadget *GadList);
 
diff --git a/engines/lab/parsefun.h b/engines/lab/parsefun.h
index 2c48311..6766dd2 100644
--- a/engines/lab/parsefun.h
+++ b/engines/lab/parsefun.h
@@ -44,9 +44,9 @@ bool parse(const char *InputFile);
 
 /* From allocRoom.c */
 
-bool initRoomBuffer(void);
+bool initRoomBuffer();
 
-void freeRoomBuffer(void);
+void freeRoomBuffer();
 
 void allocRoom(void **Ptr, uint16 Size, uint16 RoomNum);
 
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index 71707dc..b75ed6d 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -125,7 +125,7 @@ void blackScreen() {
 /*****************************************************************************/
 /* Changes the front screen to white.                                        */
 /*****************************************************************************/
-void whiteScreen(void) {
+void whiteScreen() {
 	memset(blackbuffer, 255, 248 * 3);
 	writeColorRegs(blackbuffer, 8, 248);
 }
@@ -149,7 +149,7 @@ static byte *Buffer, temp[5];
 static bool FirstThru = true, donepal   = false;
 static byte *storagefordifffile, * *difffile = &storagefordifffile;
 
-void diffNextFrame(void) {
+void diffNextFrame() {
 	if (header == 65535)  /* Already done. */
 		return;
 
@@ -340,7 +340,7 @@ void diffNextFrame(void) {
 /*****************************************************************************/
 /* A separate task launched by readDiff.  Plays the DIFF.                    */
 /*****************************************************************************/
-void playDiff(void) {
+void playDiff() {
 	processed = 0L;
 	WaitSec   = 0L;
 	WaitMicros = 0L;
@@ -445,7 +445,7 @@ void playDiff(void) {
 /*****************************************************************************/
 /* Stops an animation from running.                                          */
 /*****************************************************************************/
-void stopDiff(void) {
+void stopDiff() {
 	if (IsPlaying) {
 		StopPlaying = true;
 
@@ -464,7 +464,7 @@ void stopDiff(void) {
 /*****************************************************************************/
 /* Stops an animation from running.                                          */
 /*****************************************************************************/
-void stopDiffEnd(void) {
+void stopDiffEnd() {
 	if (IsPlaying) {
 		StopPlayingEnd = true;
 
@@ -480,7 +480,7 @@ void stopDiffEnd(void) {
 /*****************************************************************************/
 /* Stops the continuous sound from playing.                                  */
 /*****************************************************************************/
-void stopSound(void) {
+void stopSound() {
 	stopsound = true;
 }
 
@@ -500,7 +500,7 @@ bool readDiff(bool playonce) {
 static byte *mstart;
 
 
-void readSound(void) {
+void readSound() {
 	uint32 header_ = 0, size_;
 	uint16 samplespeed_;
 //  uint16 numchunks = 1;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index f9c793c..7d22121 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -117,7 +117,7 @@ static uint16 combx[] = {45, 83, 129, 166, 211, 248};
 /*****************************************************************************/
 /* Draws the images of the combination lock to the display bitmap.           */
 /*****************************************************************************/
-static void doCombination(void) {
+static void doCombination() {
 	uint16 counter;
 
 	for (counter = 0; counter <= 5; counter++)
@@ -513,7 +513,7 @@ static TextFont bmfont;
 /*****************************************************************************/
 /* Does the things to properly set up the detective notes.                   */
 /*****************************************************************************/
-void doNotes(void) {
+void doNotes() {
 	char *ntext;
 
 	/* Load in the data */
@@ -546,7 +546,7 @@ void doNotes(void) {
 /* Does the things to properly set up the old west newspaper.  Assumes that  */
 /* OpenHiRes already called.                                                 */
 /*****************************************************************************/
-void doWestPaper(void) {
+void doWestPaper() {
 	char *ntext;
 	int32 FileLen, CharsPrinted;
 	uint16 y = 268;
@@ -727,7 +727,7 @@ static bool loadJournalData() {
 /*****************************************************************************/
 /* Draws the text to the back journal screen to the appropriate Page number  */
 /*****************************************************************************/
-static void drawJournalText(void) {
+static void drawJournalText() {
 	uint16 DrawingToPage = 1;
 	int32 CharsDrawn    = 0L;
 	char *CurText = journaltext;
@@ -935,7 +935,7 @@ void doJournal() {
 extern InventoryData *Inventory;
 extern uint16 RoomNum, Direction;
 
-bool saveRestoreGame(void) {
+bool saveRestoreGame() {
 	bool isOK = false;
 
 	// The original had one screen for saving/loading. We have two.
@@ -993,7 +993,7 @@ Image *MonButton, *AltMonButton, *MonQuit, *AltMonQuit, *MonBack, *AltMonBack,
 /*****************************************************************************/
 /* Makes sure that the buttons are in memory.                                */
 /*****************************************************************************/
-static void getMonImages(void) {
+static void getMonImages() {
 	byte **buffer;
 
 	resetBuffer();
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 11713da..4c2584c 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -100,11 +100,11 @@ void setPage(uint16 PageNum) {
 	assert(PageNum == 0);
 }
 
-void VGAStorePage(void) {
+void VGAStorePage() {
 	// does nothing in SDL
 }
 
-void VGARestorePage(void) {
+void VGARestorePage() {
 	// does nothing in SDL
 }
 
@@ -321,7 +321,7 @@ void WSDL_UpdateScreen() {
 /*****************************************************************************/
 /* Returns the base address of the current VGA display.                      */
 /*****************************************************************************/
-byte *getVGABaseAddr(void) {
+byte *getVGABaseAddr() {
 	if (VGABASEADDRESS)
 		return VGABASEADDRESS;
 
diff --git a/engines/lab/vga.h b/engines/lab/vga.h
index fe6b9f0..9e45b80 100644
--- a/engines/lab/vga.h
+++ b/engines/lab/vga.h
@@ -47,17 +47,17 @@ void getMode(uint16 *Mode);
 
 void setPage(uint16 PageNum);
 
-void VGAStorePage(void);
+void VGAStorePage();
 
-void VGARestorePage(void);
+void VGARestorePage();
 
 bool createScreen(bool HiRes);
 
-void waitTOF(void);
+void waitTOF();
 
-void quickWaitTOF(void);
+void quickWaitTOF();
 
-byte *getVGABaseAddr(void);
+byte *getVGABaseAddr();
 
 void ungetVGABaseAddr();
 


Commit: ca819e0b863cf56e1f03dde302f075472ec11e79
    https://github.com/scummvm/scummvm/commit/ca819e0b863cf56e1f03dde302f075472ec11e79
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Rename playMusic() to playSoundEffect()

This function actually starts sound effects. Music is started from
playMusicBlock()

Changed paths:
    engines/lab/audioi.cpp
    engines/lab/labfun.h
    engines/lab/readdiff.cpp



diff --git a/engines/lab/audioi.cpp b/engines/lab/audioi.cpp
index 5b2d183..735f9b6 100644
--- a/engines/lab/audioi.cpp
+++ b/engines/lab/audioi.cpp
@@ -177,7 +177,7 @@ void flushAudio() {
 
 
 
-void playMusic(uint16 SampleSpeed, uint16 Volume, uint32 Length, bool flush, void *Data) {
+void playSoundEffect(uint16 SampleSpeed, uint16 Volume, uint32 Length, bool flush, void *Data) {
 	if (!DoMusic)
 		return;
 
@@ -204,7 +204,7 @@ void playMusic(uint16 SampleSpeed, uint16 Volume, uint32 Length, bool flush, voi
 		soundFlags |= Audio::FLAG_16BITS;
 
 	Audio::SeekableAudioStream *audStream = Audio::makeRawStream((const byte *)Data, Length, SampleSpeed, soundFlags, DisposeAfterUse::NO);
-	g_lab->_mixer->playStream(Audio::Mixer::kMusicSoundType, &g_musicHandle, audStream);
+	g_lab->_mixer->playStream(Audio::Mixer::kSFXSoundType, &g_musicHandle, audStream);
 
 	updateSoundBuffers();
 }
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index a527b12..cc77a4c 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -73,7 +73,7 @@ void updateSoundBuffers();
 
 void flushAudio();
 
-void playMusic(uint16 SampleSpeed, uint16 Volume, uint32 Length, bool flush, void *Data);
+void playSoundEffect(uint16 SampleSpeed, uint16 Volume, uint32 Length, bool flush, void *Data);
 
 
 
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index b75ed6d..66bfa80 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -291,7 +291,7 @@ void diffNextFrame() {
 			uint32 musicsize = size;
 			skip(difffile, size);
 
-			playMusic(samplespeed, 64, musicsize, true, music);
+			playSoundEffect(samplespeed, 64, musicsize, true, music);
 			break;
 		}
 		case 65535L:
@@ -563,7 +563,7 @@ void readSound() {
 			uint32 musicsize = size_;
 			skip(difffile_, size_);
 
-			playMusic(samplespeed_, 64, musicsize, true, music);
+			playSoundEffect(samplespeed_, 64, musicsize, true, music);
 		} else if (header_ == 65535L) {
 			if (mwaiteffect) {
 				while (EffectPlaying) {


Commit: 1c77b2daf88c465c8f8cffddff65f8a7bca1af89
    https://github.com/scummvm/scummvm/commit/1c77b2daf88c465c8f8cffddff65f8a7bca1af89
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Implement correct duration calculation for the DOS version music

Changed paths:
    engines/lab/labmusic.cpp



diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index cd08270..4a427ed 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -33,6 +33,7 @@
 #include "lab/timing.h"
 #include "lab/mouse.h"
 #include "lab/vga.h"
+#include "lab/lab.h"
 
 namespace Lab {
 
@@ -470,8 +471,10 @@ byte **Music::newOpen(const char *name) {
 	if (_musicOn) {
 		updateMusic();
 
-		LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / (2 * SAMPLESPEED);	// Windows (16-bit)
-		//LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / SAMPLESPEED;	// DOS (8-bit) - TODO
+		if (g_lab->getPlatform() == Common::kPlatformWindows)
+			LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / (2 * SAMPLESPEED);	// Windows (16-bit)
+		else
+			LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / SAMPLESPEED;	// DOS (8-bit)
 
 		filelength = sizeOfFile(name) * 10;
 		Time = 10 +                           /* Seek time for the music and the file */
@@ -507,8 +510,10 @@ void Music::fileCheckMusic(uint32 filelength) {
 		updateMusic();
 
 		
-		LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / (2 * SAMPLESPEED);	// Windows (16-bit)
-		//LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / SAMPLESPEED;	// DOS (8-bit) - TODO
+		if (g_lab->getPlatform() == Common::kPlatformWindows)
+			LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / (2 * SAMPLESPEED);	// Windows (16-bit)
+		else
+			LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / SAMPLESPEED;	// DOS (8-bit)
 
 		filelength *= 10;
 		Time = 5 +                            /* Seek time for the music */


Commit: 6006a0083627d9b43f110fe496a96d159f50b586
    https://github.com/scummvm/scummvm/commit/6006a0083627d9b43f110fe496a96d159f50b586
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: The audio data in the DOS version is unsigned

Changed paths:
    engines/lab/audioi.cpp



diff --git a/engines/lab/audioi.cpp b/engines/lab/audioi.cpp
index 735f9b6..c841e53 100644
--- a/engines/lab/audioi.cpp
+++ b/engines/lab/audioi.cpp
@@ -202,6 +202,8 @@ void playSoundEffect(uint16 SampleSpeed, uint16 Volume, uint32 Length, bool flus
 	byte soundFlags = Audio::FLAG_LITTLE_ENDIAN;
 	if (g_lab->getPlatform() == Common::kPlatformWindows)
 		soundFlags |= Audio::FLAG_16BITS;
+	else
+		soundFlags |= Audio::FLAG_UNSIGNED;
 
 	Audio::SeekableAudioStream *audStream = Audio::makeRawStream((const byte *)Data, Length, SampleSpeed, soundFlags, DisposeAfterUse::NO);
 	g_lab->_mixer->playStream(Audio::Mixer::kSFXSoundType, &g_musicHandle, audStream);


Commit: 9264f4964ece0d01db4e1bc22b24078c977d5fce
    https://github.com/scummvm/scummvm/commit/9264f4964ece0d01db4e1bc22b24078c977d5fce
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Remove the unused setMode()/getMode() functions

Changed paths:
    engines/lab/engine.cpp
    engines/lab/vga.cpp
    engines/lab/vga.h



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index ed90443..1c89a74 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -236,8 +236,6 @@ static void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr) {
 }
 
 
-static uint16 OldMode;
-
 /******************************************************************************/
 /* Sets up the Labyrinth screens, and opens up the initial windows.           */
 /******************************************************************************/
@@ -1390,8 +1388,6 @@ void LabEngine::go() {
 	bool mem, dointro = false;
 	uint16 counter;
 
-	getMode(&OldMode);
-
 	DoMusic = true;
 	g_music->_turnMusicOn = true;
 	dointro = true;
@@ -1443,8 +1439,6 @@ void LabEngine::go() {
 	}
 
 	if (!initMouse()) {
-		setMode((char) OldMode);
-
 		return;
 	}
 
@@ -1497,8 +1491,6 @@ void LabEngine::go() {
 
 	g_music->freeMusic();
 	freeAudio();
-
-	setMode((char)OldMode);
 }
 
 /*****************************************************************************/
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 4c2584c..d9633e9 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -63,13 +63,6 @@ uint16 g_NextKeyOut = 0;
 bool g_MouseAtEdge = false;
 
 /*****************************************************************************/
-/* Sets the display mode.                                                    */
-/*****************************************************************************/
-void setMode(char mode) {
-	// There are no modes for SDL.
-}
-
-/*****************************************************************************/
 /* Sets up either a low-res or a high-res 256 color screen.                  */
 /*****************************************************************************/
 bool createScreen(bool HiRes) {
@@ -334,13 +327,6 @@ void ungetVGABaseAddr() {
 }
 
 /*****************************************************************************/
-/* Gets information about the current display.                               */
-/*****************************************************************************/
-void getMode(uint16 *Mode) {
-	// Only one mode in SDL.
-}
-
-/*****************************************************************************/
 /* Draws an image to the screen.                                             */
 /*****************************************************************************/
 void drawImage(Image *Im, uint16 x, uint16 y) {
diff --git a/engines/lab/vga.h b/engines/lab/vga.h
index 9e45b80..d911000 100644
--- a/engines/lab/vga.h
+++ b/engines/lab/vga.h
@@ -41,10 +41,6 @@ struct Image {
 	byte *ImageData;
 };
 
-void setMode(char mode);
-
-void getMode(uint16 *Mode);
-
 void setPage(uint16 PageNum);
 
 void VGAStorePage();


Commit: d949375e70a5df6a9816ee83417faa5d63664596
    https://github.com/scummvm/scummvm/commit/d949375e70a5df6a9816ee83417faa5d63664596
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Remove unused variables

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 1c89a74..5a51c63 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -376,12 +376,6 @@ bool setUpScreens() {
 
 
 
-
-
-uint16 curmousex = 0, curmousey = 0;
-
-
-
 /******************************************************************************/
 /* Permanently flips the imagry of a gadget.                                  */
 /******************************************************************************/


Commit: 465f5f0c09bbdafa98bf5e0d1743bb1944a53621
    https://github.com/scummvm/scummvm/commit/465f5f0c09bbdafa98bf5e0d1743bb1944a53621
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Simplify mouse handling code

Changed paths:
    engines/lab/mouse.cpp



diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index 6e6c97d..591014c 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -39,14 +39,11 @@ namespace Lab {
 extern bool IsHiRes;
 extern uint32 VGAScreenWidth, VGAScreenHeight;
 
-void mouseHideXY();
-
 static bool LeftClick = false;
 static bool RightClick = false;
 
-static bool MouseHidden = true, QuitMouseHandler = false;
+static bool MouseHidden = true;
 static int32 NumHidden   = 1;
-static uint16 CurMouseX, CurMouseY;
 static Gadget *LastGadgetHit = NULL;
 Gadget *ScreenGadgetList = NULL;
 static byte MouseData[] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -68,11 +65,9 @@ static byte MouseData[] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
 #define MOUSE_WIDTH 10
 #define MOUSE_HEIGHT 15
 
-static bool drawmouse = false, gadhit    = false;
+static bool gadhit    = false;
 static Gadget *hitgad = NULL;
 
-void mouseShowXY(uint16 CurMouseX, uint16 CurMouseY);
-
 /*****************************************************************************/
 /* Checks whether or not the cords fall within one of the gadgets in a list  */
 /* of gadgets.                                                               */
@@ -89,20 +84,18 @@ static Gadget *checkGadgetHit(Gadget *gadlist, uint16 x, uint16 y) {
 				gadhit = true;
 				hitgad = gadlist;
 			} else {
-				QuitMouseHandler = true;
 				VGAStorePage();
-				mouseHideXY();
+				mouseHide();
 				drawImage(gadlist->ImAlt, gadlist->x, gadlist->y);
-				mouseShowXY(x, y);
+				mouseShow();
 
 				for (counter = 0; counter < 3; counter++)
 					waitTOF();
 
-				mouseHideXY();
+				mouseHide();
 				drawImage(gadlist->Im, gadlist->x, gadlist->y);
-				mouseShowXY(x, y);
+				mouseShow();
 				VGARestorePage();
-				QuitMouseHandler = false;
 			}
 
 			return gadlist;
@@ -131,14 +124,6 @@ void mouse_handler(int32 flag, int32 mouseX, int32 mouseY) {
 		mouseX /= 2;
 
 	if (flag & 0x01) { /* mouse Move */
-		if ((CurMouseX != mouseX) || (CurMouseY != mouseY)) {
-			CurMouseX = mouseX;
-			CurMouseY = mouseY;
-
-			if (IsHiRes && !QuitMouseHandler) {
-				drawmouse = true;
-			}
-		}
 	}
 
 	if ((flag & 0x02) && (NumHidden < 2)) { /* Left mouse button click */
@@ -151,15 +136,11 @@ void mouse_handler(int32 flag, int32 mouseX, int32 mouseY) {
 			LastGadgetHit = TempGad;
 		} else {
 			LeftClick = true;
-			CurMouseX     = mouseX;
-			CurMouseY     = mouseY;
 		}
 	}
 
 	if ((flag & 0x08) && (NumHidden < 2)) { /* Right mouse button click */
 		RightClick = true;
-		CurMouseX     = mouseX;
-		CurMouseY     = mouseY;
 	}
 }
 
@@ -170,16 +151,12 @@ void updateMouse() {
 	uint16 counter;
 	bool doUpdateDisplay = false;
 
-	if (drawmouse && !MouseHidden) {
-		QuitMouseHandler = true;
-		drawmouse = false;
-		QuitMouseHandler = false;
+	if (!MouseHidden) {
 		doUpdateDisplay = true;
 	}
 
 	if (gadhit) {
 		gadhit = false;
-		QuitMouseHandler = true;
 		mouseHide();
 		drawImage(hitgad->ImAlt, hitgad->x, hitgad->y);
 		mouseShow();
@@ -191,7 +168,6 @@ void updateMouse() {
 		drawImage(hitgad->Im, hitgad->x, hitgad->y);
 		mouseShow();
 		doUpdateDisplay = true;
-		QuitMouseHandler = false;
 	}
 
 	if (doUpdateDisplay)
@@ -220,62 +196,21 @@ bool initMouse() {
 /* Shows the mouse.                                                          */
 /*****************************************************************************/
 void mouseShow() {
-	mouseShowXY(CurMouseX, CurMouseY);
-
-	g_system->showMouse(true);
-}
-
-
-
-
-
-/*****************************************************************************/
-/* Shows the mouse.                                                          */
-/*****************************************************************************/
-void mouseShowXY(uint16 MouseX, uint16 MouseY) {
-	QuitMouseHandler = true;
-
 	if (NumHidden)
 		NumHidden--;
 
 	if ((NumHidden == 0) && MouseHidden) {
-		CurMouseX = MouseX;
-		CurMouseY = MouseY;
 		WSDL_ProcessInput(0);
 		MouseHidden = false;
 	}
 
-	QuitMouseHandler = false;
+	g_system->showMouse(true);
 }
 
-
-
 /*****************************************************************************/
 /* Hides the mouse.                                                          */
 /*****************************************************************************/
 void mouseHide() {
-	QuitMouseHandler = true;
-
-	NumHidden++;
-
-	if (NumHidden && !MouseHidden) {
-		MouseHidden = true;
-
-		g_system->showMouse(false);
-	}
-
-	QuitMouseHandler = false;
-}
-
-
-
-
-/*****************************************************************************/
-/* Hides the mouse.                                                          */
-/*****************************************************************************/
-void mouseHideXY() {
-	QuitMouseHandler = true;
-
 	NumHidden++;
 
 	if (NumHidden && !MouseHidden) {
@@ -283,12 +218,9 @@ void mouseHideXY() {
 
 		g_system->showMouse(false);
 	}
-
-	QuitMouseHandler = false;
 }
 
 
-
 extern uint32 g_MouseX;
 extern uint32 g_MouseY;
 
@@ -317,10 +249,7 @@ void mouseMove(uint16 x, uint16 y) {
 	g_system->warpMouse(x, y);
 
 	if (!MouseHidden) {
-		QuitMouseHandler = true;
-		mouseXY(&CurMouseX, &CurMouseY);
 		WSDL_ProcessInput(0);
-		QuitMouseHandler = false;
 	}
 }
 
@@ -335,15 +264,15 @@ void mouseMove(uint16 x, uint16 y) {
 bool mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
 	if (leftbutton) {
 		if (LeftClick) {
-			*x = CurMouseX;
-			*y = CurMouseY;
+			*x = (!IsHiRes) ? (uint16)g_MouseX / 2 : (uint16)g_MouseX;
+			*y = (uint16)g_MouseY;
 			LeftClick = false;
 			return true;
 		}
 	} else {
 		if (RightClick) {
-			*x = CurMouseX;
-			*y = CurMouseY;
+			*x = (!IsHiRes) ? (uint16)g_MouseX / 2 : (uint16)g_MouseX;
+			*y = (uint16)g_MouseY;
 			RightClick = false;
 			return true;
 		}


Commit: a83c50cf66e72d105ef64b29a10e3f9603e0141b
    https://github.com/scummvm/scummvm/commit/a83c50cf66e72d105ef64b29a10e3f9603e0141b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Remove duplicate swap code and some unused defines

Changed paths:
    engines/lab/map.cpp
    engines/lab/readdiff.cpp
    engines/lab/stddefines.h



diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index f51bf86..b6b4415 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -291,7 +291,7 @@ static bool loadMapData() {
 
 		for (counter = 1; counter <= MaxRooms; counter++) {
 			swapUShortPtr(&Maps[counter].x, 4);
-			swapULongPtr(&Maps[counter].MapFlags, 1);
+			swapULong(&Maps[counter].MapFlags);
 		}
 	} else
 		return false;
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index 66bfa80..5eb6287 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -205,9 +205,9 @@ void diffNextFrame() {
 
 		g_music->updateMusic();
 		readBlock(&header, 4L, difffile);
-		swapULongPtr(&header, 1);
+		swapULong(&header);
 		readBlock(&size, 4L, difffile);
-		swapULongPtr(&size, 1);
+		swapULong(&size);
 
 		processed += 8L;
 
@@ -379,7 +379,7 @@ void playDiff() {
 	temp[4] = '\0';
 
 	readBlock(&header, 4L, difffile);
-	swapULongPtr(&header, 1);
+	swapULong(&header);
 
 	processed += 8L;
 
@@ -389,10 +389,10 @@ void playDiff() {
 	}
 
 	readBlock(&header, 4L, difffile);
-	swapULongPtr(&header, 1);
+	swapULong(&header);
 
 	readBlock(&size, 4L, difffile);
-	swapULongPtr(&size, 1);
+	swapULong(&size);
 
 	if (header == 0) {
 		// sizeof(headerdata) != 18, but the padding might be at the end
@@ -408,9 +408,9 @@ void playDiff() {
 		skip(difffile, size - 18);
 
 		swapUShortPtr(&headerdata.Version, 3);
-		swapULongPtr(&headerdata.BufferSize, 1);
+		swapULong(&headerdata.BufferSize);
 		swapUShortPtr(&headerdata.Machine, 1);
-		swapULongPtr(&headerdata.Flags, 1);
+		swapULong(&headerdata.Flags);
 
 		continuous = CONTINUOUS & headerdata.Flags;
 		diffwidth = headerdata.x;
@@ -517,7 +517,7 @@ void readSound() {
 	readBlock(temp_, 4L, difffile_);
 	temp_[4] = '\0';
 	readBlock(&header_, 4L, difffile_);
-	swapULongPtr(&header_, 1);
+	swapULong(&header_);
 
 	processed += 8L;
 
@@ -525,10 +525,10 @@ void readSound() {
 		return;
 
 	readBlock(&header_, 4L, difffile_);
-	swapULongPtr(&header_, 1);
+	swapULong(&header_);
 
 	readBlock(&size_, 4L, difffile_);
-	swapULongPtr(&size_, 1);
+	swapULong(&size_);
 
 	if (header_ == 0)
 		skip(difffile_, size_);
@@ -538,10 +538,10 @@ void readSound() {
 	while (header_ != 65535) {
 		g_music->updateMusic();
 		readBlock(&header_, 4L, difffile_);
-		swapULongPtr(&header_, 1);
+		swapULong(&header_);
 
 		readBlock(&size_, 4L, difffile_);
-		swapULongPtr(&size_, 1);
+		swapULong(&size_);
 
 		if ((header_ == 30) || (header_ == 31)) {
 			if (mwaiteffect) {
diff --git a/engines/lab/stddefines.h b/engines/lab/stddefines.h
index 67bd39a..8c74d10 100644
--- a/engines/lab/stddefines.h
+++ b/engines/lab/stddefines.h
@@ -37,25 +37,14 @@
 
 namespace Lab {
 
-#define IS_MACOSX 1
-
-#if defined(IS_MACOSX)
-#define getTime Lab_GetTime
-#define delay Lab_Delay
-#endif
-
 #define swapUShort(value) (value)
 #define swapUShortPtr(ptr,count) (ptr)
 #define swapShort(value) (value)
 #define swapShortPtr(ptr,count) (ptr)
 #define swapUInt(value) (value)
-#define swapUIntPtr(ptr,count) (ptr)
 #define swapInt(value) (value)
-#define swapIntPtr(ptr,count) (ptr)
 #define swapULong(value) (value)
-#define swapULongPtr(ptr,count) (ptr)
 #define swapLong(value) (value)
-#define swapLongPtr(ptr,count) (ptr)
 
 } // End of namespace Lab
 


Commit: 83e58fe452828f29d59aa1b324d2040b1d6c539b
    https://github.com/scummvm/scummvm/commit/83e58fe452828f29d59aa1b324d2040b1d6c539b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Rename waiteffect -> waitForEffect

Changed paths:
    engines/lab/engine.cpp
    engines/lab/processroom.cpp
    engines/lab/readdiff.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 5a51c63..f8391d3 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -47,7 +47,7 @@ bool LongWinInFront = false;
 
 TextFont *MsgFont;
 
-extern bool DoBlack, waiteffect, EffectPlaying, stopsound, DoNotDrawMessage, IsHiRes, nopalchange, DoMusic;
+extern bool DoBlack, waitForEffect, EffectPlaying, stopsound, DoNotDrawMessage, IsHiRes, nopalchange, DoMusic;
 
 /* Global parser data */
 
@@ -612,9 +612,9 @@ static bool doUse(uint16 CurInv) {
 		}
 
 		DoBlack = false;
-		waiteffect = true;
+		waitForEffect = true;
 		readPict("Music:Click", true);
-		waiteffect = false;
+		waitForEffect = false;
 
 		DoBlack = false;
 		Test = getInvName(CurInv);
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 70eac05..9c5055f 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -62,7 +62,7 @@ const char *ViewPath = "LAB:Rooms/";
 const char *NewFileName;
 
 extern bool DoNotDrawMessage;
-extern bool NoFlip, IsBM, noupdatediff, waiteffect, mwaiteffect, QuitLab, EffectPlaying, soundplaying, MusicOn, DoBlack, ContMusic, DoNotReset;
+extern bool NoFlip, IsBM, noupdatediff, waitForEffect, mwaitForEffect, QuitLab, EffectPlaying, soundplaying, MusicOn, DoBlack, ContMusic, DoNotReset;
 extern char diffcmap[256 * 3];
 
 extern CloseDataPtr CPtr;
@@ -406,14 +406,14 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
 
 		switch (APtr->ActionType) {
 		case PLAYSOUND:
-			mwaiteffect = true; /* Plays a sound, but waits for it to be done before continuing */
+			mwaitForEffect = true; /* Plays a sound, but waits for it to be done before continuing */
 			ContMusic = false;
 			readMusic((char *)APtr->Data);
-			mwaiteffect = false;
+			mwaitForEffect = false;
 			break;
 
 		case PLAYSOUNDB:
-			mwaiteffect = false; /* Plays a sound in the background. */
+			mwaitForEffect = false; /* Plays a sound in the background. */
 			ContMusic = false;
 			readMusic((char *)APtr->Data);
 			break;
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index 5eb6287..3f7cdc7 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -58,9 +58,9 @@ bool NoFlip         = false,  /* Don't flip the new picture to front  */
      stopsound      = false,
      soundplaying   = false,
      screenbuffer   = false,
-     waiteffect     = false, /* Wait for each sound effect to finish
+     waitForEffect     = false, /* Wait for each sound effect to finish
                                                                                                       before coninuing.                    */
-                      mwaiteffect    = false;
+                      mwaitForEffect    = false;
 
 uint16 DataBytesPerRow;
 
@@ -273,7 +273,7 @@ void diffNextFrame() {
 
 		case 30L:
 		case 31L: {
-			if (waiteffect) {
+			if (waitForEffect) {
 				while (EffectPlaying) {
 					g_music->updateMusic();
 					waitTOF();
@@ -298,7 +298,7 @@ void diffNextFrame() {
 			if ((framenumber == 1) || PlayOnce || StopPlayingEnd) {
 				int didTOF = 0;
 
-				if (waiteffect) {
+				if (waitForEffect) {
 					while (EffectPlaying) {
 						g_music->updateMusic();
 						waitTOF();
@@ -544,7 +544,7 @@ void readSound() {
 		swapULong(&size_);
 
 		if ((header_ == 30) || (header_ == 31)) {
-			if (mwaiteffect) {
+			if (mwaitForEffect) {
 				while (EffectPlaying) {
 					g_music->updateMusic();
 					waitTOF();
@@ -565,7 +565,7 @@ void readSound() {
 
 			playSoundEffect(samplespeed_, 64, musicsize, true, music);
 		} else if (header_ == 65535L) {
-			if (mwaiteffect) {
+			if (mwaitForEffect) {
 				while (EffectPlaying) {
 					g_music->updateMusic();
 					waitTOF();


Commit: 22b82d7729a2bd40b981a8faba16eff5c708df21
    https://github.com/scummvm/scummvm/commit/22b82d7729a2bd40b981a8faba16eff5c708df21
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Initial music implementation

The whole music code is greatly simplified

Changed paths:
    engines/lab/audioi.cpp
    engines/lab/labfun.h
    engines/lab/labmusic.cpp



diff --git a/engines/lab/audioi.cpp b/engines/lab/audioi.cpp
index c841e53..10b570e 100644
--- a/engines/lab/audioi.cpp
+++ b/engines/lab/audioi.cpp
@@ -50,63 +50,61 @@ bool EffectPlaying = false, ContMusic = false, DoMusic = false;
 static char *CurMusic, *startMusic;
 static uint32 StartMusicLen;
 static Audio::SoundHandle g_musicHandle;
+static Audio::SoundHandle g_sfxHandle;
+static Audio::QueuingAudioStream *queuingAudioStream = NULL;
+
+static byte *playBuffer;
 
 void freeAudio() {
 	if (!DoMusic)
 		return;
 
-	// TODO
-	//SDLWrapAudio();
+	g_lab->_mixer->stopHandle(g_musicHandle);
+	g_lab->_mixer->stopHandle(g_sfxHandle);
+
+	delete queuingAudioStream;
+	queuingAudioStream = NULL;
+	delete[] playBuffer;
 }
 
 
 
 bool initAudio() {
-	if (!DoMusic)
-		return true;
-
-// TODO
-#if 0
-	// we allocate extra mempory for 16-bit samples
-	// TODO: 8-bit mono sample for DOS
-	buf1 = malloc(PLAYBUFSIZE);
-
-	if (buf1 == NULL)
-		return false;
-
-	buf2 = malloc(PLAYBUFSIZE);
-
-	if (buf2 == NULL)
-		return false;
-
-	if (!SDLInitAudio())
-		return false;
-#endif
-
+	playBuffer = new byte[PLAYBUFSIZE];
 	return true;
 }
 
 
-bool musicBufferEmpty(uint16 i) {
-	// TODO: Multiple streams
-	return !g_lab->_mixer->isSoundHandleActive(g_musicHandle);
+bool musicBufferEmpty() {
+	return !g_lab->_mixer->isSoundHandleActive(g_sfxHandle);
 }
 
 
+uint16 getPlayingBufferCount() {
+	return (queuingAudioStream) ? queuingAudioStream->numQueuedStreams() : 0;
+}
 
 void playMusicBlock(void *Ptr, uint32 Size, uint16 BufferNum, uint16 SampleSpeed) {
-	// TODO
-#if 0
+	bool startMusic = false;
 
 	if (SampleSpeed < 4000)
 		SampleSpeed = 4000;
 
-	tempblock = firstblock;
-	tempblock.sel_data = Ptr;
-	tempblock.len      = Size;
+	if (!queuingAudioStream) {
+		queuingAudioStream = Audio::makeQueuingAudioStream(SampleSpeed, false);
+		startMusic = true;
+	}
 
-	SDLPlayBuffer(BufferNum, &tempblock);
-#endif
+	byte soundFlags = Audio::FLAG_LITTLE_ENDIAN;
+	if (g_lab->getPlatform() == Common::kPlatformWindows)
+		soundFlags |= Audio::FLAG_16BITS;
+	else
+		soundFlags |= Audio::FLAG_UNSIGNED;
+
+	queuingAudioStream->queueBuffer((byte *)Ptr, Size, DisposeAfterUse::YES, soundFlags);
+
+	if (startMusic)
+		g_lab->_mixer->playStream(Audio::Mixer::kMusicSoundType, &g_musicHandle, queuingAudioStream);
 }
 
 
@@ -119,7 +117,7 @@ void updateSoundBuffers() {
 
 	// TODO
 	// FIXME: Very crude implementation
-	if (musicBufferEmpty(0)) {
+	if (musicBufferEmpty()) {
 		flushAudio();
 		EffectPlaying = false;
 	}
@@ -170,7 +168,7 @@ void flushAudio() {
 	if (!DoMusic)
 		return;
 
-	g_lab->_mixer->stopHandle(g_musicHandle);
+	g_lab->_mixer->stopHandle(g_sfxHandle);
 	EffectPlaying = false;
 }
 
@@ -206,7 +204,7 @@ void playSoundEffect(uint16 SampleSpeed, uint16 Volume, uint32 Length, bool flus
 		soundFlags |= Audio::FLAG_UNSIGNED;
 
 	Audio::SeekableAudioStream *audStream = Audio::makeRawStream((const byte *)Data, Length, SampleSpeed, soundFlags, DisposeAfterUse::NO);
-	g_lab->_mixer->playStream(Audio::Mixer::kSFXSoundType, &g_musicHandle, audStream);
+	g_lab->_mixer->playStream(Audio::Mixer::kSFXSoundType, &g_sfxHandle, audStream);
 
 	updateSoundBuffers();
 }
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index cc77a4c..d976fee 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -62,17 +62,12 @@ struct SaveGameHeader {
 /*----------------------------*/
 
 bool initAudio();
-
 void freeAudio();
-
-bool musicBufferEmpty(uint16 i);
-
+bool musicBufferEmpty();
 void playMusicBlock(void *Ptr, uint32 Size, uint16 BufferNum, uint16 SampleSpeed);
-
+uint16 getPlayingBufferCount();
 void updateSoundBuffers();
-
 void flushAudio();
-
 void playSoundEffect(uint16 SampleSpeed, uint16 Volume, uint32 Length, bool flush, void *Data);
 
 
@@ -222,9 +217,7 @@ void decrypt(byte *text);
 /*----- From LabMusic.c -----*/
 /*---------------------------*/
 
-#define MANYBUFFERS        5L
 #define MAXBUFFERS         5L
-#define MINBUFFERS         2L
 
 class Music {
 public:
@@ -243,15 +236,13 @@ public:
 	void pauseBackMusic();
 	void changeMusic(const char *newmusic);
 	void resetMusic();
-	void fileCheckMusic(uint32 filelength);
 
 	bool _winmusic, _doNotFileFlushAudio;
 	bool _turnMusicOn;
 	bool _musicOn;
 
 private:
-	void fillbuffer(uint16 unit);
-	uint16 getManyBuffersLeft();
+	void fillbuffer(byte *musicBuffer);
 	void startMusic(bool startatbegin);
 
 	Common::File *_file;
@@ -259,15 +250,8 @@ private:
 	bool _musicPaused;
 
 	bool _tMusicOn;
-	uint32 _tFileLength;
 	uint32 _tLeftInFile;
-
-	uint16 _manyBuffers;
-
-	void *_musicBuffer[MAXBUFFERS];
-	uint16 _musicFilledTo, _musicPlaying, _musicOnBuffer;
-
-	uint32 _filelength, _leftinfile;
+	uint32 _leftinfile;
 };
 
 
diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index 4a427ed..1f5794b 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -50,16 +50,8 @@ Music::Music() {
 	_musicPaused = false;
 
 	_tMusicOn = false;
-	_tFileLength = 0;
 	_tLeftInFile = 0;
 
-	_manyBuffers = MANYBUFFERS;
-
-	_musicFilledTo = 0;
-	_musicPlaying  = 0;
-	_musicOnBuffer = 0;
-
-	_filelength = 0;
 	_leftinfile = 0;
 
 	_musicOn = false;
@@ -73,143 +65,52 @@ Music::Music() {
 /* it from the Audio device.                                                 */
 /*****************************************************************************/
 void Music::updateMusic() {
-	uint16 i;
-
 	WSDL_ProcessInput(0);
 
 	updateMouse();
 
 	if (EffectPlaying)
 		updateSoundBuffers();
-	else if (_musicOn) {
-		for (i = 0; i < 2; i++) {
-			if (musicBufferEmpty(i)) {
-				playMusicBlock(_musicBuffer[_musicPlaying], MUSICBUFSIZE, i, SAMPLESPEED);
-
-				if (_musicPlaying)
-					_musicOnBuffer = _musicPlaying - 1;
-				else
-					_musicOnBuffer = _manyBuffers - 1;
-
-				_musicPlaying++;
-
-				if (_musicPlaying >= _manyBuffers)
-					_musicPlaying = 0;
-			}
-		}
+	
+	if (_musicOn && getPlayingBufferCount() < MAXBUFFERS) {
+		// NOTE: We need to use malloc(), cause this will be freed with free()
+		// by the music code
+		byte *musicBuffer = (byte *)malloc(MUSICBUFSIZE);
+		fillbuffer(musicBuffer);
+		playMusicBlock(musicBuffer, MUSICBUFSIZE, 0, SAMPLESPEED);
 	}
 }
 
 
-void Music::fillbuffer(uint16 unit) {
-	return;
-
-	warning("STUB: Music::fillbuffer");
-	uint32 Size = MUSICBUFSIZE;
-	void *ptr  = _musicBuffer[unit];
-
-	if (Size < _leftinfile) {
-		_file->read(ptr, Size);
-		_leftinfile -= Size;
+void Music::fillbuffer(byte *musicBuffer) {
+	if (MUSICBUFSIZE < _leftinfile) {
+		_file->read(musicBuffer, MUSICBUFSIZE);
+		_leftinfile -= MUSICBUFSIZE;
 	} else {
-		_file->read(ptr, _leftinfile);
+		_file->read(musicBuffer, _leftinfile);
 
-		memset((char *)ptr + _leftinfile, 0, Size - _leftinfile);
+		memset((char *)musicBuffer + _leftinfile, 0, MUSICBUFSIZE - _leftinfile);
 
 		_file->seek(0);
-		_leftinfile = _filelength;
+		_leftinfile = _file->size();
 	}
 }
 
 
-
-/*****************************************************************************/
-/* Figures out how many *complete* buffers of music left to play.            */
-/*****************************************************************************/
-uint16 Music::getManyBuffersLeft() {
-	uint16 mp = _musicOnBuffer;
-
-	if (mp == _musicFilledTo) /* Already filled */
-		return _manyBuffers;
-	else if (mp > _musicFilledTo)
-		return _manyBuffers - (mp - _musicFilledTo);
-	else
-		return _musicFilledTo - mp;
-}
-
-
-
 /*****************************************************************************/
 /* Fills up the buffers that have already been played if necessary; if doit  */
 /* is set to TRUE then it will fill up all empty buffers.  Otherwise, it     */
 /* Check if there are MINBUFFERS or less buffers that are playing.           */
 /*****************************************************************************/
 void Music::fillUpMusic(bool doit) {
-	int16 ManyLeft, ManyFill;
-
 	updateMusic();
-
-	if (!_musicOn)
-		return;
-
-	ManyLeft = getManyBuffersLeft();
-
-	if (ManyLeft < MINBUFFERS)
-		doit = true;
-	else if (ManyLeft == _manyBuffers)  /* All the buffers are already full */
-		doit = false;
-
-	if (doit && (ManyLeft < _manyBuffers) && ManyLeft) {
-		ManyFill = _manyBuffers - ManyLeft - 1;
-
-		while (ManyFill > 0) {
-			_musicFilledTo++;
-
-			if (_musicFilledTo >= _manyBuffers)
-				_musicFilledTo = 0;
-
-			fillbuffer(_musicFilledTo);
-			updateMusic();
-
-			ManyFill--;
-		}
-
-		updateMusic();
-
-		ManyLeft = getManyBuffersLeft();
-
-		if (ManyLeft < _manyBuffers) {
-			ManyFill = _manyBuffers - ManyLeft - 1;
-
-			while (ManyFill > 0) {
-				_musicFilledTo++;
-
-				if (_musicFilledTo >= _manyBuffers)
-					_musicFilledTo = 0;
-
-				fillbuffer(_musicFilledTo);
-				updateMusic();
-
-				ManyFill--;
-			}
-		}
-	}
-
-	updateMusic();
-
-	/* NYI: A check for dirty cds; for instance, if lots of buffers already
-	   played */
 }
 
 
-
-
 /*****************************************************************************/
 /* Starts up the music initially.                                            */
 /*****************************************************************************/
 void Music::startMusic(bool startatbegin) {
-	uint16 counter;
-
 	if (!_musicOn)
 		return;
 
@@ -217,32 +118,18 @@ void Music::startMusic(bool startatbegin) {
 
 	if (startatbegin) {
 		_file->seek(0);
-		_leftinfile  = _filelength;
+		_leftinfile  = _file->size();
 	}
 
-	_musicPlaying  = 0;
-	_musicOnBuffer = 0;
-	_musicFilledTo = _manyBuffers - 1;
-
-	_musicOn = false;
-
-	for (counter = 0; counter < _manyBuffers; counter++)
-		fillbuffer(counter);
-
 	_musicOn = true;
 	updateMusic();
 }
 
 
-
-
-
-
 /*****************************************************************************/
 /* Initializes the music buffers.                                            */
 /*****************************************************************************/
 bool Music::initMusic() {
-	uint16 counter;
 
 	if (!_turnMusicOn)
 		return true;
@@ -257,12 +144,6 @@ bool Music::initMusic() {
 	else
 		filename = "Music:BackGrou";
 
-	if (_musicBuffer[0] == NULL) {
-		for (counter = 0; counter < _manyBuffers; counter++)
-			_musicBuffer[counter] = malloc(MUSICBUFSIZE);
-	}
-
-	_filelength = sizeOfFile(filename);
 	_file = openPartial(filename);
 
 	if (_file) {
@@ -298,10 +179,7 @@ void Music::pauseBackMusic() {
 		_musicOn = false;
 		flushAudio();
 
-		if (_musicPlaying)
-			_musicPlaying--;
-		else
-			_musicPlaying = _manyBuffers - 1;
+		// TODO: Pause
 
 		_musicPaused = true;
 	}
@@ -373,13 +251,12 @@ void Music::changeMusic(const char *newmusic) {
 	if (!_tFile) {
 		_tFile = _file;
 		_tMusicOn = _musicOn;
-		_tFileLength = _filelength;
 #if defined(DOSCODE)
 		_tLeftInFile = _leftinfile;
 #else
 		_tLeftInFile = _leftinfile + 65536L;
 
-		if (_tLeftInFile > _tFileLength)
+		if (_tLeftInFile > (uint32)_tFile->size())
 			_tLeftInFile = _leftinfile;
 
 #endif
@@ -390,9 +267,6 @@ void Music::changeMusic(const char *newmusic) {
 	if (_file) {
 		_musicOn = true;   /* turn it off */
 		setMusic(false);
-
-		_filelength = sizeOfFile(newmusic);
-
 		_musicOn = false;  /* turn it back on */
 		setMusic(true);
 	} else {
@@ -414,10 +288,9 @@ void Music::resetMusic() {
 		_file->close();
 
 	_file      = _tFile;
-	_filelength = _tFileLength;
 	_leftinfile = _tLeftInFile;
 
-	_file->seek(_filelength - _leftinfile);
+	_file->seek(_file->size() - _leftinfile);
 
 	_musicOn = true;
 	setMusic(false);
@@ -435,14 +308,6 @@ void Music::resetMusic() {
 }
 
 
-
-
-
-#define FUDGEFACTOR  5L
-#define READSPEED    (2 * 130000L)
-
-
-
 /*****************************************************************************/
 /* Checks whether or note enough memory in music buffer before loading any   */
 /* files.  Fills it if not.  Does not take into account the current buffer   */
@@ -452,8 +317,6 @@ void Music::resetMusic() {
 /* Here, the seconds are multipled by 10.                                    */
 /*****************************************************************************/
 byte **Music::newOpen(const char *name) {
-	uint32 filelength, LeftSecs, Time;
-
 	byte **file;
 
 	if (name == NULL) {
@@ -470,19 +333,7 @@ byte **Music::newOpen(const char *name) {
 
 	if (_musicOn) {
 		updateMusic();
-
-		if (g_lab->getPlatform() == Common::kPlatformWindows)
-			LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / (2 * SAMPLESPEED);	// Windows (16-bit)
-		else
-			LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / SAMPLESPEED;	// DOS (8-bit)
-
-		filelength = sizeOfFile(name) * 10;
-		Time = 10 +                           /* Seek time for the music and the file */
-		       (filelength / READSPEED) +     /* Read time for the file */
-		       FUDGEFACTOR;
-
-		if (Time >= LeftSecs)
-			fillUpMusic(true);
+		fillUpMusic(true);
 	}
 
 	if (!_doNotFileFlushAudio && EffectPlaying)
@@ -493,36 +344,4 @@ byte **Music::newOpen(const char *name) {
 	return file;
 }
 
-
-
-/*****************************************************************************/
-/* Checks whether or note enough memory in music buffer to continue loading  */
-/* in a file.   Fills the music buffer if not.  Does not take into account   */
-/* the current buffer playing; a built in fudge factor.  We've also got      */
-/* another FUDGEFACTOR defined above in case things go wrong.                */
-/*                                                                           */
-/* Here, the seconds are multipled by 10.                                    */
-/*****************************************************************************/
-void Music::fileCheckMusic(uint32 filelength) {
-	uint32 LeftSecs, Time;
-
-	if (_musicOn) {
-		updateMusic();
-
-		
-		if (g_lab->getPlatform() == Common::kPlatformWindows)
-			LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / (2 * SAMPLESPEED);	// Windows (16-bit)
-		else
-			LeftSecs = (getManyBuffersLeft() * MUSICBUFSIZE * 10) / SAMPLESPEED;	// DOS (8-bit)
-
-		filelength *= 10;
-		Time = 5 +                            /* Seek time for the music */
-		       (filelength / READSPEED) +     /* Read time for the file  */
-		       FUDGEFACTOR;
-
-		if (Time >= LeftSecs)
-			fillUpMusic(true);
-	}
-}
-
 } // End of namespace Lab


Commit: 6842ffbe90867deb214f4f9e7f0f75476fbefdf9
    https://github.com/scummvm/scummvm/commit/6842ffbe90867deb214f4f9e7f0f75476fbefdf9
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Further clean up of the music and sound effect code

Changed paths:
  R engines/lab/audioi.cpp
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/labfun.h
    engines/lab/labmusic.cpp
    engines/lab/module.mk
    engines/lab/processroom.cpp
    engines/lab/readdiff.cpp



diff --git a/engines/lab/audioi.cpp b/engines/lab/audioi.cpp
deleted file mode 100644
index 10b570e..0000000
--- a/engines/lab/audioi.cpp
+++ /dev/null
@@ -1,212 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "audio/mixer.h"
-#include "audio/audiostream.h"
-#include "audio/decoders/raw.h"
-
-#include "lab/lab.h"
-#include "lab/stddefines.h"
-#include "lab/labfun.h"
-
-namespace Lab {
-
-#define PLAYBUFSIZE     65536L
-
-extern bool MusicOn;
-
-//static sound_buff firstblock, tempblock;
-static int bufnum;
-
-
-bool EffectPlaying = false, ContMusic = false, DoMusic = false;
-static char *CurMusic, *startMusic;
-static uint32 StartMusicLen;
-static Audio::SoundHandle g_musicHandle;
-static Audio::SoundHandle g_sfxHandle;
-static Audio::QueuingAudioStream *queuingAudioStream = NULL;
-
-static byte *playBuffer;
-
-void freeAudio() {
-	if (!DoMusic)
-		return;
-
-	g_lab->_mixer->stopHandle(g_musicHandle);
-	g_lab->_mixer->stopHandle(g_sfxHandle);
-
-	delete queuingAudioStream;
-	queuingAudioStream = NULL;
-	delete[] playBuffer;
-}
-
-
-
-bool initAudio() {
-	playBuffer = new byte[PLAYBUFSIZE];
-	return true;
-}
-
-
-bool musicBufferEmpty() {
-	return !g_lab->_mixer->isSoundHandleActive(g_sfxHandle);
-}
-
-
-uint16 getPlayingBufferCount() {
-	return (queuingAudioStream) ? queuingAudioStream->numQueuedStreams() : 0;
-}
-
-void playMusicBlock(void *Ptr, uint32 Size, uint16 BufferNum, uint16 SampleSpeed) {
-	bool startMusic = false;
-
-	if (SampleSpeed < 4000)
-		SampleSpeed = 4000;
-
-	if (!queuingAudioStream) {
-		queuingAudioStream = Audio::makeQueuingAudioStream(SampleSpeed, false);
-		startMusic = true;
-	}
-
-	byte soundFlags = Audio::FLAG_LITTLE_ENDIAN;
-	if (g_lab->getPlatform() == Common::kPlatformWindows)
-		soundFlags |= Audio::FLAG_16BITS;
-	else
-		soundFlags |= Audio::FLAG_UNSIGNED;
-
-	queuingAudioStream->queueBuffer((byte *)Ptr, Size, DisposeAfterUse::YES, soundFlags);
-
-	if (startMusic)
-		g_lab->_mixer->playStream(Audio::Mixer::kMusicSoundType, &g_musicHandle, queuingAudioStream);
-}
-
-
-void updateSoundBuffers() {
-	if (!DoMusic)
-		return;
-
-	if (!EffectPlaying)
-		return;
-
-	// TODO
-	// FIXME: Very crude implementation
-	if (musicBufferEmpty()) {
-		flushAudio();
-		EffectPlaying = false;
-	}
-
-#if 0
-	for (int i = 0; i < 2; i++) {
-		if ((SDLSoundBufferStatus(i) == DAC_DONE) && firstblock.len) {
-			// use extra memory for 16-bit samples
-			tempblock.len = MIN(PLAYBUFSIZE, firstblock.len);
-			firstblock.len -= tempblock.len;
-
-			if (!(bufnum ^= 1)) {
-				memcpy(buf1, CurMusic, (unsigned) tempblock.len);
-				tempblock.sel_data = buf1;
-			} else {
-				memcpy(buf2, CurMusic, (unsigned) tempblock.len);
-				tempblock.sel_data = buf2;
-			}
-
-			CurMusic += tempblock.len;
-
-			SDLPlayBuffer(i, &tempblock);
-		}
-	}
-
-	//
-	// Playback ends when no bytes are left in the source data and
-	// the status of both buffers equals DAC_DONE
-	//
-
-	if (!firstblock.len) {
-		if (ContMusic) {
-			CurMusic = startMusic;
-			firstblock.len = StartMusicLen;
-		} else if ((SDLSoundBufferStatus(0) == DAC_DONE) &&
-		           (SDLSoundBufferStatus(1) == DAC_DONE)) {
-			flushAudio();
-			EffectPlaying = false;
-		}
-	}
-
-#endif
-}
-
-
-
-void flushAudio() {
-	if (!DoMusic)
-		return;
-
-	g_lab->_mixer->stopHandle(g_sfxHandle);
-	EffectPlaying = false;
-}
-
-
-
-
-void playSoundEffect(uint16 SampleSpeed, uint16 Volume, uint32 Length, bool flush, void *Data) {
-	if (!DoMusic)
-		return;
-
-	g_music->pauseBackMusic();
-
-	if (flush)
-		flushAudio();
-
-	if (SampleSpeed < 4000)
-		SampleSpeed = 4000;
-
-	// TODO: 8-bit mono sample for DOS
-	//firstblock.len = Length;
-	bufnum = 0;
-
-	//tempblock = firstblock;
-	EffectPlaying = true;
-	CurMusic = (char *)Data;
-	startMusic = CurMusic;
-	StartMusicLen = Length;
-
-	byte soundFlags = Audio::FLAG_LITTLE_ENDIAN;
-	if (g_lab->getPlatform() == Common::kPlatformWindows)
-		soundFlags |= Audio::FLAG_16BITS;
-	else
-		soundFlags |= Audio::FLAG_UNSIGNED;
-
-	Audio::SeekableAudioStream *audStream = Audio::makeRawStream((const byte *)Data, Length, SampleSpeed, soundFlags, DisposeAfterUse::NO);
-	g_lab->_mixer->playStream(Audio::Mixer::kSFXSoundType, &g_sfxHandle, audStream);
-
-	updateSoundBuffers();
-}
-
-} // End of namespace Lab
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index f8391d3..b4b6409 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -47,7 +47,7 @@ bool LongWinInFront = false;
 
 TextFont *MsgFont;
 
-extern bool DoBlack, waitForEffect, EffectPlaying, stopsound, DoNotDrawMessage, IsHiRes, nopalchange, DoMusic;
+extern bool DoBlack, waitForEffect, stopsound, DoNotDrawMessage, IsHiRes, nopalchange;
 
 /* Global parser data */
 
@@ -698,7 +698,6 @@ static void decIncInv(uint16 *CurInv, bool dec) {
 
 static bool nosvgamem = false;
 static bool didintro = false;
-static bool novesa = false, noaudio = false;
 
 /******************************************************************************/
 /* Processes user input events.                                               */
@@ -750,7 +749,7 @@ static void process() {
 				break;
 			}
 
-			g_music->restartBackMusic();
+			g_music->resumeBackMusic();
 
 			/* Sees what kind of close up we're in and does the appropriate stuff, if any. */
 			if (doCloseUp(CPtr)) {
@@ -1382,8 +1381,6 @@ void LabEngine::go() {
 	bool mem, dointro = false;
 	uint16 counter;
 
-	DoMusic = true;
-	g_music->_turnMusicOn = true;
 	dointro = true;
 
 	IsHiRes = ((getFeatures() & GF_LOWRES) == 0);
@@ -1394,23 +1391,6 @@ void LabEngine::go() {
 	else
 		warning("Running in LowRes mode");
 #endif
-
-#if 0
-	for (counter = 1; counter < argc; counter++) {
-			if (((argv[counter])[0] == 'q') || ((argv[counter])[0] == 'Q')) {
-				DoMusic = false;
-				g_music->_turnMusicOn = false;
-			}
-
-			else if (((argv[counter])[0] == '/') && ((argv[counter])[1] == '?')) {
-				debug("\n\nPlayer Version 1.0.  Copyright (c) 1993 Terra Nova Development\n");
-				debug("Player v q\n");
-				debug("    q : Start in quiet mode; no sound output.\n\n");
-				return;
-			}
-	}
-#endif
-
 	if (initBuffer(BUFFERSIZE, true)) {
 		mem = true;
 	} else {
@@ -1418,17 +1398,8 @@ void LabEngine::go() {
 		return;
 	}
 
-	if (!initAudio()) {
-		noaudio = true;
-		DoMusic = false;
-		g_music->_turnMusicOn = false;
-		debug("Could not open Audio.");
-		g_system->delayMillis(500);
-	}
-
 	if (!setUpScreens()) {
 		IsHiRes = false;
-		novesa = true;
 		mem = mem && setUpScreens();
 	}
 
@@ -1484,7 +1455,6 @@ void LabEngine::go() {
 	freeBuffer();
 
 	g_music->freeMusic();
-	freeAudio();
 }
 
 /*****************************************************************************/
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 4ef132a..5fb1237 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -45,11 +45,11 @@ BitMap bit1, bit2, *DispBitMap = &bit1, *DrawBitMap = &bit1;
 
 extern BitMap RawDiffBM;
 extern char diffcmap[256 * 3], lastcmap[256 * 3];
-extern bool IsBM, NoFlip, nopalchange, ContMusic;
+extern bool IsBM, NoFlip, nopalchange;
 
 extern int32 ReadSoFar;
 extern bool ReadIsDone, ReadIsError;
-extern bool DoBlack, EffectPlaying, stopsound;
+extern bool DoBlack, stopsound;
 extern bool IsHiRes;
 extern TextFont *MsgFont;
 extern const char *CurFileName;
@@ -622,7 +622,7 @@ static void doScrollWipe(char *filename) {
 	width = VGAScaleX(320);
 	height = VGAScaleY(149) + SVGACord(2);
 
-	while (EffectPlaying) {
+	while (g_music->isSoundEffectActive()) {
 		g_music->newCheckMusic();
 		waitTOF();
 	}
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index d976fee..60b313e 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -33,6 +33,12 @@
 
 #include "lab/stddefines.h"
 #include "lab/parsetypes.h"
+
+// For the Music class - TODO: Move to another header file
+#include "audio/mixer.h"
+#include "audio/audiostream.h"
+#include "audio/decoders/raw.h"
+
 #include "common/file.h"
 #include "common/savefile.h"
 
@@ -58,22 +64,6 @@ struct SaveGameHeader {
 };
 
 /*----------------------------*/
-/*------ From Audioi.c -------*/
-/*----------------------------*/
-
-bool initAudio();
-void freeAudio();
-bool musicBufferEmpty();
-void playMusicBlock(void *Ptr, uint32 Size, uint16 BufferNum, uint16 SampleSpeed);
-uint16 getPlayingBufferCount();
-void updateSoundBuffers();
-void flushAudio();
-void playSoundEffect(uint16 SampleSpeed, uint16 Volume, uint32 Length, bool flush, void *Data);
-
-
-
-
-/*----------------------------*/
 /*----- From graphics.c ------*/
 /*----------------------------*/
 
@@ -228,18 +218,23 @@ public:
 	void freeMusic();
 	void fillUpMusic(bool doit);
 	void updateMusic();
+	uint16 getPlayingBufferCount();
 	void checkMusic();
 	void newCheckMusic();
 	void closeMusic();
 	void setMusic(bool on);
-	void restartBackMusic();
+	void resumeBackMusic();
 	void pauseBackMusic();
 	void changeMusic(const char *newmusic);
 	void resetMusic();
+	
+	void playSoundEffect(uint16 SampleSpeed, uint32 Length, void *Data);
+	void stopSoundEffect();
+	bool isSoundEffectActive() const;
 
-	bool _winmusic, _doNotFileFlushAudio;
-	bool _turnMusicOn;
+	bool _winmusic, _doNotFilestopSoundEffect;
 	bool _musicOn;
+	bool _loopSoundEffect;
 
 private:
 	void fillbuffer(byte *musicBuffer);
@@ -252,6 +247,11 @@ private:
 	bool _tMusicOn;
 	uint32 _tLeftInFile;
 	uint32 _leftinfile;
+
+	Audio::SoundHandle _musicHandle;
+	Audio::SoundHandle _sfxHandle;
+
+	Audio::QueuingAudioStream *_queuingAudioStream;
 };
 
 
diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index 1f5794b..9bc0ee0 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -28,6 +28,8 @@
  *
  */
 
+#include "audio/mixer.h"
+
 #include "lab/stddefines.h"
 #include "lab/labfun.h"
 #include "lab/timing.h"
@@ -41,7 +43,6 @@ namespace Lab {
 
 #define SAMPLESPEED    15000L
 
-extern bool EffectPlaying;
 Music *g_music;
 
 Music::Music() {
@@ -55,9 +56,10 @@ Music::Music() {
 	_leftinfile = 0;
 
 	_musicOn = false;
-	_turnMusicOn = false;
 	_winmusic = false;
-	_doNotFileFlushAudio = false;
+	_loopSoundEffect = false;
+	_queuingAudioStream = NULL;
+	_doNotFilestopSoundEffect = false;
 }
 
 /*****************************************************************************/
@@ -69,18 +71,63 @@ void Music::updateMusic() {
 
 	updateMouse();
 
-	if (EffectPlaying)
-		updateSoundBuffers();
-	
 	if (_musicOn && getPlayingBufferCount() < MAXBUFFERS) {
 		// NOTE: We need to use malloc(), cause this will be freed with free()
 		// by the music code
 		byte *musicBuffer = (byte *)malloc(MUSICBUFSIZE);
 		fillbuffer(musicBuffer);
-		playMusicBlock(musicBuffer, MUSICBUFSIZE, 0, SAMPLESPEED);
+
+		// Queue a music block, and start the music, if needed
+		bool startMusic = false;
+
+		if (!_queuingAudioStream) {
+			_queuingAudioStream = Audio::makeQueuingAudioStream(SAMPLESPEED, false);
+			startMusic = true;
+		}
+
+		byte soundFlags = Audio::FLAG_LITTLE_ENDIAN;
+		if (g_lab->getPlatform() == Common::kPlatformWindows)
+			soundFlags |= Audio::FLAG_16BITS;
+		else
+			soundFlags |= Audio::FLAG_UNSIGNED;
+
+		_queuingAudioStream->queueBuffer(musicBuffer, MUSICBUFSIZE, DisposeAfterUse::YES, soundFlags);
+
+		if (startMusic)
+			g_lab->_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _queuingAudioStream);
 	}
 }
 
+uint16 Music::getPlayingBufferCount() {
+	return (_queuingAudioStream) ? _queuingAudioStream->numQueuedStreams() : 0;
+}
+
+void Music::playSoundEffect(uint16 SampleSpeed, uint32 Length, void *Data) {
+	pauseBackMusic();
+	stopSoundEffect();
+
+	if (SampleSpeed < 4000)
+		SampleSpeed = 4000;
+
+	byte soundFlags = Audio::FLAG_LITTLE_ENDIAN;
+	if (g_lab->getPlatform() == Common::kPlatformWindows)
+		soundFlags |= Audio::FLAG_16BITS;
+	else
+		soundFlags |= Audio::FLAG_UNSIGNED;
+
+	Audio::SeekableAudioStream *audioStream = Audio::makeRawStream((const byte *)Data, Length, SampleSpeed, soundFlags, DisposeAfterUse::NO);
+	uint loops = (_loopSoundEffect) ? 0 : 1;
+	Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, loops, DisposeAfterUse::YES);
+	g_lab->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, loopingAudioStream);
+}
+
+void Music::stopSoundEffect() {
+	g_lab->_mixer->stopHandle(_sfxHandle);
+}
+
+bool Music::isSoundEffectActive() const {
+	return g_lab->_mixer->isSoundHandleActive(_sfxHandle);
+}
 
 void Music::fillbuffer(byte *musicBuffer) {
 	if (MUSICBUFSIZE < _leftinfile) {
@@ -114,7 +161,7 @@ void Music::startMusic(bool startatbegin) {
 	if (!_musicOn)
 		return;
 
-	flushAudio();
+	stopSoundEffect();
 
 	if (startatbegin) {
 		_file->seek(0);
@@ -130,10 +177,6 @@ void Music::startMusic(bool startatbegin) {
 /* Initializes the music buffers.                                            */
 /*****************************************************************************/
 bool Music::initMusic() {
-
-	if (!_turnMusicOn)
-		return true;
-
 	_musicOn = true;
 	_musicPaused = false;
 
@@ -167,6 +210,12 @@ void Music::freeMusic() {
 		_file->close();
 
 	_file = 0;
+
+	g_lab->_mixer->stopHandle(_musicHandle);
+	g_lab->_mixer->stopHandle(_sfxHandle);
+
+	delete _queuingAudioStream;
+	_queuingAudioStream = NULL;
 }
 
 
@@ -177,9 +226,9 @@ void Music::pauseBackMusic() {
 	if (!_musicPaused && _musicOn) {
 		updateMusic();
 		_musicOn = false;
-		flushAudio();
+		stopSoundEffect();
 
-		// TODO: Pause
+		g_lab->_mixer->pauseHandle(_musicHandle, true);
 
 		_musicPaused = true;
 	}
@@ -188,21 +237,21 @@ void Music::pauseBackMusic() {
 
 
 /*****************************************************************************/
-/* Restarts the paused background music.                                     */
+/* Resumes the paused background music.                                      */
 /*****************************************************************************/
-void Music::restartBackMusic() {
+void Music::resumeBackMusic() {
 	if (_musicPaused) {
-		flushAudio();
+		stopSoundEffect();
 		_musicOn = true;
+
+		g_lab->_mixer->pauseHandle(_musicHandle, false);
+
 		updateMusic();
 		_musicPaused = false;
 	}
 }
 
 
-
-
-
 /*****************************************************************************/
 /* Checks to see if need to fill buffers fill of music.                      */
 /*****************************************************************************/
@@ -232,7 +281,7 @@ void Music::newCheckMusic() {
 /* Turns the music on and off.                                               */
 /*****************************************************************************/
 void Music::setMusic(bool on) {
-	flushAudio();
+	stopSoundEffect();
 
 	if (on && !_musicOn) {
 		_musicOn = true;
@@ -251,15 +300,10 @@ void Music::changeMusic(const char *newmusic) {
 	if (!_tFile) {
 		_tFile = _file;
 		_tMusicOn = _musicOn;
-#if defined(DOSCODE)
-		_tLeftInFile = _leftinfile;
-#else
 		_tLeftInFile = _leftinfile + 65536L;
 
 		if (_tLeftInFile > (uint32)_tFile->size())
 			_tLeftInFile = _leftinfile;
-
-#endif
 	}
 
 	_file = openPartial(newmusic);
@@ -336,8 +380,8 @@ byte **Music::newOpen(const char *name) {
 		fillUpMusic(true);
 	}
 
-	if (!_doNotFileFlushAudio && EffectPlaying)
-		flushAudio();
+	if (!_doNotFilestopSoundEffect && isSoundEffectActive())
+		stopSoundEffect();
 
 	file = openFile(name);
 	checkMusic();
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index 8057fad..7389c18 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -2,7 +2,6 @@ MODULE := engines/lab
 
 MODULE_OBJS := \
 	allocroom.o \
-	audioi.o \
 	detection.o \
 	engine.o \
 	graphics.o \
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 9c5055f..54d7605 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -62,7 +62,7 @@ const char *ViewPath = "LAB:Rooms/";
 const char *NewFileName;
 
 extern bool DoNotDrawMessage;
-extern bool NoFlip, IsBM, noupdatediff, waitForEffect, mwaitForEffect, QuitLab, EffectPlaying, soundplaying, MusicOn, DoBlack, ContMusic, DoNotReset;
+extern bool NoFlip, IsBM, noupdatediff, waitForEffect, mwaitForEffect, QuitLab, soundplaying, MusicOn, DoBlack, DoNotReset;
 extern char diffcmap[256 * 3];
 
 extern CloseDataPtr CPtr;
@@ -407,20 +407,20 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
 		switch (APtr->ActionType) {
 		case PLAYSOUND:
 			mwaitForEffect = true; /* Plays a sound, but waits for it to be done before continuing */
-			ContMusic = false;
+			g_music->_loopSoundEffect = false;
 			readMusic((char *)APtr->Data);
 			mwaitForEffect = false;
 			break;
 
 		case PLAYSOUNDB:
 			mwaitForEffect = false; /* Plays a sound in the background. */
-			ContMusic = false;
+			g_music->_loopSoundEffect = false;
 			readMusic((char *)APtr->Data);
 			break;
 
 		case PLAYSOUNDCONT:
-			g_music->_doNotFileFlushAudio = true;
-			ContMusic = true;
+			g_music->_doNotFilestopSoundEffect = true;
+			g_music->_loopSoundEffect = true;
 			readMusic((char *)APtr->Data);
 			break;
 
@@ -605,19 +605,13 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
 			break;
 
 		case CHANGEMUSIC:
-			if (g_music->_turnMusicOn) {
-				g_music->changeMusic((const char *)APtr->Data);
-				DoNotReset = true;
-			}
-
+			g_music->changeMusic((const char *)APtr->Data);
+			DoNotReset = true;
 			break;
 
 		case RESETMUSIC:
-			if (g_music->_turnMusicOn) {
-				g_music->resetMusic();
-				DoNotReset = false;
-			}
-
+			g_music->resetMusic();
+			DoNotReset = false;
 			break;
 
 		case FILLMUSIC:
@@ -625,7 +619,7 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
 			break;
 
 		case WAITSOUND:
-			while (EffectPlaying) {
+			while (g_music->isSoundEffectActive()) {
 				g_music->updateMusic();
 				diffNextFrame();
 				waitTOF();
@@ -634,21 +628,18 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
 			break;
 
 		case CLEARSOUND:
-			if (ContMusic) {
-				ContMusic = false;
-				flushAudio();
-			} else if (EffectPlaying)
-				flushAudio();
+			if (g_music->_loopSoundEffect) {
+				g_music->_loopSoundEffect = false;
+				g_music->stopSoundEffect();
+			} else if (g_music->isSoundEffectActive())
+				g_music->stopSoundEffect();
 
 			break;
 
 		case WINMUSIC:
-			if (g_music->_turnMusicOn) {
-				g_music->_winmusic = true;
-				g_music->freeMusic();
-				g_music->initMusic();
-			}
-
+			g_music->_winmusic = true;
+			g_music->freeMusic();
+			g_music->initMusic();
 			break;
 
 		case WINGAME:
@@ -699,18 +690,18 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
 		APtr = APtr->NextAction;
 	}
 
-	if (ContMusic) {
-		ContMusic = false;
-		flushAudio();
+	if (g_music->_loopSoundEffect) {
+		g_music->_loopSoundEffect = false;
+		g_music->stopSoundEffect();
 	} else {
-		while (EffectPlaying) {
+		while (g_music->isSoundEffectActive()) {
 			g_music->updateMusic();
 			diffNextFrame();
 			waitTOF();
 		}
 	}
 
-	g_music->_doNotFileFlushAudio = false;
+	g_music->_doNotFilestopSoundEffect = false;
 }
 
 /*****************************************************************************/
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index 3f7cdc7..d5e29fa 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -64,9 +64,6 @@ bool NoFlip         = false,  /* Don't flip the new picture to front  */
 
 uint16 DataBytesPerRow;
 
-extern bool EffectPlaying;
-
-
 #define CONTINUOUS      0xFFFF
 
 DIFFHeader headerdata;
@@ -274,7 +271,7 @@ void diffNextFrame() {
 		case 30L:
 		case 31L: {
 			if (waitForEffect) {
-				while (EffectPlaying) {
+				while (g_music->isSoundEffectActive()) {
 					g_music->updateMusic();
 					waitTOF();
 				}
@@ -291,7 +288,7 @@ void diffNextFrame() {
 			uint32 musicsize = size;
 			skip(difffile, size);
 
-			playSoundEffect(samplespeed, 64, musicsize, true, music);
+			g_music->playSoundEffect(samplespeed, musicsize, music);
 			break;
 		}
 		case 65535L:
@@ -299,7 +296,7 @@ void diffNextFrame() {
 				int didTOF = 0;
 
 				if (waitForEffect) {
-					while (EffectPlaying) {
+					while (g_music->isSoundEffectActive()) {
 						g_music->updateMusic();
 						waitTOF();
 
@@ -545,7 +542,7 @@ void readSound() {
 
 		if ((header_ == 30) || (header_ == 31)) {
 			if (mwaitForEffect) {
-				while (EffectPlaying) {
+				while (g_music->isSoundEffectActive()) {
 					g_music->updateMusic();
 					waitTOF();
 				}
@@ -563,10 +560,10 @@ void readSound() {
 			uint32 musicsize = size_;
 			skip(difffile_, size_);
 
-			playSoundEffect(samplespeed_, 64, musicsize, true, music);
+			g_music->playSoundEffect(samplespeed_, musicsize, music);
 		} else if (header_ == 65535L) {
 			if (mwaitForEffect) {
-				while (EffectPlaying) {
+				while (g_music->isSoundEffectActive()) {
 					g_music->updateMusic();
 					waitTOF();
 				}


Commit: 16df4305f4334845b52b0bbc999e4d6d04cdbbbb
    https://github.com/scummvm/scummvm/commit/16df4305f4334845b52b0bbc999e4d6d04cdbbbb
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Allow skipping the credits in the intro sequence

Also, remove some unused variables and perform some minor renaming

Changed paths:
    engines/lab/engine.cpp
    engines/lab/intro.cpp
    engines/lab/readdiff.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index b4b6409..2916186 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -696,13 +696,10 @@ static void decIncInv(uint16 *CurInv, bool dec) {
 }
 
 
-static bool nosvgamem = false;
-static bool didintro = false;
-
 /******************************************************************************/
-/* Processes user input events.                                               */
+/* The main game loop                                                         */
 /******************************************************************************/
-static void process() {
+static void mainGameLoop() {
 	IntuiMessage *Msg;
 	uint32 Class;
 
@@ -1415,16 +1412,16 @@ void LabEngine::go() {
 
 	openFont("P:AvanteG.12", &MsgFont);
 
+	mouseHide();
+
 	if (dointro && mem) {
-		didintro = true;
 		introSequence();
-		didintro = true;
 	} else
 		DoBlack = true;
 
 	if (mem) {
 		mouseShow();
-		process();
+		mainGameLoop();
 	} else
 		debug("\n\nNot enough memory to start game.\n\n");
 
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 8d508ae..e37b347 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -40,7 +40,7 @@ namespace Lab {
 
 static TextFont filler, *msgfont = &filler;
 
-extern bool nopalchange, noscreenchange, hidemouse, DoBlack, NoFlip, IsHiRes;
+extern bool nopalchange, hidemouse, DoBlack, NoFlip, IsHiRes;
 
 extern char diffcmap[256 * 3];
 
@@ -248,18 +248,19 @@ void musicDelay() {
 
 
 static void NReadPict(const char *Filename, bool PlayOnce) {
-	char filename[20] = "P:Intro/";
+	Common::String finalFileName = "P:Intro/";
 
 	g_music->newCheckMusic();
+	introEatMessages();
 
 	if (QuitIntro)
 		return;
 
-	strcat(filename, Filename);
+	finalFileName += Filename;
 
 	DoBlack = IntroDoBlack;
 	stopDiffEnd();
-	readPict(filename, PlayOnce);
+	readPict(finalFileName.c_str(), PlayOnce);
 }
 
 
@@ -274,13 +275,17 @@ void introSequence() {
 	DoBlack = true;
 
 	if (g_lab->getPlatform() != Common::kPlatformWindows) {
-		readPict("p:Intro/EA0", true);
-		readPict("p:Intro/EA1", true);
-		readPict("p:Intro/EA2", true);
-		readPict("p:Intro/EA3", true);
+		NReadPict("EA0", true);
+		NReadPict("EA1", true);
+		NReadPict("EA2", true);
+		NReadPict("EA3", true);
 	} else {
-		readPict("p:Intro/WYRMKEEP", true);
-		microDelay(4, 0);
+		NReadPict("WYRMKEEP", true);
+		for (counter = 0; counter < 4; counter++) {
+			if (QuitIntro)
+				break;
+			microDelay(1, 0);
+		}
 	}
 
 	blackAllScreen();
@@ -288,14 +293,15 @@ void introSequence() {
 	g_music->initMusic();
 
 	nopalchange = true;
-	noscreenchange = true;
-	readPict("p:Intro/TNDcycle2.pic", true);
+	NReadPict("TNDcycle2.pic", true);
 	nopalchange = false;
-	noscreenchange = false;
 
 	FadePalette = Palette;
 
 	for (counter = 0; counter < 16; counter++) {
+		if (QuitIntro)
+			break;
+
 		Palette[counter] = ((diffcmap[counter * 3] >> 2) << 8) +
 		                   ((diffcmap[counter * 3 + 1] >> 2) << 4) +
 		                   (diffcmap[counter * 3 + 2] >> 2);
@@ -305,6 +311,9 @@ void introSequence() {
 	fade(true, 0);
 
 	for (int times = 0; times < 150; times++) {
+		if (QuitIntro)
+			break;
+
 		g_music->newCheckMusic();
 		uint16 temp = Palette[2];
 
@@ -322,24 +331,24 @@ void introSequence() {
 
 	g_music->newCheckMusic();
 
-	readPict("p:Intro/Title.A", true);
-	readPict("p:Intro/AB", true);
+	NReadPict("Title.A", true);
+	NReadPict("AB", true);
 	musicDelay();
-	readPict("p:Intro/BA", true);
-	readPict("p:Intro/AC", true);
+	NReadPict("BA", true);
+	NReadPict("AC", true);
 	musicDelay();
 
 	if (g_lab->getPlatform() == Common::kPlatformWindows)
 		musicDelay(); // more credits on this page now
 
-	readPict("p:Intro/CA", true);
-	readPict("p:Intro/AD", true);
+	NReadPict("CA", true);
+	NReadPict("AD", true);
 	musicDelay();
 
 	if (g_lab->getPlatform() == Common::kPlatformWindows)
 		musicDelay(); // more credits on this page now
 
-	readPict("p:Intro/DA", true);
+	NReadPict("DA", true);
 	musicDelay();
 
 	g_music->newOpen("p:Intro/Intro.1");  /* load the picture into the buffer */
@@ -351,9 +360,7 @@ void introSequence() {
 	getFont("P:Map.font", msgfont);
 
 	nopalchange = true;
-	noscreenchange = true;
-	readPict("p:Intro/Intro.1", true);
-	noscreenchange = false;
+	NReadPict("Intro.1", true);
 	nopalchange = false;
 
 	for (counter = 0; counter < 16; counter++) {
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index d5e29fa..fa1a009 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -52,7 +52,6 @@ static bool PlayOnce = false, changedscreen;
 bool NoFlip         = false,  /* Don't flip the new picture to front  */
      DoBlack        = false,     /* Black the screen before new picture  */
      nopalchange    = false,     /* Don't change the palette.            */
-     noscreenchange = false,     /* Don't change the screen type.        */
      IsBM           = false,     /* Just fill in the RawDIFFBM structure */
      hidemouse      = false,     /* Don't set the mouse colors           */
      stopsound      = false,


Commit: 219811feaa9fcf23266d97423d013244280cf9f3
    https://github.com/scummvm/scummvm/commit/219811feaa9fcf23266d97423d013244280cf9f3
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Add support for the Wyrmkeep Windows trial version

Only the trial part of this version can be played in ScummVM, since we
can't check for game payment status

Changed paths:
    engines/lab/detection.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/processroom.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/detection.cpp b/engines/lab/detection.cpp
index 2b1bb21..1da269e 100644
--- a/engines/lab/detection.cpp
+++ b/engines/lab/detection.cpp
@@ -120,7 +120,7 @@ Common::Platform LabEngine::getPlatform() const {
 }
 
 uint32 LabEngine::getFeatures() const {
-	return _gameDescription->flags;
+	return _gameDescription->flags | _extraGameFeatures;
 }
 
 } // End of namespace Lab
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 563ccef..f1d0fe9 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -36,6 +36,8 @@
 
 #include "engines/util.h"
 
+#include "gui/message.h"
+
 #include "lab/lab.h"
 #include "lab/labfun.h"
 
@@ -46,7 +48,7 @@ namespace Lab {
 LabEngine *g_lab;
 
 LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
- : Engine(syst), _gameDescription(gameDesc) {
+ : Engine(syst), _gameDescription(gameDesc), _extraGameFeatures(0) {
 	g_lab = this;
 }
 
@@ -63,6 +65,40 @@ Common::Error LabEngine::run() {
 
 	g_music = new Music();
 
+	if (getPlatform() == Common::kPlatformWindows) {
+		// Check if this is the Wyrmkeep trial
+		Common::File roomFile;
+		bool knownVersion = true;
+		bool roomFileOpened = roomFile.open("game/rooms/48");
+
+		if (!roomFileOpened)
+			knownVersion = false;
+		else if (roomFile.size() != 892)
+			knownVersion = false;
+		else {
+			roomFile.seek(352);
+			byte checkByte = roomFile.readByte();
+			if (checkByte == 0x00) {
+				// Full Windows version
+			} else if (checkByte == 0x80) {
+				// Wyrmkeep trial version
+				_extraGameFeatures = GF_WINDOWS_TRIAL;
+
+				GUI::MessageDialog trialMessage("This is a trial Windows version of the game. To play the full version, you will need to use the original interpreter and purchase a key from Wyrmkeep");
+				trialMessage.runModal();
+			} else {
+				knownVersion = false;
+			}
+			
+			roomFile.close();
+
+			if (!knownVersion) {
+				warning("Unknown Windows version found, please report this version to the ScummVM team");
+				return Common::kNoGameDataFoundError;
+			}
+		}
+	}
+
 	go();
 
 	return Common::kNoError;
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index fa5edd6..b16b598 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -41,7 +41,8 @@ struct ADGameDescription;
 namespace Lab {
 
 enum GameFeatures {
-        GF_LOWRES = 1 << 0
+	GF_LOWRES = 1 << 0,
+	GF_WINDOWS_TRIAL = 1 << 1
 };
 
 class LabEngine : public Engine {
@@ -60,6 +61,9 @@ public:
 	Common::String generateSaveFileName(uint slot);
 
 	LargeSet *_conditions, *_roomsFound;
+
+private:
+	uint32 _extraGameFeatures;
 };
 
 extern LabEngine *g_lab;
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 54d7605..27d480b 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -28,6 +28,8 @@
  *
  */
 
+#include "gui/message.h"
+
 #include "lab/lab.h"
 #include "lab/stddefines.h"
 #include "lab/labfun.h"
@@ -40,10 +42,6 @@
 
 namespace Lab {
 
-#ifdef GAME_TRIAL
-extern int g_IsRegistered;
-#endif
-
 /* Global parser data */
 
 RoomData *Rooms;
@@ -519,30 +517,16 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
 			}
 
 #endif
-#if defined(GAME_TRIAL)
-
-			if (APtr->Param1 & 0x8000) { // check registration if high-bit set
-				if (!g_IsRegistered) {
-					extern int trialCheckInGame();
-					int result;
-
-					// Time to pay up!
-					result = trialCheckInGame();
-
-					CurFileName = getPictName(LCPtr);
-					readPict(CurFileName, true);
-
-					if (!g_IsRegistered) {
-						APtr = NULL;
-						continue;
-					}
-				}
-
-				// fix-up data
-				APtr->Param1 &= 0x7fff; // clear high-bit
+			if (APtr->Param1 & 0x8000) {
+				// This is a Wyrmkeep Windows trial version, thus stop at this
+				// point, since we can't check for game payment status
+				readPict(getPictName(LCPtr), true);
+				APtr = NULL;
+				GUI::MessageDialog trialMessage("This is the end of the trial version. You can play the full game using the original interpreter from Wyrmkeep");
+				trialMessage.runModal();
+				continue;
 			}
 
-#endif
 			RoomNum   = APtr->Param1;
 			Direction = APtr->Param2 - 1;
 			*LCPtr      = NULL;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 7d22121..74625a6 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -47,10 +47,6 @@
 
 namespace Lab {
 
-#ifdef GAME_TRIAL
-int g_IsRegistered;
-#endif
-
 extern bool nopalchange, DoBlack, IsHiRes;
 
 extern BitMap *DispBitMap, *DrawBitMap;
@@ -450,12 +446,11 @@ static void changeTile(uint16 col, uint16 row) {
 		return;
 #endif
 
-#if defined(GAME_TRIAL)
-
-		if (!g_IsRegistered)
+		if (g_lab->getFeatures() & GF_WINDOWS_TRIAL) {
+			GUI::MessageDialog trialMessage("This puzzle is not available in the trial version of the game");
+			trialMessage.runModal();
 			return;
-
-#endif
+		}
 
 		check = true;
 		row   = 0;


Commit: 4cf271054ab215d78f746c0596f86ef7c72f81c0
    https://github.com/scummvm/scummvm/commit/4cf271054ab215d78f746c0596f86ef7c72f81c0
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Bugfix for freeMusic()

Changed paths:
    engines/lab/labmusic.cpp



diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index 9bc0ee0..5222cd9 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -117,7 +117,7 @@ void Music::playSoundEffect(uint16 SampleSpeed, uint32 Length, void *Data) {
 
 	Audio::SeekableAudioStream *audioStream = Audio::makeRawStream((const byte *)Data, Length, SampleSpeed, soundFlags, DisposeAfterUse::NO);
 	uint loops = (_loopSoundEffect) ? 0 : 1;
-	Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, loops, DisposeAfterUse::YES);
+	Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, loops);
 	g_lab->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, loopingAudioStream);
 }
 
@@ -143,7 +143,6 @@ void Music::fillbuffer(byte *musicBuffer) {
 	}
 }
 
-
 /*****************************************************************************/
 /* Fills up the buffers that have already been played if necessary; if doit  */
 /* is set to TRUE then it will fill up all empty buffers.  Otherwise, it     */
@@ -153,7 +152,6 @@ void Music::fillUpMusic(bool doit) {
 	updateMusic();
 }
 
-
 /*****************************************************************************/
 /* Starts up the music initially.                                            */
 /*****************************************************************************/
@@ -172,7 +170,6 @@ void Music::startMusic(bool startatbegin) {
 	updateMusic();
 }
 
-
 /*****************************************************************************/
 /* Initializes the music buffers.                                            */
 /*****************************************************************************/
@@ -198,27 +195,21 @@ bool Music::initMusic() {
 	return false;
 }
 
-
-
 /*****************************************************************************/
 /* Frees up the music buffers and closes the file.                           */
 /*****************************************************************************/
 void Music::freeMusic() {
 	_musicOn = false;
 
-	if (_file->isOpen())
-		_file->close();
-
-	_file = 0;
-
 	g_lab->_mixer->stopHandle(_musicHandle);
+	_queuingAudioStream = NULL;
+
 	g_lab->_mixer->stopHandle(_sfxHandle);
 
-	delete _queuingAudioStream;
-	_queuingAudioStream = NULL;
+	delete _file;
+	_file = NULL;
 }
 
-
 /*****************************************************************************/
 /* Pauses the background music.                                              */
 /*****************************************************************************/
@@ -234,8 +225,6 @@ void Music::pauseBackMusic() {
 	}
 }
 
-
-
 /*****************************************************************************/
 /* Resumes the paused background music.                                      */
 /*****************************************************************************/
@@ -251,7 +240,6 @@ void Music::resumeBackMusic() {
 	}
 }
 
-
 /*****************************************************************************/
 /* Checks to see if need to fill buffers fill of music.                      */
 /*****************************************************************************/
@@ -264,8 +252,6 @@ void Music::checkMusic() {
 	fillUpMusic(false);
 }
 
-
-
 /*****************************************************************************/
 /* Checks to see if need to fill buffers fill of music.                      */
 /*****************************************************************************/
@@ -273,10 +259,6 @@ void Music::newCheckMusic() {
 	checkMusic();
 }
 
-
-
-
-
 /*****************************************************************************/
 /* Turns the music on and off.                                               */
 /*****************************************************************************/
@@ -319,8 +301,6 @@ void Music::changeMusic(const char *newmusic) {
 	}
 }
 
-
-
 /*****************************************************************************/
 /* Changes the background music to the original piece playing.               */
 /*****************************************************************************/
@@ -351,7 +331,6 @@ void Music::resetMusic() {
 	_tFile = 0;
 }
 
-
 /*****************************************************************************/
 /* Checks whether or note enough memory in music buffer before loading any   */
 /* files.  Fills it if not.  Does not take into account the current buffer   */


Commit: cc0baf48ed9a545a04d4d8f84213bdda3223ccc4
    https://github.com/scummvm/scummvm/commit/cc0baf48ed9a545a04d4d8f84213bdda3223ccc4
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Check for engine quit events

Changed paths:
    engines/lab/engine.cpp
    engines/lab/intro.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 2916186..69ebae6 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -741,7 +741,7 @@ static void mainGameLoop() {
 		WSDL_ProcessInput(1);
 
 		if (GotMessage) {
-			if (QuitLab) {
+			if (QuitLab || g_engine->shouldQuit()) {
 				stopDiff();
 				break;
 			}
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index e37b347..7f0b53f 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -69,11 +69,17 @@ void introEatMessages() {
 	while (1) {
 		Msg = getMsg();
 
+		if (g_engine->shouldQuit()) {
+			QuitIntro = true;
+			return;
+		}
+
 		if (Msg == NULL)
 			return;
 		else {
 			if (((Msg->Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Msg->Qualifier)) ||
-			        ((Msg->Class == RAWKEY) && (Msg->Code == 27)))
+			        ((Msg->Class == RAWKEY) && (Msg->Code == 27))
+				)
 				QuitIntro = true;
 
 			replyMsg(Msg);


Commit: 650819cfecf1877e07202fa0ec898dbb5609855b
    https://github.com/scummvm/scummvm/commit/650819cfecf1877e07202fa0ec898dbb5609855b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Simplify allocRoom()

Changed paths:
    engines/lab/allocroom.cpp



diff --git a/engines/lab/allocroom.cpp b/engines/lab/allocroom.cpp
index 3a5c7b9..e6dad3b 100644
--- a/engines/lab/allocroom.cpp
+++ b/engines/lab/allocroom.cpp
@@ -168,26 +168,21 @@ static void *getCurMem(uint16 Size) {
 	return Ptr;
 }
 
-
-
-
-
 /*****************************************************************************/
 /* Grabs a chunk of memory from the room buffer, and manages it for a        */
 /* particular room.                                                          */
 /*****************************************************************************/
 void allocRoom(void **Ptr, uint16 size, uint16 roomNum) {
 	uint16 rMarker;
-	bool doit = true;
 
 	if (1 & size)  /* Memory is required to be even aligned */
 		size++;
 
 	rMarker = 0;
 
-	while ((rMarker < MAXMARKERS) && doit) {
+	while ((rMarker < MAXMARKERS)) {
 		if (RoomMarkers[rMarker].RoomNum == roomNum)
-			doit = false;
+			break;
 		else
 			rMarker++;
 	}


Commit: 8ebb53948d006f816510a311ae95dc963171d77c
    https://github.com/scummvm/scummvm/commit/8ebb53948d006f816510a311ae95dc963171d77c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Remove superfluous white space

Changed paths:
    engines/lab/diff.h
    engines/lab/interface.h
    engines/lab/text.h
    engines/lab/vga.h



diff --git a/engines/lab/diff.h b/engines/lab/diff.h
index 6889bcc..4c906f7 100644
--- a/engines/lab/diff.h
+++ b/engines/lab/diff.h
@@ -64,29 +64,19 @@ bool unDIFFMemory(byte *Dest,       /* Where to Un-DIFF               */
                                                    (1, 2 or 4 bytes)              */
 
 bool VUnDIFFMemory(byte *Dest, byte *diff, uint16 HeaderSize, uint16 CopySize, uint16 bytesperrow);
-
 void runLengthDecode(byte *Dest, byte *Source);
-
 void VRunLengthDecode(byte *Dest, byte *Source, uint16 bytesperrow);
 
 /* readDiff.c */
 
 void blackScreen();
-
 void blackAllScreen();
-
 void whiteScreen();
-
 bool readDiff(bool playonce);
-
 void diffNextFrame();
-
 void readSound();
-
 void stopDiff();
-
 void stopDiffEnd();
-
 void stopSound();
 
 } // End of namespace Lab
diff --git a/engines/lab/interface.h b/engines/lab/interface.h
index 1c0439b..170006f 100644
--- a/engines/lab/interface.h
+++ b/engines/lab/interface.h
@@ -115,17 +115,11 @@ extern Common::KeyState _keyPressed;
 
 
 Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt);
-
 void freeButtonList(void *gptrlist);
-
 void drawGadgetList(Gadget *gadlist);
-
 void ghoastGadget(Gadget *curgad, uint16 pencolor);
-
 void unGhoastGadget(Gadget *curgad);
-
 IntuiMessage *getMsg();
-
 void replyMsg(void *Msg);
 
 } // End of namespace Lab
diff --git a/engines/lab/text.h b/engines/lab/text.h
index 254a137..944b363 100644
--- a/engines/lab/text.h
+++ b/engines/lab/text.h
@@ -53,15 +53,10 @@ struct TextFont {
 #endif
 
 bool openFontMem(const char *TextFontPath, TextFont *tf, byte *fontbuffer);
-
 bool openFont(const char *TextFontPath, TextFont **tf);
-
 void closeFont(TextFont *tf);
-
 uint16 textLength(TextFont *tf, const char *text, uint16 numchars);
-
 uint16 textHeight(TextFont *tf);
-
 void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numchars);
 
 } // End of namespace Lab
diff --git a/engines/lab/vga.h b/engines/lab/vga.h
index d911000..5821a0c 100644
--- a/engines/lab/vga.h
+++ b/engines/lab/vga.h
@@ -42,63 +42,36 @@ struct Image {
 };
 
 void setPage(uint16 PageNum);
-
 void VGAStorePage();
-
 void VGARestorePage();
-
 bool createScreen(bool HiRes);
-
 void waitTOF();
-
 void quickWaitTOF();
-
 byte *getVGABaseAddr();
-
 void ungetVGABaseAddr();
-
 void writeColorReg(byte *buf, uint16 regnum);
-
 void writeColorRegs(byte *buf, uint16 first, uint16 numreg);
-
 void writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg);
-
 void VGASetPal(void *cmap, uint16 numcolors);
 
 /*---------- Drawing Routines ----------*/
 
 void drawImage(Image *Im, uint16 x, uint16 y);
-
 void drawMaskImage(Image *Im, uint16 x, uint16 y);
-
 void readScreenImage(Image *Im, uint16 x, uint16 y);
-
 void bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest, uint16 xd, uint16 yd, uint16 width, uint16 height);
-
 void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-
 void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-
 void setAPen(uint16 pennum);
-
 void drawHLine(uint16 x, uint16 y1, uint16 y2);
-
 void drawVLine(uint16 x1, uint16 y, uint16 x2);
-
 void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-
 void ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-
 void WSDL_UpdateScreen();
-
 void WSDL_IgnoreUpdateDisplay(int state);
-
 void WSDL_GetMousePos(int *x, int *y);
-
 uint16 WSDL_GetNextChar();
-
 bool WSDL_HasNextChar();
-
 void WSDL_ProcessInput(bool can_delay);
 
 } // End of namespace Lab


Commit: f017cb624e219aa7ace135b4c2d6a3b262202f12
    https://github.com/scummvm/scummvm/commit/f017cb624e219aa7ace135b4c2d6a3b262202f12
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Use CamelCase, and simplify mouseHandler()

Changed paths:
    engines/lab/engine.cpp
    engines/lab/mouse.cpp
    engines/lab/mouse.h
    engines/lab/vga.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 69ebae6..37e86fb 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -1400,9 +1400,7 @@ void LabEngine::go() {
 		mem = mem && setUpScreens();
 	}
 
-	if (!initMouse()) {
-		return;
-	}
+	initMouse();
 
 	mem = mem && initRoomBuffer() &&
 	      initLabText();
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index 591014c..8636ad7 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -37,7 +37,6 @@
 namespace Lab {
 
 extern bool IsHiRes;
-extern uint32 VGAScreenWidth, VGAScreenHeight;
 
 static bool LeftClick = false;
 static bool RightClick = false;
@@ -65,7 +64,6 @@ static byte MouseData[] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
 #define MOUSE_WIDTH 10
 #define MOUSE_HEIGHT 15
 
-static bool gadhit    = false;
 static Gadget *hitgad = NULL;
 
 /*****************************************************************************/
@@ -81,7 +79,6 @@ static Gadget *checkGadgetHit(Gadget *gadlist, uint16 x, uint16 y) {
 		        (y <= (gadlist->y + gadlist->Im->Height)) &&
 		        !(GADGETOFF & gadlist->GadgetFlags)) {
 			if (IsHiRes) {
-				gadhit = true;
 				hitgad = gadlist;
 			} else {
 				VGAStorePage();
@@ -116,47 +113,36 @@ void attachGadgetList(Gadget *GadList) {
 	ScreenGadgetList = GadList;
 }
 
-static Gadget *TempGad;
+void mouseHandler(int32 flag, int32 mouseX, int32 mouseY) {
+	if (NumHidden >= 2)
+		return;
 
-
-void mouse_handler(int32 flag, int32 mouseX, int32 mouseY) {
 	if (!IsHiRes)
 		mouseX /= 2;
 
-	if (flag & 0x01) { /* mouse Move */
-	}
-
-	if ((flag & 0x02) && (NumHidden < 2)) { /* Left mouse button click */
+	if (flag & 0x02) { /* Left mouse button click */
+		Gadget *tmp = NULL;
 		if (ScreenGadgetList)
-			TempGad = checkGadgetHit(ScreenGadgetList, mouseX, mouseY);
-		else
-			TempGad = NULL;
+			tmp = checkGadgetHit(ScreenGadgetList, mouseX, mouseY);
 
-		if (TempGad) {
-			LastGadgetHit = TempGad;
-		} else {
+		if (tmp)
+			LastGadgetHit = tmp;
+		else
 			LeftClick = true;
-		}
 	}
 
-	if ((flag & 0x08) && (NumHidden < 2)) { /* Right mouse button click */
+	if (flag & 0x08) /* Right mouse button click */
 		RightClick = true;
-	}
 }
 
-
-
-
 void updateMouse() {
 	uint16 counter;
 	bool doUpdateDisplay = false;
 
-	if (!MouseHidden) {
+	if (!MouseHidden)
 		doUpdateDisplay = true;
-	}
 
-	if (gadhit) {
-		gadhit = false;
+	if (hitgad) {
 		mouseHide();
 		drawImage(hitgad->ImAlt, hitgad->x, hitgad->y);
 		mouseShow();
@@ -168,6 +154,7 @@ void updateMouse() {
 		drawImage(hitgad->Im, hitgad->x, hitgad->y);
 		mouseShow();
 		doUpdateDisplay = true;
+		hitgad = NULL;
 	}
 
 	if (doUpdateDisplay)
@@ -175,23 +162,17 @@ void updateMouse() {
 }
 
 
-
-
 /*****************************************************************************/
 /* Initializes the mouse.                                                    */
 /*****************************************************************************/
-bool initMouse() {
+void initMouse() {
 	g_system->setMouseCursor(MouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0);
 	g_system->showMouse(false);
 
 	mouseMove(0, 0);
-
-	return true;
 }
 
 
-
-
 /*****************************************************************************/
 /* Shows the mouse.                                                          */
 /*****************************************************************************/
@@ -237,8 +218,6 @@ void mouseXY(uint16 *x, uint16 *y) {
 }
 
 
-
-
 /*****************************************************************************/
 /* Moves the mouse to new co-ordinates.                                      */
 /*****************************************************************************/
@@ -248,14 +227,11 @@ void mouseMove(uint16 x, uint16 y) {
 
 	g_system->warpMouse(x, y);
 
-	if (!MouseHidden) {
+	if (!MouseHidden)
 		WSDL_ProcessInput(0);
-	}
 }
 
 
-
-
 /*****************************************************************************/
 /* Checks whether or not the mouse buttons have been pressed, and the last   */
 /* co-ordinates of the button press.  leftbutton tells whether to check the  */
diff --git a/engines/lab/mouse.h b/engines/lab/mouse.h
index 18e5c2c..5dd77fb 100644
--- a/engines/lab/mouse.h
+++ b/engines/lab/mouse.h
@@ -37,7 +37,7 @@ namespace Lab {
 
 struct Gadget;
 
-bool initMouse();
+void initMouse();
 
 void updateMouse();
 
@@ -55,7 +55,7 @@ Gadget *mouseGadget();
 
 void attachGadgetList(Gadget *GadList);
 
-void mouse_handler(int32 flag, int32 mouseX, int32 mouseY);
+void mouseHandler(int32 flag, int32 mouseX, int32 mouseY);
 
 } // End of namespace Lab
 
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index d9633e9..388af2d 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -135,12 +135,12 @@ void WSDL_ProcessInput(bool can_delay) {
 			switch (event.type) {
 			case Common::EVENT_RBUTTONDOWN:
 				flags |= 8;
-				mouse_handler(flags, g_MouseX, g_MouseY);
+				mouseHandler(flags, g_MouseX, g_MouseY);
 				break;
 
 			case Common::EVENT_LBUTTONDOWN:
 				flags |= 2;
-				mouse_handler(flags, g_MouseX, g_MouseY);
+				mouseHandler(flags, g_MouseX, g_MouseY);
 				break;
 
 			case Common::EVENT_MOUSEMOVE:
@@ -167,7 +167,7 @@ void WSDL_ProcessInput(bool can_delay) {
 				}
 
 				if (!lastMouseAtEdge || !g_MouseAtEdge)
-					mouse_handler(1, g_MouseX, g_MouseY);
+					mouseHandler(1, g_MouseX, g_MouseY);
 
 				break;
 


Commit: 884b80f2150c4509912988b19e0106aa15e1008f
    https://github.com/scummvm/scummvm/commit/884b80f2150c4509912988b19e0106aa15e1008f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Remove unused variables, some cleanup

Changed paths:
    engines/lab/graphics.cpp
    engines/lab/labfile.cpp



diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 5fb1237..360ffa8 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -48,7 +48,6 @@ extern char diffcmap[256 * 3], lastcmap[256 * 3];
 extern bool IsBM, NoFlip, nopalchange;
 
 extern int32 ReadSoFar;
-extern bool ReadIsDone, ReadIsError;
 extern bool DoBlack, stopsound;
 extern bool IsHiRes;
 extern TextFont *MsgFont;
@@ -74,8 +73,6 @@ bool readPict(const char *filename, bool PlayOnce) {
 	stopDiff();
 
 	ReadSoFar  = 0L;
-	ReadIsDone = false;
-	ReadIsError = false;
 
 	file = g_music->newOpen(filename);
 
@@ -132,8 +129,6 @@ byte *readPictToMem(const char *filename, uint16 x, uint16 y) {
 	stopDiff();
 
 	ReadSoFar  = 0L;
-	ReadIsDone = false;
-	ReadIsError = false;
 
 	allocFile((void **)&Mem, (int32) x * (int32) y, "Bitmap");
 	CurMem = Mem;
diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
index e5ff491..c2acb20 100644
--- a/engines/lab/labfile.cpp
+++ b/engines/lab/labfile.cpp
@@ -35,7 +35,6 @@
 namespace Lab {
 
 #define MAXREADSIZE 30720L
-#define DMABUGSIZE  0     /* The number of bytes the DMA driver might screw */
 /* NOTE: set to 0 for non-CDTV machines.          */
 
 
@@ -46,7 +45,6 @@ byte **startoffile = &startoffilestorage;
 static uint32 buffersize, realbuffersize;
 
 int32 ReadSoFar;
-bool ReadIsError, ReadIsDone;
 
 /*****************************************************************************/
 /* Returns the size of a file.                                               */
@@ -145,19 +143,14 @@ static void *getCurMemLabFile(uint32 size) {
 /* Checks if a file is already buffered.                                     */
 /*****************************************************************************/
 byte **isBuffered(const char *fileName) {
-	uint16 RMarker;
-
 	if (fileName == NULL)
 		return NULL;
 
-	RMarker = 0;
-
-	while (RMarker < MAXMARKERS) {
-		if (strcmp(FileMarkers[RMarker].name, fileName) == 0) {
-			*startoffile = (byte *) FileMarkers[RMarker].Start;
+	for (int i = 0; i < MAXMARKERS; i++) {
+		if (strcmp(FileMarkers[i].name, fileName) == 0) {
+			*startoffile = (byte *)FileMarkers[i].Start;
 			return startoffile;
-		} else
-			RMarker++;
+		}
 	}
 
 	return NULL;
@@ -174,8 +167,6 @@ bool allocFile(void **Ptr, uint32 Size, const char *fileName) {
 	uint16 RMarker;
 	byte **temp;
 
-	Size += DMABUGSIZE;
-
 	if (1 & Size)  /* Memory is required to be even aligned */
 		Size++;
 
@@ -221,8 +212,6 @@ byte **openFile(const char *name) {
 	if (!file.isOpen()) {
 		warning("Cannot open file %s", translateFileName(name));
 
-		ReadIsError = true;
-		ReadIsDone  = true;
 		return NULL;
 	}
 
@@ -336,14 +325,8 @@ void freeBuffer() {
 /* Clears all the buffers.                                                   */
 /*****************************************************************************/
 static void flushBuffers() {
-	uint16 RMarker;
-
-	RMarker = 0;
-
-	while (RMarker < MAXMARKERS) {
-		freeFile(RMarker);
-		RMarker++;
-	}
+	for (int i = 0; i < MAXMARKERS; i++)
+		freeFile(i);
 }
 
 
@@ -354,8 +337,6 @@ static void flushBuffers() {
 void *stealBufMem(int32 Size) {
 	void *Mem;
 
-	Size += DMABUGSIZE;
-
 	flushBuffers();
 	Mem = buffer;
 


Commit: 79ed1e1f05dc1537f666018bc7240a5d96835b5b
    https://github.com/scummvm/scummvm/commit/79ed1e1f05dc1537f666018bc7240a5d96835b5b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Get rid of numtostr(), and simplify most uses of sizeOfFile()

Changed paths:
    engines/lab/engine.cpp
    engines/lab/labfile.cpp
    engines/lab/labfun.h
    engines/lab/labmusic.cpp
    engines/lab/map.cpp
    engines/lab/readparse.cpp
    engines/lab/text.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 37e86fb..9af2a22 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -208,8 +208,6 @@ static bool LastTooLong = false;
 /* Draws the message for the room.                                            */
 /******************************************************************************/
 static void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr) {
-	char text[250], ManyText[8], *ManyPtr;
-
 	if (LastTooLong) {
 		LastTooLong = false;
 		return;
@@ -220,12 +218,8 @@ static void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr) {
 			if ((CurInv == LAMPNUM) && g_lab->_conditions->in(LAMPON))  /* LAB: Labyrith specific */
 				drawMessage(LAMPONMSG);
 			else if (Inventory[CurInv].Many > 1) {
-				ManyPtr = numtostr(ManyText, Inventory[CurInv].Many);
-				strcpy(text, Inventory[CurInv].name);
-				strcat(text, "  (");
-				strcat(text, ManyPtr);
-				strcat(text, ")");
-				drawMessage(text);
+				Common::String roomMessage = Common::String(Inventory[CurInv].name) + "  (" + Common::String::format("%d", Inventory[CurInv].Many) + ")";
+				drawMessage(roomMessage.c_str());
 			} else
 				drawMessage(Inventory[CurInv].name);
 		}
@@ -249,19 +243,14 @@ bool setUpScreens() {
 		return false;
 
 	/* Loads in the graphics for the movement control panel */
-	MovePanelBufferSize = sizeOfFile("P:Control");
-
-	if (MovePanelBufferSize == 0L)
-		return false;
-
-	if (!(MovePanelBuffer = (byte *)calloc(MovePanelBufferSize, 1)))
-		return false;
-
 	Common::File *file = openPartial("P:Control");
-
 	if (!file)
 		return false;
 
+	MovePanelBufferSize = file->size();
+	if (!MovePanelBufferSize || !(MovePanelBuffer = (byte *)calloc(MovePanelBufferSize, 1)))
+		return false;
+
 	file->read(MovePanelBuffer, MovePanelBufferSize);
 	file->close();
 
@@ -315,19 +304,14 @@ bool setUpScreens() {
 		curgad->NextGadget = createButton(VGAScaleX(289), y, 9, 0, MoveImages[10], MoveImages[11]);
 	}
 
-	InvPanelBufferSize = sizeOfFile("P:Inv");
-
-	if (InvPanelBufferSize == 0L)
-		return false;
-
-	if (!(InvPanelBuffer = (byte *)calloc(InvPanelBufferSize, 1)))
-		return false;
-
 	file = openPartial("P:Inv");
-
 	if (!file)
 		return false;
 
+	InvPanelBufferSize = file->size();
+	if (!InvPanelBufferSize || !(InvPanelBuffer = (byte *)calloc(InvPanelBufferSize, 1)))
+		return false;
+
 	file->read(InvPanelBuffer, InvPanelBufferSize);
 	file->close();
 
@@ -413,19 +397,13 @@ void eatMessages() {
 
 	do {
 		Msg = getMsg();
-
-		if (Msg) {
+		if (Msg)
 			replyMsg((void *) Msg);
-		}
 	} while (Msg);
 
 	return;
 }
 
-
-
-
-
 static uint16 lastmusicroom = 1;
 
 
diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
index c2acb20..43825f0 100644
--- a/engines/lab/labfile.cpp
+++ b/engines/lab/labfile.cpp
@@ -203,7 +203,7 @@ bool allocFile(void **Ptr, uint32 Size, const char *fileName) {
 /*****************************************************************************/
 /* Reads a file into memory.                                                 */
 /*****************************************************************************/
-byte **openFile(const char *name) {
+byte **openFile(const char *name, uint32 &size) {
 	byte *buf;
 
 	Common::File file;
@@ -215,7 +215,7 @@ byte **openFile(const char *name) {
 		return NULL;
 	}
 
-	uint32 size = file.size();
+	size = file.size();
 
 	buf = (byte *)malloc(size);
 
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 60b313e..61f27fc 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -70,9 +70,7 @@ struct SaveGameHeader {
 /* Reads in pictures */
 
 bool readPict(const char *filename, bool PlayOnce);
-
 bool readMusic(const char *filename);
-
 byte *readPictToMem(const char *filename, uint16 x, uint16 y);
 
 /* Window text stuff */
@@ -100,31 +98,23 @@ uint32 flowTextToMem(Image *DestIm, void *font,     /* the TextAttr pointer */
                      uint16 y1, uint16 x2, uint16 y2, const char *text); /* The text itself */
 
 void drawMessage(const char *text);
-
 void longDrawMessage(const char *text);
-
 bool readFont(char *filename, void *font, void *data);
 
 /* The Wipes */
 
 void doWipe(uint16 WipeType, CloseDataPtr *CPtr, char *filename);
 
-
 /* Double Buffer stuff */
 
 void newFlipViews(void *scrPtr, uint16 *newpal, uint16 numcolors);
-
 void flipViews(void *scrPtr);
 
-
-
-
 /*----------------------------*/
 /*----- From Interface.c -----*/
 /*----------------------------*/
 
 Gadget *addGadButton(uint16 x, uint16 y, void *UpImage, void *DownImage, uint16 id);
-
 void gadgetsOnOff(void *gptr, void *win, int32 num, bool on);
 
 /*----------------------*/
@@ -133,22 +123,15 @@ void gadgetsOnOff(void *gptr, void *win, int32 num, bool on);
 
 void introSequence();
 
-
-
 /*----------------------*/
 /*----- From Lab.c -----*/
 /*----------------------*/
 
 void eatMessages();
-
 bool setUpScreens();
-
 void drawPanel();
-
 bool quitPlaying();
 
-
-
 /*---------------------------*/
 /*------ From LabFile.c -----*/
 /*---------------------------*/
@@ -156,53 +139,33 @@ bool quitPlaying();
 uint32 sizeOfFile(const char *name);
 
 /* Buffer a whole file */
-
 byte **isBuffered(const char *fileName);
-
-byte **openFile(const char *name);
-
+byte **openFile(const char *name, uint32 &size);
 void readBlock(void *Buffer, uint32 Size, byte **File);
-
 char readChar(char **File);
-
 void skip(byte **File, uint32 skip);
-
 void resetBuffer();
-
 bool initBuffer(uint32 BufSize, bool IsGraphicsMem);
-
 void freeBuffer();
 
-
 /* Functions that borrow memory from the buffer */
-
 bool allocFile(void **Ptr, uint32 Size, const char *fileName);
-
 void *stealBufMem(int32 Size);
-
 void freeAllStolenMem();
 
 
 /* Read chunks of a file */
-
-
 Common::File *openPartial(const char *name);
-
 void closePartial(int32 File);
 
-
 /*---------------------------*/
 /*------ From LabText.c -----*/
 /*---------------------------*/
 
 bool initLabText();
-
 void freeLabText();
-
 void decrypt(byte *text);
 
-
-
 /*---------------------------*/
 /*----- From LabMusic.c -----*/
 /*---------------------------*/
@@ -214,6 +177,7 @@ public:
 	Music();
 
 	byte **newOpen(const char *name);
+	byte **newOpen(const char *name, uint32 &size);
 	bool initMusic();
 	void freeMusic();
 	void fillUpMusic(bool doit);
@@ -264,17 +228,11 @@ extern Music *g_music;
 class LargeSet {
 public:
     LargeSet(uint16 last);
-
     ~LargeSet();
-
     bool in(uint16 element);
-
     void inclElement(uint16 element);
-
     void exclElement(uint16 element);
-
     bool readInitialConditions(const char *fileName);
-
 public:
     uint16 _lastElement;
     uint16 *_array;
@@ -285,62 +243,38 @@ public:
 /*---------------------------*/
 
 uint16 scaleX(uint16 x);
-
 uint16 scaleY(uint16 y);
-
 uint16 VGAScaleX(uint16 x);
-
 uint16 VGAScaleY(uint16 y);
-
 int16 VGAScaleXs(int16 x);
-
 int16 VGAScaleYs(int16 y);
-
 uint16 SVGACord(uint16 cord);
-
 uint16 VGAUnScaleX(uint16 x);
-
 uint16 VGAUnScaleY(uint16 y);
-
 char *translateFileName(const char *filename);
 
-
-
 /*---------------------------*/
 /*-------- From Map.c -------*/
 /*---------------------------*/
 
 void fade(bool fadein, uint16 res);
-
 void setAmigaPal(uint16 *pal, uint16 numcolors);
-
 char *getText(const char *filename);
-
 bool getFont(const char *filename, TextFont *textfont);
-
 void readImage(byte **buffer, Image **im);
-
 void doMap(uint16 CurRoom);
-
 void doJournal();
-
 void doNotes();
-
 void doWestPaper();
-
 void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-
 bool saveRestoreGame();
 
-
-
 /*--------------------------*/
 /*----- From saveGame.c ----*/
 /*--------------------------*/
 
 bool saveGame(uint16 RoomNum, uint16 Direction, uint16 Quarters, int slot, Common::String desc);
 bool loadGame(uint16 *RoomNum, uint16 *Direction, uint16 *Quarters, int slot);
-
 bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header);
 
 /*--------------------------*/
@@ -348,13 +282,9 @@ bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header);
 /*--------------------------*/
 
 void showCombination(const char *filename);
-
 void mouseCombination(uint16 x, uint16 y);
-
 void showTile(const char *filename, bool showsolution);
-
 void mouseTile(uint16 x, uint16 y);
-
 void inner_main();
 
 } // End of namespace Lab
diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index 5222cd9..a435710 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -331,6 +331,11 @@ void Music::resetMusic() {
 	_tFile = 0;
 }
 
+byte **Music::newOpen(const char *name) {
+	uint32 unused;
+	return newOpen(name, unused);
+}
+
 /*****************************************************************************/
 /* Checks whether or note enough memory in music buffer before loading any   */
 /* files.  Fills it if not.  Does not take into account the current buffer   */
@@ -339,20 +344,14 @@ void Music::resetMusic() {
 /*                                                                           */
 /* Here, the seconds are multipled by 10.                                    */
 /*****************************************************************************/
-byte **Music::newOpen(const char *name) {
+byte **Music::newOpen(const char *name, uint32 &size) {
 	byte **file;
 
-	if (name == NULL) {
+	if (!name || !strcmp(name, "") || !strcmp(name, " "))
 		return NULL;
-	}
 
-	if ((strcmp(name, "") == 0) || (strcmp(name, " ") == 0)) {
-		return NULL;
-	}
-
-	if ((file = isBuffered(name))) {
+	if (file = isBuffered(name))
 		return file;
-	}
 
 	if (_musicOn) {
 		updateMusic();
@@ -362,7 +361,7 @@ byte **Music::newOpen(const char *name) {
 	if (!_doNotFilestopSoundEffect && isSoundEffectActive())
 		stopSoundEffect();
 
-	file = openFile(name);
+	file = openFile(name, size);
 	checkMusic();
 	return file;
 }
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index b6b4415..a0dffe0 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -219,7 +219,7 @@ static uint16 mapScaleY(uint16 y) {
 /*****************************************************************************/
 static bool loadMapData() {
 	byte **buffer, Temp[5];
-	int32 Size;
+	uint32 Size;
 	Gadget *gptr;
 	uint16 counter;
 
@@ -228,9 +228,8 @@ static bool loadMapData() {
 	if (!getFont("P:Map.fon", BigMsgFont))
 		BigMsgFont = MsgFont;
 
-	Size = sizeOfFile("P:MapImage");
 	resetBuffer();  /* Make images load into start of buffer */
-	buffer = g_music->newOpen("P:MapImage");
+	buffer = g_music->newOpen("P:MapImage", Size);
 
 	if (!buffer)
 		return false;
@@ -279,8 +278,9 @@ static bool loadMapData() {
 		counter++;
 	}
 
-	buffer = g_music->newOpen("Lab:Maps");
-	stealBufMem(sizeOfFile("Lab:Maps"));  /* Freeze the memory for the maps */
+	uint32 bufferSize;
+	buffer = g_music->newOpen("Lab:Maps", bufferSize);
+	stealBufMem(bufferSize);  /* Freeze the memory for the maps */
 	readBlock(Temp, 4L, buffer);
 	Temp[4] = 0;
 
diff --git a/engines/lab/readparse.cpp b/engines/lab/readparse.cpp
index 5e4bf62..672688c 100644
--- a/engines/lab/readparse.cpp
+++ b/engines/lab/readparse.cpp
@@ -181,58 +181,6 @@ bool readInventory(const char *fileName) {
 	return true;
 }
 
-
-
-
-
-
-/*****************************************************************************/
-/* Converts a number to a string.                                            */
-/*****************************************************************************/
-char *numtostr(char *text, uint16 Num) {
-	uint16 Counter = 0;
-
-	if (Num == 0) {
-		text[0] = '0';
-		text[1] = 0;
-		return text;
-	}
-
-	strcpy(text, "00000");
-
-	if (Num >= 10000) {
-		text[0] = (Num / 10000) + '0';
-		Num -= (Num / 10000) * 10000;
-	}
-
-	if (Num >= 1000) {
-		text[1] = (Num / 1000) + '0';
-		Num -= (Num / 1000) * 1000;
-	}
-
-	if (Num >= 100) {
-		text[2] = (Num / 100) + '0';
-		Num -= (Num / 100) * 100;
-	}
-
-	if (Num >= 10) {
-		text[3] = (Num / 10) + '0';
-		Num -= (Num / 10) * 10;
-	}
-
-	text[4] = Num + '0';
-	text[5] = 0;
-
-	while (text[Counter] == '0')
-		Counter++;
-
-	return (&text[Counter]);
-}
-
-
-
-
-
 /*****************************************************************************/
 /* Reads in a list of conditions.                                            */
 /*****************************************************************************/
@@ -258,9 +206,6 @@ static int16 *readConditions(byte **file) {
 	return ptr;
 }
 
-
-
-
 /*****************************************************************************/
 /* Reads in some CloseUp data.                                               */
 /*****************************************************************************/
@@ -417,16 +362,13 @@ static bool readRule(RulePtr *RPtr, byte **file) {
 /* Reads in the views of a room.                                             */
 /*****************************************************************************/
 bool readViews(uint16 RoomNum, const char *Path) {
-	char Temp[10], *RoomString, fileName[250];
+	Common::String fileName = Common::String(Path) + Common::String::format("%d", RoomNum);
+	char Temp[10];
 	byte **file;
 
 	allocroom = RoomNum;
 
-	RoomString = numtostr(Temp, RoomNum);
-	strcpy(fileName, Path);
-	strcat(fileName, RoomString);
-
-	if ((file = g_music->newOpen(fileName)) != NULL) {
+	if ((file = g_music->newOpen(fileName.c_str())) != NULL) {
 		readBlock(Temp, 4L, file);
 		Temp[4] = '\0';
 
diff --git a/engines/lab/text.cpp b/engines/lab/text.cpp
index 5c456c4..5056d24 100644
--- a/engines/lab/text.cpp
+++ b/engines/lab/text.cpp
@@ -41,10 +41,9 @@ namespace Lab {
 bool openFontMem(const char *TextFontPath, struct TextFont *tf, byte *fontbuffer) {
 	byte **file = NULL;
 	char header[5];
-	int32 filesize, headersize = 4L + 2L + 256 * 3 + 4L;
+	uint32 filesize, headersize = 4L + 2L + 256 * 3 + 4L;
 
-	filesize = sizeOfFile(TextFontPath);
-	file = g_music->newOpen(TextFontPath);
+	file = g_music->newOpen(TextFontPath, filesize);
 
 	if ((file != NULL) && (filesize > headersize)) {
 		header[4] = 0;
@@ -76,11 +75,10 @@ bool openFontMem(const char *TextFontPath, struct TextFont *tf, byte *fontbuffer
 bool openFont(const char *TextFontPath, struct TextFont **tf) {
 	byte **file = NULL;
 	char header[5];
-	int32 filesize, headersize = 4L + 2L + 256 * 3 + 4L;
+	uint32 filesize, headersize = 4L + 2L + 256 * 3 + 4L;
 
 	if ((*tf = (TextFont *)calloc(sizeof(struct TextFont), 1))) {
-		filesize = sizeOfFile(TextFontPath);
-		file = g_music->newOpen(TextFontPath);
+		file = g_music->newOpen(TextFontPath, filesize);
 
 		if ((file != NULL) && (filesize > headersize)) {
 			header[4] = 0;


Commit: 047df0b0e8d85593dd8200a169f0a68a66c138c2
    https://github.com/scummvm/scummvm/commit/047df0b0e8d85593dd8200a169f0a68a66c138c2
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Simplify usage of createButton()

Changed paths:
    engines/lab/engine.cpp
    engines/lab/interface.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 9af2a22..661cbdf 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -263,45 +263,45 @@ bool setUpScreens() {
 	y = VGAScaleY(173) - SVGACord(2);
 
 	if (g_lab->getPlatform() == Common::kPlatformWindows) {
-		MoveGadgetList = createButton(VGAScaleX(1), y, 0, 't', MoveImages[0], MoveImages[1]);
+		MoveGadgetList = createButton(1, y, 0, 't', MoveImages[0], MoveImages[1]);
 		curgad = MoveGadgetList;
-		curgad->NextGadget = createButton(VGAScaleX(33), y, 1, 'm', MoveImages[2], MoveImages[3]);
+		curgad->NextGadget = createButton(33, y, 1, 'm', MoveImages[2], MoveImages[3]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(65), y, 2, 'o', MoveImages[4], MoveImages[5]);
+		curgad->NextGadget = createButton(65, y, 2, 'o', MoveImages[4], MoveImages[5]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(97), y, 3, 'c', MoveImages[6], MoveImages[7]);
+		curgad->NextGadget = createButton(97, y, 3, 'c', MoveImages[6], MoveImages[7]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(129), y, 4, 'l', MoveImages[8], MoveImages[9]);
+		curgad->NextGadget = createButton(129, y, 4, 'l', MoveImages[8], MoveImages[9]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(161), y, 5, 'i', MoveImages[12], MoveImages[13]);
+		curgad->NextGadget = createButton(161, y, 5, 'i', MoveImages[12], MoveImages[13]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(193), y, 6, VKEY_LTARROW, MoveImages[14], MoveImages[15]);
+		curgad->NextGadget = createButton(193, y, 6, VKEY_LTARROW, MoveImages[14], MoveImages[15]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(225), y, 7, VKEY_UPARROW, MoveImages[16], MoveImages[17]);
+		curgad->NextGadget = createButton(225, y, 7, VKEY_UPARROW, MoveImages[16], MoveImages[17]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(257), y, 8, VKEY_RTARROW, MoveImages[18], MoveImages[19]);
+		curgad->NextGadget = createButton(257, y, 8, VKEY_RTARROW, MoveImages[18], MoveImages[19]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(289), y, 9, 'p', MoveImages[10], MoveImages[11]);
+		curgad->NextGadget = createButton(289, y, 9, 'p', MoveImages[10], MoveImages[11]);
 	} else {
-		MoveGadgetList = createButton(VGAScaleX(1), y, 0, 0, MoveImages[0], MoveImages[1]);
+		MoveGadgetList = createButton(1, y, 0, 0, MoveImages[0], MoveImages[1]);
 		curgad = MoveGadgetList;
-		curgad->NextGadget = createButton(VGAScaleX(33), y, 1, 0, MoveImages[2], MoveImages[3]);
+		curgad->NextGadget = createButton(33, y, 1, 0, MoveImages[2], MoveImages[3]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(65), y, 2, 0, MoveImages[4], MoveImages[5]);
+		curgad->NextGadget = createButton(65, y, 2, 0, MoveImages[4], MoveImages[5]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(97), y, 3, 0, MoveImages[6], MoveImages[7]);
+		curgad->NextGadget = createButton(97, y, 3, 0, MoveImages[6], MoveImages[7]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(129), y, 4, 0, MoveImages[8], MoveImages[9]);
+		curgad->NextGadget = createButton(129, y, 4, 0, MoveImages[8], MoveImages[9]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(161), y, 5, 0, MoveImages[12], MoveImages[13]);
+		curgad->NextGadget = createButton(161, y, 5, 0, MoveImages[12], MoveImages[13]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(193), y, 6, 0, MoveImages[14], MoveImages[15]);
+		curgad->NextGadget = createButton(193, y, 6, 0, MoveImages[14], MoveImages[15]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(225), y, 7, 0, MoveImages[16], MoveImages[17]);
+		curgad->NextGadget = createButton(225, y, 7, 0, MoveImages[16], MoveImages[17]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(257), y, 8, 0, MoveImages[18], MoveImages[19]);
+		curgad->NextGadget = createButton(257, y, 8, 0, MoveImages[18], MoveImages[19]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(289), y, 9, 0, MoveImages[10], MoveImages[11]);
+		curgad->NextGadget = createButton(289, y, 9, 0, MoveImages[10], MoveImages[11]);
 	}
 
 	file = openPartial("P:Inv");
@@ -321,37 +321,37 @@ bool setUpScreens() {
 		for (counter = 0; counter < 10; counter++)
 			readImage(buffer, &(InvImages[counter]));
 
-		InvGadgetList = createButton(VGAScaleX(24), y, 0, 'm', InvImages[0], InvImages[1]);
+		InvGadgetList = createButton(24, y, 0, 'm', InvImages[0], InvImages[1]);
 		curgad = InvGadgetList;
-		curgad->NextGadget = createButton(VGAScaleX(56), y, 1, 'g', InvImages[2], InvImages[3]);
+		curgad->NextGadget = createButton(56, y, 1, 'g', InvImages[2], InvImages[3]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(94), y, 2, 'u', InvImages[4], InvImages[5]);
+		curgad->NextGadget = createButton(94, y, 2, 'u', InvImages[4], InvImages[5]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(126), y, 3, 'l', MoveImages[8], MoveImages[9]);
+		curgad->NextGadget = createButton(126, y, 3, 'l', MoveImages[8], MoveImages[9]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(164), y, 4, VKEY_LTARROW, MoveImages[14], MoveImages[15]);
+		curgad->NextGadget = createButton(164, y, 4, VKEY_LTARROW, MoveImages[14], MoveImages[15]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(196), y, 5, VKEY_RTARROW, MoveImages[18], MoveImages[19]);
+		curgad->NextGadget = createButton(196, y, 5, VKEY_RTARROW, MoveImages[18], MoveImages[19]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(234), y, 6, 'b', InvImages[6], InvImages[7]);
+		curgad->NextGadget = createButton(234, y, 6, 'b', InvImages[6], InvImages[7]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(266), y, 7, 'f', InvImages[8], InvImages[9]);
+		curgad->NextGadget = createButton(266, y, 7, 'f', InvImages[8], InvImages[9]);
 		curgad = curgad->NextGadget;
 	} else {
 		for (counter = 0; counter < 6; counter++)
 			readImage(buffer, &(InvImages[counter]));
 
-		InvGadgetList = createButton(VGAScaleX(58), y, 0, 0, InvImages[0], InvImages[1]);
+		InvGadgetList = createButton(58, y, 0, 0, InvImages[0], InvImages[1]);
 		curgad = InvGadgetList;
-		curgad->NextGadget = createButton(VGAScaleX(90), y, 1, 0, InvImages[2], InvImages[3]);
+		curgad->NextGadget = createButton(90, y, 1, 0, InvImages[2], InvImages[3]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(128), y, 2, 0, InvImages[4], InvImages[5]);
+		curgad->NextGadget = createButton(128, y, 2, 0, InvImages[4], InvImages[5]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(160), y, 3, 0, MoveImages[8], MoveImages[9]);
+		curgad->NextGadget = createButton(160, y, 3, 0, MoveImages[8], MoveImages[9]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(198), y, 4, 0, MoveImages[14], MoveImages[15]);
+		curgad->NextGadget = createButton(198, y, 4, 0, MoveImages[14], MoveImages[15]);
 		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(VGAScaleX(230), y, 5, 0, MoveImages[18], MoveImages[19]);
+		curgad->NextGadget = createButton(230, y, 5, 0, MoveImages[18], MoveImages[19]);
 		curgad = curgad->NextGadget;
 	}
 
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 62d35c1..cffa054 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -28,6 +28,7 @@
  *
  */
 
+#include "lab/labfun.h"
 #include "lab/stddefines.h"
 #include "lab/interface.h"
 #include "lab/timing.h"
@@ -44,6 +45,8 @@ Common::KeyState _keyPressed;
 Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt) {
 	Gadget *gptr;
 
+	x = VGAScaleX(x);
+
 	if ((gptr = new Gadget())) {
 		gptr->x = x;
 		gptr->y = y;


Commit: e35307ccba5b62979e3ee58d9606cb519c54ace3
    https://github.com/scummvm/scummvm/commit/e35307ccba5b62979e3ee58d9606cb519c54ace3
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Simplify initLabText()

Changed paths:
    engines/lab/labtext.cpp



diff --git a/engines/lab/labtext.cpp b/engines/lab/labtext.cpp
index 3c26ea7..4284865 100644
--- a/engines/lab/labtext.cpp
+++ b/engines/lab/labtext.cpp
@@ -65,78 +65,77 @@ static void setString(char **string) {
 /* Initializes everything for the Labyrinth text stuff                       */
 /*****************************************************************************/
 bool initLabText() {
-	if ((SizeOfMemChunk = sizeOfFile(LABTEXTFILE)))
-		if ((BeginOfMemChunk = (char *)calloc(SizeOfMemChunk, 1))) {
-			Common::File *file = openPartial(LABTEXTFILE);
-
-			if (file) {
-				file->read(BeginOfMemChunk, SizeOfMemChunk);
-				file->close();
-
-				CurPlace = BeginOfMemChunk;
-
-				setString(&LOWERFLOORS);
-				setString(&MIDDLEFLOORS);
-				setString(&UPPERFLOORS);
-				setString(&MEDMAZEFLOORS);
-				setString(&HEDGEMAZEFLOORS);
-				setString(&SURMAZEFLOORS);
-				setString(&CARNIVALFLOOR);
-				setString(&SURMAZEMSG);
-
-				setString(&FACINGNORTH);
-				setString(&FACINGEAST);
-				setString(&FACINGSOUTH);
-				setString(&FACINGWEST);
-
-				setString(&LAMPONMSG);
-
-				setString(&TURNLEFT);
-				setString(&TURNRIGHT);
-				setString(&GOFORWARDDIR);
-				setString(&NOPATH);
-				setString(&TAKEITEM);
-
-				setString(&SAVETEXT);
-				setString(&LOADTEXT);
-				setString(&BOOKMARKTEXT);
-				setString(&PERSONALTEXT);
-				setString(&DISKTEXT);
-
-				setString(&SAVEBOOK);
-				setString(&RESTOREBOOK);
-				setString(&SAVEFLASH);
-				setString(&RESTOREFLASH);
-				setString(&SAVEDISK);
-				setString(&RESTOREDISK);
-				setString(&NODISKINDRIVE);
-				setString(&WRITEPROTECTED);
-				setString(&SELECTDISK);
-
-				setString(&FORMATFLOPPY);
-				setString(&FORMATTING);
-
-				setString(&NOTHING);
-				setString(&USEONWHAT);
-				setString(&TAKEWHAT);
-				setString(&MOVEWHAT);
-				setString(&OPENWHAT);
-				setString(&CLOSEWHAT);
-				setString(&LOOKWHAT);
-
-				setString(&USEMAP);
-				setString(&USEJOURNAL);
-				setString(&TURNLAMPON);
-				setString(&TURNLAMPOFF);
-				setString(&USEWHISKEY);
-				setString(&USEPITH);
-				setString(&USEHELMET);
-
-				return true;
-			}
-		}
-
-	return false;
+	Common::File *file = openPartial(LABTEXTFILE);
+	if (!file)
+		return false;
+
+	SizeOfMemChunk = file->size();
+	if (!SizeOfMemChunk || !(BeginOfMemChunk = (char *)calloc(SizeOfMemChunk, 1)))
+		return false;
+
+	file->read(BeginOfMemChunk, SizeOfMemChunk);
+	file->close();
+
+	CurPlace = BeginOfMemChunk;
+
+	setString(&LOWERFLOORS);
+	setString(&MIDDLEFLOORS);
+	setString(&UPPERFLOORS);
+	setString(&MEDMAZEFLOORS);
+	setString(&HEDGEMAZEFLOORS);
+	setString(&SURMAZEFLOORS);
+	setString(&CARNIVALFLOOR);
+	setString(&SURMAZEMSG);
+
+	setString(&FACINGNORTH);
+	setString(&FACINGEAST);
+	setString(&FACINGSOUTH);
+	setString(&FACINGWEST);
+
+	setString(&LAMPONMSG);
+
+	setString(&TURNLEFT);
+	setString(&TURNRIGHT);
+	setString(&GOFORWARDDIR);
+	setString(&NOPATH);
+	setString(&TAKEITEM);
+
+	setString(&SAVETEXT);
+	setString(&LOADTEXT);
+	setString(&BOOKMARKTEXT);
+	setString(&PERSONALTEXT);
+	setString(&DISKTEXT);
+
+	setString(&SAVEBOOK);
+	setString(&RESTOREBOOK);
+	setString(&SAVEFLASH);
+	setString(&RESTOREFLASH);
+	setString(&SAVEDISK);
+	setString(&RESTOREDISK);
+	setString(&NODISKINDRIVE);
+	setString(&WRITEPROTECTED);
+	setString(&SELECTDISK);
+
+	setString(&FORMATFLOPPY);
+	setString(&FORMATTING);
+
+	setString(&NOTHING);
+	setString(&USEONWHAT);
+	setString(&TAKEWHAT);
+	setString(&MOVEWHAT);
+	setString(&OPENWHAT);
+	setString(&CLOSEWHAT);
+	setString(&LOOKWHAT);
+
+	setString(&USEMAP);
+	setString(&USEJOURNAL);
+	setString(&TURNLAMPON);
+	setString(&TURNLAMPOFF);
+	setString(&USEWHISKEY);
+	setString(&USEPITH);
+	setString(&USEHELMET);
+
+	return true;
 }
 
 


Commit: e031359d9933cc9c7ce88e1b99876b4ec257437d
    https://github.com/scummvm/scummvm/commit/e031359d9933cc9c7ce88e1b99876b4ec257437d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Use the correct splash screen file for the DOS version

Changed paths:
    engines/lab/intro.cpp



diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 7f0b53f..c14546e 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -270,8 +270,6 @@ static void NReadPict(const char *Filename, bool PlayOnce) {
 }
 
 
-//#define ALL_LOGOS
-
 /*****************************************************************************/
 /* Does the introduction sequence for Labyrinth.                             */
 /*****************************************************************************/
@@ -299,7 +297,10 @@ void introSequence() {
 	g_music->initMusic();
 
 	nopalchange = true;
-	NReadPict("TNDcycle2.pic", true);
+	if (g_lab->getPlatform() != Common::kPlatformWindows)
+		NReadPict("TNDcycle.pic", true);
+	else
+		NReadPict("TNDcycle2.pic", true);
 	nopalchange = false;
 
 	FadePalette = Palette;


Commit: 9a12f6be3fc48f4fa4cc3dc45fce7a0b406bff9b
    https://github.com/scummvm/scummvm/commit/9a12f6be3fc48f4fa4cc3dc45fce7a0b406bff9b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Simplify translateFileName()

Changed paths:
    engines/lab/intro.cpp
    engines/lab/machine.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index c14546e..1f05afe 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -364,7 +364,7 @@ void introSequence() {
 	blackAllScreen();
 	g_music->fillUpMusic(true);
 
-	getFont("P:Map.font", msgfont);
+	getFont("P:Map.fon", msgfont);
 
 	nopalchange = true;
 	NReadPict("Intro.1", true);
diff --git a/engines/lab/machine.cpp b/engines/lab/machine.cpp
index 3806b5f..61375d6 100644
--- a/engines/lab/machine.cpp
+++ b/engines/lab/machine.cpp
@@ -28,6 +28,8 @@
  *
  */
 
+#include "common/str.h"
+
 #include "lab/stddefines.h"
 
 namespace Lab {
@@ -45,9 +47,6 @@ uint16 scaleX(uint16 x) {
 		return (uint16)((x * 8) / 9);
 }
 
-
-
-
 /*****************************************************************************/
 /* Scales the y co-ordinates to that of the new display.  In the room parser */
 /* file, co-ordinates are set up on a 368x336 display.                       */
@@ -59,9 +58,6 @@ uint16 scaleY(uint16 y) {
 		return ((y * 10) / 24);
 }
 
-
-
-
 /*****************************************************************************/
 /* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
 /*****************************************************************************/
@@ -120,9 +116,6 @@ uint16 SVGACord(uint16 cord) {
 		return 0;
 }
 
-
-
-
 /*****************************************************************************/
 /* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
 /*****************************************************************************/
@@ -133,9 +126,6 @@ uint16 VGAUnScaleX(uint16 x) {
 		return x;
 }
 
-
-
-
 /*****************************************************************************/
 /* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
 /*****************************************************************************/
@@ -146,29 +136,6 @@ uint16 VGAUnScaleY(uint16 y) {
 		return y;
 }
 
-
-/*****************************************************************************/
-/* Checks to see if all the characters in the second string are at the start */
-/* of the first.                                                             */
-/*****************************************************************************/
-static bool strstart(const char **Source, const char *Start) {
-	uint16 len1, len2, counter;
-
-	len1 = strlen(*Source);
-	len2 = strlen(Start);
-
-	if (len1 < len2)
-		return false;
-
-	for (counter = 0; counter < len2; counter++)
-		if ((*Source)[counter] != Start[counter])
-			return false;
-
-	(*Source) += len2;
-	return true;
-}
-
-
 static char NewFileName[255];
 
 /*****************************************************************************/
@@ -180,40 +147,32 @@ static char NewFileName[255];
 /* attention to one file at a time, it would be fine to have one variable    */
 /* not on the stack which is used to store the new filename.                 */
 /*****************************************************************************/
-static void mystrupr(char *s) {
-	char c;
-
-	while ((c = *s) != 0)
-		*s++ = toupper(c);
-}
-
 char *translateFileName(const char *filename) {
-	char tempfilename[255];
-	char *dot;
-
-	strcpy(tempfilename, filename);
-	mystrupr(tempfilename);
-
-	*NewFileName = 0;
-	filename = tempfilename;
+	Common::String fileNameStr = filename;
+	fileNameStr.toUppercase();
+	Common::String fileNameStrFinal;
 
-	if (strstart(&filename, "P:")) {
+	if (fileNameStr.hasPrefix("P:")) {
 		if (IsHiRes)
-			strcat(NewFileName, "GAME/SPICT/");
+			fileNameStrFinal = "GAME/SPICT/";
 		else
-			strcat(NewFileName, "GAME/PICT/");
-	} else if (strstart(&filename, "LAB:"))
-		strcat(NewFileName, "GAME/");
-	else if (strstart(&filename, "MUSIC:"))
-		strcat(NewFileName, "GAME/MUSIC/");
-
-	strcat(NewFileName, filename);
+			fileNameStrFinal = "GAME/PICT/";
+	} else if (fileNameStr.hasPrefix("LAB:"))
+		fileNameStrFinal = "GAME/";
+	else if (fileNameStr.hasPrefix("MUSIC:"))
+		fileNameStrFinal = "GAME/MUSIC/";
+
+	if (fileNameStr.contains(':')) {
+		while (fileNameStr[0] != ':') {
+			fileNameStr.deleteChar(0);
+		}
+
+		fileNameStr.deleteChar(0);
+	}
 
-	dot = strrchr(NewFileName, '.');
+	fileNameStrFinal += fileNameStr;
 
-	if (dot != NewFileName && dot != NULL && dot[4] != '/') { // Linux may start with '.'
-		dot[4] = 0; // Back to the days of 8.3, even if your OS was never DOSish!!
-	}
+	strcpy(NewFileName, fileNameStrFinal.c_str());
 
 	return NewFileName;
 }
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 74625a6..603dfbe 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -1193,7 +1193,7 @@ void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1,
 
 	BigMsgFont = &bmfont;
 
-	if (!getFont("P:Map.font", BigMsgFont)) {
+	if (!getFont("P:Map.fon", BigMsgFont)) {
 		freeAllStolenMem();
 		BigMsgFont = NULL;
 		return;


Commit: 4f0c63c0f89aedad21ab41f4b440d0a8b7ae8b6b
    https://github.com/scummvm/scummvm/commit/4f0c63c0f89aedad21ab41f4b440d0a8b7ae8b6b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Merge the VGAScale and setCurClose functions

Changed paths:
    engines/lab/labfun.h
    engines/lab/machine.cpp
    engines/lab/parsefun.h
    engines/lab/processroom.cpp
    engines/lab/readdiff.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 61f27fc..e2f7844 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -244,10 +244,8 @@ public:
 
 uint16 scaleX(uint16 x);
 uint16 scaleY(uint16 y);
-uint16 VGAScaleX(uint16 x);
-uint16 VGAScaleY(uint16 y);
-int16 VGAScaleXs(int16 x);
-int16 VGAScaleYs(int16 y);
+int16 VGAScaleX(int16 x);
+int16 VGAScaleY(int16 y);
 uint16 SVGACord(uint16 cord);
 uint16 VGAUnScaleX(uint16 x);
 uint16 VGAUnScaleY(uint16 y);
diff --git a/engines/lab/machine.cpp b/engines/lab/machine.cpp
index 61375d6..ede75e0 100644
--- a/engines/lab/machine.cpp
+++ b/engines/lab/machine.cpp
@@ -61,54 +61,23 @@ uint16 scaleY(uint16 y) {
 /*****************************************************************************/
 /* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
 /*****************************************************************************/
-uint16 VGAScaleX(uint16 x) {
+int16 VGAScaleX(int16 x) {
 	if (IsHiRes)
 		return (x * 2);
 	else
 		return x;
 }
 
-
-
-
 /*****************************************************************************/
 /* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
 /*****************************************************************************/
-uint16 VGAScaleY(uint16 y) {
+int16 VGAScaleY(int16 y) {
 	if (IsHiRes)
 		return ((y * 12) / 5);
 	else
 		return y;
 }
 
-
-
-/*****************************************************************************/
-/* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
-/*****************************************************************************/
-int16 VGAScaleXs(int16 x) {
-	if (IsHiRes)
-		return (x * 2);
-	else
-		return x;
-}
-
-
-
-
-/*****************************************************************************/
-/* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
-/*****************************************************************************/
-int16 VGAScaleYs(int16 y) {
-	if (IsHiRes)
-		return ((y * 12) / 5);
-	else
-		return y;
-}
-
-
-
-
 uint16 SVGACord(uint16 cord) {
 	if (IsHiRes)
 		return cord;
diff --git a/engines/lab/parsefun.h b/engines/lab/parsefun.h
index 6766dd2..f5929ae 100644
--- a/engines/lab/parsefun.h
+++ b/engines/lab/parsefun.h
@@ -45,54 +45,30 @@ bool parse(const char *InputFile);
 /* From allocRoom.c */
 
 bool initRoomBuffer();
-
 void freeRoomBuffer();
-
 void allocRoom(void **Ptr, uint16 Size, uint16 RoomNum);
 
 /* From ReadParse.c */
 
 bool readRoomData(const char *fileName);
-
 bool readInventory(const char *fileName);
-
-char *numtostr(char *text, uint16 Num);
-
 bool readViews(uint16 RoomNum, const char *Path);
 
 
 /* From ProcessRoom.c */
 
 ViewDataPtr getViewData(uint16 RoomNum, uint16 Direction);
-
 char *getPictName(CloseDataPtr *LCPtr);
-
 void drawDirection(CloseDataPtr LCPtr);
-
 bool processArrow(uint16 *Direction, uint16 Arrow);
-
-void setCurCloseAbs(uint16 x, uint16 y, CloseDataPtr *cptr);
-
-void setCurClose(uint16 x, uint16 y, CloseDataPtr *cptr);
-
+void setCurClose(uint16 x, uint16 y, CloseDataPtr *cptr, bool useAbsoluteCoords = false);
 bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr);
-
 bool doActionRule(int16 x, int16 y, int16 action, int16 RoomNum, CloseDataPtr *LCPtr);
-
 bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *LCPtr);
-
 bool doGoForward(CloseDataPtr *LCPtr);
-
 bool doTurn(uint16 from, uint16 to, CloseDataPtr *LCPtr);
-
 bool doMainView(CloseDataPtr *LCPtr);
 
-/*
-   bool doConditions(int16           x,
-                     int16           y,
-                     CloseDataPtr *LCPtr);
- */
-
 } // End of namespace Lab
 
 #endif /* LAB_PARSEFUN_H */
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 27d480b..7293b90 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -234,12 +234,6 @@ void drawDirection(CloseDataPtr LCPtr) {
 	else if (Direction == WEST)
 		strcat(Message, FACINGWEST);
 
-	/*
-	   numtostr(test, RoomNum);
-	   strcat(Message, ", ");
-	   strcat(Message, test);
-	 */
-
 	drawMessage(Message);
 }
 
@@ -307,11 +301,12 @@ bool processArrow(uint16 *direction, uint16 Arrow) {
 }
 
 /*****************************************************************************/
-/* Sets the current close up data, but uses absolute cords.                  */
+/* Sets the current close up data.                                           */
 /*****************************************************************************/
-void setCurCloseAbs(uint16 x, uint16 y, CloseDataPtr *cptr) {
+void setCurClose(uint16 x, uint16 y, CloseDataPtr *cptr, bool useAbsoluteCoords) {
 	ViewDataPtr VPtr;
 	CloseDataPtr LCPtr;
+	uint16 x1, y1, x2, y2;
 
 	if (*cptr == NULL) {
 		VPtr = getViewData(RoomNum, Direction);
@@ -319,37 +314,20 @@ void setCurCloseAbs(uint16 x, uint16 y, CloseDataPtr *cptr) {
 	} else
 		LCPtr = (*cptr)->SubCloseUps;
 
-
 	while (LCPtr != NULL) {
-		if ((x >= LCPtr->x1) && (y >= LCPtr->y1) &&
-		        (x <= LCPtr->x2) && (y <= LCPtr->y2) &&
-		        (LCPtr->GraphicName)) {
-			*cptr = LCPtr;
-			return;
+		if (!useAbsoluteCoords) {
+			x1 = LCPtr->x1;
+			y1 = LCPtr->y1;
+			x2 = LCPtr->x2;
+			y2 = LCPtr->y2;
+		} else {
+			x1 = scaleX(LCPtr->x1);
+			y1 = scaleY(LCPtr->y1);
+			x2 = scaleX(LCPtr->x2);
+			y2 = scaleY(LCPtr->y2);
 		}
 
-		LCPtr = LCPtr->NextCloseUp;
-	}
-}
-
-/*****************************************************************************/
-/* Sets the current close up data.                                           */
-/*****************************************************************************/
-void setCurClose(uint16 x, uint16 y, CloseDataPtr *cptr) {
-	ViewDataPtr VPtr;
-	CloseDataPtr LCPtr;
-
-	if (*cptr == NULL) {
-		VPtr = getViewData(RoomNum, Direction);
-		LCPtr = VPtr->closeUps;
-	} else
-		LCPtr = (*cptr)->SubCloseUps;
-
-
-	while (LCPtr != NULL) {
-		if ((x >= scaleX(LCPtr->x1)) && (y >= scaleY(LCPtr->y1)) &&
-		        (x <= scaleX(LCPtr->x2)) && (y <= scaleY(LCPtr->y2)) &&
-		        (LCPtr->GraphicName)) {
+		if (x >= x1 && y >= y1 && x <= x2 && y <= y2 && LCPtr->GraphicName) {
 			*cptr = LCPtr;
 			return;
 		}
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index fa1a009..e1ecb3b 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -42,8 +42,6 @@ extern uint32 VGABytesPerPage;
 
 /*
    extern int32             ReadSoFar;
-   extern bool          ReadIsDone,
-                        ReadIsError;
  */
 extern byte **startoffile;
 
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 603dfbe..b8e6662 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -363,22 +363,22 @@ static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 	uint16 counter;
 
 	if (scrolltype == LEFTSCROLL) {
-		dX =  VGAScaleXs(5);
-		sx =  VGAScaleXs(5);
+		dX =  VGAScaleX(5);
+		sx =  VGAScaleX(5);
 		last = 6;
 	} else if (scrolltype == RIGHTSCROLL) {
-		dX = VGAScaleXs(-5);
-		dx = VGAScaleXs(-5);
+		dX = VGAScaleX(-5);
+		dx = VGAScaleX(-5);
 		sx =  VGAScaleX(5);
 		last = 6;
 	} else if (scrolltype == UPSCROLL) {
-		dY =  VGAScaleYs(5);
-		sy =  VGAScaleYs(5);
+		dY =  VGAScaleY(5);
+		sy =  VGAScaleY(5);
 		last = 5;
 	} else if (scrolltype == DOWNSCROLL) {
-		dY = VGAScaleYs(-5);
-		dy = VGAScaleYs(-5);
-		sy =  VGAScaleYs(5);
+		dY = VGAScaleY(-5);
+		dy = VGAScaleY(-5);
+		sy =  VGAScaleY(5);
 		last = 5;
 	}
 
@@ -437,9 +437,6 @@ static void changeTile(uint16 col, uint16 row) {
 	}
 
 	if (scrolltype != -1) {
-		/* NYI:
-		    readPict("Music:Click", true);
-		 */
 		doTileScroll(col, row, scrolltype);
 
 #if defined(LABDEMO)
@@ -933,6 +930,8 @@ extern uint16 RoomNum, Direction;
 bool saveRestoreGame() {
 	bool isOK = false;
 
+	//g_lab->showMainMenu();
+
 	// The original had one screen for saving/loading. We have two.
 	// Ask the user which screen to use.
 	GUI::MessageDialog saveOrLoad(_("Would you like to save or restore a game?"), _("Save"), _("Restore"));
@@ -990,17 +989,18 @@ Image *MonButton, *AltMonButton, *MonQuit, *AltMonQuit, *MonBack, *AltMonBack,
 /*****************************************************************************/
 static void getMonImages() {
 	byte **buffer;
+	uint32 bufferSize;
 
 	resetBuffer();
 
-	buffer = g_music->newOpen("P:MonImage");
+	buffer = g_music->newOpen("P:MonImage", bufferSize);
 
 	if (!buffer)
 		return;
 
 	readImage(buffer, &MonButton);
 
-	stealBufMem(sizeOfFile("P:MonImage"));  /* Trick: protects the memory where the buttons are so they won't be over-written */
+	stealBufMem(bufferSize);  /* Trick: protects the memory where the buttons are so they won't be over-written */
 }
 
 
@@ -1150,7 +1150,7 @@ static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1
 					TestCPtr = CPtr;
 					MouseY = 64 + (MouseY / MonGadHeight) * 42;
 					MouseX = 101;
-					setCurCloseAbs(MouseX, MouseY, &CPtr);
+					setCurClose(MouseX, MouseY, &CPtr, true);
 
 					if (TestCPtr != CPtr) {
 						LastCPtr[depth] = TestCPtr;


Commit: 5ae4d3bf9eac72cc554d6ecbcd89528dda9cea5c
    https://github.com/scummvm/scummvm/commit/5ae4d3bf9eac72cc554d6ecbcd89528dda9cea5c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Initial code to simplify translateFileName() and the save menu

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



diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index f1d0fe9..3f92de1 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -28,12 +28,15 @@
  *
  */
 
+#include "common/config-manager.h"
 #include "common/debug-channels.h"
 #include "common/scummsys.h"
 #include "common/error.h"
 #include "common/fs.h"
 #include "common/rect.h"
 
+#include "engines/dialogs.h"
+#include "engines/engine.h"
 #include "engines/util.h"
 
 #include "gui/message.h"
@@ -50,6 +53,12 @@ LabEngine *g_lab;
 LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
  : Engine(syst), _gameDescription(gameDesc), _extraGameFeatures(0) {
 	g_lab = this;
+
+	//const Common::FSNode gameDataDir(ConfMan.get("path"));
+	//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
+	//SearchMan.addSubDirectoryMatching(gameDataDir, "game/pict");
+	//SearchMan.addSubDirectoryMatching(gameDataDir, "game/spict");
+	//SearchMan.addSubDirectoryMatching(gameDataDir, "music");
 }
 
 LabEngine::~LabEngine() {
@@ -108,4 +117,8 @@ Common::String LabEngine::generateSaveFileName(uint slot) {
 	return Common::String::format("%s.%03u", _targetName.c_str(), slot);
 }
 
+/*void LabEngine::showMainMenu() {
+
+}*/
+
 } // End of namespace Lab
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index b16b598..c1bf433 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -60,6 +60,8 @@ public:
 	bool hasFeature(EngineFeature f) const;
 	Common::String generateSaveFileName(uint slot);
 
+	//void showMainMenu();
+
 	LargeSet *_conditions, *_roomsFound;
 
 private:


Commit: 27683945e609d50947cecaf1b947fd85e40e9159
    https://github.com/scummvm/scummvm/commit/27683945e609d50947cecaf1b947fd85e40e9159
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Simplify timeDiff()

Changed paths:
    engines/lab/timing.cpp



diff --git a/engines/lab/timing.cpp b/engines/lab/timing.cpp
index acba16d..a9f593e 100644
--- a/engines/lab/timing.cpp
+++ b/engines/lab/timing.cpp
@@ -105,24 +105,8 @@ void anyTimeDiff(uint32 sec1, uint32 micros1, uint32 sec2, uint32 micros2, uint3
 /*****************************************************************************/
 void timeDiff(uint32 sec, uint32 micros, uint32 *diffSec, uint32 *diffMicros) {
 	uint32 curSec, curMicros;
-
-	*diffSec    = 0;
-	*diffMicros = 0;
-
 	getTime(&curSec, &curMicros);
-
-	if (curSec > sec)  /* Already passed the time */
-		return;
-	else if ((curSec == sec) && (curMicros >= micros))  /* Already passed the time */
-		return;
-
-	if (curMicros > micros) {
-		*diffSec    = sec - curSec - 1;
-		*diffMicros = (ONESECOND - curMicros) + micros;
-	} else {
-		*diffSec    = sec - curSec;
-		*diffMicros = micros - curMicros;
-	}
+	anyTimeDiff(curSec, curMicros, sec, micros, diffSec, diffMicros);
 }
 
 /*****************************************************************************/


Commit: 21e360b9b18e887bb35efaf21a16bf7f97338a35
    https://github.com/scummvm/scummvm/commit/21e360b9b18e887bb35efaf21a16bf7f97338a35
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Remove dead/superfluous code, and remove the newCheckMusic() wrapper

Changed paths:
    engines/lab/diff.h
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/interface.cpp
    engines/lab/interface.h
    engines/lab/intro.cpp
    engines/lab/labfun.h
    engines/lab/labmusic.cpp
    engines/lab/map.cpp
    engines/lab/processroom.cpp
    engines/lab/readdiff.cpp
    engines/lab/special.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/diff.h b/engines/lab/diff.h
index 4c906f7..b5c84d3a 100644
--- a/engines/lab/diff.h
+++ b/engines/lab/diff.h
@@ -46,7 +46,7 @@ struct DIFFHeader {
 
 struct BitMap {
 	uint16 BytesPerRow, Rows;
-	byte Flags, Depth;
+	byte Flags;
 	byte *Planes[16];
 };
 
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 661cbdf..8960464 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -397,8 +397,6 @@ void eatMessages() {
 
 	do {
 		Msg = getMsg();
-		if (Msg)
-			replyMsg((void *) Msg);
 	} while (Msg);
 
 	return;
@@ -787,7 +785,7 @@ static void mainGameLoop() {
 		if (Msg == NULL) { /* Does music load and next animation frame when you've run out of messages */
 			GotMessage = false;
 			checkRoomMusic();
-			g_music->newCheckMusic();
+			g_music->checkMusic();
 			diffNextFrame();
 
 			if (FollowingCrumbs) {
@@ -830,8 +828,6 @@ static void mainGameLoop() {
 			MouseY    = Msg->MouseY;
 			GadID     = Msg->GadgetID;
 
-			replyMsg((void *) Msg);
-
 			FollowingCrumbs = false;
 
 from_crumbs:
@@ -893,11 +889,9 @@ from_crumbs:
 						Msg = getMsg();
 
 						if (Msg == NULL) { /* Does music load and next animation frame when you've run out of messages */
-							g_music->newCheckMusic();
+							g_music->checkMusic();
 							diffNextFrame();
 						} else {
-							replyMsg((void *) Msg);    /* Can't do this in non-IBM versions */
-
 							if (Msg->Class == RAWKEY) {
 								if ((Msg->Code == 'Y') || (Msg->Code == 'y') || (Msg->Code == 'Q') || (Msg->Code == 'q')) {
 									doit = true;
@@ -1406,7 +1400,7 @@ void LabEngine::go() {
 		readPict("P:End/L2In.1", true);
 
 		for (counter = 0; counter < 120; counter++) {
-			g_music->newCheckMusic();
+			g_music->checkMusic();
 			waitTOF();
 		}
 
@@ -1415,7 +1409,7 @@ void LabEngine::go() {
 
 		warning("STUB: waitForPress");
 		while (!1) { // 1 means ignore SDL_ProcessInput calls
-			g_music->newCheckMusic();
+			g_music->checkMusic();
 			diffNextFrame();
 			waitTOF();
 		}
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 360ffa8..7f949d6 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -47,7 +47,6 @@ extern BitMap RawDiffBM;
 extern char diffcmap[256 * 3], lastcmap[256 * 3];
 extern bool IsBM, NoFlip, nopalchange;
 
-extern int32 ReadSoFar;
 extern bool DoBlack, stopsound;
 extern bool IsHiRes;
 extern TextFont *MsgFont;
@@ -62,7 +61,7 @@ extern const char *CurFileName;
 /*---------------------------------------------------------------------------*/
 
 
-extern uint32 VGAScreenWidth, VGAScreenHeight, VGAPages, VGABytesPerPage;
+extern uint32 VGAScreenWidth, VGAScreenHeight, VGABytesPerPage;
 
 /*****************************************************************************/
 /* Reads in a picture into the dest bitmap.                                  */
@@ -72,8 +71,6 @@ bool readPict(const char *filename, bool PlayOnce) {
 
 	stopDiff();
 
-	ReadSoFar  = 0L;
-
 	file = g_music->newOpen(filename);
 
 	if (file == NULL) {
@@ -86,7 +83,6 @@ bool readPict(const char *filename, bool PlayOnce) {
 	DispBitMap->BytesPerRow = VGAScreenWidth;
 	DispBitMap->Rows        = VGAScreenHeight;
 	DispBitMap->Flags       = BITMAPF_VIDEO;
-	DispBitMap->Depth       = VGAPages;
 
 	readDiff(PlayOnce);
 
@@ -128,8 +124,6 @@ byte *readPictToMem(const char *filename, uint16 x, uint16 y) {
 
 	stopDiff();
 
-	ReadSoFar  = 0L;
-
 	allocFile((void **)&Mem, (int32) x * (int32) y, "Bitmap");
 	CurMem = Mem;
 
@@ -141,7 +135,6 @@ byte *readPictToMem(const char *filename, uint16 x, uint16 y) {
 	DispBitMap->BytesPerRow = x;
 	DispBitMap->Rows        = y;
 	DispBitMap->Flags       = 0;
-	DispBitMap->Depth       = VGAPages;
 	DispBitMap->Planes[0] = CurMem;
 	DispBitMap->Planes[1] = DispBitMap->Planes[0] + 0x10000;
 	DispBitMap->Planes[2] = DispBitMap->Planes[1] + 0x10000;
@@ -423,70 +416,6 @@ void drawMessage(const char *str) {
 #define READFIRSTFRAME 6
 #define READNEXTFRAME  7
 
-
-
-
-/*****************************************************************************/
-/* Copies memory from one location to another 64 bytes at a time.            */
-/*****************************************************************************/
-void copyLong64(uint32 *Dest, uint32 *Source, uint32 Many64) {
-	while (Many64) {
-		*Dest = *Source;
-		Dest++;
-		Source++;
-		*Dest = *Source;
-		Dest++;
-		Source++;
-		*Dest = *Source;
-		Dest++;
-		Source++;
-		*Dest = *Source;
-		Dest++;
-		Source++;
-		*Dest = *Source;
-		Dest++;
-		Source++;
-		*Dest = *Source;
-		Dest++;
-		Source++;
-		*Dest = *Source;
-		Dest++;
-		Source++;
-		*Dest = *Source;
-		Dest++;
-		Source++;
-		*Dest = *Source;
-		Dest++;
-		Source++;
-		*Dest = *Source;
-		Dest++;
-		Source++;
-		*Dest = *Source;
-		Dest++;
-		Source++;
-		*Dest = *Source;
-		Dest++;
-		Source++;
-		*Dest = *Source;
-		Dest++;
-		Source++;
-		*Dest = *Source;
-		Dest++;
-		Source++;
-		*Dest = *Source;
-		Dest++;
-		Source++;
-		*Dest = *Source;
-		Dest++;
-		Source++;
-
-		Many64--;
-	}
-}
-
-
-
-
 /*****************************************************************************/
 /* Scrolls the display to black.                                             */
 /*****************************************************************************/
@@ -516,7 +445,7 @@ static void doScrollBlack() {
 	nheight = height;
 
 	while (nheight) {
-		g_music->newCheckMusic();
+		g_music->checkMusic();
 
 		if (!IsHiRes)
 			waitTOF();
@@ -541,7 +470,7 @@ static void doScrollBlack() {
 			size -= copysize;
 
 			setPage(CurPage);
-			copyLong64(BaseAddr, (uint32 *) tempmem, copysize >> 6);
+			memcpy(BaseAddr, tempmem, copysize);
 			tempmem += copysize;
 			CurPage++;
 		}
@@ -596,7 +525,7 @@ static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startli
 		size -= copysize;
 
 		setPage(CurPage);
-		copyLong64(BaseAddr + (OffSet >> 2), (uint32 *) mem, copysize >> 6);
+		memcpy(BaseAddr + (OffSet >> 2), mem, copysize);
 		mem += copysize;
 		CurPage++;
 		OffSet = 0;
@@ -618,7 +547,7 @@ static void doScrollWipe(char *filename) {
 	height = VGAScaleY(149) + SVGACord(2);
 
 	while (g_music->isSoundEffectActive()) {
-		g_music->newCheckMusic();
+		g_music->checkMusic();
 		waitTOF();
 	}
 
@@ -633,7 +562,7 @@ static void doScrollWipe(char *filename) {
 	nheight = height;
 
 	while (onrow < headerdata.y) {
-		g_music->newCheckMusic();
+		g_music->checkMusic();
 
 		if ((by > nheight) && nheight)
 			by = nheight;
@@ -694,7 +623,7 @@ static void doScrollBounce() {
 	int startline = headerdata.y - height - 1;
 
 	for (int counter = 0; counter < 5; counter++) {
-		g_music->newCheckMusic();
+		g_music->checkMusic();
 		startline -= newby[counter];
 		copyPage(width, height, 0, startline, mem);
 
@@ -703,7 +632,7 @@ static void doScrollBounce() {
 	}
 
 	for (int counter = 8; counter > 0; counter--) {
-		g_music->newCheckMusic();
+		g_music->checkMusic();
 		startline += newby1[counter - 1];
 		copyPage(width, height, 0, startline, mem);
 
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index cffa054..e2f7401 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -207,8 +207,4 @@ IntuiMessage *getMsg() {
 		return NULL;
 }
 
-void replyMsg(void *Msg) {
-	return;
-}
-
 } // End of namespace Lab
diff --git a/engines/lab/interface.h b/engines/lab/interface.h
index 170006f..ea110f4 100644
--- a/engines/lab/interface.h
+++ b/engines/lab/interface.h
@@ -111,16 +111,12 @@ extern Common::KeyState _keyPressed;
 /*--------------------------- Function Prototypes ---------------------------*/
 /*---------------------------------------------------------------------------*/
 
-
-
-
 Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt);
 void freeButtonList(void *gptrlist);
 void drawGadgetList(Gadget *gadlist);
 void ghoastGadget(Gadget *curgad, uint16 pencolor);
 void unGhoastGadget(Gadget *curgad);
 IntuiMessage *getMsg();
-void replyMsg(void *Msg);
 
 } // End of namespace Lab
 
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 1f05afe..c430b61 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -81,8 +81,6 @@ void introEatMessages() {
 			        ((Msg->Class == RAWKEY) && (Msg->Code == 27))
 				)
 				QuitIntro = true;
-
-			replyMsg(Msg);
 		}
 	}
 }
@@ -110,7 +108,7 @@ static void doPictText(const char *Filename, bool isscreen) {
 		g_music->fillUpMusic(true);
 		timedelay = 35;
 	} else {
-		g_music->newCheckMusic();
+		g_music->checkMusic();
 		timedelay = 7;
 	}
 
@@ -162,7 +160,7 @@ static void doPictText(const char *Filename, bool isscreen) {
 		Msg = getMsg();
 
 		if (Msg == NULL) {
-			g_music->newCheckMusic();
+			g_music->checkMusic();
 			diffNextFrame();
 
 			getTime(&secs, &micros);
@@ -184,7 +182,6 @@ static void doPictText(const char *Filename, bool isscreen) {
 			Class     = Msg->Class;
 			Qualifier = Msg->Qualifier;
 			Code      = Msg->Code;
-			replyMsg(Msg);
 
 			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) ||
 			        ((Class == RAWKEY) && (Code == 27))) {
@@ -238,13 +235,13 @@ static void doPictText(const char *Filename, bool isscreen) {
 void musicDelay() {
 	int16 counter;
 
-	g_music->newCheckMusic();
+	g_music->checkMusic();
 
 	if (QuitIntro)
 		return;
 
 	for (counter = 0; counter < 20; counter++) {
-		g_music->newCheckMusic();
+		g_music->checkMusic();
 		waitTOF();
 		waitTOF();
 		waitTOF();
@@ -256,7 +253,7 @@ void musicDelay() {
 static void NReadPict(const char *Filename, bool PlayOnce) {
 	Common::String finalFileName = "P:Intro/";
 
-	g_music->newCheckMusic();
+	g_music->checkMusic();
 	introEatMessages();
 
 	if (QuitIntro)
@@ -285,10 +282,12 @@ void introSequence() {
 		NReadPict("EA3", true);
 	} else {
 		NReadPict("WYRMKEEP", true);
-		for (counter = 0; counter < 4; counter++) {
+		// Wait 4 seconds
+		for (counter = 0; counter < 4 * 1000 / 10; counter++) {
+			introEatMessages();
 			if (QuitIntro)
 				break;
-			microDelay(1, 0);
+			g_system->delayMillis(10);
 		}
 	}
 
@@ -314,14 +313,14 @@ void introSequence() {
 		                   (diffcmap[counter * 3 + 2] >> 2);
 	}
 
-	g_music->newCheckMusic();
+	g_music->checkMusic();
 	fade(true, 0);
 
 	for (int times = 0; times < 150; times++) {
 		if (QuitIntro)
 			break;
 
-		g_music->newCheckMusic();
+		g_music->checkMusic();
 		uint16 temp = Palette[2];
 
 		for (counter = 2; counter < 15; counter++)
@@ -336,7 +335,7 @@ void introSequence() {
 	fade(false, 0);
 	blackAllScreen();
 
-	g_music->newCheckMusic();
+	g_music->checkMusic();
 
 	NReadPict("Title.A", true);
 	NReadPict("AB", true);
@@ -360,7 +359,7 @@ void introSequence() {
 
 	g_music->newOpen("p:Intro/Intro.1");  /* load the picture into the buffer */
 
-	g_music->newCheckMusic();
+	g_music->checkMusic();
 	blackAllScreen();
 	g_music->fillUpMusic(true);
 
@@ -415,7 +414,7 @@ void introSequence() {
 			for (counter1 = (8 * 3); counter1 < (255 * 3); counter1++)
 				diffcmap[counter1] = 255 - diffcmap[counter1];
 
-			g_music->newCheckMusic();
+			g_music->checkMusic();
 			waitTOF();
 			VGASetPal(diffcmap, 256);
 			waitTOF();
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index e2f7844..cd1e2df 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -184,7 +184,6 @@ public:
 	void updateMusic();
 	uint16 getPlayingBufferCount();
 	void checkMusic();
-	void newCheckMusic();
 	void closeMusic();
 	void setMusic(bool on);
 	void resumeBackMusic();
diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index a435710..ecb5fd1 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -253,13 +253,6 @@ void Music::checkMusic() {
 }
 
 /*****************************************************************************/
-/* Checks to see if need to fill buffers fill of music.                      */
-/*****************************************************************************/
-void Music::newCheckMusic() {
-	checkMusic();
-}
-
-/*****************************************************************************/
 /* Turns the music on and off.                                               */
 /*****************************************************************************/
 void Music::setMusic(bool on) {
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index a0dffe0..458ff21 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -142,16 +142,10 @@ void readImage(byte **buffer, Image **im) {
 }
 
 
-
-
-
-
 /*---------------------------------------------------------------------------*/
 /*------------------------------ The Map stuff ------------------------------*/
 /*---------------------------------------------------------------------------*/
 
-
-
 extern RoomData *Rooms;
 extern const char *ViewPath;
 
@@ -620,7 +614,7 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b
 	}
 
 	if ((Maps[CurRoom].PageNumber == Floor)   /* Makes sure the X is drawn in corridors */
-	        && g_lab->_roomsFound->in(CurRoom) /* NOTE: this here on purpose just in case there's some wierd condition, like the surreal maze where there are no rooms */
+	        && g_lab->_roomsFound->in(CurRoom) /* NOTE: this here on purpose just in case there's some weird condition, like the surreal maze where there are no rooms */
 	        && Maps[CurRoom].x)
 		drawRoom(CurRoom, true);
 
@@ -664,38 +658,28 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b
 	}
 
 
-	/* LAB: Labyrinth specific code */
-	sptr = NULL;
-
 	switch (Floor) {
 	case LOWERFLOOR:
 		sptr = LOWERFLOORS;
 		break;
-
 	case MIDDLEFLOOR:
 		sptr = MIDDLEFLOORS;
 		break;
-
 	case UPPERFLOOR:
 		sptr = UPPERFLOORS;
 		break;
-
 	case MEDMAZEFLOOR:
 		sptr = MEDMAZEFLOORS;
 		break;
-
 	case HEDGEMAZEFLOOR:
 		sptr = HEDGEMAZEFLOORS;
 		break;
-
 	case SURMAZEFLOOR:
 		sptr = SURMAZEFLOORS;
 		break;
-
 	case CARNIVAL:
 		sptr = CARNIVALFLOOR;
 		break;
-
 	default:
 		sptr = NULL;
 		break;
@@ -734,7 +718,7 @@ void processMap(uint16 CurRoom) {
 		Msg = getMsg();
 
 		if (Msg == NULL) {
-			g_music->newCheckMusic();
+			g_music->checkMusic();
 
 			if (place <= 14) {
 				newcolor[0] = 14 << 2;
@@ -888,17 +872,6 @@ void processMap(uint16 CurRoom) {
 }
 
 
-
-/*****************************************************************************/
-/* Cleans up behind itself.                                                  */
-/*****************************************************************************/
-void mapCleanUp() {
-	freeAllStolenMem();
-}
-
-
-
-
 /*****************************************************************************/
 /* Does the map processing.                                                  */
 /*****************************************************************************/
@@ -929,7 +902,7 @@ void doMap(uint16 CurRoom) {
 	mouseHide();
 	setAPen(0);
 	rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1);
-	mapCleanUp();
+	freeAllStolenMem();
 	blackAllScreen();
 	mouseShow();
 	WSDL_UpdateScreen();
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 7293b90..9d501e6 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -206,9 +206,6 @@ char *getPictName(CloseDataPtr *LCPtr) {
 /*****************************************************************************/
 void drawDirection(CloseDataPtr LCPtr) {
 	char Message[250];
-	/*
-	   char test[15];
-	 */
 
 	if (LCPtr != NULL) {
 		if (LCPtr->Message) {
@@ -378,7 +375,7 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
 	uint32 StartSecs, StartMicros, CurSecs, CurMicros;
 
 	while (APtr) {
-		g_music->newCheckMusic();
+		g_music->checkMusic();
 
 		switch (APtr->ActionType) {
 		case PLAYSOUND:
@@ -547,7 +544,7 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
 			WSDL_UpdateScreen();
 
 			while (1) {
-				g_music->newCheckMusic();
+				g_music->checkMusic();
 				diffNextFrame();
 				getTime(&CurSecs, &CurMicros);
 
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index e1ecb3b..f2a39b4 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -40,9 +40,6 @@ namespace Lab {
 extern BitMap *DispBitMap, *DrawBitMap;
 extern uint32 VGABytesPerPage;
 
-/*
-   extern int32             ReadSoFar;
- */
 extern byte **startoffile;
 
 static bool PlayOnce = false, changedscreen;
@@ -258,10 +255,6 @@ void diffNextFrame() {
 			break;
 
 		case 26L:
-			/* NYI: This don't work no more
-			   memcpy((void *) DrawBitMap->Planes[CurBit],
-			   (void *) DispBitMap->Planes[CurBit],  (uint16) (diffheight*diffwidth));
-			 */
 			CurBit++;
 			break;
 
@@ -443,11 +436,6 @@ void stopDiff() {
 	if (IsPlaying) {
 		StopPlaying = true;
 
-		/* NYI:
-		    while (IsPlaying)
-		      waitTOF();
-		 */
-
 		if (IsAnim)
 			blackScreen();
 	}
@@ -463,7 +451,7 @@ void stopDiffEnd() {
 		StopPlayingEnd = true;
 
 		while (IsPlaying) {
-			g_music->newCheckMusic();
+			g_music->checkMusic();
 			diffNextFrame();
 		}
 	}
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index b8e6662..57f3284 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -171,10 +171,6 @@ static void changeCombination(uint16 number) {
 	display.Width     = VGAScreenWidth;
 	display.Height    = VGAScreenHeight;
 
-	/* NYI:
-	   readPict("Music:Thunk", true);
-	 */
-
 	for (counter = 1; counter <= (Images[combnum]->Height / 2); counter++) {
 		if (IsHiRes) {
 			if (counter & 1)
@@ -725,7 +721,7 @@ static void drawJournalText() {
 	char *CurText = journaltext;
 
 	while (DrawingToPage < JPage) {
-		g_music->newCheckMusic();
+		g_music->checkMusic();
 		CurText = (char *)(journaltext + CharsDrawn);
 		CharsDrawn += flowText(BigMsgFont, -2, 2, 0, false, false, false, false, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText);
 
@@ -846,14 +842,12 @@ static void processJournal() {
 		Msg = (IntuiMessage *) getMsg();
 
 		if (Msg == NULL) {
-			g_music->newCheckMusic();
+			g_music->checkMusic();
 		} else {
 			Class     = Msg->Class;
 			Qualifier = Msg->Qualifier;
 			GadID     = Msg->Code;
 
-			replyMsg((void *) Msg);
-
 			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) ||
 			        ((Class == RAWKEY) && (GadID == 27)))
 				return;
@@ -1047,7 +1041,7 @@ static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2,
 	}
 
 	while (DrawingToPage < monpage) {
-		g_music->newCheckMusic();
+		g_music->checkMusic();
 		CurText = (char *)(text + CharsDrawn);
 		CharsDrawn += flowText(BigMsgFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, CurText);
 		lastpage = (*CurText == 0);
@@ -1105,7 +1099,7 @@ static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1
 		Msg = getMsg();
 
 		if (Msg == NULL) {
-			g_music->newCheckMusic();
+			g_music->checkMusic();
 		} else {
 			Class     = Msg->Class;
 			Qualifier = Msg->Qualifier;
@@ -1113,8 +1107,6 @@ static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1
 			MouseY    = Msg->MouseY;
 			Code      = Msg->Code;
 
-			replyMsg(Msg);
-
 			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) ||
 			        ((Class == RAWKEY) && (Code == 27)))
 				return;
@@ -1242,7 +1234,7 @@ void doTrialBlock() {
 		Msg = getMsg();
 
 		if (Msg == NULL) {
-			g_music->newCheckMusic();
+			g_music->checkMusic();
 		} else {
 			Class     = Msg->Class;
 			Qualifier = Msg->Qualifier;
@@ -1250,8 +1242,6 @@ void doTrialBlock() {
 			MouseY    = Msg->MouseY;
 			Code      = Msg->Code;
 
-			replyMsg(Msg);
-
 			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) ||
 			        ((Class == RAWKEY) && (Code == 27)))
 				return;
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 388af2d..31477a7 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -38,11 +38,8 @@
 
 namespace Lab {
 
-//static uint16 NotInRefresh = 0;
-
 uint32 VGAScreenWidth = 320UL,
               VGAScreenHeight = 200UL,
-              VGAPages        = 1UL,
               VGABytesPerPage = 65536UL;
 
 byte *VGABASEADDRESS = 0;
@@ -76,7 +73,6 @@ bool createScreen(bool HiRes) {
 		VGAScreenWidth  = 320;
 		VGAScreenHeight = 200;
 	}
-	VGAPages        = 1;
 	VGABytesPerPage = VGAScreenWidth * VGAScreenHeight;
 
 	g_DisplayBuffer = (byte *)malloc(VGABytesPerPage);


Commit: a4bad804f61eb933532f9936e185c54ceaf2b285
    https://github.com/scummvm/scummvm/commit/a4bad804f61eb933532f9936e185c54ceaf2b285
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Get rid of sizeOfFile(), some cleanup

Changed paths:
    engines/lab/labfile.cpp
    engines/lab/labfun.h
    engines/lab/map.cpp
    engines/lab/text.cpp
    engines/lab/text.h



diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
index 43825f0..dfb7257 100644
--- a/engines/lab/labfile.cpp
+++ b/engines/lab/labfile.cpp
@@ -44,29 +44,6 @@ static byte *buffer = NULL, *realbufferstart = NULL, *startoffilestorage = NULL;
 byte **startoffile = &startoffilestorage;
 static uint32 buffersize, realbuffersize;
 
-int32 ReadSoFar;
-
-/*****************************************************************************/
-/* Returns the size of a file.                                               */
-/*****************************************************************************/
-uint32 sizeOfFile(const char *name) {
-	Common::File file;
-
-	file.open(translateFileName(name));
-	if (!file.isOpen()) {
-		warning("Cannot open file %s", translateFileName(name));
-
-		return 0;
-	}
-	uint32 size = file.size();
-	file.close();
-
-	return size;
-}
-
-
-
-
 /*-------------------- Routines that buffer a whole file --------------------*/
 
 
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index cd1e2df..ea0d3c8 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -136,8 +136,6 @@ bool quitPlaying();
 /*------ From LabFile.c -----*/
 /*---------------------------*/
 
-uint32 sizeOfFile(const char *name);
-
 /* Buffer a whole file */
 byte **isBuffered(const char *fileName);
 byte **openFile(const char *name, uint32 &size);
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 458ff21..cb51a51 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -59,20 +59,15 @@ extern uint16 RoomNum;
 /*****************************************************************************/
 void setAmigaPal(uint16 *pal, uint16 numcolors) {
 	byte vgapal[16 * 3];
-	uint16 counter, vgacount;
+	uint16 vgacount = 0;
 
 	if (numcolors > 16)
 		numcolors = 16;
 
-	vgacount = 0;
-
-	for (counter = 0; counter < numcolors; counter++) {
-		vgapal[vgacount]   = (byte)(((pal[counter] & 0xf00) >> 8) << 2);
-		vgacount++;
-		vgapal[vgacount] = (byte)(((pal[counter] & 0x0f0) >> 4) << 2);
-		vgacount++;
-		vgapal[vgacount] = (byte)(((pal[counter] & 0x00f)) << 2);
-		vgacount++;
+	for (uint16 counter = 0; counter < numcolors; counter++) {
+		vgapal[vgacount++] = (byte)(((pal[counter] & 0xf00) >> 8) << 2);
+		vgapal[vgacount++] = (byte)(((pal[counter] & 0x0f0) >> 4) << 2);
+		vgapal[vgacount++] = (byte)(((pal[counter] & 0x00f)) << 2);
 	}
 
 	writeColorRegsSmooth(vgapal, 0, 16);
@@ -83,18 +78,39 @@ void setAmigaPal(uint16 *pal, uint16 numcolors) {
 /* Gets a font from disk and puts it into temporary memory.                  */
 /*****************************************************************************/
 bool getFont(const char *filename, TextFont *textfont) {
-	byte *fontbuffer;
+	byte **file = NULL;
+	char header[5];
+	uint32 filesize, headersize = 4L + 2L + 256 * 3 + 4L;
 
-	fontbuffer = (byte *)stealBufMem(sizeOfFile(filename) - (sizeof(TextFont) + 4));
+	file = g_music->newOpen(filename, filesize);
 	g_music->checkMusic();
 
-	if (fontbuffer == NULL)
-		return false;
+	if ((file != NULL) && (filesize > headersize)) {
+		byte *fontbuffer = (byte *)stealBufMem(filesize - (sizeof(TextFont) + 4));
+		if (!fontbuffer)
+			return false;
 
-	return openFontMem(filename, textfont, fontbuffer);
-}
+		header[4] = 0;
+		readBlock(&header, 4L, file);
+
+		if (strcmp(header, "VGAF") == 0) {
+			textfont->DataLength = filesize - headersize;
+			readBlock(&(textfont->Height), 2L, file);
+			swapUShortPtr(&(textfont->Height), 1);
+
+			readBlock(textfont->Widths, 256L, file);
+			readBlock(textfont->Offsets, 256L * 2L, file);
+			swapUShortPtr(textfont->Offsets, 256);
 
+			skip(file, 4L);
+			textfont->data = fontbuffer;
+			readBlock(textfont->data, textfont->DataLength, file);
+			return true;
+		}
+	}
 
+	return false;
+}
 
 
 /*****************************************************************************/
diff --git a/engines/lab/text.cpp b/engines/lab/text.cpp
index 5056d24..5120a19 100644
--- a/engines/lab/text.cpp
+++ b/engines/lab/text.cpp
@@ -36,40 +36,6 @@
 namespace Lab {
 
 /*****************************************************************************/
-/* Opens up a font from disk, but uses buffer memory to store it in.         */
-/*****************************************************************************/
-bool openFontMem(const char *TextFontPath, struct TextFont *tf, byte *fontbuffer) {
-	byte **file = NULL;
-	char header[5];
-	uint32 filesize, headersize = 4L + 2L + 256 * 3 + 4L;
-
-	file = g_music->newOpen(TextFontPath, filesize);
-
-	if ((file != NULL) && (filesize > headersize)) {
-		header[4] = 0;
-		readBlock(&header, 4L, file);
-
-		if (strcmp(header, "VGAF") == 0) {
-			tf->DataLength = filesize - headersize;
-			readBlock(&(tf->Height), 2L, file);
-			swapUShortPtr(&(tf->Height), 1);
-
-			readBlock(tf->Widths, 256L, file);
-			readBlock(tf->Offsets, 256L * 2L, file);
-			swapUShortPtr(tf->Offsets, 256);
-
-			skip(file, 4L);
-			tf->data = fontbuffer;
-			readBlock(tf->data, tf->DataLength, file);
-			return true;
-		}
-	}
-
-	return false;
-}
-
-
-/*****************************************************************************/
 /* Opens up a font from disk.                                                */
 /*****************************************************************************/
 bool openFont(const char *TextFontPath, struct TextFont **tf) {
@@ -145,10 +111,7 @@ uint16 textLength(struct TextFont *tf, const char *text, uint16 numchars) {
 /* Returns the height of a specified font.                                   */
 /*****************************************************************************/
 uint16 textHeight(struct TextFont *tf) {
-	if (tf)
-		return tf->Height;
-	else
-		return 0;
+	return (tf) ? tf->Height : 0;
 }
 
 
@@ -177,8 +140,7 @@ void text(struct TextFont *tf, uint16 x, uint16 y, uint16 color, const char *tex
 
 		if (tf->Widths[(uint)*text]) {
 			cdata = tf->data + tf->Offsets[(uint)*text];
-			bwidth = *cdata;
-			cdata++;
+			bwidth = *cdata++;
 			VGATemp = VGACur;
 			VGATempLine = VGACur;
 
@@ -187,49 +149,14 @@ void text(struct TextFont *tf, uint16 x, uint16 y, uint16 color, const char *tex
 				templeft = LeftInSegment;
 
 				for (cols = 0; cols < bwidth; cols++) {
-					data = *cdata;
-					cdata++;
+					data = *cdata++;
 
 					if (data && (templeft >= 8)) {
-						if (0x80 & data)
-							*VGATemp = color;
-
-						VGATemp++;
-
-						if (0x40 & data)
-							*VGATemp = color;
-
-						VGATemp++;
-
-						if (0x20 & data)
-							*VGATemp = color;
-
-						VGATemp++;
-
-						if (0x10 & data)
-							*VGATemp = color;
-
-						VGATemp++;
-
-						if (0x08 & data)
-							*VGATemp = color;
-
-						VGATemp++;
-
-						if (0x04 & data)
-							*VGATemp = color;
-
-						VGATemp++;
-
-						if (0x02 & data)
-							*VGATemp = color;
-
-						VGATemp++;
-
-						if (0x01 & data)
-							*VGATemp = color;
-
-						VGATemp++;
+						for (int i = 7; i >= 0; i--) {
+							if ((1 << i) & data)
+								*VGATemp = color;
+							VGATemp++;
+						}
 
 						templeft -= 8;
 					} else if (data) {
diff --git a/engines/lab/text.h b/engines/lab/text.h
index 944b363..333f449 100644
--- a/engines/lab/text.h
+++ b/engines/lab/text.h
@@ -52,7 +52,6 @@ struct TextFont {
 #pragma pack(pop)
 #endif
 
-bool openFontMem(const char *TextFontPath, TextFont *tf, byte *fontbuffer);
 bool openFont(const char *TextFontPath, TextFont **tf);
 void closeFont(TextFont *tf);
 uint16 textLength(TextFont *tf, const char *text, uint16 numchars);


Commit: 77f4a10901d749b3e0f01c9ecde4948e8ceb65a5
    https://github.com/scummvm/scummvm/commit/77f4a10901d749b3e0f01c9ecde4948e8ceb65a5
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Remove dead code

Changed paths:
    engines/lab/allocroom.cpp
    engines/lab/labfile.cpp
    engines/lab/labfun.h
    engines/lab/map.cpp
    engines/lab/undiff.cpp



diff --git a/engines/lab/allocroom.cpp b/engines/lab/allocroom.cpp
index e6dad3b..434a147 100644
--- a/engines/lab/allocroom.cpp
+++ b/engines/lab/allocroom.cpp
@@ -40,16 +40,12 @@ namespace Lab {
 #define MAXMARKERS     10
 
 extern RoomData *Rooms;
-extern uint16 ManyRooms;
-
 
 typedef struct {
 	uint16 RoomNum;
 	void *Start0, *End0, *Start1, *End1;
 } RoomMarker;
 
-
-
 static RoomMarker RoomMarkers[MAXMARKERS];
 static void *RoomBuffer = NULL;
 static uint16 CurMarker  = 0;
diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
index dfb7257..231c63a 100644
--- a/engines/lab/labfile.cpp
+++ b/engines/lab/labfile.cpp
@@ -34,10 +34,6 @@
 
 namespace Lab {
 
-#define MAXREADSIZE 30720L
-/* NOTE: set to 0 for non-CDTV machines.          */
-
-
 
 static byte *buffer = NULL, *realbufferstart = NULL, *startoffilestorage = NULL;
 
@@ -46,16 +42,9 @@ static uint32 buffersize, realbuffersize;
 
 /*-------------------- Routines that buffer a whole file --------------------*/
 
-
-
-/*----- divides up and manages the buffer -----*/
-
-
-
 #define MAXMARKERS        15
 
 
-
 struct FileMarker {
 	char name[32];
 	void *Start, *End;
@@ -182,7 +171,6 @@ bool allocFile(void **Ptr, uint32 Size, const char *fileName) {
 /*****************************************************************************/
 byte **openFile(const char *name, uint32 &size) {
 	byte *buf;
-
 	Common::File file;
 
 	file.open(translateFileName(name));
@@ -195,10 +183,8 @@ byte **openFile(const char *name, uint32 &size) {
 	size = file.size();
 
 	buf = (byte *)malloc(size);
-
-	if (!buf) {
+	if (!buf)
 		error("Unable to allocate %d bytes file file %s", size, name);
-	}
 
 	*startoffile = buf;
 
@@ -208,7 +194,6 @@ byte **openFile(const char *name, uint32 &size) {
 }
 
 
-
 /*****************************************************************************/
 /* Reads a block of memory.                                                  */
 /*****************************************************************************/
@@ -217,30 +202,6 @@ void readBlock(void *Buffer, uint32 Size, byte **File) {
 	(*File) += Size;
 }
 
-
-
-/*****************************************************************************/
-/* Reads on character.                                                       */
-/*****************************************************************************/
-char readChar(char **File) {
-	char c = **File;
-
-	(*File)++;
-	return c;
-}
-
-
-
-
-/*****************************************************************************/
-/* Skips a chunk of memory.                                                  */
-/*****************************************************************************/
-void skip(byte **File, uint32 skip) {
-	(*File) += skip;
-}
-
-
-
 /*****************************************************************************/
 /* Resets the internal buffers to empty.                                     */
 /*****************************************************************************/
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index ea0d3c8..9655c24 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -140,8 +140,6 @@ bool quitPlaying();
 byte **isBuffered(const char *fileName);
 byte **openFile(const char *name, uint32 &size);
 void readBlock(void *Buffer, uint32 Size, byte **File);
-char readChar(char **File);
-void skip(byte **File, uint32 skip);
 void resetBuffer();
 bool initBuffer(uint32 BufSize, bool IsGraphicsMem);
 void freeBuffer();
@@ -280,7 +278,6 @@ void showCombination(const char *filename);
 void mouseCombination(uint16 x, uint16 y);
 void showTile(const char *filename, bool showsolution);
 void mouseTile(uint16 x, uint16 y);
-void inner_main();
 
 } // End of namespace Lab
 
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index cb51a51..a3cae9b 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -163,7 +163,6 @@ void readImage(byte **buffer, Image **im) {
 /*---------------------------------------------------------------------------*/
 
 extern RoomData *Rooms;
-extern const char *ViewPath;
 
 static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge,
 			 *HRoom, *VRoom, *Maze, *HugeMaze, *Path, *MapNorth,
diff --git a/engines/lab/undiff.cpp b/engines/lab/undiff.cpp
index bc4eacc..d9d53a3 100644
--- a/engines/lab/undiff.cpp
+++ b/engines/lab/undiff.cpp
@@ -322,39 +322,13 @@ bool VUnDIFFMemory(byte *Dest, byte *diff, uint16 HeaderSize, uint16 CopySize, u
 
 		else
 			return false;
-	}
-	/*
-	   else if (HeaderSize == 2)
-	   {
-	    if (CopySize == 1)
-	      VUnDIFFWordByte(Dest, diff, bytesperrow);
-
-	    else if (CopySize == 2)
-	      VUnDIFFWordWord(Dest, diff, bytesperrow);
-
-	    else if (CopySize == 4)
-	      VUnDIFFWordLong(Dest, diff, bytesperrow);
-
-	    else
-	      return false;
-	   }
-	 */
-	else
+	} else
 		return (false);
 
 	return true;
 }
 
 
-
-
-
-/*---------------------------- Runlength Decodes ----------------------------*/
-
-
-
-
-
 /*****************************************************************************/
 /* Runlength decodes a chunk of memory.                                      */
 /*****************************************************************************/


Commit: b1eb345f8076806ce73cd41ecae51b14be121a34
    https://github.com/scummvm/scummvm/commit/b1eb345f8076806ce73cd41ecae51b14be121a34
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Move some static variables to the top. Some cleanup

Changed paths:
    engines/lab/savegame.cpp
    engines/lab/text.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 4d40540..a32971b 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -58,6 +58,7 @@ extern CrumbData BreadCrumbs[MAX_CRUMBS];
 extern uint16 NumCrumbs;
 extern bool DroppingCrumbs;
 extern bool FollowingCrumbs;
+extern char *getPictName(CloseDataPtr *LCPtr);
 
 void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName) {
 	out->writeUint32BE(SAVEGAME_ID);
@@ -128,8 +129,6 @@ bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
 	return true;
 }
 
-extern char *getPictName(CloseDataPtr *LCPtr);
-
 /*****************************************************************************/
 /* Writes the game out to disk.                                              */
 /*****************************************************************************/
diff --git a/engines/lab/text.cpp b/engines/lab/text.cpp
index 5120a19..e99114e 100644
--- a/engines/lab/text.cpp
+++ b/engines/lab/text.cpp
@@ -35,6 +35,8 @@
 
 namespace Lab {
 
+extern uint32 VGAScreenWidth, VGABytesPerPage;
+
 /*****************************************************************************/
 /* Opens up a font from disk.                                                */
 /*****************************************************************************/
@@ -59,7 +61,7 @@ bool openFont(const char *TextFontPath, struct TextFont **tf) {
 				readBlock((*tf)->Offsets, 256L * 2L, file);
 				swapUShortPtr((*tf)->Offsets, 256);
 
-				skip(file, 4L);
+				(*file) += 4;
 
 				if (((*tf)->data = (byte *)calloc((*tf)->DataLength, 1))) {
 					readBlock((*tf)->data, (*tf)->DataLength, file);
@@ -75,7 +77,6 @@ bool openFont(const char *TextFontPath, struct TextFont **tf) {
 	return false;
 }
 
-
 /*****************************************************************************/
 /* Closes a font and frees all memory associated with it.                    */
 /*****************************************************************************/
@@ -88,8 +89,6 @@ void closeFont(struct TextFont *tf) {
 	}
 }
 
-
-
 /*****************************************************************************/
 /* Returns the length of a text in the specified font.                       */
 /*****************************************************************************/
@@ -114,11 +113,6 @@ uint16 textHeight(struct TextFont *tf) {
 	return (tf) ? tf->Height : 0;
 }
 
-
-
-extern uint32 VGAScreenWidth, VGABytesPerPage;
-
-
 /*****************************************************************************/
 /* Draws the text to the screen.                                             */
 /*****************************************************************************/
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 31477a7..7b74576 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -38,6 +38,9 @@
 
 namespace Lab {
 
+static byte curvgapal[256 * 3];
+static unsigned char curapen = 0;
+
 uint32 VGAScreenWidth = 320UL,
               VGAScreenHeight = 200UL,
               VGABytesPerPage = 65536UL;
@@ -58,6 +61,7 @@ uint16 g_NextKeyIn = 0;
 uint16 g_KeyBuf[64];
 uint16 g_NextKeyOut = 0;
 bool g_MouseAtEdge = false;
+byte *TempScrollData;
 
 /*****************************************************************************/
 /* Sets up either a low-res or a high-res 256 color screen.                  */
@@ -245,8 +249,6 @@ void WSDL_SetColors(byte *buf, uint16 first, uint16 numreg, uint16 slow) {
     	waitTOF();
 }
 
-static byte curvgapal[256 * 3];
-
 /*****************************************************************************/
 /* Writes any number of the 256 color registers.                             */
 /* first:    the number of the first color register to write.                */
@@ -467,9 +469,6 @@ void readScreenImage(Image *Im, uint16 x, uint16 y) {
 	}
 }
 
-
-
-
 /*****************************************************************************/
 /* Blits a piece of one image to another.                                    */
 /* NOTE: for our purposes, assumes that ImDest is to be in VGA memory.       */
@@ -515,8 +514,6 @@ void bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest,
 	}
 }
 
-byte *TempScrollData;
-
 /*****************************************************************************/
 /* Scrolls the display in the x direction by blitting.                       */
 /* The TempScrollData variable must be initialized to some memory, or this   */
@@ -603,8 +600,6 @@ void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	}
 }
 
-static unsigned char curapen = 0;
-
 /*****************************************************************************/
 /* Sets the pen number to use on all the drawing operations.                 */
 /*****************************************************************************/


Commit: da0ee48ab941185749f639e884b79e9892dfca82
    https://github.com/scummvm/scummvm/commit/da0ee48ab941185749f639e884b79e9892dfca82
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Remove the fillUpMusic() and checkMusic() wrappers. Some cleanup

Changed paths:
    engines/lab/intro.cpp
    engines/lab/map.cpp



diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index c430b61..16a54ff 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -39,25 +39,13 @@
 namespace Lab {
 
 static TextFont filler, *msgfont = &filler;
+static bool QuitIntro = false, IntroDoBlack;
 
-extern bool nopalchange, hidemouse, DoBlack, NoFlip, IsHiRes;
-
+extern bool nopalchange, DoBlack, IsHiRes;
 extern char diffcmap[256 * 3];
-
 extern uint32 VGAScreenWidth, VGAScreenHeight;
-
-
 extern uint16 *FadePalette;
 
-static uint16 Palette[16] = {
-	0x0000, 0x0855, 0x0FF9, 0x0EE7, 0x0ED5, 0x0DB4, 0x0CA2, 0x0C91, 0x0B80, 0x0B80, 0x0B91, 0x0CA2, 0x0CB3, 0x0DC4, 0x0DD6, 0x0EE7
-};
-
-
-static bool QuitIntro = false, IntroDoBlack;
-extern int32 longcharsdrawn;
-
-
 
 /******************************************************************************/
 /* Goes thru, and responds to all the intuition messages currently in the     */
@@ -105,10 +93,10 @@ static void doPictText(const char *Filename, bool isscreen) {
 	strcat(filename, Filename);
 
 	if (isscreen) {
-		g_music->fillUpMusic(true);
+		g_music->updateMusic();
 		timedelay = 35;
 	} else {
-		g_music->checkMusic();
+		g_music->updateMusic();
 		timedelay = 7;
 	}
 
@@ -160,7 +148,7 @@ static void doPictText(const char *Filename, bool isscreen) {
 		Msg = getMsg();
 
 		if (Msg == NULL) {
-			g_music->checkMusic();
+			g_music->updateMusic();
 			diffNextFrame();
 
 			getTime(&secs, &micros);
@@ -235,13 +223,13 @@ static void doPictText(const char *Filename, bool isscreen) {
 void musicDelay() {
 	int16 counter;
 
-	g_music->checkMusic();
+	g_music->updateMusic();
 
 	if (QuitIntro)
 		return;
 
 	for (counter = 0; counter < 20; counter++) {
-		g_music->checkMusic();
+		g_music->updateMusic();
 		waitTOF();
 		waitTOF();
 		waitTOF();
@@ -253,7 +241,7 @@ void musicDelay() {
 static void NReadPict(const char *Filename, bool PlayOnce) {
 	Common::String finalFileName = "P:Intro/";
 
-	g_music->checkMusic();
+	g_music->updateMusic();
 	introEatMessages();
 
 	if (QuitIntro)
@@ -272,6 +260,10 @@ static void NReadPict(const char *Filename, bool PlayOnce) {
 /*****************************************************************************/
 void introSequence() {
 	uint16 counter, counter1;
+	
+	uint16 Palette[16] = {
+		0x0000, 0x0855, 0x0FF9, 0x0EE7, 0x0ED5, 0x0DB4, 0x0CA2, 0x0C91, 0x0B80, 0x0B80, 0x0B91, 0x0CA2, 0x0CB3, 0x0DC4, 0x0DD6, 0x0EE7
+	};
 
 	DoBlack = true;
 
@@ -313,14 +305,14 @@ void introSequence() {
 		                   (diffcmap[counter * 3 + 2] >> 2);
 	}
 
-	g_music->checkMusic();
+	g_music->updateMusic();
 	fade(true, 0);
 
 	for (int times = 0; times < 150; times++) {
 		if (QuitIntro)
 			break;
 
-		g_music->checkMusic();
+		g_music->updateMusic();
 		uint16 temp = Palette[2];
 
 		for (counter = 2; counter < 15; counter++)
@@ -335,7 +327,7 @@ void introSequence() {
 	fade(false, 0);
 	blackAllScreen();
 
-	g_music->checkMusic();
+	g_music->updateMusic();
 
 	NReadPict("Title.A", true);
 	NReadPict("AB", true);
@@ -359,9 +351,9 @@ void introSequence() {
 
 	g_music->newOpen("p:Intro/Intro.1");  /* load the picture into the buffer */
 
-	g_music->checkMusic();
+	g_music->updateMusic();
 	blackAllScreen();
-	g_music->fillUpMusic(true);
+	g_music->updateMusic();
 
 	getFont("P:Map.fon", msgfont);
 
@@ -382,7 +374,7 @@ void introSequence() {
 	freeAllStolenMem();
 
 	blackAllScreen();
-	g_music->fillUpMusic(true);
+	g_music->updateMusic();
 
 	IntroDoBlack = true;
 	NReadPict("Station1", true);
@@ -414,7 +406,7 @@ void introSequence() {
 			for (counter1 = (8 * 3); counter1 < (255 * 3); counter1++)
 				diffcmap[counter1] = 255 - diffcmap[counter1];
 
-			g_music->checkMusic();
+			g_music->updateMusic();
 			waitTOF();
 			VGASetPal(diffcmap, 256);
 			waitTOF();
@@ -479,8 +471,6 @@ void introSequence() {
 		rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1);
 		DoBlack = true;
 	}
-
-	hidemouse = false;
 }
 
 } // End of namespace Lab
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index a3cae9b..3b2eaf6 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -83,7 +83,7 @@ bool getFont(const char *filename, TextFont *textfont) {
 	uint32 filesize, headersize = 4L + 2L + 256 * 3 + 4L;
 
 	file = g_music->newOpen(filename, filesize);
-	g_music->checkMusic();
+	g_music->updateMusic();
 
 	if ((file != NULL) && (filesize > headersize)) {
 		byte *fontbuffer = (byte *)stealBufMem(filesize - (sizeof(TextFont) + 4));
@@ -102,7 +102,7 @@ bool getFont(const char *filename, TextFont *textfont) {
 			readBlock(textfont->Offsets, 256L * 2L, file);
 			swapUShortPtr(textfont->Offsets, 256);
 
-			skip(file, 4L);
+			(*file) += 4;
 			textfont->data = fontbuffer;
 			readBlock(textfont->data, textfont->DataLength, file);
 			return true;
@@ -120,7 +120,7 @@ char *getText(const char *filename) {
 	bool dodecrypt;
 	byte **tfile;
 
-	g_music->checkMusic();
+	g_music->updateMusic();
 	dodecrypt = (isBuffered(filename) == NULL);
 	tfile = g_music->newOpen(filename);
 
@@ -624,7 +624,7 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b
 		        && g_lab->_roomsFound->in(drawroom)
 		        && Maps[drawroom].x) {
 			drawRoom(drawroom, (bool)(drawroom == CurRoom));
-			g_music->checkMusic();
+			g_music->updateMusic();
 		}
 	}
 
@@ -729,11 +729,11 @@ void processMap(uint16 CurRoom) {
 	CurFloor = Maps[CurRoom].PageNumber;
 
 	while (1) {
-		g_music->checkMusic();  /* Make sure we check the music at least after every message */
+		g_music->updateMusic();  /* Make sure we check the music at least after every message */
 		Msg = getMsg();
 
 		if (Msg == NULL) {
-			g_music->checkMusic();
+			g_music->updateMusic();
 
 			if (place <= 14) {
 				newcolor[0] = 14 << 2;
@@ -893,7 +893,7 @@ void processMap(uint16 CurRoom) {
 void doMap(uint16 CurRoom) {
 	FadePalette = AmigaMapPalette;
 
-	g_music->checkMusic();
+	g_music->updateMusic();
 	loadMapData();
 	blackAllScreen();
 


Commit: 75882daa498618bba82fe9494f6d7b803e5e8c46
    https://github.com/scummvm/scummvm/commit/75882daa498618bba82fe9494f6d7b803e5e8c46
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Simplify decrypt()

Changed paths:
    engines/lab/labtext.cpp



diff --git a/engines/lab/labtext.cpp b/engines/lab/labtext.cpp
index 4284865..568ad82 100644
--- a/engines/lab/labtext.cpp
+++ b/engines/lab/labtext.cpp
@@ -154,12 +154,8 @@ void freeLabText() {
 /* Decrypts a chunk of text.                                                 */
 /*****************************************************************************/
 void decrypt(byte *text) {
-	if (text == NULL)
-		return;
-
-	while (*text != '\0') {
-		(*text) -= (byte)95;
-		text++;
+	while (text && *text != '\0') {
+		*text++ -= (byte)95;
 	}
 }
 


Commit: df3200ef0c0bc590f03888a26e49e52da51d53ce
    https://github.com/scummvm/scummvm/commit/df3200ef0c0bc590f03888a26e49e52da51d53ce
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Simplify readViews()

Changed paths:
    engines/lab/map.cpp
    engines/lab/parsefun.h
    engines/lab/processroom.cpp



diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 3b2eaf6..2e3dffc 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -855,7 +855,7 @@ void processMap(uint16 CurRoom) {
 
 					if (OldMsg != CurMsg) {
 						if (Rooms[CurMsg].RoomMsg == NULL)
-							readViews(CurMsg, ViewPath);
+							readViews(CurMsg);
 
 						if ((sptr = Rooms[CurMsg].RoomMsg)) {
 							mouseHide();
diff --git a/engines/lab/parsefun.h b/engines/lab/parsefun.h
index f5929ae..b75368d 100644
--- a/engines/lab/parsefun.h
+++ b/engines/lab/parsefun.h
@@ -52,7 +52,7 @@ void allocRoom(void **Ptr, uint16 Size, uint16 RoomNum);
 
 bool readRoomData(const char *fileName);
 bool readInventory(const char *fileName);
-bool readViews(uint16 RoomNum, const char *Path);
+bool readViews(uint16 RoomNum);
 
 
 /* From ProcessRoom.c */
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 9d501e6..c6acf36 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -116,7 +116,7 @@ ViewDataPtr getViewData(uint16 roomNum, uint16 direction) {
 		VPtr = &Rooms[roomNum].WestView;
 
 	if (*VPtr == NULL)
-		readViews(roomNum, ViewPath);
+		readViews(roomNum);
 
 	ViewPtr = *VPtr;
 
@@ -187,9 +187,7 @@ static CloseDataPtr findCPtrMatch(CloseDataPtr Main, CloseDataPtr List) {
 /* Returns the current picture name.                                         */
 /*****************************************************************************/
 char *getPictName(CloseDataPtr *LCPtr) {
-	ViewDataPtr ViewPtr;
-
-	ViewPtr = getViewData(RoomNum, Direction);
+	ViewDataPtr ViewPtr = getViewData(RoomNum, Direction);
 
 	if (*LCPtr != NULL) {
 		*LCPtr = findCPtrMatch(*LCPtr, ViewPtr->closeUps);
@@ -675,7 +673,7 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr LCPtr, Clo
 		RPtr = Rooms[roomNum].RuleList;
 
 		if ((RPtr == NULL) && (roomNum == 0)) {
-			readViews(roomNum, ViewPath);
+			readViews(roomNum);
 			RPtr = Rooms[roomNum].RuleList;
 		}
 
@@ -737,7 +735,7 @@ static bool doOperateRuleSub(int16 ItemNum, int16 roomNum, CloseDataPtr LCPtr, C
 			RPtr = Rooms[roomNum].RuleList;
 
 			if ((RPtr == NULL) && (roomNum == 0)) {
-				readViews(roomNum, ViewPath);
+				readViews(roomNum);
 				RPtr = Rooms[roomNum].RuleList;
 			}
 


Commit: 524d30ee169046440696fe5861a3bcee9b7dabea
    https://github.com/scummvm/scummvm/commit/524d30ee169046440696fe5861a3bcee9b7dabea
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Cleanup

Changed paths:
    engines/lab/parsetypes.h



diff --git a/engines/lab/parsetypes.h b/engines/lab/parsetypes.h
index c409750..0f9ec50 100644
--- a/engines/lab/parsetypes.h
+++ b/engines/lab/parsetypes.h
@@ -201,10 +201,10 @@ struct MapData {
 #pragma pack(pop)
 #endif
 
-typedef struct {
+struct CrumbData {
 	uint16 RoomNum;
 	uint16 Direction;
-} CrumbData;
+};
 
 #define MAX_CRUMBS          128
 


Commit: eae0773b41143bd0bca7280d62e98c4baf78ab0d
    https://github.com/scummvm/scummvm/commit/eae0773b41143bd0bca7280d62e98c4baf78ab0d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Move more static variables to the top

Changed paths:
    engines/lab/special.cpp



diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 57f3284..2cd383d 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -47,26 +47,69 @@
 
 namespace Lab {
 
-extern bool nopalchange, DoBlack, IsHiRes;
-
-extern BitMap *DispBitMap, *DrawBitMap;
-extern char diffcmap[3 * 256];
+static uint16 MonGadHeight = 1;
+static uint16 hipal[20];
 
-extern uint32 VGAScreenWidth, VGAScreenHeight;
+// Combination lock rules
+static Image *Images[10];
+byte combination[6] = { 0, 0, 0, 0, 0, 0 }, solution[] = { 0, 4, 0, 8, 7, 2 };
+static uint16 combx[] = { 45, 83, 129, 166, 211, 248 };
 
+static TextFont *BigMsgFont;
+static TextFont bmfont;
+static char *journaltext, *journaltexttitle;
+static uint16 JPage = 0;
+static bool lastpage = false;
+static Image *JCancel, *JCancelAlt, *JLeft, *JLeftAlt, *JRight, *JRightAlt, JBackImage, ScreenImage;
+static uint16 JGadX[3] = { 80, 144, 194 }, JGadY[3] = { 162, 164, 162 };
+static Gadget ForwardG, CancelG, BackG;
+static bool GotBackImage = false;
+static uint16 monpage;
+static const char *TextFileName;
 
-#define COMBINATIONUNLOCKED  130
-#define BRICKOPEN            115
+Image *MonButton, *AltMonButton, *MonQuit, *AltMonQuit, *MonBack, *AltMonBack,
+*MonDown, *AltMonDown, *MonUp, *AltMonUp;
 
+// Tile puzzle rules
+Image *Tiles[16];
+uint16 CurTile[4][4] = {
+	{ 1, 5, 9, 13 },
+	{ 2, 6, 10, 14 },
+	{ 3, 7, 11, 15 },
+	{ 4, 8, 12, 0 }
+}, TileSolution[4][4] = {
+	{ 7, 1, 8, 3 },
+	{ 2, 11, 15, 4 },
+	{ 9, 5, 14, 6 },
+	{ 10, 13, 12, 0 }
+};
 
-static uint16 hipal[20];
+extern TextFont *MsgFont;
 extern uint16 *FadePalette;
+extern bool nopalchange, DoBlack, IsHiRes;
+extern BitMap *DispBitMap, *DrawBitMap;
+extern char diffcmap[3 * 256];
+extern uint32 VGAScreenWidth, VGAScreenHeight;
+extern byte *TempScrollData;
+extern CloseDataPtr CPtr;
+extern InventoryData *Inventory;
+extern uint16 RoomNum, Direction;
 
+#define COMBINATIONUNLOCKED  130
+#define BRICKOPEN            115
 #define INCL(BITSET,BIT) ((BITSET) |= (BIT))
-
 #define SETBIT(BITSET,BITNUM)   INCL(BITSET, (1 << (BITNUM)))
-
 #define INBIT(BITSET,BITNUM)    ( ((1 << (BITNUM)) & (BITSET)) > 0 )
+#define LEFTSCROLL     1
+#define RIGHTSCROLL    2
+#define UPSCROLL       3
+#define DOWNSCROLL     4
+#define BRIDGE0   148
+#define BRIDGE1   104
+#define DIRTY     175
+#define NONEWS    135
+#define NOCLEAN   152
+#define QUARTERNUM           30
 
 
 static byte *loadBackPict(const char *fileName, bool tomem) {
@@ -92,24 +135,6 @@ static byte *loadBackPict(const char *fileName, bool tomem) {
 	return res;
 }
 
-
-
-/*----------------------------------------------------------------------------*/
-/*-------------------------- Combination Lock Rules --------------------------*/
-/*----------------------------------------------------------------------------*/
-
-
-
-
-static Image *Images[10];
-
-
-byte combination[6] = {0, 0, 0, 0, 0, 0}, solution[] = {0, 4, 0, 8, 7, 2};
-
-static uint16 combx[] = {45, 83, 129, 166, 211, 248};
-
-
-
 /*****************************************************************************/
 /* Draws the images of the combination lock to the display bitmap.           */
 /*****************************************************************************/
@@ -120,9 +145,6 @@ static void doCombination() {
 		drawImage(Images[combination[counter]], VGAScaleX(combx[counter]), VGAScaleY(65));
 }
 
-
-extern byte *TempScrollData;
-
 /*****************************************************************************/
 /* Reads in a backdrop picture.                                              */
 /*****************************************************************************/
@@ -197,9 +219,6 @@ static void changeCombination(uint16 number) {
 }
 
 
-
-
-
 /*****************************************************************************/
 /* Processes mouse clicks and changes the combination.                       */
 /*****************************************************************************/
@@ -229,26 +248,6 @@ void mouseCombination(uint16 x, uint16 y) {
 	}
 }
 
-
-
-/*----------------------------------------------------------------------------*/
-/*----------------------------- Tile Puzzle Rules ----------------------------*/
-/*----------------------------------------------------------------------------*/
-
-Image *Tiles[16];
-uint16 CurTile[4] [4] = {
-	{ 1, 5,  9, 13 },
-	{ 2, 6, 10, 14 },
-	{ 3, 7, 11, 15 },
-	{ 4, 8, 12,  0 }
-}, TileSolution[4] [4] = {
-	{ 7,   1,  8,  3 },
-	{ 2,  11, 15,  4 },
-	{ 9,   5, 14,  6 },
-	{ 10, 13, 12,  0}
-};
-
-
 /*****************************************************************************/
 /* Draws the images of the combination lock to the display bitmap.           */
 /*****************************************************************************/
@@ -291,9 +290,6 @@ static void doTile(bool showsolution) {
 	}
 }
 
-
-
-
 /*****************************************************************************/
 /* Reads in a backdrop picture.                                              */
 /*****************************************************************************/
@@ -329,16 +325,6 @@ void showTile(const char *filename, bool showsolution) {
 	VGASetPal(diffcmap, 256);
 }
 
-
-
-#define LEFTSCROLL     1
-#define RIGHTSCROLL    2
-#define UPSCROLL       3
-#define DOWNSCROLL     4
-
-
-
-
 static void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	if (dx)
 		scrollDisplayX(dx, x1, y1, x2, y2);
@@ -347,9 +333,6 @@ static void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, ui
 		scrollDisplayY(dy, x1, y1, x2, y2);
 }
 
-
-
-
 /*****************************************************************************/
 /* Does the scrolling for the tiles on the tile puzzle.                      */
 /*****************************************************************************/
@@ -391,8 +374,6 @@ static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 	}
 }
 
-
-
 /*****************************************************************************/
 /* Changes the combination number of one of the slots                        */
 /*****************************************************************************/
@@ -468,9 +449,6 @@ static void changeTile(uint16 col, uint16 row) {
 }
 
 
-
-
-
 /*****************************************************************************/
 /* Processes mouse clicks and changes the combination.                       */
 /*****************************************************************************/
@@ -489,15 +467,6 @@ void mouseTile(uint16 x, uint16 y) {
 }
 
 
-/*---------------------------------------------------------------------------*/
-/*------------------------ Does the detective notes. ------------------------*/
-/*---------------------------------------------------------------------------*/
-
-extern TextFont *MsgFont;
-static TextFont *BigMsgFont;
-static TextFont bmfont;
-
-
 /*****************************************************************************/
 /* Does the things to properly set up the detective notes.                   */
 /*****************************************************************************/
@@ -522,14 +491,6 @@ void doNotes() {
 }
 
 
-
-
-/*---------------------------------------------------------------------------*/
-/*---------------------- Does the Old West newspaper.  ----------------------*/
-/*---------------------------------------------------------------------------*/
-
-
-
 /*****************************************************************************/
 /* Does the things to properly set up the old west newspaper.  Assumes that  */
 /* OpenHiRes already called.                                                 */
@@ -591,34 +552,6 @@ void doWestPaper() {
 	freeAllStolenMem();
 }
 
-
-
-
-/*---------------------------------------------------------------------------*/
-/*---------------------------- The Journal stuff ----------------------------*/
-/*---------------------------------------------------------------------------*/
-
-
-#define BRIDGE0   148
-#define BRIDGE1   104
-#define DIRTY     175
-#define NONEWS    135
-#define NOCLEAN   152
-
-
-static char *journaltext, *journaltexttitle;
-static uint16 JPage = 0;
-
-static bool lastpage = false;
-
-static Image *JCancel, *JCancelAlt, *JLeft, *JLeftAlt, *JRight, *JRightAlt, JBackImage, ScreenImage;
-
-static uint16 JGadX[3] = {80, 144, 194}, JGadY[3] = {162, 164, 162};
-static Gadget ForwardG, CancelG, BackG;
-
-
-
-
 /*****************************************************************************/
 /* Loads in the data for the journal.                                        */
 /*****************************************************************************/
@@ -710,8 +643,6 @@ static bool loadJournalData() {
 	return true;
 }
 
-
-
 /*****************************************************************************/
 /* Draws the text to the back journal screen to the appropriate Page number  */
 /*****************************************************************************/
@@ -750,9 +681,6 @@ static void drawJournalText() {
 	lastpage = lastpage || (*CurText == 0);
 }
 
-
-
-
 /*****************************************************************************/
 /* Does the turn page wipe.                                                  */
 /*****************************************************************************/
@@ -777,9 +705,6 @@ static void turnPage(bool FromLeft) {
 }
 
 
-
-static bool GotBackImage = false;
-
 /*****************************************************************************/
 /* Draws the journal from page x.                                            */
 /*****************************************************************************/
@@ -826,9 +751,6 @@ static void drawJournal(uint16 wipenum, bool needFade) {
 	nopalchange = false;
 }
 
-
-
-
 /*****************************************************************************/
 /* Processes user input.                                                     */
 /*****************************************************************************/
@@ -871,8 +793,6 @@ static void processJournal() {
 	}
 }
 
-
-
 /*****************************************************************************/
 /* Does the journal processing.                                              */
 /*****************************************************************************/
@@ -916,11 +836,6 @@ void doJournal() {
 	ungetVGABaseAddr();
 }
 
-#define QUARTERNUM           30
-
-extern InventoryData *Inventory;
-extern uint16 RoomNum, Direction;
-
 bool saveRestoreGame() {
 	bool isOK = false;
 
@@ -961,23 +876,6 @@ bool saveRestoreGame() {
 	return isOK;
 }
 
-/*---------------------------------------------------------------------------*/
-/*--------------------------- The Monitors stuff ----------------------------*/
-/*---------------------------------------------------------------------------*/
-
-
-extern CloseDataPtr CPtr;
-
-static uint16 monpage;
-static const char *TextFileName;
-
-
-Image *MonButton, *AltMonButton, *MonQuit, *AltMonQuit, *MonBack, *AltMonBack,
-		*MonDown, *AltMonDown, *MonUp, *AltMonUp;
-
-
-
-
 /*****************************************************************************/
 /* Makes sure that the buttons are in memory.                                */
 /*****************************************************************************/
@@ -998,9 +896,6 @@ static void getMonImages() {
 }
 
 
-static uint16 MonGadHeight = 1;
-
-
 /*****************************************************************************/
 /* Draws the text for the monitor.                                           */
 /*****************************************************************************/
@@ -1154,9 +1049,6 @@ static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1
 	}
 }
 
-
-
-
 /*****************************************************************************/
 /* Does what's necessary for the monitor.                                    */
 /*****************************************************************************/


Commit: 8bf15cbe4bfda68dd38dbb4ed44a269f57f93b5a
    https://github.com/scummvm/scummvm/commit/8bf15cbe4bfda68dd38dbb4ed44a269f57f93b5a
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Replace more calls to checkMusic()

Changed paths:
    engines/lab/special.cpp



diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 2cd383d..4d64dd3 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -569,7 +569,7 @@ static bool loadJournalData() {
 		return false;
 	}
 
-	g_music->checkMusic();
+	g_music->updateMusic();
 
 	strcpy(filename, "Lab:Rooms/j0");
 	bridge = g_lab->_conditions->in(BRIDGE0) || g_lab->_conditions->in(BRIDGE1);
@@ -652,7 +652,7 @@ static void drawJournalText() {
 	char *CurText = journaltext;
 
 	while (DrawingToPage < JPage) {
-		g_music->checkMusic();
+		g_music->updateMusic();
 		CurText = (char *)(journaltext + CharsDrawn);
 		CharsDrawn += flowText(BigMsgFont, -2, 2, 0, false, false, false, false, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText);
 
@@ -672,7 +672,7 @@ static void drawJournalText() {
 		CharsDrawn += flowTextToMem(&JBackImage, BigMsgFont, -2, 2, 0, false, false, false, true, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText);
 	}
 
-	g_music->checkMusic();
+	g_music->updateMusic();
 	CurText = (char *)(journaltext + CharsDrawn);
 	lastpage = (*CurText == 0);
 	flowTextToMem(&JBackImage, BigMsgFont, -2, 2, 0, false, false, false, true, VGAScaleX(171), VGAScaleY(32), VGAScaleX(271), VGAScaleY(148), CurText);
@@ -711,7 +711,7 @@ static void turnPage(bool FromLeft) {
 static void drawJournal(uint16 wipenum, bool needFade) {
 	mouseHide();
 
-	g_music->checkMusic();
+	g_music->updateMusic();
 
 	if (!GotBackImage)
 		JBackImage.ImageData = loadBackPict("P:Journal.pic", true);
@@ -760,11 +760,11 @@ static void processJournal() {
 	uint16 Qualifier, GadID;
 
 	while (1) {
-		g_music->checkMusic();  /* Make sure we check the music at least after every message */
+		g_music->updateMusic();  /* Make sure we check the music at least after every message */
 		Msg = (IntuiMessage *) getMsg();
 
 		if (Msg == NULL) {
-			g_music->checkMusic();
+			g_music->updateMusic();
 		} else {
 			Class     = Msg->Class;
 			Qualifier = Msg->Qualifier;
@@ -813,7 +813,7 @@ void doJournal() {
 	ScreenImage = JBackImage;
 	ScreenImage.ImageData = getVGABaseAddr();
 
-	g_music->checkMusic();
+	g_music->updateMusic();
 	loadJournalData();
 
 	drawJournal(0, true);
@@ -936,7 +936,7 @@ static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2,
 	}
 
 	while (DrawingToPage < monpage) {
-		g_music->checkMusic();
+		g_music->updateMusic();
 		CurText = (char *)(text + CharsDrawn);
 		CharsDrawn += flowText(BigMsgFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, CurText);
 		lastpage = (*CurText == 0);
@@ -990,11 +990,11 @@ static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1
 			}
 		}
 
-		g_music->checkMusic();  /* Make sure we check the music at least after every message */
+		g_music->updateMusic();  /* Make sure we check the music at least after every message */
 		Msg = getMsg();
 
 		if (Msg == NULL) {
-			g_music->checkMusic();
+			g_music->updateMusic();
 		} else {
 			Class     = Msg->Class;
 			Qualifier = Msg->Qualifier;
@@ -1122,11 +1122,11 @@ void doTrialBlock() {
 	memcpy(g_CommonPalette, diffcmap, 3 * 256);
 
 	while (1) {
-		g_music->checkMusic();  /* Make sure we check the music at least after every message */
+		g_music->updateMusic();  /* Make sure we check the music at least after every message */
 		Msg = getMsg();
 
 		if (Msg == NULL) {
-			g_music->checkMusic();
+			g_music->updateMusic();
 		} else {
 			Class     = Msg->Class;
 			Qualifier = Msg->Qualifier;


Commit: c3bb54989c21faccf77ee151fd0c4b530bc12a97
    https://github.com/scummvm/scummvm/commit/c3bb54989c21faccf77ee151fd0c4b530bc12a97
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Cleanup

Changed paths:
    engines/lab/readparse.cpp



diff --git a/engines/lab/readparse.cpp b/engines/lab/readparse.cpp
index 672688c..3d3c270 100644
--- a/engines/lab/readparse.cpp
+++ b/engines/lab/readparse.cpp
@@ -35,21 +35,17 @@
 
 namespace Lab {
 
+/* Global parser data */
+
 #define MAXSTRINGLENGTH 250
 
 static bool UseMemory = false;
-
-
-
-/* Global parser data */
+static uint16 allocroom;
 
 extern RoomData *Rooms;
 extern InventoryData *Inventory;
 extern uint16 NumInv, ManyRooms, HighestCondition, Direction;
 
-static uint16 allocroom;
-
-
 static bool rallocate(void **Ptr, uint32 Size) {
 	if (UseMemory)
 		return ((*Ptr = calloc(Size, 1)) != 0);
@@ -104,8 +100,6 @@ bool readRoomData(const char *fileName) {
 }
 
 
-
-
 /*****************************************************************************/
 /* Reads in a NULL terminated string, and allocates memory for it.           */
 /*****************************************************************************/
@@ -134,7 +128,6 @@ static bool readString(char **string, byte **file) {
 }
 
 
-
 /*****************************************************************************/
 /* Reads in the Inventory data.                                              */
 /*****************************************************************************/
@@ -244,8 +237,6 @@ static bool readCloseUps(CloseDataPtr *CPtr, uint16 depth, byte **file) {
 }
 
 
-
-
 /*****************************************************************************/
 /* Reads in a View.                                                          */
 /*****************************************************************************/
@@ -258,7 +249,7 @@ static bool readView(ViewDataPtr *VPtr, byte **file) {
 		readBlock(&c, 1L, file);
 
 		if (c == 1) {
-			if (rallocate((void **) VPtr, sizeof(viewData))) {
+			if (rallocate((void **)VPtr, sizeof(viewData))) {
 				(*VPtr)->closeUps = NULL;
 				(*VPtr)->NextCondition = NULL;
 
@@ -273,16 +264,16 @@ static bool readView(ViewDataPtr *VPtr, byte **file) {
 				readCloseUps(&((*VPtr)->closeUps), 0, file);
 
 				VPtr = &((*VPtr)->NextCondition);
-			} else
+			}
+			else
 				return false;
-		} else
+		}
+		else
 			return true;
 	}
 }
 
 
-
-
 /*****************************************************************************/
 /* Reads in an Action.                                                       */
 /*****************************************************************************/
@@ -321,9 +312,6 @@ static bool readAction(ActionPtr *APtr, byte **file) {
 }
 
 
-
-
-
 /*****************************************************************************/
 /* Reads in a rule.                                                          */
 /*****************************************************************************/
@@ -355,14 +343,11 @@ static bool readRule(RulePtr *RPtr, byte **file) {
 }
 
 
-
-
-
 /*****************************************************************************/
 /* Reads in the views of a room.                                             */
 /*****************************************************************************/
-bool readViews(uint16 RoomNum, const char *Path) {
-	Common::String fileName = Common::String(Path) + Common::String::format("%d", RoomNum);
+bool readViews(uint16 RoomNum) {
+	Common::String fileName = "LAB:Rooms/" + Common::String::format("%d", RoomNum);
 	char Temp[10];
 	byte **file;
 
@@ -378,19 +363,14 @@ bool readViews(uint16 RoomNum, const char *Path) {
 		readString(&(Rooms[RoomNum].RoomMsg), file);
 
 		readView(&Rooms[RoomNum].NorthView, file);
-		g_music->checkMusic();
-
 		readView(&Rooms[RoomNum].SouthView, file);
-		g_music->checkMusic();
-
 		readView(&Rooms[RoomNum].EastView, file);
-		g_music->checkMusic();
-
 		readView(&Rooms[RoomNum].WestView, file);
-		g_music->checkMusic();
 
 		readRule(&Rooms[RoomNum].RuleList, file);
 
+		g_music->updateMusic();
+
 		return true;
 	} else
 		return false;


Commit: c8b2745f7a960e1afc421782ac81fcddf81f6e60
    https://github.com/scummvm/scummvm/commit/c8b2745f7a960e1afc421782ac81fcddf81f6e60
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Replace some more calls to checkMusic(). Some cleanup

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 8960464..54050f2 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -78,11 +78,7 @@ extern char *LAMPONMSG, *TURNLEFT, *TURNRIGHT;
 extern char *GOFORWARDDIR, *NOPATH, *TAKEITEM, *USEONWHAT, *TAKEWHAT, *MOVEWHAT, *OPENWHAT, *CLOSEWHAT, *LOOKWHAT, *NOTHING, *USEMAP, *USEJOURNAL, *TURNLAMPON, *TURNLAMPOFF, *USEWHISKEY, *USEPITH, *USEHELMET;
 
 
-#define BIGBUFFERSIZE 850000L
-#define SMALLBUFFERSIZE 250000L
-
-static uint32 BUFFERSIZE = BIGBUFFERSIZE;
-
+#define BUFFERSIZE 850000L
 
 /* LAB: Labyrinth specific code for the special puzzles */
 #define SPECIALLOCK         100
@@ -444,25 +440,36 @@ static bool doCloseUp(CloseDataPtr cptr) {
 		lutertmargin = 128;
 	}
 
-	if ((cptr->CloseUpType == MUSEUMMONITOR) || (cptr->CloseUpType == LIBRARYMONITOR) ||
-	        (cptr->CloseUpType == WINDOWMONITOR))
+	switch (cptr->CloseUpType) {
+	case MUSEUMMONITOR:
+	case LIBRARYMONITOR:
+	case WINDOWMONITOR:
 		doMonitor(cptr->GraphicName, cptr->Message, false, monltmargin, montopmargin, monrtmargin, 165);
-	else if (cptr->CloseUpType == GRAMAPHONEMONITOR)
+		break;
+	case GRAMAPHONEMONITOR:
 		doMonitor(cptr->GraphicName, cptr->Message, false, monltmargin, montopmargin, 171, 165);
-	else if (cptr->CloseUpType == UNICYCLEMONITOR)
+		break;
+	case UNICYCLEMONITOR:
 		doMonitor(cptr->GraphicName, cptr->Message, false, 100, montopmargin, monrtmargin, 165);
-	else if (cptr->CloseUpType == STATUEMONITOR)
+		break;
+	case STATUEMONITOR:
 		doMonitor(cptr->GraphicName, cptr->Message, false, 117, montopmargin, monrtmargin, 165);
-	else if (cptr->CloseUpType == TALISMANMONITOR)
+		break;
+	case TALISMANMONITOR:
 		doMonitor(cptr->GraphicName, cptr->Message, false, monltmargin, montopmargin, 184, 165);
-	else if (cptr->CloseUpType == LUTEMONITOR)
+		break;
+	case LUTEMONITOR:
 		doMonitor(cptr->GraphicName, cptr->Message, false, monltmargin, montopmargin, lutertmargin, 165);
-	else if (cptr->CloseUpType == CLOCKMONITOR)
+		break;
+	case CLOCKMONITOR:
 		doMonitor(cptr->GraphicName, cptr->Message, false, monltmargin, montopmargin, 206, 165);
-	else if (cptr->CloseUpType == TERMINALMONITOR)
+		break;
+	case TERMINALMONITOR:
 		doMonitor(cptr->GraphicName, cptr->Message, true, monltmargin, montopmargin, monrtmargin, 165);
-	else
+		break;
+	default:
 		return false;
+	}
 
 	CurFileName = " ";
 	drawPanel();
@@ -778,14 +785,14 @@ static void mainGameLoop() {
 			}
 		}
 
-		g_music->checkMusic();  /* Make sure we check the music at least after every message */
+		g_music->updateMusic();  /* Make sure we check the music at least after every message */
 		interfaceOn();
 		Msg = getMsg();
 
 		if (Msg == NULL) { /* Does music load and next animation frame when you've run out of messages */
 			GotMessage = false;
 			checkRoomMusic();
-			g_music->checkMusic();
+			g_music->updateMusic();
 			diffNextFrame();
 
 			if (FollowingCrumbs) {
@@ -885,11 +892,11 @@ from_crumbs:
 					interfaceOff();
 
 					while (1) {
-						g_music->checkMusic();  /* Make sure we check the music at least after every message */
+						g_music->updateMusic();  /* Make sure we check the music at least after every message */
 						Msg = getMsg();
 
 						if (Msg == NULL) { /* Does music load and next animation frame when you've run out of messages */
-							g_music->checkMusic();
+							g_music->updateMusic();
 							diffNextFrame();
 						} else {
 							if (Msg->Class == RAWKEY) {
@@ -1400,7 +1407,7 @@ void LabEngine::go() {
 		readPict("P:End/L2In.1", true);
 
 		for (counter = 0; counter < 120; counter++) {
-			g_music->checkMusic();
+			g_music->updateMusic();
 			waitTOF();
 		}
 
@@ -1409,7 +1416,7 @@ void LabEngine::go() {
 
 		warning("STUB: waitForPress");
 		while (!1) { // 1 means ignore SDL_ProcessInput calls
-			g_music->checkMusic();
+			g_music->updateMusic();
 			diffNextFrame();
 			waitTOF();
 		}


Commit: cb4b86cdb8e1a4f42ec87a09863d8e2f9b3a1f1a
    https://github.com/scummvm/scummvm/commit/cb4b86cdb8e1a4f42ec87a09863d8e2f9b3a1f1a
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Replace more uses of checkMusic(). Some cleanup

Changed paths:
    engines/lab/graphics.cpp



diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 7f949d6..e2a221f 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -44,8 +44,8 @@ BitMap bit1, bit2, *DispBitMap = &bit1, *DrawBitMap = &bit1;
 
 
 extern BitMap RawDiffBM;
-extern char diffcmap[256 * 3], lastcmap[256 * 3];
-extern bool IsBM, NoFlip, nopalchange;
+extern char diffcmap[256 * 3];
+extern bool IsBM, nopalchange;
 
 extern bool DoBlack, stopsound;
 extern bool IsHiRes;
@@ -435,9 +435,9 @@ static void doScrollBlack() {
 	Im.Width = width;
 	Im.Height = height;
 	Im.ImageData = mem;
-	g_music->fillUpMusic(true);
+	g_music->updateMusic();
 	readScreenImage(&Im, 0, 0);
-	g_music->fillUpMusic(true);
+	g_music->updateMusic();
 
 	BaseAddr = (uint32 *) getVGABaseAddr();
 
@@ -445,7 +445,7 @@ static void doScrollBlack() {
 	nheight = height;
 
 	while (nheight) {
-		g_music->checkMusic();
+		g_music->updateMusic();
 
 		if (!IsHiRes)
 			waitTOF();
@@ -547,7 +547,7 @@ static void doScrollWipe(char *filename) {
 	height = VGAScaleY(149) + SVGACord(2);
 
 	while (g_music->isSoundEffectActive()) {
-		g_music->checkMusic();
+		g_music->updateMusic();
 		waitTOF();
 	}
 
@@ -557,12 +557,12 @@ static void doScrollWipe(char *filename) {
 	IsBM = false;
 	mem = RawDiffBM.Planes[0];
 
-	g_music->fillUpMusic(true);
+	g_music->updateMusic();
 	by      = VGAScaleX(3);
 	nheight = height;
 
 	while (onrow < headerdata.y) {
-		g_music->checkMusic();
+		g_music->updateMusic();
 
 		if ((by > nheight) && nheight)
 			by = nheight;
@@ -619,11 +619,11 @@ static void doScrollBounce() {
 	int height = VGAScaleY(149) + SVGACord(2);
 	byte *mem = RawDiffBM.Planes[0];
 
-	g_music->fillUpMusic(true);
+	g_music->updateMusic();
 	int startline = headerdata.y - height - 1;
 
 	for (int counter = 0; counter < 5; counter++) {
-		g_music->checkMusic();
+		g_music->updateMusic();
 		startline -= newby[counter];
 		copyPage(width, height, 0, startline, mem);
 
@@ -632,7 +632,7 @@ static void doScrollBounce() {
 	}
 
 	for (int counter = 8; counter > 0; counter--) {
-		g_music->checkMusic();
+		g_music->updateMusic();
 		startline += newby1[counter - 1];
 		copyPage(width, height, 0, startline, mem);
 


Commit: e9f161b3aafb971f3682aa8d6a5647283d8239cf
    https://github.com/scummvm/scummvm/commit/e9f161b3aafb971f3682aa8d6a5647283d8239cf
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Clean up readSound(), readMusic() and longDrawMessage()

Changed paths:
    engines/lab/diff.h
    engines/lab/graphics.cpp
    engines/lab/intro.cpp
    engines/lab/labfun.h
    engines/lab/readdiff.cpp



diff --git a/engines/lab/diff.h b/engines/lab/diff.h
index b5c84d3a..614148e 100644
--- a/engines/lab/diff.h
+++ b/engines/lab/diff.h
@@ -74,7 +74,7 @@ void blackAllScreen();
 void whiteScreen();
 bool readDiff(bool playonce);
 void diffNextFrame();
-void readSound();
+void readSound(bool waitTillFinished);
 void stopDiff();
 void stopDiffEnd();
 void stopSound();
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index e2a221f..049053f 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -97,17 +97,13 @@ bool readPict(const char *filename, bool PlayOnce) {
 /*****************************************************************************/
 /* Reads in a music file.  Ignores any graphics.                             */
 /*****************************************************************************/
-bool readMusic(const char *filename) {
-	byte **file = NULL;
-
-	file = g_music->newOpen(filename);
-
-	if (file == NULL) {
+bool readMusic(const char *filename, bool waitTillFinished) {
+	byte **file = g_music->newOpen(filename);
+	if (!file)
 		return false;
-	}
 
 	DoBlack = false;
-	readSound();
+	readSound(waitTillFinished);
 
 	return true;
 }
@@ -346,14 +342,13 @@ void createBox(uint16 y2) {
 
 
 
-int32 longcharsdrawn = 0L;
 bool LastMessageLong = false;
 
-void longDrawMessage(const char *str) {
+int32 longDrawMessage(const char *str) {
 	char NewText[512];
 
 	if (str == NULL)
-		return;
+		return 0;
 
 	attachGadgetList(NULL);
 	mouseHide();
@@ -366,8 +361,9 @@ void longDrawMessage(const char *str) {
 	}
 
 	createBox(198);
-	longcharsdrawn = flowText(MsgFont, 0, 1, 7, false, true, true, true, VGAScaleX(6), VGAScaleY(155), VGAScaleX(313), VGAScaleY(195), str);
 	mouseShow();
+
+	return flowText(MsgFont, 0, 1, 7, false, true, true, true, VGAScaleX(6), VGAScaleY(155), VGAScaleX(313), VGAScaleY(195), str);
 }
 
 
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 16a54ff..5d5f604 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -124,8 +124,7 @@ static void doPictText(const char *Filename, bool isscreen) {
 				Drawn = flowText(msgfont, (!IsHiRes) * -1, 5, 7, false, false, true, true, VGAScaleX(14), VGAScaleY(11), VGAScaleX(306), VGAScaleY(189), (char *)curplace);
 				fade(true, 0);
 			} else {
-				longDrawMessage((char *)curplace);
-				Drawn = longcharsdrawn;
+				Drawn = longDrawMessage((char *)curplace);
 			}
 
 			curplace += Drawn;
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 9655c24..1db04a8 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -70,7 +70,7 @@ struct SaveGameHeader {
 /* Reads in pictures */
 
 bool readPict(const char *filename, bool PlayOnce);
-bool readMusic(const char *filename);
+bool readMusic(const char *filename, bool waitTillFinished);
 byte *readPictToMem(const char *filename, uint16 x, uint16 y);
 
 /* Window text stuff */
@@ -98,7 +98,7 @@ uint32 flowTextToMem(Image *DestIm, void *font,     /* the TextAttr pointer */
                      uint16 y1, uint16 x2, uint16 y2, const char *text); /* The text itself */
 
 void drawMessage(const char *text);
-void longDrawMessage(const char *text);
+int32 longDrawMessage(const char *text);
 bool readFont(char *filename, void *font, void *data);
 
 /* The Wipes */
@@ -176,17 +176,16 @@ public:
 	byte **newOpen(const char *name, uint32 &size);
 	bool initMusic();
 	void freeMusic();
-	void fillUpMusic(bool doit);
 	void updateMusic();
 	uint16 getPlayingBufferCount();
-	void checkMusic();
 	void closeMusic();
 	void setMusic(bool on);
 	void resumeBackMusic();
 	void pauseBackMusic();
 	void changeMusic(const char *newmusic);
+	void checkRoomMusic();
 	void resetMusic();
-	
+	void setMusicReset(bool reset) { _doReset = reset; }
 	void playSoundEffect(uint16 SampleSpeed, uint32 Length, void *Data);
 	void stopSoundEffect();
 	bool isSoundEffectActive() const;
@@ -194,6 +193,9 @@ public:
 	bool _winmusic, _doNotFilestopSoundEffect;
 	bool _musicOn;
 	bool _loopSoundEffect;
+	bool _waitTillFinished;
+	uint16 _lastMusicRoom ;
+	bool _doReset;
 
 private:
 	void fillbuffer(byte *musicBuffer);
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index f2a39b4..ebf3d07 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -158,7 +158,7 @@ void diffNextFrame() {
 		if (CurBit >= numchunks) {
 			mouseShow();
 
-			if (!NoFlip && !IsBM) {
+			if (!IsBM) {
 				if (headerdata.fps) {
 					waitForTime(WaitSec, WaitMicros);
 					addCurTime(0L, DelayMicros, &WaitSec, &WaitMicros);
@@ -451,14 +451,13 @@ void stopDiffEnd() {
 		StopPlayingEnd = true;
 
 		while (IsPlaying) {
-			g_music->checkMusic();
+			g_music->updateMusic();
 			diffNextFrame();
 		}
 	}
 }
 
 
-
 /*****************************************************************************/
 /* Stops the continuous sound from playing.                                  */
 /*****************************************************************************/
@@ -466,8 +465,6 @@ void stopSound() {
 	stopsound = true;
 }
 
-
-
 /*****************************************************************************/
 /* Reads in a DIFF file.                                                     */
 /*****************************************************************************/
@@ -478,16 +475,13 @@ bool readDiff(bool playonce) {
 }
 
 
-
 static byte *mstart;
 
 
-void readSound() {
+void readSound(bool waitTillFinished) {
 	uint32 header_ = 0, size_;
 	uint16 samplespeed_;
-//  uint16 numchunks = 1;
 	char temp_[5];
-//  bool        FirstThru = true;
 	byte *storagefordifffile_, **difffile_ = &storagefordifffile_;
 
 	mstart = *startoffile;            /* Make a copy of the pointer to the start of the file    */
@@ -526,7 +520,7 @@ void readSound() {
 		swapULong(&size_);
 
 		if ((header_ == 30) || (header_ == 31)) {
-			if (mwaitForEffect) {
+			if (waitTillFinished) {
 				while (g_music->isSoundEffectActive()) {
 					g_music->updateMusic();
 					waitTOF();
@@ -547,7 +541,7 @@ void readSound() {
 
 			g_music->playSoundEffect(samplespeed_, musicsize, music);
 		} else if (header_ == 65535L) {
-			if (mwaitForEffect) {
+			if (waitTillFinished) {
 				while (g_music->isSoundEffectActive()) {
 					g_music->updateMusic();
 					waitTOF();


Commit: db969dc9388855f2c80ab9cc5fd6e870c5979395
    https://github.com/scummvm/scummvm/commit/db969dc9388855f2c80ab9cc5fd6e870c5979395
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Move more static variables to the top

Changed paths:
    engines/lab/readdiff.cpp



diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index ebf3d07..d220b3e 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -37,38 +37,23 @@
 
 namespace Lab {
 
-extern BitMap *DispBitMap, *DrawBitMap;
-extern uint32 VGABytesPerPage;
-
-extern byte **startoffile;
-
 static bool PlayOnce = false, changedscreen;
+static uint32 header, size, processed = 0L, WaitSec = 0L, WaitMicros = 0L, DelayMicros = 0L;
+static uint16 CurBit = 0, framenumber = 0, samplespeed, numchunks = 1;
+static byte *Buffer, temp[5];
+static bool FirstThru = true, donepal = false;
+static byte *storagefordifffile, **difffile = &storagefordifffile;
+static byte *start;
+static uint32 diffwidth, diffheight;
+static byte blackbuffer[256 * 3];
+static byte *mstart;
 
-bool NoFlip         = false,  /* Don't flip the new picture to front  */
-     DoBlack        = false,     /* Black the screen before new picture  */
+bool DoBlack        = false,     /* Black the screen before new picture  */
      nopalchange    = false,     /* Don't change the palette.            */
      IsBM           = false,     /* Just fill in the RawDIFFBM structure */
-     hidemouse      = false,     /* Don't set the mouse colors           */
      stopsound      = false,
-     soundplaying   = false,
-     screenbuffer   = false,
-     waitForEffect     = false, /* Wait for each sound effect to finish
-                                                                                                      before coninuing.                    */
-                      mwaitForEffect    = false;
-
-uint16 DataBytesPerRow;
-
-#define CONTINUOUS      0xFFFF
-
-DIFFHeader headerdata;
-
-
-
-/*------ Stuff for the animation task. -----*/
-
-static byte *start;
-
-static uint32 diffwidth, diffheight;
+     waitForEffect  = false;     /* Wait for each sound effect to finish
+                                   before coninuing.                    */
 
 static bool continuous,
 	IsPlaying      = false,
@@ -77,11 +62,16 @@ static bool continuous,
 	IsAnim         = false,
 	IsPal          = false;
 
-char diffcmap[256 * 3], lastcmap[256 * 3];
-
+uint16 DataBytesPerRow;
+DIFFHeader headerdata;
+char diffcmap[256 * 3];
 BitMap RawDiffBM;
 
+extern BitMap *DispBitMap, *DrawBitMap;
+extern uint32 VGABytesPerPage;
+extern byte **startoffile;
 
+#define CONTINUOUS      0xFFFF
 
 
 /*****************************************************************************/
@@ -101,8 +91,6 @@ void unDiff(byte *NewBuf, byte *OldBuf, byte *DiffData, uint16 bytesperrow, bool
 }
 
 
-static byte blackbuffer[256 * 3];
-
 /*****************************************************************************/
 /* Changes the front screen to black.                                        */
 /*****************************************************************************/
@@ -132,14 +120,6 @@ void blackAllScreen() {
 }
 
 
-
-/* For Play Diff */
-static uint32 header, size, processed = 0L, WaitSec    = 0L, WaitMicros = 0L, DelayMicros = 0L;
-static uint16 CurBit = 0, framenumber = 0, samplespeed, numchunks = 1;
-static byte *Buffer, temp[5];
-static bool FirstThru = true, donepal   = false;
-static byte *storagefordifffile, * *difffile = &storagefordifffile;
-
 void diffNextFrame() {
 	if (header == 65535)  /* Already done. */
 		return;
@@ -474,10 +454,6 @@ bool readDiff(bool playonce) {
 	return true;
 }
 
-
-static byte *mstart;
-
-
 void readSound(bool waitTillFinished) {
 	uint32 header_ = 0, size_;
 	uint16 samplespeed_;


Commit: f085a3187edb2ac6077c00a995309b25869db336
    https://github.com/scummvm/scummvm/commit/f085a3187edb2ac6077c00a995309b25869db336
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Remove several usages of skip(). Remove dead code

Changed paths:
    engines/lab/readdiff.cpp



diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index d220b3e..6820e4e 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -186,8 +186,6 @@ void diffNextFrame() {
 
 		switch (header) {
 		case 8L:
-			memcpy(lastcmap, diffcmap, 256 * 3);
-
 			readBlock(diffcmap, size, difffile);
 			IsPal = true;
 			break;
@@ -196,7 +194,7 @@ void diffNextFrame() {
 			RawDiffBM.Planes[CurBit] = *difffile;
 
 			if (IsBM)
-				skip(difffile, size);
+				(*difffile) += size;
 			else {
 				readBlock(DrawBitMap->Planes[CurBit], size, difffile);
 			}
@@ -205,29 +203,29 @@ void diffNextFrame() {
 			break;
 
 		case 11L:
-			skip(difffile, 4L);
+			(*difffile) += 4;
 			runLengthDecode(DrawBitMap->Planes[CurBit], *difffile);
 			CurBit++;
-			skip(difffile, size - 4);
+			(*difffile) += size - 4;
 			break;
 
 		case 12L:
-			skip(difffile, 4L);
+			(*difffile) += 4;
 			VRunLengthDecode(DrawBitMap->Planes[CurBit], *difffile, DrawBitMap->BytesPerRow);
 			CurBit++;
-			skip(difffile, size - 4);
+			(*difffile) += size - 4;
 			break;
 
 		case 20L:
 			unDiff(DrawBitMap->Planes[CurBit], DispBitMap->Planes[CurBit], *difffile, DrawBitMap->BytesPerRow, false);
 			CurBit++;
-			skip(difffile, size);
+			(*difffile) += size;
 			break;
 
 		case 21L:
 			unDiff(DrawBitMap->Planes[CurBit], DispBitMap->Planes[CurBit], *difffile, DrawBitMap->BytesPerRow, true);
 			CurBit++;
-			skip(difffile, size);
+			(*difffile) += size;
 			break;
 
 		case 25L:
@@ -249,14 +247,15 @@ void diffNextFrame() {
 
 			size -= 8L;
 
-			skip(difffile, 4L);
+
+			(*difffile) += 4;
 			readBlock(&samplespeed, 2L, difffile);
 			swapUShortPtr(&samplespeed, 1);
-			skip(difffile, 2L);
+			(*difffile) += 2;
 
 			byte *music = *difffile;
 			uint32 musicsize = size;
-			skip(difffile, size);
+			(*difffile) += size;
 
 			g_music->playSoundEffect(samplespeed, musicsize, music);
 			break;
@@ -292,7 +291,7 @@ void diffNextFrame() {
 			break;
 
 		default:
-			skip(difffile, size);
+			(*difffile) += size;
 			break;
 		}
 	}
@@ -372,7 +371,7 @@ void playDiff() {
 		readBlock(&headerdata.Machine, 2, difffile);
 		readBlock(&headerdata.Flags, 4, difffile);
 
-		skip(difffile, size - 18);
+		(*difffile) += size - 18;
 
 		swapUShortPtr(&headerdata.Version, 3);
 		swapULong(&headerdata.BufferSize);
@@ -454,6 +453,7 @@ bool readDiff(bool playonce) {
 	return true;
 }
 
+
 void readSound(bool waitTillFinished) {
 	uint32 header_ = 0, size_;
 	uint16 samplespeed_;
@@ -483,7 +483,7 @@ void readSound(bool waitTillFinished) {
 	swapULong(&size_);
 
 	if (header_ == 0)
-		skip(difffile_, size_);
+		(*difffile_) += size_;
 	else
 		return;
 
@@ -505,15 +505,15 @@ void readSound(bool waitTillFinished) {
 
 			size_ -= 8L;
 
-			skip(difffile_, 4L);
+			(*difffile_) += 4;
 			readBlock(&samplespeed_, 2L, difffile_);
 			swapUShortPtr(&samplespeed_, 1);
 
-			skip(difffile_, 2L);
+			(*difffile_) += 2;
 
 			byte *music = *difffile_;
 			uint32 musicsize = size_;
-			skip(difffile_, size_);
+			(*difffile_) += size_;
 
 			g_music->playSoundEffect(samplespeed_, musicsize, music);
 		} else if (header_ == 65535L) {
@@ -524,7 +524,7 @@ void readSound(bool waitTillFinished) {
 				}
 			}
 		} else
-			skip(difffile_, size_);
+			(*difffile_) += size_;
 	}
 }
 


Commit: d0171440df2d7b372563f342eac6cdd11488311f
    https://github.com/scummvm/scummvm/commit/d0171440df2d7b372563f342eac6cdd11488311f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Move checkRoomMusic to the Music class. Some cleanup

Changed paths:
    engines/lab/engine.cpp
    engines/lab/labmusic.cpp
    engines/lab/processroom.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 54050f2..34ca89c 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -69,7 +69,7 @@ int     followCrumbs();
 void    mayShowCrumbIndicator();
 void    mayShowCrumbIndicatorOff();
 
-bool Alternate = false, ispal = false, noupdatediff = false, MainDisplay = true, QuitLab = false, DoNotReset = false;
+bool Alternate = false, ispal = false, noupdatediff = false, MainDisplay = true, QuitLab = false;
 
 extern const char *NewFileName;  /* When ProcessRoom.c decides to change the filename
                                     of the current picture. */
@@ -118,11 +118,6 @@ extern char *GOFORWARDDIR, *NOPATH, *TAKEITEM, *USEONWHAT, *TAKEWHAT, *MOVEWHAT,
 #define LEVERSMONITOR        82
 
 
-#define CLOWNROOM           123
-#define DIMROOM              80
-
-
-
 static byte *MovePanelBuffer, *InvPanelBuffer;
 static uint32 MovePanelBufferSize, InvPanelBufferSize;
 static Image *MoveImages[20], *InvImages[10];
@@ -398,27 +393,6 @@ void eatMessages() {
 	return;
 }
 
-static uint16 lastmusicroom = 1;
-
-
-/******************************************************************************/
-/* Checks the music that should be playing in a particular room.              */
-/******************************************************************************/
-static void checkRoomMusic() {
-	if ((lastmusicroom == RoomNum) || !g_music->_musicOn)
-		return;
-
-	if (RoomNum == CLOWNROOM)
-		g_music->changeMusic("Music:Laugh");
-	else if (RoomNum == DIMROOM)
-		g_music->changeMusic("Music:Rm81");
-	else if (!DoNotReset)
-		g_music->resetMusic();
-
-	lastmusicroom = RoomNum;
-}
-
-
 /******************************************************************************/
 /* Checks whether the close up is one of the special case closeups.           */
 /******************************************************************************/
@@ -791,7 +765,7 @@ static void mainGameLoop() {
 
 		if (Msg == NULL) { /* Does music load and next animation frame when you've run out of messages */
 			GotMessage = false;
-			checkRoomMusic();
+			g_music->checkRoomMusic();
 			g_music->updateMusic();
 			diffNextFrame();
 
diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index ecb5fd1..3f35579 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -40,10 +40,13 @@
 namespace Lab {
 
 #define MUSICBUFSIZE   (2 * 65536L)
-
 #define SAMPLESPEED    15000L
 
+#define CLOWNROOM           123
+#define DIMROOM              80
+
 Music *g_music;
+extern uint16 RoomNum;	// TODO: Move into a class
 
 Music::Music() {
 	_file = 0;
@@ -60,6 +63,9 @@ Music::Music() {
 	_loopSoundEffect = false;
 	_queuingAudioStream = NULL;
 	_doNotFilestopSoundEffect = false;
+	_lastMusicRoom = 1;
+	_doReset = true;
+	_waitTillFinished = false;
 }
 
 /*****************************************************************************/
@@ -144,15 +150,6 @@ void Music::fillbuffer(byte *musicBuffer) {
 }
 
 /*****************************************************************************/
-/* Fills up the buffers that have already been played if necessary; if doit  */
-/* is set to TRUE then it will fill up all empty buffers.  Otherwise, it     */
-/* Check if there are MINBUFFERS or less buffers that are playing.           */
-/*****************************************************************************/
-void Music::fillUpMusic(bool doit) {
-	updateMusic();
-}
-
-/*****************************************************************************/
 /* Starts up the music initially.                                            */
 /*****************************************************************************/
 void Music::startMusic(bool startatbegin) {
@@ -241,18 +238,6 @@ void Music::resumeBackMusic() {
 }
 
 /*****************************************************************************/
-/* Checks to see if need to fill buffers fill of music.                      */
-/*****************************************************************************/
-void Music::checkMusic() {
-	updateMusic();
-
-	if (!_musicOn)
-		return;
-
-	fillUpMusic(false);
-}
-
-/*****************************************************************************/
 /* Turns the music on and off.                                               */
 /*****************************************************************************/
 void Music::setMusic(bool on) {
@@ -268,6 +253,23 @@ void Music::setMusic(bool on) {
 		_musicOn = on;
 }
 
+/******************************************************************************/
+/* Checks the music that should be playing in a particular room.              */
+/******************************************************************************/
+void Music::checkRoomMusic() {
+	if ((_lastMusicRoom == RoomNum) || !_musicOn)
+		return;
+
+	if (RoomNum == CLOWNROOM)
+		g_music->changeMusic("Music:Laugh");
+	else if (RoomNum == DIMROOM)
+		g_music->changeMusic("Music:Rm81");
+	else if (_doReset)
+		g_music->resetMusic();
+
+	_lastMusicRoom = RoomNum;
+}
+
 /*****************************************************************************/
 /* Changes the background music to something else.                           */
 /*****************************************************************************/
@@ -348,14 +350,14 @@ byte **Music::newOpen(const char *name, uint32 &size) {
 
 	if (_musicOn) {
 		updateMusic();
-		fillUpMusic(true);
+		updateMusic();
 	}
 
 	if (!_doNotFilestopSoundEffect && isSoundEffectActive())
 		stopSoundEffect();
 
 	file = openFile(name, size);
-	checkMusic();
+	updateMusic();
 	return file;
 }
 
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index c6acf36..3c5d1f6 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -44,26 +44,18 @@ namespace Lab {
 
 /* Global parser data */
 
+#define NOFILE         "no file"
+
 RoomData *Rooms;
 InventoryData *Inventory;
 uint16 NumInv, RoomNum, ManyRooms, HighestCondition, Direction;
-
-extern char *FACINGNORTH, *FACINGEAST, *FACINGSOUTH, *FACINGWEST;
-extern bool LongWinInFront;
-
-#define NOFILE         "no file"
-
-extern const char *CurFileName;
-
-const char *ViewPath = "LAB:Rooms/";
-
 const char *NewFileName;
 
-extern bool DoNotDrawMessage;
-extern bool NoFlip, IsBM, noupdatediff, waitForEffect, mwaitForEffect, QuitLab, soundplaying, MusicOn, DoBlack, DoNotReset;
+extern bool DoNotDrawMessage, IsBM, noupdatediff, QuitLab, MusicOn, DoBlack, LongWinInFront;
 extern char diffcmap[256 * 3];
-
+extern const char *CurFileName;
 extern CloseDataPtr CPtr;
+extern char *FACINGNORTH, *FACINGEAST, *FACINGSOUTH, *FACINGWEST;
 
 /*****************************************************************************/
 /* Generates a random number.                                                */
@@ -373,26 +365,26 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
 	uint32 StartSecs, StartMicros, CurSecs, CurMicros;
 
 	while (APtr) {
-		g_music->checkMusic();
+		g_music->updateMusic();
 
 		switch (APtr->ActionType) {
 		case PLAYSOUND:
-			mwaitForEffect = true; /* Plays a sound, but waits for it to be done before continuing */
 			g_music->_loopSoundEffect = false;
-			readMusic((char *)APtr->Data);
-			mwaitForEffect = false;
+			g_music->_waitTillFinished = true;
+			readMusic((char *)APtr->Data, true);
+			g_music->_waitTillFinished = false;
 			break;
 
 		case PLAYSOUNDB:
-			mwaitForEffect = false; /* Plays a sound in the background. */
 			g_music->_loopSoundEffect = false;
-			readMusic((char *)APtr->Data);
+			g_music->_waitTillFinished = false;
+			readMusic((char *)APtr->Data, false);
 			break;
 
 		case PLAYSOUNDCONT:
 			g_music->_doNotFilestopSoundEffect = true;
 			g_music->_loopSoundEffect = true;
-			readMusic((char *)APtr->Data);
+			readMusic((char *)APtr->Data, g_music->_waitTillFinished);
 			break;
 
 		case SHOWDIFF:
@@ -542,7 +534,7 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
 			WSDL_UpdateScreen();
 
 			while (1) {
-				g_music->checkMusic();
+				g_music->updateMusic();
 				diffNextFrame();
 				getTime(&CurSecs, &CurMicros);
 
@@ -563,16 +555,16 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
 
 		case CHANGEMUSIC:
 			g_music->changeMusic((const char *)APtr->Data);
-			DoNotReset = true;
+			g_music->setMusicReset(false);
 			break;
 
 		case RESETMUSIC:
 			g_music->resetMusic();
-			DoNotReset = false;
+			g_music->setMusicReset(true);
 			break;
 
 		case FILLMUSIC:
-			g_music->fillUpMusic(true);
+			g_music->updateMusic();
 			break;
 
 		case WAITSOUND:


Commit: 76b66de8b673b878efe4ef5159a0dec20bd94890
    https://github.com/scummvm/scummvm/commit/76b66de8b673b878efe4ef5159a0dec20bd94890
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Remove dead code

Changed paths:
    engines/lab/graphics.cpp
    engines/lab/readdiff.cpp
    engines/lab/special.cpp
    engines/lab/text.cpp
    engines/lab/vga.cpp
    engines/lab/vga.h



diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 049053f..23e587c 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -86,8 +86,6 @@ bool readPict(const char *filename, bool PlayOnce) {
 
 	readDiff(PlayOnce);
 
-	ungetVGABaseAddr();
-
 	return true;
 }
 
@@ -488,7 +486,6 @@ static void doScrollBlack() {
 
 	freeAllStolenMem();
 	mouseShow();
-	ungetVGABaseAddr();
 }
 
 
@@ -526,8 +523,6 @@ static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startli
 		CurPage++;
 		OffSet = 0;
 	}
-
-	ungetVGABaseAddr();
 }
 
 
@@ -751,8 +746,6 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
 			}
 		}
 	}
-
-	ungetVGABaseAddr();
 }
 
 
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index 6820e4e..ab93d32 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -277,9 +277,6 @@ void diffNextFrame() {
 				IsPlaying = false;
 				mouseShow();
 
-				if (DispBitMap->Flags & BITMAPF_VIDEO)
-					ungetVGABaseAddr();
-
 				if (!didTOF)
 					WSDL_UpdateScreen();
 
@@ -295,10 +292,6 @@ void diffNextFrame() {
 			break;
 		}
 	}
-
-	if (DispBitMap->Flags & BITMAPF_VIDEO)
-		ungetVGABaseAddr();
-
 }
 
 
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 4d64dd3..bedf721 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -214,8 +214,6 @@ static void changeCombination(uint16 number) {
 		g_lab->_conditions->inclElement(COMBINATIONUNLOCKED);
 	else
 		g_lab->_conditions->exclElement(COMBINATIONUNLOCKED);
-
-	ungetVGABaseAddr();
 }
 
 
@@ -735,8 +733,6 @@ static void drawJournal(uint16 wipenum, bool needFade) {
 	else
 		unGhoastGadget(&ForwardG);
 
-	ungetVGABaseAddr();
-
 
 	if (needFade)
 		fade(true, 0);
@@ -832,8 +828,6 @@ void doJournal() {
 	blackScreen();
 
 	freeAllStolenMem();
-
-	ungetVGABaseAddr();
 }
 
 bool saveRestoreGame() {
diff --git a/engines/lab/text.cpp b/engines/lab/text.cpp
index e99114e..f31515f 100644
--- a/engines/lab/text.cpp
+++ b/engines/lab/text.cpp
@@ -198,8 +198,6 @@ void text(struct TextFont *tf, uint16 x, uint16 y, uint16 color, const char *tex
 		x += tf->Widths[(int)*text];
 		text++;
 	}
-
-	ungetVGABaseAddr();
 }
 
 } // End of namespace Lab
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 7b74576..aa31d19 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -290,16 +290,11 @@ byte *WSDL_LockVideo() {
 	return g_DisplayBuffer;
 }
 
-void WSDL_UnlockVideo() {
-}
-
 void WSDL_IgnoreUpdateDisplay(int state) {
 	g_IgnoreUpdateDisplay = state;
 }
 
 void WSDL_UpdateScreen() {
-	WSDL_UnlockVideo();
-
 	if (g_ScreenWasLocked && !g_IgnoreUpdateDisplay) {
 		g_system->copyRectToScreen(g_DisplayBuffer, VGAScreenWidth, 0, 0, VGAScreenWidth, VGAScreenHeight);
   		g_system->updateScreen();
@@ -319,11 +314,6 @@ byte *getVGABaseAddr() {
 	return WSDL_LockVideo();
 }
 
-void ungetVGABaseAddr() {
-	if (!VGABASEADDRESS)
-		WSDL_UnlockVideo();
-}
-
 /*****************************************************************************/
 /* Draws an image to the screen.                                             */
 /*****************************************************************************/
@@ -364,8 +354,6 @@ void drawImage(Image *Im, uint16 x, uint16 y) {
 			s += Im->Width;
 			d += VGAScreenWidth;
 		}
-
-		ungetVGABaseAddr();
 	}
 }
 
@@ -419,8 +407,6 @@ void drawMaskImage(Image *Im, uint16 x, uint16 y) {
 			s += Im->Width;
 			d += VGAScreenWidth;
 		}
-
-		ungetVGABaseAddr();
 	}
 }
 
@@ -464,8 +450,6 @@ void readScreenImage(Image *Im, uint16 x, uint16 y) {
 			s += Im->Width;
 			d += VGAScreenWidth;
 		}
-
-		ungetVGABaseAddr();
 	}
 }
 
@@ -647,8 +631,6 @@ void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 
 			d += VGAScreenWidth;
 		}
-
-		ungetVGABaseAddr();
 	}
 }
 
@@ -714,8 +696,6 @@ void ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 			d += VGAScreenWidth;
 			dy++;
 		}
-
-		ungetVGABaseAddr();
 	}
 }
 
diff --git a/engines/lab/vga.h b/engines/lab/vga.h
index 5821a0c..376411a 100644
--- a/engines/lab/vga.h
+++ b/engines/lab/vga.h
@@ -48,7 +48,6 @@ bool createScreen(bool HiRes);
 void waitTOF();
 void quickWaitTOF();
 byte *getVGABaseAddr();
-void ungetVGABaseAddr();
 void writeColorReg(byte *buf, uint16 regnum);
 void writeColorRegs(byte *buf, uint16 first, uint16 numreg);
 void writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg);


Commit: 454c02f321660585aa693329c7aa67eaf1f112fe
    https://github.com/scummvm/scummvm/commit/454c02f321660585aa693329c7aa67eaf1f112fe
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Get rid of some uses of readBlock()

Changed paths:
    engines/lab/labsets.cpp



diff --git a/engines/lab/labsets.cpp b/engines/lab/labsets.cpp
index d68370b..0210754 100644
--- a/engines/lab/labsets.cpp
+++ b/engines/lab/labsets.cpp
@@ -57,22 +57,22 @@ void LargeSet::exclElement(uint16 element) {
 }
 
 bool LargeSet::readInitialConditions(const char *fileName) {
-	byte **file;
+	byte *file;
 	uint16 many, set;
 	char temp[5];
 
 	if ((file = g_music->newOpen(fileName)) != NULL) {
-		readBlock(temp, 4L, file);
+		memcpy(&temp, file, 4);	file += 4;
 		temp[4] = '\0';
 
 		if (strcmp(temp, "CON0") != 0)
 			return false;
 
-		readBlock(&many, 2L, file);
+		memcpy(&many, file, 2);	file += 2;
 		swapUShortPtr(&many, 1);
 
 		for (int counter = 0; counter < many; counter++) {
-			readBlock(&set, 2L, file);
+			memcpy(&set, file, 2);	file += 2;
 			swapUShortPtr(&set, 1);
 			inclElement(set);
 		}


Commit: afa9475d2ad18486203a73869930caff29a40dff
    https://github.com/scummvm/scummvm/commit/afa9475d2ad18486203a73869930caff29a40dff
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Some cleanup

Changed paths:
    engines/lab/intro.cpp



diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 5d5f604..4f1720f 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -238,7 +238,7 @@ void musicDelay() {
 
 
 static void NReadPict(const char *Filename, bool PlayOnce) {
-	Common::String finalFileName = "P:Intro/";
+	Common::String finalFileName = Common::String("P:Intro/") + Filename;
 
 	g_music->updateMusic();
 	introEatMessages();
@@ -246,8 +246,6 @@ static void NReadPict(const char *Filename, bool PlayOnce) {
 	if (QuitIntro)
 		return;
 
-	finalFileName += Filename;
-
 	DoBlack = IntroDoBlack;
 	stopDiffEnd();
 	readPict(finalFileName.c_str(), PlayOnce);


Commit: 69694b6b459791a71aac39ba7a4ffaa0d643bc52
    https://github.com/scummvm/scummvm/commit/69694b6b459791a71aac39ba7a4ffaa0d643bc52
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Check if a sound effect is active before attempting to stop it

Changed paths:
    engines/lab/labmusic.cpp



diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index 3f35579..fe2d6e9 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -128,7 +128,8 @@ void Music::playSoundEffect(uint16 SampleSpeed, uint32 Length, void *Data) {
 }
 
 void Music::stopSoundEffect() {
-	g_lab->_mixer->stopHandle(_sfxHandle);
+	if (isSoundEffectActive())
+		g_lab->_mixer->stopHandle(_sfxHandle);
 }
 
 bool Music::isSoundEffectActive() const {


Commit: 98e9eff2d1576328c58e0bb64cae0e01c4df2084
    https://github.com/scummvm/scummvm/commit/98e9eff2d1576328c58e0bb64cae0e01c4df2084
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Remove superfluous references to g_music, some cleanup

Changed paths:
    engines/lab/labmusic.cpp



diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index fe2d6e9..d4752c6 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -262,11 +262,11 @@ void Music::checkRoomMusic() {
 		return;
 
 	if (RoomNum == CLOWNROOM)
-		g_music->changeMusic("Music:Laugh");
+		changeMusic("Music:Laugh");
 	else if (RoomNum == DIMROOM)
-		g_music->changeMusic("Music:Rm81");
+		changeMusic("Music:Rm81");
 	else if (_doReset)
-		g_music->resetMusic();
+		resetMusic();
 
 	_lastMusicRoom = RoomNum;
 }
@@ -349,12 +349,9 @@ byte **Music::newOpen(const char *name, uint32 &size) {
 	if (file = isBuffered(name))
 		return file;
 
-	if (_musicOn) {
-		updateMusic();
-		updateMusic();
-	}
+	updateMusic();
 
-	if (!_doNotFilestopSoundEffect && isSoundEffectActive())
+	if (!_doNotFilestopSoundEffect)
 		stopSoundEffect();
 
 	file = openFile(name, size);


Commit: f1351dcd9e80acc305365f8726fd05600283a6e4
    https://github.com/scummvm/scummvm/commit/f1351dcd9e80acc305365f8726fd05600283a6e4
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Remove dead code

Changed paths:
    engines/lab/readdiff.cpp



diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index ab93d32..b2720ea 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -37,11 +37,11 @@
 
 namespace Lab {
 
-static bool PlayOnce = false, changedscreen;
+static bool PlayOnce = false;
 static uint32 header, size, processed = 0L, WaitSec = 0L, WaitMicros = 0L, DelayMicros = 0L;
 static uint16 CurBit = 0, framenumber = 0, samplespeed, numchunks = 1;
 static byte *Buffer, temp[5];
-static bool FirstThru = true, donepal = false;
+static bool donepal = false;
 static byte *storagefordifffile, **difffile = &storagefordifffile;
 static byte *start;
 static uint32 diffwidth, diffheight;
@@ -57,7 +57,6 @@ bool DoBlack        = false,     /* Black the screen before new picture  */
 
 static bool continuous,
 	IsPlaying      = false,
-	StopPlaying    = false,
 	StopPlayingEnd = false,
 	IsAnim         = false,
 	IsPal          = false;
@@ -150,7 +149,6 @@ void diffNextFrame() {
 				}
 
 				donepal = true;
-				FirstThru = false;
 			}
 
 			if (IsPal && !nopalchange && !IsBM && !donepal) {
@@ -308,16 +306,12 @@ void playDiff() {
 	CurBit = 0;
 	framenumber = 0;
 	numchunks   = 1;
-	FirstThru   = true;
 	donepal     = false;
 	difffile    = &storagefordifffile;
 
 	IsPlaying   = true;
-	StopPlaying = false;
 	StopPlayingEnd = false;
 
-	changedscreen = false;
-
 	if (DoBlack) {
 		DoBlack = false;
 		blackScreen();
@@ -406,8 +400,6 @@ void playDiff() {
 /*****************************************************************************/
 void stopDiff() {
 	if (IsPlaying) {
-		StopPlaying = true;
-
 		if (IsAnim)
 			blackScreen();
 	}
@@ -420,8 +412,6 @@ void stopDiff() {
 /*****************************************************************************/
 void stopDiffEnd() {
 	if (IsPlaying) {
-		StopPlayingEnd = true;
-
 		while (IsPlaying) {
 			g_music->updateMusic();
 			diffNextFrame();


Commit: edf92fc6809830d819a1471ccf295aa110340cb0
    https://github.com/scummvm/scummvm/commit/edf92fc6809830d819a1471ccf295aa110340cb0
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Revert accidental change

Changed paths:
    engines/lab/labsets.cpp



diff --git a/engines/lab/labsets.cpp b/engines/lab/labsets.cpp
index 0210754..ae70d81 100644
--- a/engines/lab/labsets.cpp
+++ b/engines/lab/labsets.cpp
@@ -57,7 +57,7 @@ void LargeSet::exclElement(uint16 element) {
 }
 
 bool LargeSet::readInitialConditions(const char *fileName) {
-	byte *file;
+	byte **file;
 	uint16 many, set;
 	char temp[5];
 


Commit: c67852d940c31ecaf330a7f3b0cdb82f1f57819c
    https://github.com/scummvm/scummvm/commit/c67852d940c31ecaf330a7f3b0cdb82f1f57819c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Initial implementation of the Resource class

This will eventually replace all the other resource loading routines

Changed paths:
  A engines/lab/resource.cpp
  A engines/lab/resource.h
    engines/lab/lab.cpp
    engines/lab/module.mk



diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 3f92de1..c13f5cd 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -43,6 +43,7 @@
 
 #include "lab/lab.h"
 #include "lab/labfun.h"
+#include "lab/resource.h"
 
 #include "engines/advancedDetector.h"
 
@@ -73,6 +74,7 @@ Common::Error LabEngine::run() {
 		initGraphics(640, 480, true);
 
 	g_music = new Music();
+	g_resource = new Resource();
 
 	if (getPlatform() == Common::kPlatformWindows) {
 		// Check if this is the Wyrmkeep trial
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index 7389c18..1520672 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -18,6 +18,7 @@ MODULE_OBJS := \
 	processroom.o \
 	readdiff.o \
 	readparse.o \
+	resource.o \
 	savegame.o \
 	special.o \
 	text.o \
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
new file mode 100644
index 0000000..9babc5c
--- /dev/null
+++ b/engines/lab/resource.cpp
@@ -0,0 +1,324 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+//#include "lab/labfun.h"
+//#include "lab/parsetypes.h"
+//#include "lab/parsefun.h"
+//#include "lab/stddefines.h"
+#include "lab/text.h"
+#include "lab/resource.h"
+
+namespace Lab {
+
+static uint16 allocroom;
+
+extern RoomData *Rooms;
+extern InventoryData *Inventory;
+extern uint16 NumInv, ManyRooms, HighestCondition;
+
+Resource *g_resource;
+
+Resource::Resource() {
+	readStaticText();
+}
+
+void Resource::readStaticText() {
+	Common::File labTextFile;
+	labTextFile.open(translateFileName("Lab:Rooms/LabText"));
+
+	for (int i = 0; i < 48; i++)
+		_staticText[i] = labTextFile.readLine();
+
+	labTextFile.close();
+}
+
+TextFont *Resource::getFont(const char *fileName) {
+	Common::File *dataFile;
+	if (!(dataFile = openDataFile(fileName, MKTAG('V', 'G', 'A', 'F'))))
+		return NULL;
+
+	uint32 headerSize = 4L + 2L + 256 * 3 + 4L;
+	uint32 fileSize = dataFile->size();
+	if (fileSize <= headerSize)
+		return NULL;
+
+	g_music->updateMusic();
+
+	TextFont *textfont = (TextFont *)malloc(sizeof(TextFont));
+	textfont->DataLength = fileSize - headerSize;
+	textfont->Height = dataFile->readUint16LE();
+	dataFile->read(textfont->Widths, 256);
+	for (int i = 0; i < 256; i++)
+		textfont->Offsets[i] = dataFile->readUint16LE();
+	dataFile->skip(4);
+	// TODO: Fix memory leak!!
+	textfont->data = new byte[textfont->DataLength + 4];
+	dataFile->read(textfont->data, textfont->DataLength);
+	return textfont;
+}
+
+bool Resource::readRoomData(const char *fileName) {
+	Common::File *dataFile;
+	if (!(dataFile = openDataFile(fileName, MKTAG('D', 'O', 'R', '1'))))
+		return false;
+
+	ManyRooms = dataFile->readUint16LE();
+	HighestCondition = dataFile->readUint16LE();
+	Rooms = (RoomData *)malloc((ManyRooms + 1) * sizeof(RoomData));
+	memset(Rooms, 0, (ManyRooms + 1) * sizeof(RoomData));
+
+	for (uint16 i = 1; i <= ManyRooms; i++) {
+		Rooms[i].NorthDoor = dataFile->readUint16LE();
+		Rooms[i].SouthDoor = dataFile->readUint16LE();
+		Rooms[i].EastDoor = dataFile->readUint16LE();
+		Rooms[i].WestDoor = dataFile->readUint16LE();
+		Rooms[i].WipeType = dataFile->readByte();
+
+		Rooms[i].NorthView = NULL;
+		Rooms[i].SouthView = NULL;
+		Rooms[i].EastView = NULL;
+		Rooms[i].WestView = NULL;
+		Rooms[i].RuleList = NULL;
+		Rooms[i].RoomMsg = NULL;
+	}
+
+	delete dataFile;
+	return true;
+}
+
+bool Resource::readInventory(const char *fileName) {
+	Common::File *dataFile;
+	if (!(dataFile = openDataFile(fileName, MKTAG('I', 'N', 'V', '1'))))
+		return false;
+
+	NumInv = dataFile->readUint16LE();
+	Inventory = (InventoryData *)malloc((NumInv + 1) * sizeof(InventoryData));
+
+	for (uint16 i = 1; i <= NumInv; i++) {
+		Inventory[i].Many = dataFile->readUint16LE();
+		Inventory[i].name = readString(dataFile);
+		Inventory[i].BInvName = readString(dataFile);
+	}
+
+	delete dataFile;
+	return true;
+}
+
+bool Resource::readViews(uint16 roomNum) {
+	Common::String fileName = "LAB:Rooms/" + Common::String::format("%d", roomNum);
+	Common::File *dataFile;
+	if (!(dataFile = openDataFile(fileName.c_str(), MKTAG('R', 'O', 'M', '4'))))
+		return false;
+
+	allocroom = roomNum;
+
+	Rooms[roomNum].RoomMsg = readString(dataFile);
+	Rooms[roomNum].NorthView = readView(dataFile);
+	Rooms[roomNum].SouthView = readView(dataFile);
+	Rooms[roomNum].EastView = readView(dataFile);
+	Rooms[roomNum].WestView = readView(dataFile);
+	Rooms[roomNum].RuleList = readRule(dataFile);
+	/*warning("Room %d, msg %s, north %s, south %s, east %s, west %s",
+		Rooms[roomNum].RoomMsg,
+		Rooms[roomNum].NorthView->GraphicName,
+		Rooms[roomNum].SouthView->GraphicName,
+		Rooms[roomNum].EastView->GraphicName,
+		Rooms[roomNum].WestView->GraphicName
+	);*/
+
+	g_music->updateMusic();
+
+	delete dataFile;
+	return true;
+}
+
+Common::File *Resource::openDataFile(const char * fileName, uint32 fileHeader) {
+	Common::File *dataFile = new Common::File();
+	dataFile->open(translateFileName(fileName));
+	if (dataFile->readUint32BE() != fileHeader) {
+		dataFile->close();
+		return NULL;
+	}
+
+	return dataFile;
+}
+
+char *Resource::readString(Common::File *file) {
+	byte size = file->readByte();
+	if (!size)
+		return NULL;
+	char *str = (char *)malloc(size);
+	char *c = str;
+	for (int i = 0; i < size; i++) {
+		*c = file->readByte();
+		if (*c != '\0')
+			*c -= 95;	// decrypt char
+		c++;
+	}
+	*c = 0;
+
+	return str;
+}
+
+int16 *Resource::readConditions(Common::File *file) {
+	int16 i = 0, cond;
+	//int16 *list = new int16[25];
+	int16 *list = (int16 *)malloc(25 * 2);
+	memset(list, 0, 25 * 2);
+
+	do {
+		cond = file->readUint16LE();
+		if (i < 25)
+			list[i++] = cond;
+	} while (cond);
+
+	return list;
+}
+
+Rule *Resource::readRule(Common::File *file) {
+	char c;
+	Rule *rule = NULL;
+	Rule *head = NULL;
+
+	do {
+		c = file->readByte();
+
+		if (c == 1) {
+			rule = (Rule *)malloc(sizeof(Rule));
+			rule->RuleType = file->readSint16LE();
+			rule->Param1 = file->readSint16LE();
+			rule->Param2 = file->readSint16LE();
+			rule->Condition = readConditions(file);
+			if (!rule->Condition)
+				return NULL;
+			rule->ActionList = readAction(file);
+			rule->NextRule = NULL;
+			if (!head)
+				head = rule;
+			rule = rule->NextRule;
+		}
+	} while (c == 1);
+
+	return head;
+}
+
+Action *Resource::readAction(Common::File *file) {
+	char c;
+	Action *action = NULL;
+	Action *head = NULL;
+	char **messages;
+
+	do {
+		c = file->readByte();
+
+		if (c == 1) {
+			action = (Action *)malloc(sizeof(Action));
+			action->ActionType = file->readSint16LE();
+			action->Param1 = file->readSint16LE();
+			action->Param2 = file->readSint16LE();
+			action->Param3 = file->readSint16LE();
+
+			if (action->ActionType == SHOWMESSAGES) {
+				messages = (char **)malloc(action->Param1 * 4);
+
+				for (int i = 0; i < action->Param1; i++)
+					messages[i] = readString(file);
+
+				action->Data = (byte *)messages;
+			} else {
+				action->Data = (byte *)readString(file);
+			}
+
+			action->NextAction = NULL;
+			if (!head)
+				head = action;
+			action = action->NextAction;
+		}
+	} while (c == 1);
+
+	return head;
+}
+
+CloseData *Resource::readCloseUps(uint16 depth, Common::File *file) {
+	char c;
+	CloseData *closeups = NULL;
+	CloseData *head = NULL;
+
+	do {
+		c = file->readByte();
+
+		if (c != '\0') {
+			closeups = (CloseData *)malloc(sizeof(CloseData));
+			closeups->x1 = file->readUint16LE();
+			closeups->y1 = file->readUint16LE();
+			closeups->x2 = file->readUint16LE();
+			closeups->y2 = file->readUint16LE();
+			closeups->CloseUpType = file->readSint16LE();
+			closeups->depth = depth;
+			closeups->GraphicName = readString(file);
+			closeups->Message = readString(file);
+			if (!(closeups->SubCloseUps = readCloseUps(depth + 1, file)))
+				return NULL;
+			closeups->NextCloseUp = NULL;
+			if (!head)
+				head = closeups;
+			closeups = closeups->NextCloseUp;
+		}
+	} while (c != '\0');
+	
+	return head;
+}
+
+viewData *Resource::readView(Common::File *file) {
+	char c;
+	viewData *view = NULL;
+	viewData *head = NULL;
+
+	do {
+		c = file->readByte();
+
+		if (c == 1) {
+			view = (viewData *)malloc(sizeof(viewData));
+			view->Condition = readConditions(file);
+			if (!view->Condition)
+				return NULL;
+			view->GraphicName = readString(file);
+			view->closeUps = readCloseUps(0, file);
+			view->NextCondition = NULL;
+			if (!head)
+				head = view;
+			view = view->NextCondition;
+		}
+	} while (c == 1);
+
+	return head;
+}
+
+} // End of namespace Lab
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
new file mode 100644
index 0000000..9bcd638
--- /dev/null
+++ b/engines/lab/resource.h
@@ -0,0 +1,124 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#ifndef LAB_RESOURCE_H
+#define LAB_RESOURCE_H
+
+#include "lab/labfun.h"
+#include "lab/text.h"
+
+namespace Lab {
+
+enum StaticText {
+	kTextLowerFloor,
+	kTextMiddleFloor,
+	kTextUpperFloor,
+	kTextMedMazeFloor,
+	kTextHedgeMazeFloor,
+	kTextSurMazeFloor,
+	kTextCarnivalFloor,
+
+	kTextSurmazeMessage,
+
+	kTextFacingNorth,
+	kTextFacingEast,
+	kTextFacingSouth,
+	kTextFacingWest,
+
+	kTextLampOn,
+
+	kTextTurnLeft,
+	kTextTurnRight,
+	kTextGoForward,
+	kTextNoPath,
+	kTextTakeItem,
+	kTextSave,
+	kTextLoad,
+	kTextBookmark,
+	kTextPersonal,
+	kTextDisk,
+	kTextSaveBook,
+	kTextRestoreBook,
+	kTextSaveFlash,
+	kTextRestoreFlash,
+	kTextSaveDisk,
+	kTextRestoreDisk,
+	kTextNoDiskInDrive,
+	kTextWriteProtected,
+	kTextSelectDisk,
+	kTextFormatFloppy,
+	kTextFormatting,
+
+	kTextNothing,
+	kTextUseOnWhat,
+	kTextTakeWhat,
+	kTextMoveWhat,
+	kTextOpenWhat,
+	kTextCloseWhat,
+	kTextLookWhat,
+
+	kTextUseMap,
+	kTextUseJournal,
+	kTextTurnLampOn,
+	kTextTurnLampOff,
+	kTextUseWhiskey,
+	kTextUsePith,
+	kTextUseHelmet
+};
+
+class Resource {
+public:
+	Resource();
+	~Resource() {}
+
+	bool readRoomData(const char *fileName);
+	bool readInventory(const char *fileName);
+	bool readViews(uint16 roomNum);
+	TextFont *getFont(const char *filename);
+	Common::String getStaticText(byte index) const { return _staticText[index + 1]; }
+
+private:
+	Common::File *openDataFile(const char * fileName, uint32 fileHeader);
+	char *readString(Common::File *file);
+	int16 *readConditions(Common::File *file);
+	Rule *readRule(Common::File *file);
+	Action *readAction(Common::File *file);
+	CloseData *readCloseUps(uint16 depth, Common::File *file);
+	viewData *readView(Common::File *file);
+	void readStaticText();
+
+	Common::String _staticText[48];
+};
+
+extern Resource *g_resource;
+
+} // End of namespace Lab
+
+#endif /* LAB_RESOURCE_H */


Commit: d565b10384dd771fdae7f8fedb793e87c05c022d
    https://github.com/scummvm/scummvm/commit/d565b10384dd771fdae7f8fedb793e87c05c022d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Move the font loading code into the Resource class

Changed paths:
    engines/lab/engine.cpp
    engines/lab/intro.cpp
    engines/lab/labfun.h
    engines/lab/map.cpp
    engines/lab/special.cpp
    engines/lab/text.cpp
    engines/lab/text.h



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 34ca89c..571b72d 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -38,6 +38,7 @@
 #include "lab/parsefun.h"
 #include "lab/interface.h"
 #include "lab/mouse.h"
+#include "lab/resource.h"
 
 namespace Lab {
 
@@ -1361,7 +1362,7 @@ void LabEngine::go() {
 	if (!dointro)
 		g_music->initMusic();
 
-	openFont("P:AvanteG.12", &MsgFont);
+	MsgFont = g_resource->getFont("P:AvanteG.12");
 
 	mouseHide();
 
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 4f1720f..2ffddf7 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -31,6 +31,7 @@
 #include "lab/lab.h"
 #include "lab/stddefines.h"
 #include "lab/labfun.h"
+#include "lab/resource.h"
 #include "lab/timing.h"
 #include "lab/diff.h"
 #include "lab/text.h"
@@ -352,7 +353,7 @@ void introSequence() {
 	blackAllScreen();
 	g_music->updateMusic();
 
-	getFont("P:Map.fon", msgfont);
+	msgfont = g_resource->getFont("P:Map.fon");
 
 	nopalchange = true;
 	NReadPict("Intro.1", true);
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 1db04a8..9ed334f 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -99,7 +99,6 @@ uint32 flowTextToMem(Image *DestIm, void *font,     /* the TextAttr pointer */
 
 void drawMessage(const char *text);
 int32 longDrawMessage(const char *text);
-bool readFont(char *filename, void *font, void *data);
 
 /* The Wipes */
 
@@ -255,7 +254,6 @@ char *translateFileName(const char *filename);
 void fade(bool fadein, uint16 res);
 void setAmigaPal(uint16 *pal, uint16 numcolors);
 char *getText(const char *filename);
-bool getFont(const char *filename, TextFont *textfont);
 void readImage(byte **buffer, Image **im);
 void doMap(uint16 CurRoom);
 void doJournal();
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 2e3dffc..34eb018 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -37,6 +37,7 @@
 #include "lab/mouse.h"
 #include "lab/parsefun.h"
 #include "lab/parsetypes.h"
+#include "lab/resource.h"
 #include "lab/interface.h"
 #include "lab/text.h"
 
@@ -74,44 +75,6 @@ void setAmigaPal(uint16 *pal, uint16 numcolors) {
 }
 
 
-/*****************************************************************************/
-/* Gets a font from disk and puts it into temporary memory.                  */
-/*****************************************************************************/
-bool getFont(const char *filename, TextFont *textfont) {
-	byte **file = NULL;
-	char header[5];
-	uint32 filesize, headersize = 4L + 2L + 256 * 3 + 4L;
-
-	file = g_music->newOpen(filename, filesize);
-	g_music->updateMusic();
-
-	if ((file != NULL) && (filesize > headersize)) {
-		byte *fontbuffer = (byte *)stealBufMem(filesize - (sizeof(TextFont) + 4));
-		if (!fontbuffer)
-			return false;
-
-		header[4] = 0;
-		readBlock(&header, 4L, file);
-
-		if (strcmp(header, "VGAF") == 0) {
-			textfont->DataLength = filesize - headersize;
-			readBlock(&(textfont->Height), 2L, file);
-			swapUShortPtr(&(textfont->Height), 1);
-
-			readBlock(textfont->Widths, 256L, file);
-			readBlock(textfont->Offsets, 256L * 2L, file);
-			swapUShortPtr(textfont->Offsets, 256);
-
-			(*file) += 4;
-			textfont->data = fontbuffer;
-			readBlock(textfont->data, textfont->DataLength, file);
-			return true;
-		}
-	}
-
-	return false;
-}
-
 
 /*****************************************************************************/
 /* Gets a chunk of text and puts it into the graphics memory.                */
@@ -234,7 +197,7 @@ static bool loadMapData() {
 
 	BigMsgFont = &bmf;
 
-	if (!getFont("P:Map.fon", BigMsgFont))
+	if (!(BigMsgFont = g_resource->getFont("P:Map.fon")))
 		BigMsgFont = MsgFont;
 
 	resetBuffer();  /* Make images load into start of buffer */
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index bedf721..b7f1472 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -44,6 +44,7 @@
 #include "lab/timing.h"
 #include "lab/stddefines.h"
 #include "lab/parsetypes.h"
+#include "lab/resource.h"
 
 namespace Lab {
 
@@ -474,7 +475,7 @@ void doNotes() {
 	/* Load in the data */
 	BigMsgFont = &bmfont;
 
-	if (!getFont("P:Note.fon", BigMsgFont)) {
+	if (!(BigMsgFont = g_resource->getFont("P:Note.fon"))) {
 		BigMsgFont = NULL;
 		return;
 	}
@@ -500,7 +501,7 @@ void doWestPaper() {
 
 	BigMsgFont = &bmfont;
 
-	if (!getFont("P:News22.fon", BigMsgFont)) {
+	if (!(BigMsgFont = g_resource->getFont("P:News22.fon"))) {
 		BigMsgFont = NULL;
 		return;
 	}
@@ -512,7 +513,7 @@ void doWestPaper() {
 
 	BigMsgFont = &bmfont;
 
-	if (!getFont("P:News32.fon", BigMsgFont)) {
+	if (!(BigMsgFont = g_resource->getFont("P:News32.fon"))) {
 		BigMsgFont = NULL;
 		return;
 	}
@@ -531,7 +532,7 @@ void doWestPaper() {
 
 	BigMsgFont = &bmfont;
 
-	if (!getFont("P:Note.fon", BigMsgFont)) {
+	if (!(BigMsgFont = g_resource->getFont("P:Note.fon"))) {
 		BigMsgFont = NULL;
 		return;
 	}
@@ -562,7 +563,7 @@ static bool loadJournalData() {
 
 	BigMsgFont = &bmfont;
 
-	if (!getFont("P:Journal.fon", BigMsgFont)) {
+	if (!(BigMsgFont = g_resource->getFont("P:Journal.fon"))) {
 		BigMsgFont = NULL;
 		return false;
 	}
@@ -1071,7 +1072,7 @@ void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1,
 
 	BigMsgFont = &bmfont;
 
-	if (!getFont("P:Map.fon", BigMsgFont)) {
+	if (!(BigMsgFont = g_resource->getFont("P:Map.fon"))) {
 		freeAllStolenMem();
 		BigMsgFont = NULL;
 		return;
diff --git a/engines/lab/text.cpp b/engines/lab/text.cpp
index f31515f..807df45 100644
--- a/engines/lab/text.cpp
+++ b/engines/lab/text.cpp
@@ -38,52 +38,12 @@ namespace Lab {
 extern uint32 VGAScreenWidth, VGABytesPerPage;
 
 /*****************************************************************************/
-/* Opens up a font from disk.                                                */
-/*****************************************************************************/
-bool openFont(const char *TextFontPath, struct TextFont **tf) {
-	byte **file = NULL;
-	char header[5];
-	uint32 filesize, headersize = 4L + 2L + 256 * 3 + 4L;
-
-	if ((*tf = (TextFont *)calloc(sizeof(struct TextFont), 1))) {
-		file = g_music->newOpen(TextFontPath, filesize);
-
-		if ((file != NULL) && (filesize > headersize)) {
-			header[4] = 0;
-			readBlock(&header, 4L, file);
-
-			if (strcmp(header, "VGAF") == 0) {
-				(*tf)->DataLength = filesize - headersize;
-				readBlock(&((*tf)->Height), 2L, file);
-				swapUShortPtr(&((*tf)->Height), 1);
-
-				readBlock((*tf)->Widths, 256L, file);
-				readBlock((*tf)->Offsets, 256L * 2L, file);
-				swapUShortPtr((*tf)->Offsets, 256);
-
-				(*file) += 4;
-
-				if (((*tf)->data = (byte *)calloc((*tf)->DataLength, 1))) {
-					readBlock((*tf)->data, (*tf)->DataLength, file);
-					return true;
-				}
-			}
-		}
-
-		free(*tf);
-	}
-
-	*tf = NULL;
-	return false;
-}
-
-/*****************************************************************************/
 /* Closes a font and frees all memory associated with it.                    */
 /*****************************************************************************/
 void closeFont(struct TextFont *tf) {
 	if (tf) {
 		if (tf->data && tf->DataLength)
-			free(tf->data);
+			delete[] tf->data;
 
 		free(tf);
 	}
diff --git a/engines/lab/text.h b/engines/lab/text.h
index 333f449..8d171b2 100644
--- a/engines/lab/text.h
+++ b/engines/lab/text.h
@@ -52,7 +52,6 @@ struct TextFont {
 #pragma pack(pop)
 #endif
 
-bool openFont(const char *TextFontPath, TextFont **tf);
 void closeFont(TextFont *tf);
 uint16 textLength(TextFont *tf, const char *text, uint16 numchars);
 uint16 textHeight(TextFont *tf);


Commit: 01dffc75a1fec635879f176f9a62a539269d9adf
    https://github.com/scummvm/scummvm/commit/01dffc75a1fec635879f176f9a62a539269d9adf
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Move static text loading to the Resource class

Changed paths:
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/labfun.h
    engines/lab/labtext.cpp
    engines/lab/map.cpp
    engines/lab/processroom.cpp
    engines/lab/resource.h



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 571b72d..c1883a0 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -75,10 +75,6 @@ bool Alternate = false, ispal = false, noupdatediff = false, MainDisplay = true,
 extern const char *NewFileName;  /* When ProcessRoom.c decides to change the filename
                                     of the current picture. */
 
-extern char *LAMPONMSG, *TURNLEFT, *TURNRIGHT;
-extern char *GOFORWARDDIR, *NOPATH, *TAKEITEM, *USEONWHAT, *TAKEWHAT, *MOVEWHAT, *OPENWHAT, *CLOSEWHAT, *LOOKWHAT, *NOTHING, *USEMAP, *USEJOURNAL, *TURNLAMPON, *TURNLAMPOFF, *USEWHISKEY, *USEPITH, *USEHELMET;
-
-
 #define BUFFERSIZE 850000L
 
 /* LAB: Labyrinth specific code for the special puzzles */
@@ -208,7 +204,7 @@ static void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr) {
 	if (Alternate) {
 		if ((CurInv <= NumInv) && g_lab->_conditions->in(CurInv) && Inventory[CurInv].BInvName) {
 			if ((CurInv == LAMPNUM) && g_lab->_conditions->in(LAMPON))  /* LAB: Labyrith specific */
-				drawMessage(LAMPONMSG);
+				drawStaticMessage(kTextLampOn);
 			else if (Inventory[CurInv].Many > 1) {
 				Common::String roomMessage = Common::String(Inventory[CurInv].name) + "  (" + Common::String::format("%d", Inventory[CurInv].Many) + ")";
 				drawMessage(roomMessage.c_str());
@@ -536,7 +532,7 @@ static const char *Test;
 static bool doUse(uint16 CurInv) {
 
 	if (CurInv == MAPNUM) {                  /* LAB: Labyrinth specific */
-		drawMessage(USEMAP);
+		drawStaticMessage(kTextUseMap);
 		interfaceOff();
 		stopDiff();
 		CurFileName = " ";
@@ -548,7 +544,7 @@ static bool doUse(uint16 CurInv) {
 	}
 
 	else if (CurInv == JOURNALNUM) {         /* LAB: Labyrinth specific */
-		drawMessage(USEJOURNAL);
+		drawStaticMessage(kTextUseJournal);
 		interfaceOff();
 		stopDiff();
 		CurFileName = " ";
@@ -562,10 +558,10 @@ static bool doUse(uint16 CurInv) {
 		interfaceOff();
 
 		if (g_lab->_conditions->in(LAMPON)) {
-			drawMessage(TURNLAMPOFF);
+			drawStaticMessage(kTextTurnLampOff);
 			g_lab->_conditions->exclElement(LAMPON);
 		} else {
-			drawMessage(TURNLAMPON);
+			drawStaticMessage(kTextTurnLampOn);
 			g_lab->_conditions->inclElement(LAMPON);
 		}
 
@@ -588,17 +584,17 @@ static bool doUse(uint16 CurInv) {
 
 	else if (CurInv == WHISKEYNUM) {                 /* LAB: Labyrinth specific */
 		g_lab->_conditions->inclElement(USEDHELMET);
-		drawMessage(USEWHISKEY);
+		drawStaticMessage(kTextUseWhiskey);
 	}
 
 	else if (CurInv == PITHHELMETNUM) {              /* LAB: Labyrinth specific */
 		g_lab->_conditions->inclElement(USEDHELMET);
-		drawMessage(USEPITH);
+		drawStaticMessage(kTextUsePith);
 	}
 
 	else if (CurInv == HELMETNUM) {                  /* LAB: Labyrinth specific */
 		g_lab->_conditions->inclElement(USEDHELMET);
-		drawMessage(USEHELMET);
+		drawStaticMessage(kTextUseHelmet);
 	}
 
 	else
@@ -955,15 +951,15 @@ from_crumbs:
 						perFlipGadget(ActionMode);
 
 						if (GadID == 0)
-							drawMessage(TAKEWHAT);
+							drawStaticMessage(kTextTakeWhat);
 						else if (GadID == 1)
-							drawMessage(MOVEWHAT);
+							drawStaticMessage(kTextMoveWhat);
 						else if (GadID == 2)
-							drawMessage(OPENWHAT);
+							drawStaticMessage(kTextOpenWhat);
 						else if (GadID == 3)
-							drawMessage(CLOSEWHAT);
+							drawStaticMessage(kTextCloseWhat);
 						else if (GadID == 4)
-							drawMessage(LOOKWHAT);
+							drawStaticMessage(kTextLookWhat);
 
 						WSDL_UpdateScreen();
 					}
@@ -978,9 +974,9 @@ from_crumbs:
 
 					if ((GadID == 6) || (GadID == 8)) {
 						if (GadID == 6)
-							drawMessage(TURNLEFT);
+							drawStaticMessage(kTextTurnLeft);
 						else
-							drawMessage(TURNRIGHT);
+							drawStaticMessage(kTextTurnRight);
 
 						CurFileName = " ";
 
@@ -1006,13 +1002,13 @@ from_crumbs:
 							processArrow(&Direction, GadID - 6);
 
 							if (OldRoomNum != RoomNum) {
-								drawMessage(GOFORWARDDIR);
+								drawStaticMessage(kTextGoForward);
 								g_lab->_roomsFound->inclElement(RoomNum); /* Potentially entered a new room */
 								CurFileName = " ";
 								ForceDraw = true;
 							} else {
 								DoBlack = true;
-								drawMessage(NOPATH);
+								drawStaticMessage(kTextNoPath);
 							}
 						}
 
@@ -1117,7 +1113,7 @@ from_crumbs:
 						if (Old < 5)
 							perFlipGadget(Old);
 
-						drawMessage(USEONWHAT);
+						drawStaticMessage(kTextUseOnWhat);
 						MainDisplay = true;
 
 						WSDL_UpdateScreen();
@@ -1211,13 +1207,13 @@ from_crumbs:
 						if (doActionRule(MouseX, MouseY, ActionMode, RoomNum, &CPtr))
 							CurFileName = NewFileName;
 						else if (takeItem(MouseX, MouseY, &CPtr))
-							drawMessage(TAKEITEM);
+							drawStaticMessage(kTextTakeItem);
 						else if (doActionRule(MouseX, MouseY, TAKEDEF - 1, RoomNum, &CPtr))
 							CurFileName = NewFileName;
 						else if (doActionRule(MouseX, MouseY, TAKE - 1, 0, &CPtr))
 							CurFileName = NewFileName;
 						else if (MouseY < (VGAScaleY(149) + SVGACord(2)))
-							drawMessage(NOTHING);
+							drawStaticMessage(kTextNothing);
 					} else if ((ActionMode == 1) /* Manipulate an object */  ||
 					         (ActionMode == 2) /* Open up a "door" */      ||
 					         (ActionMode == 3)) { /* Close a "door" */
@@ -1225,7 +1221,7 @@ from_crumbs:
 							CurFileName = NewFileName;
 						else if (!doActionRule(MouseX, MouseY, ActionMode, 0, &CPtr)) {
 							if (MouseY < (VGAScaleY(149) + SVGACord(2)))
-								drawMessage(NOTHING);
+								drawStaticMessage(kTextNothing);
 						}
 					} else if (ActionMode == 4) { /* Look at closeups */
 						TempCPtr = CPtr;
@@ -1233,15 +1229,15 @@ from_crumbs:
 
 						if (CPtr == TempCPtr) {
 							if (MouseY < (VGAScaleY(149) + SVGACord(2)))
-								drawMessage(NOTHING);
+								drawStaticMessage(kTextNothing);
 						} else if (TempCPtr->GraphicName) {
 							if (*(TempCPtr->GraphicName)) {
 								DoBlack = true;
 								CPtr = TempCPtr;
 							} else if (MouseY < (VGAScaleY(149) + SVGACord(2)))
-								drawMessage(NOTHING);
+								drawStaticMessage(kTextNothing);
 						} else if (MouseY < (VGAScaleY(149) + SVGACord(2)))
-							drawMessage(NOTHING);
+							drawStaticMessage(kTextNothing);
 					} else if ((ActionMode == 5)  &&
 					         g_lab->_conditions->in(CurInv)) { /* Use an item on something else */
 						if (doOperateRule(MouseX, MouseY, CurInv, &CPtr)) {
@@ -1250,7 +1246,7 @@ from_crumbs:
 							if (!g_lab->_conditions->in(CurInv))
 								decIncInv(&CurInv, false);
 						} else if (MouseY < (VGAScaleY(149) + SVGACord(2)))
-							drawMessage(NOTHING);
+							drawStaticMessage(kTextNothing);
 					}
 				}
 
@@ -1356,8 +1352,7 @@ void LabEngine::go() {
 
 	initMouse();
 
-	mem = mem && initRoomBuffer() &&
-	      initLabText();
+	mem = mem && initRoomBuffer();
 
 	if (!dointro)
 		g_music->initMusic();
@@ -1399,7 +1394,6 @@ void LabEngine::go() {
 
 	closeFont(MsgFont);
 
-	freeLabText();
 	freeRoomBuffer();
 	freeBuffer();
 
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 23e587c..c8d23e9 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -37,6 +37,7 @@
 #include "lab/mouse.h"
 #include "lab/vga.h"
 #include "lab/text.h"
+#include "lab/resource.h"
 
 namespace Lab {
 
@@ -366,6 +367,9 @@ int32 longDrawMessage(const char *str) {
 
 
 
+void drawStaticMessage(byte index) {
+	drawMessage(g_resource->getStaticText((StaticText)index).c_str());
+}
 
 /******************************************************************************/
 /* Draws a message to the message box.                                        */
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 9ed334f..3a77855 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -98,6 +98,7 @@ uint32 flowTextToMem(Image *DestIm, void *font,     /* the TextAttr pointer */
                      uint16 y1, uint16 x2, uint16 y2, const char *text); /* The text itself */
 
 void drawMessage(const char *text);
+void drawStaticMessage(byte index);
 int32 longDrawMessage(const char *text);
 
 /* The Wipes */
diff --git a/engines/lab/labtext.cpp b/engines/lab/labtext.cpp
index 568ad82..9955c43 100644
--- a/engines/lab/labtext.cpp
+++ b/engines/lab/labtext.cpp
@@ -37,119 +37,6 @@ static uint32 SizeOfMemChunk;
 static char *BeginOfMemChunk, *CurPlace;
 
 
-char *LOWERFLOORS, *MIDDLEFLOORS, *UPPERFLOORS, *MEDMAZEFLOORS, *HEDGEMAZEFLOORS, *SURMAZEFLOORS, *CARNIVALFLOOR, *SURMAZEMSG, *FACINGNORTH, *FACINGEAST, *FACINGSOUTH, *FACINGWEST, *LAMPONMSG, *TURNLEFT, *TURNRIGHT, *GOFORWARDDIR, *NOPATH, *TAKEITEM, *SAVETEXT, *LOADTEXT, *BOOKMARKTEXT, *PERSONALTEXT, *DISKTEXT, *SAVEBOOK, *RESTOREBOOK, *SAVEFLASH, *RESTOREFLASH, *SAVEDISK, *RESTOREDISK, *NODISKINDRIVE, *WRITEPROTECTED, *SELECTDISK, *FORMATFLOPPY, *FORMATTING, *NOTHING, *USEONWHAT, *TAKEWHAT, *MOVEWHAT, *OPENWHAT, *CLOSEWHAT, *LOOKWHAT, *USEMAP, *USEJOURNAL, *TURNLAMPON, *TURNLAMPOFF, *USEWHISKEY, *USEPITH, *USEHELMET;
-
-
-#define LABTEXTFILE "Lab:Rooms/LabText"
-
-
-
-
-/*****************************************************************************/
-/* Gets the next string from the list, and changes the end of string marker  */
-/* from an end of line to a null character.                                  */
-/*****************************************************************************/
-static void setString(char **string) {
-	*string = CurPlace;
-
-	while (*CurPlace != '\n')
-		CurPlace++;
-
-	*CurPlace = 0;
-	CurPlace++;
-}
-
-
-
-/*****************************************************************************/
-/* Initializes everything for the Labyrinth text stuff                       */
-/*****************************************************************************/
-bool initLabText() {
-	Common::File *file = openPartial(LABTEXTFILE);
-	if (!file)
-		return false;
-
-	SizeOfMemChunk = file->size();
-	if (!SizeOfMemChunk || !(BeginOfMemChunk = (char *)calloc(SizeOfMemChunk, 1)))
-		return false;
-
-	file->read(BeginOfMemChunk, SizeOfMemChunk);
-	file->close();
-
-	CurPlace = BeginOfMemChunk;
-
-	setString(&LOWERFLOORS);
-	setString(&MIDDLEFLOORS);
-	setString(&UPPERFLOORS);
-	setString(&MEDMAZEFLOORS);
-	setString(&HEDGEMAZEFLOORS);
-	setString(&SURMAZEFLOORS);
-	setString(&CARNIVALFLOOR);
-	setString(&SURMAZEMSG);
-
-	setString(&FACINGNORTH);
-	setString(&FACINGEAST);
-	setString(&FACINGSOUTH);
-	setString(&FACINGWEST);
-
-	setString(&LAMPONMSG);
-
-	setString(&TURNLEFT);
-	setString(&TURNRIGHT);
-	setString(&GOFORWARDDIR);
-	setString(&NOPATH);
-	setString(&TAKEITEM);
-
-	setString(&SAVETEXT);
-	setString(&LOADTEXT);
-	setString(&BOOKMARKTEXT);
-	setString(&PERSONALTEXT);
-	setString(&DISKTEXT);
-
-	setString(&SAVEBOOK);
-	setString(&RESTOREBOOK);
-	setString(&SAVEFLASH);
-	setString(&RESTOREFLASH);
-	setString(&SAVEDISK);
-	setString(&RESTOREDISK);
-	setString(&NODISKINDRIVE);
-	setString(&WRITEPROTECTED);
-	setString(&SELECTDISK);
-
-	setString(&FORMATFLOPPY);
-	setString(&FORMATTING);
-
-	setString(&NOTHING);
-	setString(&USEONWHAT);
-	setString(&TAKEWHAT);
-	setString(&MOVEWHAT);
-	setString(&OPENWHAT);
-	setString(&CLOSEWHAT);
-	setString(&LOOKWHAT);
-
-	setString(&USEMAP);
-	setString(&USEJOURNAL);
-	setString(&TURNLAMPON);
-	setString(&TURNLAMPOFF);
-	setString(&USEWHISKEY);
-	setString(&USEPITH);
-	setString(&USEHELMET);
-
-	return true;
-}
-
-
-/*****************************************************************************/
-/* Frees the memory from the Labyrinth text stuff.                           */
-/*****************************************************************************/
-void freeLabText() {
-	if (SizeOfMemChunk && BeginOfMemChunk)
-		free(BeginOfMemChunk);
-}
-
-
-
-
 /*****************************************************************************/
 /* Decrypts a chunk of text.                                                 */
 /*****************************************************************************/
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 34eb018..06a0ac1 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -616,47 +616,42 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b
 	if (Floor == LOWERFLOOR) {
 		if (onFloor(SURMAZEFLOOR))
 			drawImage(Maze, mapScaleX(538), mapScaleY(277));
-	}
-
-	else if (Floor == MIDDLEFLOOR) {
+	} else if (Floor == MIDDLEFLOOR) {
 		if (onFloor(CARNIVAL))
 			drawImage(Maze, mapScaleX(358), mapScaleY(72));
 
 		if (onFloor(MEDMAZEFLOOR))
 			drawImage(Maze, mapScaleX(557), mapScaleY(325));
-	}
-
-	else if (Floor == UPPERFLOOR) {
+	} else if (Floor == UPPERFLOOR) {
 		if (onFloor(HEDGEMAZEFLOOR))
 			drawImage(HugeMaze, mapScaleX(524), mapScaleY(97));
-	}
-
-	else if (Floor == SURMAZEFLOOR) {
-		flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), SURMAZEMSG);
+	} else if (Floor == SURMAZEFLOOR) {
+		sptr = (char *)g_resource->getStaticText(kTextSurmazeMessage).c_str();
+		flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr);
 	}
 
 
 	switch (Floor) {
 	case LOWERFLOOR:
-		sptr = LOWERFLOORS;
+		sptr = (char *)g_resource->getStaticText(kTextLowerFloor).c_str();
 		break;
 	case MIDDLEFLOOR:
-		sptr = MIDDLEFLOORS;
+		sptr = (char *)g_resource->getStaticText(kTextMiddleFloor).c_str();
 		break;
 	case UPPERFLOOR:
-		sptr = UPPERFLOORS;
+		sptr = (char *)g_resource->getStaticText(kTextUpperFloor).c_str();
 		break;
 	case MEDMAZEFLOOR:
-		sptr = MEDMAZEFLOORS;
+		sptr = (char *)g_resource->getStaticText(kTextMedMazeFloor).c_str();
 		break;
 	case HEDGEMAZEFLOOR:
-		sptr = HEDGEMAZEFLOORS;
+		sptr = (char *)g_resource->getStaticText(kTextHedgeMazeFloor).c_str();
 		break;
 	case SURMAZEFLOOR:
-		sptr = SURMAZEFLOORS;
+		sptr = (char *)g_resource->getStaticText(kTextSurMazeFloor).c_str();
 		break;
 	case CARNIVAL:
-		sptr = CARNIVALFLOOR;
+		sptr = (char *)g_resource->getStaticText(kTextCarnivalFloor).c_str();
 		break;
 	default:
 		sptr = NULL;
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 3c5d1f6..87f3e58 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -35,6 +35,7 @@
 #include "lab/labfun.h"
 #include "lab/parsetypes.h"
 #include "lab/parsefun.h"
+#include "lab/resource.h"
 #include "lab/timing.h"
 #include "lab/diff.h"
 #include "lab/vga.h"
@@ -55,7 +56,6 @@ extern bool DoNotDrawMessage, IsBM, noupdatediff, QuitLab, MusicOn, DoBlack, Lon
 extern char diffcmap[256 * 3];
 extern const char *CurFileName;
 extern CloseDataPtr CPtr;
-extern char *FACINGNORTH, *FACINGEAST, *FACINGSOUTH, *FACINGWEST;
 
 /*****************************************************************************/
 /* Generates a random number.                                                */
@@ -195,53 +195,28 @@ char *getPictName(CloseDataPtr *LCPtr) {
 /* Draws the current direction to the screen.                                */
 /*****************************************************************************/
 void drawDirection(CloseDataPtr LCPtr) {
-	char Message[250];
-
-	if (LCPtr != NULL) {
-		if (LCPtr->Message) {
-			drawMessage(LCPtr->Message);
-			return;
-		}
+	if (LCPtr != NULL && LCPtr->Message) {
+		drawMessage(LCPtr->Message);
+		return;
 	}
 
-
-	Message[0] = '\0';
+	Common::String message;
 
 	if (Rooms[RoomNum].RoomMsg) {
-		strcpy(Message, Rooms[RoomNum].RoomMsg);
-		strcat(Message, ", ");
+		message += Rooms[RoomNum].RoomMsg;
+		message += ", ";
 	}
 
 	if (Direction == NORTH)
-		strcat(Message, FACINGNORTH);
+		message += g_resource->getStaticText(kTextFacingNorth);
 	else if (Direction == EAST)
-		strcat(Message, FACINGEAST);
+		message += g_resource->getStaticText(kTextFacingEast);
 	else if (Direction == SOUTH)
-		strcat(Message, FACINGSOUTH);
+		message += g_resource->getStaticText(kTextFacingSouth);
 	else if (Direction == WEST)
-		strcat(Message, FACINGWEST);
-
-	drawMessage(Message);
-}
-
-void getRoomMessage(int MyRoomNum, int MyDirection, char *msg) {
-	getViewData(MyRoomNum, MyDirection);
-
-	msg[0] = '\0';
-
-	if (Rooms[MyRoomNum].RoomMsg) {
-		strcpy(msg, Rooms[MyRoomNum].RoomMsg);
-		strcat(msg, ", ");
-	}
+		message += g_resource->getStaticText(kTextFacingWest);
 
-	if (MyDirection == NORTH)
-		strcat(msg, FACINGNORTH);
-	else if (MyDirection == EAST)
-		strcat(msg, FACINGEAST);
-	else if (MyDirection == SOUTH)
-		strcat(msg, FACINGSOUTH);
-	else if (MyDirection == WEST)
-		strcat(msg, FACINGWEST);
+	drawMessage(message.c_str());
 }
 
 /*****************************************************************************/
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index 9bcd638..59240a3 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -102,7 +102,7 @@ public:
 	bool readInventory(const char *fileName);
 	bool readViews(uint16 roomNum);
 	TextFont *getFont(const char *filename);
-	Common::String getStaticText(byte index) const { return _staticText[index + 1]; }
+	Common::String getStaticText(byte index) const { return _staticText[index]; }
 
 private:
 	Common::File *openDataFile(const char * fileName, uint32 fileHeader);


Commit: 92bb4a522abb2f707fd94a529e7e384203ca2b88
    https://github.com/scummvm/scummvm/commit/92bb4a522abb2f707fd94a529e7e384203ca2b88
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-15T00:05:02+01:00

Commit Message:
LAB: Replace readRoomData() and readInventory()

Changed paths:
    engines/lab/engine.cpp
    engines/lab/readparse.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index c1883a0..f7f65e2 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -673,8 +673,8 @@ static void mainGameLoop() {
 	RoomNum = 1;
 	Direction = NORTH;
 
-	readRoomData("LAB:Doors");
-	readInventory("LAB:Inventor");
+	g_resource->readRoomData("LAB:Doors");
+	g_resource->readInventory("LAB:Inventor");
 
 	if (!(g_lab->_conditions = new LargeSet(HighestCondition + 1)))
 		return;
diff --git a/engines/lab/readparse.cpp b/engines/lab/readparse.cpp
index 3d3c270..624f7a3 100644
--- a/engines/lab/readparse.cpp
+++ b/engines/lab/readparse.cpp
@@ -58,49 +58,6 @@ static bool rallocate(void **Ptr, uint32 Size) {
 
 
 /*****************************************************************************/
-/* Reads in the RoomData.                                                    */
-/*****************************************************************************/
-bool readRoomData(const char *fileName) {
-	byte **file;
-	uint16 Counter;
-	char Temp[5];
-
-	if ((file = g_music->newOpen(fileName)) != NULL) {
-		readBlock(Temp, 4L, file);
-		Temp[4] = '\0';
-
-		if (strcmp(Temp, "DOR1") != 0)
-			return false;
-
-		readBlock(&ManyRooms, 2L, file);
-		swapUShortPtr(&ManyRooms, 1);
-		readBlock(&HighestCondition, 2L, file);
-		swapUShortPtr(&HighestCondition, 1);
-
-		if ((Rooms = (RoomData *)calloc(ManyRooms + 1, sizeof(RoomData)))) {
-			for (Counter = 1; Counter <= ManyRooms; Counter++) {
-				readBlock(&(Rooms[Counter].NorthDoor), 2L, file);
-				readBlock(&(Rooms[Counter].SouthDoor), 2L, file);
-				readBlock(&(Rooms[Counter].EastDoor),  2L, file);
-				readBlock(&(Rooms[Counter].WestDoor),  2L, file);
-
-				swapUShortPtr(&(Rooms[Counter].NorthDoor), 1);
-				swapUShortPtr(&(Rooms[Counter].SouthDoor), 1);
-				swapUShortPtr(&(Rooms[Counter].EastDoor), 1);
-				swapUShortPtr(&(Rooms[Counter].WestDoor), 1);
-
-				readBlock(&(Rooms[Counter].WipeType),  1L, file);
-			}
-		} else
-			return false;
-	} else
-		return false;
-
-	return true;
-}
-
-
-/*****************************************************************************/
 /* Reads in a NULL terminated string, and allocates memory for it.           */
 /*****************************************************************************/
 static bool readString(char **string, byte **file) {
@@ -129,52 +86,6 @@ static bool readString(char **string, byte **file) {
 
 
 /*****************************************************************************/
-/* Reads in the Inventory data.                                              */
-/*****************************************************************************/
-bool readInventory(const char *fileName) {
-	byte **file;
-	uint16 Counter;
-	char Temp[5];
-
-	if ((file = g_music->newOpen(fileName)) != NULL) {
-		readBlock(Temp, 4L, file);
-		Temp[4] = '\0';
-
-		if (strcmp(Temp, "INV1") != 0)
-			return false;
-
-		readBlock(&NumInv, 2L, file);
-		swapUShortPtr(&NumInv, 1);
-
-		UseMemory = true;
-
-		if (rallocate((void **) &Inventory, (NumInv + 1) * sizeof(InventoryData))) {
-			for (Counter = 1; Counter <= NumInv; Counter++) {
-				readBlock(&(Inventory[Counter].Many), 2L, file);
-				swapUShortPtr(&(Inventory[Counter].Many), 1);
-
-				if (!readString(&(Inventory[Counter].name), file)) {
-					UseMemory = false;
-					return false;
-				}
-
-				if (!readString(&(Inventory[Counter].BInvName), file)) {
-					UseMemory = false;
-					return false;
-				}
-			}
-		} else {
-			UseMemory = false;
-			return false;
-		}
-	} else
-		return false;
-
-	UseMemory = false;
-	return true;
-}
-
-/*****************************************************************************/
 /* Reads in a list of conditions.                                            */
 /*****************************************************************************/
 static int16 *readConditions(byte **file) {


Commit: 9cd640a6ef6ea57edb516c98dd107b161e059e1f
    https://github.com/scummvm/scummvm/commit/9cd640a6ef6ea57edb516c98dd107b161e059e1f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:32+01:00

Commit Message:
LAB: Bugfixes to the Resource class

Changed paths:
    engines/lab/resource.cpp



diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 9babc5c..6675409 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -178,11 +178,10 @@ char *Resource::readString(Common::File *file) {
 	char *c = str;
 	for (int i = 0; i < size; i++) {
 		*c = file->readByte();
-		if (*c != '\0')
-			*c -= 95;	// decrypt char
+		// Decrypt char
+		*c = (i < size - 1) ? *c - 95 : '\0';
 		c++;
 	}
-	*c = 0;
 
 	return str;
 }
@@ -212,16 +211,16 @@ Rule *Resource::readRule(Common::File *file) {
 
 		if (c == 1) {
 			rule = (Rule *)malloc(sizeof(Rule));
+			if (!head)
+				head = rule;
 			rule->RuleType = file->readSint16LE();
 			rule->Param1 = file->readSint16LE();
 			rule->Param2 = file->readSint16LE();
 			rule->Condition = readConditions(file);
+			rule->NextRule = NULL;
 			if (!rule->Condition)
-				return NULL;
+				return head;
 			rule->ActionList = readAction(file);
-			rule->NextRule = NULL;
-			if (!head)
-				head = rule;
 			rule = rule->NextRule;
 		}
 	} while (c == 1);
@@ -240,6 +239,8 @@ Action *Resource::readAction(Common::File *file) {
 
 		if (c == 1) {
 			action = (Action *)malloc(sizeof(Action));
+			if (!head)
+				head = action;
 			action->ActionType = file->readSint16LE();
 			action->Param1 = file->readSint16LE();
 			action->Param2 = file->readSint16LE();
@@ -257,8 +258,6 @@ Action *Resource::readAction(Common::File *file) {
 			}
 
 			action->NextAction = NULL;
-			if (!head)
-				head = action;
 			action = action->NextAction;
 		}
 	} while (c == 1);
@@ -276,6 +275,8 @@ CloseData *Resource::readCloseUps(uint16 depth, Common::File *file) {
 
 		if (c != '\0') {
 			closeups = (CloseData *)malloc(sizeof(CloseData));
+			if (!head)
+				head = closeups;
 			closeups->x1 = file->readUint16LE();
 			closeups->y1 = file->readUint16LE();
 			closeups->x2 = file->readUint16LE();
@@ -284,11 +285,9 @@ CloseData *Resource::readCloseUps(uint16 depth, Common::File *file) {
 			closeups->depth = depth;
 			closeups->GraphicName = readString(file);
 			closeups->Message = readString(file);
-			if (!(closeups->SubCloseUps = readCloseUps(depth + 1, file)))
-				return NULL;
 			closeups->NextCloseUp = NULL;
-			if (!head)
-				head = closeups;
+			if (!(closeups->SubCloseUps = readCloseUps(depth + 1, file)))
+				return head;
 			closeups = closeups->NextCloseUp;
 		}
 	} while (c != '\0');
@@ -306,14 +305,14 @@ viewData *Resource::readView(Common::File *file) {
 
 		if (c == 1) {
 			view = (viewData *)malloc(sizeof(viewData));
+			if (!head)
+				head = view;
 			view->Condition = readConditions(file);
 			if (!view->Condition)
-				return NULL;
+				return head;
 			view->GraphicName = readString(file);
 			view->closeUps = readCloseUps(0, file);
 			view->NextCondition = NULL;
-			if (!head)
-				head = view;
 			view = view->NextCondition;
 		}
 	} while (c == 1);


Commit: 72f7fbe82bd358f2a3c98ff18a0b81964aaf15d4
    https://github.com/scummvm/scummvm/commit/72f7fbe82bd358f2a3c98ff18a0b81964aaf15d4
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:39+01:00

Commit Message:
LAB: Bugfixes to the Resource class

Changed paths:
    engines/lab/resource.cpp



diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 6675409..dcce41b 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -145,13 +145,6 @@ bool Resource::readViews(uint16 roomNum) {
 	Rooms[roomNum].EastView = readView(dataFile);
 	Rooms[roomNum].WestView = readView(dataFile);
 	Rooms[roomNum].RuleList = readRule(dataFile);
-	/*warning("Room %d, msg %s, north %s, south %s, east %s, west %s",
-		Rooms[roomNum].RoomMsg,
-		Rooms[roomNum].NorthView->GraphicName,
-		Rooms[roomNum].SouthView->GraphicName,
-		Rooms[roomNum].EastView->GraphicName,
-		Rooms[roomNum].WestView->GraphicName
-	);*/
 
 	g_music->updateMusic();
 
@@ -204,6 +197,7 @@ int16 *Resource::readConditions(Common::File *file) {
 Rule *Resource::readRule(Common::File *file) {
 	char c;
 	Rule *rule = NULL;
+	Rule *prev = NULL;
 	Rule *head = NULL;
 
 	do {
@@ -213,15 +207,15 @@ Rule *Resource::readRule(Common::File *file) {
 			rule = (Rule *)malloc(sizeof(Rule));
 			if (!head)
 				head = rule;
+			if (prev)
+				prev->NextRule = rule;
 			rule->RuleType = file->readSint16LE();
 			rule->Param1 = file->readSint16LE();
 			rule->Param2 = file->readSint16LE();
 			rule->Condition = readConditions(file);
-			rule->NextRule = NULL;
-			if (!rule->Condition)
-				return head;
 			rule->ActionList = readAction(file);
-			rule = rule->NextRule;
+			rule->NextRule = NULL;
+			prev = rule;
 		}
 	} while (c == 1);
 
@@ -231,6 +225,7 @@ Rule *Resource::readRule(Common::File *file) {
 Action *Resource::readAction(Common::File *file) {
 	char c;
 	Action *action = NULL;
+	Action *prev = NULL;
 	Action *head = NULL;
 	char **messages;
 
@@ -241,6 +236,8 @@ Action *Resource::readAction(Common::File *file) {
 			action = (Action *)malloc(sizeof(Action));
 			if (!head)
 				head = action;
+			if (prev)
+				prev->NextAction = action;
 			action->ActionType = file->readSint16LE();
 			action->Param1 = file->readSint16LE();
 			action->Param2 = file->readSint16LE();
@@ -258,7 +255,7 @@ Action *Resource::readAction(Common::File *file) {
 			}
 
 			action->NextAction = NULL;
-			action = action->NextAction;
+			prev = action;
 		}
 	} while (c == 1);
 
@@ -267,28 +264,30 @@ Action *Resource::readAction(Common::File *file) {
 
 CloseData *Resource::readCloseUps(uint16 depth, Common::File *file) {
 	char c;
-	CloseData *closeups = NULL;
+	CloseData *closeup = NULL;
+	CloseData *prev = NULL;
 	CloseData *head = NULL;
 
 	do {
 		c = file->readByte();
 
 		if (c != '\0') {
-			closeups = (CloseData *)malloc(sizeof(CloseData));
+			closeup = (CloseData *)malloc(sizeof(CloseData));
 			if (!head)
-				head = closeups;
-			closeups->x1 = file->readUint16LE();
-			closeups->y1 = file->readUint16LE();
-			closeups->x2 = file->readUint16LE();
-			closeups->y2 = file->readUint16LE();
-			closeups->CloseUpType = file->readSint16LE();
-			closeups->depth = depth;
-			closeups->GraphicName = readString(file);
-			closeups->Message = readString(file);
-			closeups->NextCloseUp = NULL;
-			if (!(closeups->SubCloseUps = readCloseUps(depth + 1, file)))
-				return head;
-			closeups = closeups->NextCloseUp;
+				head = closeup;
+			if (prev)
+				prev->NextCloseUp = closeup;
+			closeup->x1 = file->readUint16LE();
+			closeup->y1 = file->readUint16LE();
+			closeup->x2 = file->readUint16LE();
+			closeup->y2 = file->readUint16LE();
+			closeup->CloseUpType = file->readSint16LE();
+			closeup->depth = depth;
+			closeup->GraphicName = readString(file);
+			closeup->Message = readString(file);
+			closeup->SubCloseUps = readCloseUps(depth + 1, file);
+			closeup->NextCloseUp = NULL;
+			prev = closeup;
 		}
 	} while (c != '\0');
 	
@@ -298,6 +297,7 @@ CloseData *Resource::readCloseUps(uint16 depth, Common::File *file) {
 viewData *Resource::readView(Common::File *file) {
 	char c;
 	viewData *view = NULL;
+	viewData *prev = NULL;
 	viewData *head = NULL;
 
 	do {
@@ -307,13 +307,13 @@ viewData *Resource::readView(Common::File *file) {
 			view = (viewData *)malloc(sizeof(viewData));
 			if (!head)
 				head = view;
+			if (prev)
+				prev->NextCondition = view;
 			view->Condition = readConditions(file);
-			if (!view->Condition)
-				return head;
 			view->GraphicName = readString(file);
 			view->closeUps = readCloseUps(0, file);
 			view->NextCondition = NULL;
-			view = view->NextCondition;
+			prev = view;
 		}
 	} while (c == 1);
 


Commit: 77608bfc66d3b8b8d7414d005fbde39b2af67658
    https://github.com/scummvm/scummvm/commit/77608bfc66d3b8b8d7414d005fbde39b2af67658
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:39+01:00

Commit Message:
LAB: Move more room reading functions to the Resource class

Changed paths:
  R engines/lab/labtext.cpp
  R engines/lab/readparse.cpp
    engines/lab/labfun.h
    engines/lab/map.cpp
    engines/lab/module.mk
    engines/lab/parsefun.h
    engines/lab/processroom.cpp



diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 3a77855..c9fa307 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -155,14 +155,6 @@ Common::File *openPartial(const char *name);
 void closePartial(int32 File);
 
 /*---------------------------*/
-/*------ From LabText.c -----*/
-/*---------------------------*/
-
-bool initLabText();
-void freeLabText();
-void decrypt(byte *text);
-
-/*---------------------------*/
 /*----- From LabMusic.c -----*/
 /*---------------------------*/
 
diff --git a/engines/lab/labtext.cpp b/engines/lab/labtext.cpp
deleted file mode 100644
index 9955c43..0000000
--- a/engines/lab/labtext.cpp
+++ /dev/null
@@ -1,49 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "lab/stddefines.h"
-#include "lab/labfun.h"
-
-namespace Lab {
-
-static uint32 SizeOfMemChunk;
-static char *BeginOfMemChunk, *CurPlace;
-
-
-/*****************************************************************************/
-/* Decrypts a chunk of text.                                                 */
-/*****************************************************************************/
-void decrypt(byte *text) {
-	while (text && *text != '\0') {
-		*text++ -= (byte)95;
-	}
-}
-
-} // End of namespace Lab
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 06a0ac1..ceddc4b 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -74,7 +74,11 @@ void setAmigaPal(uint16 *pal, uint16 numcolors) {
 	writeColorRegsSmooth(vgapal, 0, 16);
 }
 
-
+void decrypt(byte *text) {
+	while (text && *text != '\0') {
+		*text++ -= (byte)95;
+	}
+}
 
 /*****************************************************************************/
 /* Gets a chunk of text and puts it into the graphics memory.                */
@@ -813,7 +817,7 @@ void processMap(uint16 CurRoom) {
 
 					if (OldMsg != CurMsg) {
 						if (Rooms[CurMsg].RoomMsg == NULL)
-							readViews(CurMsg);
+							g_resource->readViews(CurMsg);
 
 						if ((sptr = Rooms[CurMsg].RoomMsg)) {
 							mouseHide();
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index 1520672..f36871c 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -11,13 +11,11 @@ MODULE_OBJS := \
 	labfile.o \
 	labmusic.o \
 	labsets.o \
-	labtext.o \
 	machine.o \
 	map.o \
 	mouse.o \
 	processroom.o \
 	readdiff.o \
-	readparse.o \
 	resource.o \
 	savegame.o \
 	special.o \
diff --git a/engines/lab/parsefun.h b/engines/lab/parsefun.h
index b75368d..b634e9c 100644
--- a/engines/lab/parsefun.h
+++ b/engines/lab/parsefun.h
@@ -48,12 +48,6 @@ bool initRoomBuffer();
 void freeRoomBuffer();
 void allocRoom(void **Ptr, uint16 Size, uint16 RoomNum);
 
-/* From ReadParse.c */
-
-bool readRoomData(const char *fileName);
-bool readInventory(const char *fileName);
-bool readViews(uint16 RoomNum);
-
 
 /* From ProcessRoom.c */
 
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 87f3e58..19e9588 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -108,7 +108,7 @@ ViewDataPtr getViewData(uint16 roomNum, uint16 direction) {
 		VPtr = &Rooms[roomNum].WestView;
 
 	if (*VPtr == NULL)
-		readViews(roomNum);
+		g_resource->readViews(roomNum);
 
 	ViewPtr = *VPtr;
 
@@ -640,7 +640,7 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr LCPtr, Clo
 		RPtr = Rooms[roomNum].RuleList;
 
 		if ((RPtr == NULL) && (roomNum == 0)) {
-			readViews(roomNum);
+			g_resource->readViews(roomNum);
 			RPtr = Rooms[roomNum].RuleList;
 		}
 
@@ -702,7 +702,7 @@ static bool doOperateRuleSub(int16 ItemNum, int16 roomNum, CloseDataPtr LCPtr, C
 			RPtr = Rooms[roomNum].RuleList;
 
 			if ((RPtr == NULL) && (roomNum == 0)) {
-				readViews(roomNum);
+				g_resource->readViews(roomNum);
 				RPtr = Rooms[roomNum].RuleList;
 			}
 
diff --git a/engines/lab/readparse.cpp b/engines/lab/readparse.cpp
deleted file mode 100644
index 624f7a3..0000000
--- a/engines/lab/readparse.cpp
+++ /dev/null
@@ -1,292 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "lab/labfun.h"
-#include "lab/parsetypes.h"
-#include "lab/parsefun.h"
-#include "lab/stddefines.h"
-
-namespace Lab {
-
-/* Global parser data */
-
-#define MAXSTRINGLENGTH 250
-
-static bool UseMemory = false;
-static uint16 allocroom;
-
-extern RoomData *Rooms;
-extern InventoryData *Inventory;
-extern uint16 NumInv, ManyRooms, HighestCondition, Direction;
-
-static bool rallocate(void **Ptr, uint32 Size) {
-	if (UseMemory)
-		return ((*Ptr = calloc(Size, 1)) != 0);
-	else {
-		allocRoom(Ptr, (uint16) Size, allocroom);
-		return true;
-	}
-}
-
-
-
-/*****************************************************************************/
-/* Reads in a NULL terminated string, and allocates memory for it.           */
-/*****************************************************************************/
-static bool readString(char **string, byte **file) {
-	char len;
-	uint32 counter = 0L;
-
-
-	readBlock(&len, 1L, file);
-
-	if (len) {
-		counter = len;
-
-		if (rallocate((void **) string, counter)) {
-			readBlock(*string, counter, file);
-			(*string)[counter - 1] = 0; /* Sanity modification */
-			decrypt((byte *)*string);
-			return true;
-		}
-	} else {
-		*string = NULL;
-		return true;
-	}
-
-	return false;
-}
-
-
-/*****************************************************************************/
-/* Reads in a list of conditions.                                            */
-/*****************************************************************************/
-static int16 *readConditions(byte **file) {
-	int16 Counter = 0, last, list[25], *ptr;
-
-	do {
-		readBlock(&last, 2L, file);
-		swapUShortPtr((uint16 *)&last, 1);
-
-		if (Counter < 25) {
-			list[Counter] = last;
-			Counter++;
-		} else
-			list[Counter] = 0;
-	} while (last);
-
-	if (!rallocate((void **) & (ptr), Counter * 2L))
-		return NULL;
-
-	memcpy(ptr, list, (size_t)(Counter * 2L));
-
-	return ptr;
-}
-
-/*****************************************************************************/
-/* Reads in some CloseUp data.                                               */
-/*****************************************************************************/
-static bool readCloseUps(CloseDataPtr *CPtr, uint16 depth, byte **file) {
-	char c;
-
-	while (1) {
-		*CPtr = NULL;
-
-		readBlock(&c, 1L, file);
-
-		if (c != '\0') {
-			if (rallocate((void **) CPtr, sizeof(CloseData))) {
-				(*CPtr)->SubCloseUps = NULL;
-				(*CPtr)->NextCloseUp = NULL;
-				(*CPtr)->depth       = depth;
-
-				readBlock(*CPtr, 10L, file);
-				swapUShortPtr((uint16 *)*CPtr, 5);
-
-				if (!readString(&((*CPtr)->GraphicName), file))
-					return false;
-
-				if (!readString(&((*CPtr)->Message), file))
-					return false;
-
-				if (!readCloseUps(&((*CPtr)->SubCloseUps), depth + 1, file))
-					return false;
-
-				CPtr = &((*CPtr)->NextCloseUp);
-			} else
-				return false;
-		} else
-			return true;
-	}
-}
-
-
-/*****************************************************************************/
-/* Reads in a View.                                                          */
-/*****************************************************************************/
-static bool readView(ViewDataPtr *VPtr, byte **file) {
-	char c;
-
-	while (1) {
-		*VPtr = NULL;
-
-		readBlock(&c, 1L, file);
-
-		if (c == 1) {
-			if (rallocate((void **)VPtr, sizeof(viewData))) {
-				(*VPtr)->closeUps = NULL;
-				(*VPtr)->NextCondition = NULL;
-
-				(*VPtr)->Condition = readConditions(file);
-
-				if (!(*VPtr)->Condition)
-					return false;
-
-				if (!readString(&((*VPtr)->GraphicName), file))
-					return false;
-
-				readCloseUps(&((*VPtr)->closeUps), 0, file);
-
-				VPtr = &((*VPtr)->NextCondition);
-			}
-			else
-				return false;
-		}
-		else
-			return true;
-	}
-}
-
-
-/*****************************************************************************/
-/* Reads in an Action.                                                       */
-/*****************************************************************************/
-static bool readAction(ActionPtr *APtr, byte **file) {
-	char c;
-	byte **ptrarray;
-	uint16 counter;
-
-	while (1) {
-		*APtr = NULL;
-
-		readBlock(&c, 1L, file);
-
-		if (c == 1) {
-			if (rallocate((void **) APtr, sizeof(Action))) {
-				readBlock(*APtr, 8L, file);
-				swapShortPtr((int16 *)*APtr, 4);
-
-				if ((*APtr)->ActionType == SHOWMESSAGES) {
-					if (!rallocate((void **) &ptrarray, 4L * (*APtr)->Param1))
-						return false;
-
-					for (counter = 0; counter < (*APtr)->Param1; counter++)
-						readString((char **) & (ptrarray[counter]), file);
-
-					(*APtr)->Data = (byte *)ptrarray;
-				} else
-					readString((char **) & ((*APtr)->Data), file);
-
-				APtr = &((*APtr)->NextAction);
-			} else
-				return false;
-		} else
-			return true;
-	}
-}
-
-
-/*****************************************************************************/
-/* Reads in a rule.                                                          */
-/*****************************************************************************/
-static bool readRule(RulePtr *RPtr, byte **file) {
-	char c;
-
-	while (1) {
-		*RPtr = NULL;
-		readBlock(&c, 1L, file);
-
-		if (c == 1) {
-			if (rallocate((void **) RPtr, sizeof(Rule))) {
-				readBlock(*RPtr, 6L, file);
-				swapShortPtr((int16 *)*RPtr, 3);
-
-				(*RPtr)->Condition = readConditions(file);
-
-				if (!(*RPtr)->Condition)
-					return false;
-
-				readAction(&((*RPtr)->ActionList), file);
-			} else
-				return false;
-
-			RPtr = &((*RPtr)->NextRule);
-		} else
-			return true;
-	}
-}
-
-
-/*****************************************************************************/
-/* Reads in the views of a room.                                             */
-/*****************************************************************************/
-bool readViews(uint16 RoomNum) {
-	Common::String fileName = "LAB:Rooms/" + Common::String::format("%d", RoomNum);
-	char Temp[10];
-	byte **file;
-
-	allocroom = RoomNum;
-
-	if ((file = g_music->newOpen(fileName.c_str())) != NULL) {
-		readBlock(Temp, 4L, file);
-		Temp[4] = '\0';
-
-		if (strcmp(Temp, "ROM4") != 0)
-			return false;
-
-		readString(&(Rooms[RoomNum].RoomMsg), file);
-
-		readView(&Rooms[RoomNum].NorthView, file);
-		readView(&Rooms[RoomNum].SouthView, file);
-		readView(&Rooms[RoomNum].EastView, file);
-		readView(&Rooms[RoomNum].WestView, file);
-
-		readRule(&Rooms[RoomNum].RuleList, file);
-
-		g_music->updateMusic();
-
-		return true;
-	} else
-		return false;
-
-	return false;
-}
-
-} // End of namespace Lab


Commit: b033b7e539d356b5e94987dfa8d3be68c2acf4ab
    https://github.com/scummvm/scummvm/commit/b033b7e539d356b5e94987dfa8d3be68c2acf4ab
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:40+01:00

Commit Message:
LAB: Simplify readInitialConditions()

Changed paths:
    engines/lab/labsets.cpp
    engines/lab/resource.cpp
    engines/lab/resource.h



diff --git a/engines/lab/labsets.cpp b/engines/lab/labsets.cpp
index ae70d81..4dcc0c8 100644
--- a/engines/lab/labsets.cpp
+++ b/engines/lab/labsets.cpp
@@ -30,6 +30,7 @@
 
 #include "lab/stddefines.h"
 #include "lab/labfun.h"
+#include "lab/resource.h"
 
 namespace Lab {
 
@@ -57,29 +58,19 @@ void LargeSet::exclElement(uint16 element) {
 }
 
 bool LargeSet::readInitialConditions(const char *fileName) {
-	byte **file;
-	uint16 many, set;
-	char temp[5];
+	Common::File *file;
 
-	if ((file = g_music->newOpen(fileName)) != NULL) {
-		memcpy(&temp, file, 4);	file += 4;
-		temp[4] = '\0';
-
-		if (strcmp(temp, "CON0") != 0)
-			return false;
-
-		memcpy(&many, file, 2);	file += 2;
-		swapUShortPtr(&many, 1);
-
-		for (int counter = 0; counter < many; counter++) {
-			memcpy(&set, file, 2);	file += 2;
-			swapUShortPtr(&set, 1);
-			inclElement(set);
+	if (file = g_resource->openDataFile(fileName, MKTAG('C', 'O', 'N', '0'))) {
+		uint16 conditions = file->readUint16LE();
+		for (int i = 0; i < conditions; i++) {
+			inclElement(file->readUint16LE());
 		}
-	} else
-		return false;
 
-	return true;
+		delete file;
+		return true;
+	}
+
+	return false;
 }
 
 
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index dcce41b..268b4b6 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -28,10 +28,6 @@
  *
  */
 
-//#include "lab/labfun.h"
-//#include "lab/parsetypes.h"
-//#include "lab/parsefun.h"
-//#include "lab/stddefines.h"
 #include "lab/text.h"
 #include "lab/resource.h"
 
@@ -152,7 +148,7 @@ bool Resource::readViews(uint16 roomNum) {
 	return true;
 }
 
-Common::File *Resource::openDataFile(const char * fileName, uint32 fileHeader) {
+Common::File *Resource::openDataFile(const char *fileName, uint32 fileHeader) {
 	Common::File *dataFile = new Common::File();
 	dataFile->open(translateFileName(fileName));
 	if (dataFile->readUint32BE() != fileHeader) {
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index 59240a3..f9ec4f6 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -98,6 +98,7 @@ public:
 	Resource();
 	~Resource() {}
 
+	Common::File *openDataFile(const char * fileName, uint32 fileHeader);
 	bool readRoomData(const char *fileName);
 	bool readInventory(const char *fileName);
 	bool readViews(uint16 roomNum);
@@ -105,7 +106,6 @@ public:
 	Common::String getStaticText(byte index) const { return _staticText[index]; }
 
 private:
-	Common::File *openDataFile(const char * fileName, uint32 fileHeader);
 	char *readString(Common::File *file);
 	int16 *readConditions(Common::File *file);
 	Rule *readRule(Common::File *file);


Commit: 9676165436e1e3e7ee4db16c2cb905e0b2aeb1ff
    https://github.com/scummvm/scummvm/commit/9676165436e1e3e7ee4db16c2cb905e0b2aeb1ff
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:40+01:00

Commit Message:
LAB: Remove unused code for the demo version

The two places where the game stops in the demo versions should already
be handled by the current code

Changed paths:
    engines/lab/processroom.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 19e9588..03fedaa 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -440,23 +440,6 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
 			break;
 
 		case SETPOSITION:
-#if defined(LABDEMO)
-
-			// if teleporting to room 45 or 49
-			if (APtr->Param1 == 45 || APtr->Param1 == 49) {
-				extern void doTrialBlock();
-
-				// Time to pay up!
-				doTrialBlock();
-
-				CurFileName = getPictName(LCPtr);
-				readPict(CurFileName, true);
-
-				APtr = NULL;
-				continue;
-			}
-
-#endif
 			if (APtr->Param1 & 0x8000) {
 				// This is a Wyrmkeep Windows trial version, thus stop at this
 				// point, since we can't check for game payment status
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index b7f1472..2c0a488 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -415,10 +415,6 @@ static void changeTile(uint16 col, uint16 row) {
 	if (scrolltype != -1) {
 		doTileScroll(col, row, scrolltype);
 
-#if defined(LABDEMO)
-		return;
-#endif
-
 		if (g_lab->getFeatures() & GF_WINDOWS_TRIAL) {
 			GUI::MessageDialog trialMessage("This puzzle is not available in the trial version of the game");
 			trialMessage.runModal();
@@ -1102,56 +1098,4 @@ void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1,
 	blackAllScreen();
 }
 
-#if defined(LABDEMO)
-void doTrialBlock() {
-	IntuiMessage *Msg;
-
-	uint32 Class;
-	uint16 Qualifier, MouseX, MouseY, Code, Temp;
-	int i;
-
-	loadBackPict("P:Warning", false);
-	mouseShow();
-
-	VGASetPal(diffcmap, 256);
-	memcpy(g_CommonPalette, diffcmap, 3 * 256);
-
-	while (1) {
-		g_music->updateMusic();  /* Make sure we check the music at least after every message */
-		Msg = getMsg();
-
-		if (Msg == NULL) {
-			g_music->updateMusic();
-		} else {
-			Class     = Msg->Class;
-			Qualifier = Msg->Qualifier;
-			MouseX    = Msg->MouseX;
-			MouseY    = Msg->MouseY;
-			Code      = Msg->Code;
-
-			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) ||
-			        ((Class == RAWKEY) && (Code == 27)))
-				return;
-
-			if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) {
-				if (MouseY > 399) {
-					// click on control panel, exit
-					break;
-				}
-
-				if (MouseX >= 0 && MouseX <= 319 && MouseY >= 0 && MouseY <= 399) {
-					extern void getItNow();
-					getItNow();
-				} else if (MouseX >= 320 && MouseX <= 639 && MouseY >= 0 && MouseY <= 399) {
-					break;
-				}
-			}
-		}
-	}
-
-	eatMessages();
-	mouseHide();
-}
-#endif
-
 } // End of namespace Lab


Commit: 93b2e413fd8085a1985519429c369282c99c941e
    https://github.com/scummvm/scummvm/commit/93b2e413fd8085a1985519429c369282c99c941e
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:40+01:00

Commit Message:
LAB: Change the scene rule list to use a Common::List

Changed paths:
    engines/lab/allocroom.cpp
    engines/lab/parsetypes.h
    engines/lab/processroom.cpp
    engines/lab/resource.cpp
    engines/lab/resource.h



diff --git a/engines/lab/allocroom.cpp b/engines/lab/allocroom.cpp
index 434a147..2d7016d 100644
--- a/engines/lab/allocroom.cpp
+++ b/engines/lab/allocroom.cpp
@@ -97,7 +97,14 @@ static void freeRoom(uint16 RMarker) {
 		Rooms[RoomNum].SouthView = NULL;
 		Rooms[RoomNum].EastView  = NULL;
 		Rooms[RoomNum].WestView  = NULL;
-		Rooms[RoomNum].RuleList  = NULL;
+
+		RuleList *rules = Rooms[RoomNum].rules;
+		for (RuleList::iterator rule = rules->begin(); rule != rules->end(); rule++)
+			delete *rule;
+		Rooms[RoomNum].rules->clear();
+		delete Rooms[RoomNum].rules;
+		Rooms[RoomNum].rules  = NULL;
+
 		Rooms[RoomNum].RoomMsg   = NULL;
 	}
 
diff --git a/engines/lab/parsetypes.h b/engines/lab/parsetypes.h
index 0f9ec50..f185c11 100644
--- a/engines/lab/parsetypes.h
+++ b/engines/lab/parsetypes.h
@@ -138,7 +138,7 @@ struct Rule {
 	Rule *NextRule;
 };
 
-typedef Rule *RulePtr;
+typedef Common::List<Rule *> RuleList;
 
 struct RoomData {
 	uint16 NorthDoor, SouthDoor, EastDoor, WestDoor;
@@ -146,7 +146,7 @@ struct RoomData {
 	byte WipeType;
 
 	ViewDataPtr NorthView, SouthView, EastView, WestView;
-	RulePtr RuleList;
+	RuleList *rules;
 	char *RoomMsg;
 };
 
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 03fedaa..ea0309a 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -615,34 +615,29 @@ static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
 /* Does the work for doActionRule.                                           */
 /*****************************************************************************/
 static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr LCPtr, CloseDataPtr *Set, bool AllowDefaults) {
-	RulePtr RPtr;
-
 	action++;
 
 	if (LCPtr) {
-		RPtr = Rooms[roomNum].RuleList;
-
-		if ((RPtr == NULL) && (roomNum == 0)) {
+		RuleList *rules = Rooms[RoomNum].rules;
+		
+		if ((rules == NULL) && (roomNum == 0)) {
 			g_resource->readViews(roomNum);
-			RPtr = Rooms[roomNum].RuleList;
+			rules = Rooms[roomNum].rules;
 		}
 
-
-		while (RPtr) {
-			if ((RPtr->RuleType == ACTION) &&
-			        ((RPtr->Param1 == action) || ((RPtr->Param1 == 0) && AllowDefaults))) {
-				if (((RPtr->Param2 == LCPtr->CloseUpType) ||
-				        ((RPtr->Param2 == 0) && AllowDefaults))
+		for (RuleList::iterator rule = rules->begin(); rule != rules->end(); rule++) {
+			if (((*rule)->RuleType == ACTION) &&
+				(((*rule)->Param1 == action) || (((*rule)->Param1 == 0) && AllowDefaults))) {
+				if ((((*rule)->Param2 == LCPtr->CloseUpType) ||
+					(((*rule)->Param2 == 0) && AllowDefaults))
 				        ||
-				        ((action == 1) && (RPtr->Param2 == (-LCPtr->CloseUpType)))) {
-					if (checkConditions(RPtr->Condition)) {
-						doActions(RPtr->ActionList, Set);
+						((action == 1) && ((*rule)->Param2 == (-LCPtr->CloseUpType)))) {
+					if (checkConditions((*rule)->Condition)) {
+						doActions((*rule)->ActionList, Set);
 						return true;
 					}
 				}
 			}
-
-			RPtr = RPtr->NextRule;
 		}
 	}
 
@@ -678,28 +673,24 @@ bool doActionRule(int16 x, int16 y, int16 action, int16 roomNum, CloseDataPtr *L
 /* Does the work for doActionRule.                                           */
 /*****************************************************************************/
 static bool doOperateRuleSub(int16 ItemNum, int16 roomNum, CloseDataPtr LCPtr, CloseDataPtr *Set, bool AllowDefaults) {
-	RulePtr RPtr;
-
 	if (LCPtr)
 		if (LCPtr->CloseUpType > 0) {
-			RPtr = Rooms[roomNum].RuleList;
+			RuleList *rules = Rooms[roomNum].rules;
 
-			if ((RPtr == NULL) && (roomNum == 0)) {
+			if ((rules == NULL) && (roomNum == 0)) {
 				g_resource->readViews(roomNum);
-				RPtr = Rooms[roomNum].RuleList;
+				rules = Rooms[roomNum].rules;
 			}
 
-			while (RPtr) {
-				if ((RPtr->RuleType == OPERATE) &&
-				        ((RPtr->Param1 == ItemNum) || ((RPtr->Param1 == 0) && AllowDefaults)) &&
-				        ((RPtr->Param2 == LCPtr->CloseUpType) || ((RPtr->Param2 == 0) && AllowDefaults))) {
-					if (checkConditions(RPtr->Condition)) {
-						doActions(RPtr->ActionList, Set);
+			for (RuleList::iterator rule = rules->begin(); rule != rules->end(); rule++) {
+				if (((*rule)->RuleType == OPERATE) &&
+				        (((*rule)->Param1 == ItemNum) || (((*rule)->Param1 == 0) && AllowDefaults)) &&
+						(((*rule)->Param2 == LCPtr->CloseUpType) || (((*rule)->Param2 == 0) && AllowDefaults))) {
+					if (checkConditions((*rule)->Condition)) {
+						doActions((*rule)->ActionList, Set);
 						return true;
 					}
 				}
-
-				RPtr = RPtr->NextRule;
 			}
 		}
 
@@ -744,19 +735,15 @@ bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *LCPtr) {
 /* Goes thru the rules if the user tries to go forward.                      */
 /*****************************************************************************/
 bool doGoForward(CloseDataPtr *LCPtr) {
-	RulePtr RPtr;
-
-	RPtr = Rooms[RoomNum].RuleList;
+	RuleList *rules = Rooms[RoomNum].rules;
 
-	while (RPtr) {
-		if ((RPtr->RuleType == GOFORWARD) && (RPtr->Param1 == (Direction + 1))) {
-			if (checkConditions(RPtr->Condition)) {
-				doActions(RPtr->ActionList, LCPtr);
+	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); rule++) {
+		if (((*rule)->RuleType == GOFORWARD) && ((*rule)->Param1 == (Direction + 1))) {
+			if (checkConditions((*rule)->Condition)) {
+				doActions((*rule)->ActionList, LCPtr);
 				return true;
 			}
 		}
-
-		RPtr = RPtr->NextRule;
 	}
 
 	return false;
@@ -766,25 +753,20 @@ bool doGoForward(CloseDataPtr *LCPtr) {
 /* Goes thru the rules if the user tries to turn.                            */
 /*****************************************************************************/
 bool doTurn(uint16 from, uint16 to, CloseDataPtr *LCPtr) {
-	RulePtr RPtr;
-
 	from++;
 	to++;
 
-	RPtr = Rooms[RoomNum].RuleList;
+	RuleList *rules = Rooms[RoomNum].rules;
 
-	while (RPtr) {
-		if ((RPtr->RuleType == TURN) ||
-
-		        ((RPtr->RuleType == TURNFROMTO) &&
-		         (RPtr->Param1   == from) && (RPtr->Param2 == to))) {
-			if (checkConditions(RPtr->Condition)) {
-				doActions(RPtr->ActionList, LCPtr);
+	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); rule++) {
+		if (((*rule)->RuleType == TURN) ||
+		        (((*rule)->RuleType == TURNFROMTO) &&
+		         ((*rule)->Param1   == from) && ((*rule)->Param2 == to))) {
+			if (checkConditions((*rule)->Condition)) {
+				doActions((*rule)->ActionList, LCPtr);
 				return true;
 			}
 		}
-
-		RPtr = RPtr->NextRule;
 	}
 
 	return false;
@@ -794,19 +776,14 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *LCPtr) {
 /* Goes thru the rules if the user tries to go to the main view              */
 /*****************************************************************************/
 bool doMainView(CloseDataPtr *LCPtr) {
-	RulePtr RPtr;
-
-	RPtr = Rooms[RoomNum].RuleList;
-
-	while (RPtr) {
-		if (RPtr->RuleType == GOMAINVIEW) {
-			if (checkConditions(RPtr->Condition)) {
-				doActions(RPtr->ActionList, LCPtr);
+	RuleList *rules = Rooms[RoomNum].rules;
+	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); rule++) {
+		if ((*rule)->RuleType == GOMAINVIEW) {
+			if (checkConditions((*rule)->Condition)) {
+				doActions((*rule)->ActionList, LCPtr);
 				return true;
 			}
 		}
-
-		RPtr = RPtr->NextRule;
 	}
 
 	return false;
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 268b4b6..7ca59ba 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -101,7 +101,7 @@ bool Resource::readRoomData(const char *fileName) {
 		Rooms[i].SouthView = NULL;
 		Rooms[i].EastView = NULL;
 		Rooms[i].WestView = NULL;
-		Rooms[i].RuleList = NULL;
+		Rooms[i].rules = NULL;
 		Rooms[i].RoomMsg = NULL;
 	}
 
@@ -140,7 +140,7 @@ bool Resource::readViews(uint16 roomNum) {
 	Rooms[roomNum].SouthView = readView(dataFile);
 	Rooms[roomNum].EastView = readView(dataFile);
 	Rooms[roomNum].WestView = readView(dataFile);
-	Rooms[roomNum].RuleList = readRule(dataFile);
+	Rooms[roomNum].rules = readRule(dataFile);
 
 	g_music->updateMusic();
 
@@ -190,32 +190,25 @@ int16 *Resource::readConditions(Common::File *file) {
 	return list;
 }
 
-Rule *Resource::readRule(Common::File *file) {
+RuleList *Resource::readRule(Common::File *file) {
 	char c;
-	Rule *rule = NULL;
-	Rule *prev = NULL;
-	Rule *head = NULL;
+	RuleList *rules = new Common::List<Rule *>();
 
 	do {
 		c = file->readByte();
 
 		if (c == 1) {
-			rule = (Rule *)malloc(sizeof(Rule));
-			if (!head)
-				head = rule;
-			if (prev)
-				prev->NextRule = rule;
+			Rule *rule = new Rule();;
 			rule->RuleType = file->readSint16LE();
 			rule->Param1 = file->readSint16LE();
 			rule->Param2 = file->readSint16LE();
 			rule->Condition = readConditions(file);
 			rule->ActionList = readAction(file);
-			rule->NextRule = NULL;
-			prev = rule;
+			rules->push_back(rule);
 		}
 	} while (c == 1);
 
-	return head;
+	return rules;
 }
 
 Action *Resource::readAction(Common::File *file) {
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index f9ec4f6..d254cd0 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -108,7 +108,7 @@ public:
 private:
 	char *readString(Common::File *file);
 	int16 *readConditions(Common::File *file);
-	Rule *readRule(Common::File *file);
+	RuleList *readRule(Common::File *file);
 	Action *readAction(Common::File *file);
 	CloseData *readCloseUps(uint16 depth, Common::File *file);
 	viewData *readView(Common::File *file);


Commit: 5cc3d3b682a69fee4ed76e2892a946711ec23926
    https://github.com/scummvm/scummvm/commit/5cc3d3b682a69fee4ed76e2892a946711ec23926
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:40+01:00

Commit Message:
LAB: Remove superfluous image buffers

Changed paths:
    engines/lab/special.cpp



diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 2c0a488..7e8bc96 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -61,7 +61,7 @@ static TextFont bmfont;
 static char *journaltext, *journaltexttitle;
 static uint16 JPage = 0;
 static bool lastpage = false;
-static Image *JCancel, *JCancelAlt, *JLeft, *JLeftAlt, *JRight, *JRightAlt, JBackImage, ScreenImage;
+static Image JBackImage, ScreenImage;
 static uint16 JGadX[3] = { 80, 144, 194 }, JGadY[3] = { 162, 164, 162 };
 static Gadget ForwardG, CancelG, BackG;
 static bool GotBackImage = false;
@@ -602,24 +602,16 @@ static bool loadJournalData() {
 	if (!buffer)
 		return false;
 
-	readImage(buffer, &JLeft);
-	readImage(buffer, &JLeftAlt);
-	readImage(buffer, &JRight);
-	readImage(buffer, &JRightAlt);
-	readImage(buffer, &JCancel);
-	readImage(buffer, &JCancelAlt);
+	readImage(buffer, &(BackG.Im));
+	readImage(buffer, &(BackG.ImAlt));
+	readImage(buffer, &(ForwardG.Im));
+	readImage(buffer, &(ForwardG.ImAlt));
+	readImage(buffer, &(CancelG.Im));
+	readImage(buffer, &(CancelG.ImAlt));
 
-	BackG.Im = JLeft;
-	BackG.ImAlt = JLeftAlt;
 	BackG.KeyEquiv = VKEY_LTARROW;
-
-	ForwardG.Im = JRight;
-	ForwardG.ImAlt = JRightAlt;
 	ForwardG.KeyEquiv = VKEY_RTARROW;
 
-	CancelG.Im = JCancel;
-	CancelG.ImAlt = JCancelAlt;
-
 	counter = 0;
 
 	while (TopGadget) {


Commit: 1bdf07c7acd209f3ca5ca792a6ddfe51e5e712b5
    https://github.com/scummvm/scummvm/commit/1bdf07c7acd209f3ca5ca792a6ddfe51e5e712b5
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:40+01:00

Commit Message:
LAB: Remove unused code

Changed paths:
    engines/lab/readdiff.cpp



diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index b2720ea..dacd4fb 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -46,7 +46,6 @@ static byte *storagefordifffile, **difffile = &storagefordifffile;
 static byte *start;
 static uint32 diffwidth, diffheight;
 static byte blackbuffer[256 * 3];
-static byte *mstart;
 
 bool DoBlack        = false,     /* Black the screen before new picture  */
      nopalchange    = false,     /* Don't change the palette.            */
@@ -57,7 +56,6 @@ bool DoBlack        = false,     /* Black the screen before new picture  */
 
 static bool continuous,
 	IsPlaying      = false,
-	StopPlayingEnd = false,
 	IsAnim         = false,
 	IsPal          = false;
 
@@ -259,7 +257,7 @@ void diffNextFrame() {
 			break;
 		}
 		case 65535L:
-			if ((framenumber == 1) || PlayOnce || StopPlayingEnd) {
+			if ((framenumber == 1) || PlayOnce) {
 				int didTOF = 0;
 
 				if (waitForEffect) {
@@ -310,7 +308,6 @@ void playDiff() {
 	difffile    = &storagefordifffile;
 
 	IsPlaying   = true;
-	StopPlayingEnd = false;
 
 	if (DoBlack) {
 		DoBlack = false;
@@ -443,7 +440,7 @@ void readSound(bool waitTillFinished) {
 	char temp_[5];
 	byte *storagefordifffile_, **difffile_ = &storagefordifffile_;
 
-	mstart = *startoffile;            /* Make a copy of the pointer to the start of the file    */
+	byte *mstart = *startoffile;            /* Make a copy of the pointer to the start of the file    */
 	*difffile_ = mstart;               /* Now can modify the file without modifying the original */
 
 	if (mstart == NULL)


Commit: a6805e884d812e974832160311543ac1048a9f0e
    https://github.com/scummvm/scummvm/commit/a6805e884d812e974832160311543ac1048a9f0e
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:40+01:00

Commit Message:
LAB: Rewrite readSound() to use Common::File

Changed paths:
    engines/lab/diff.h
    engines/lab/graphics.cpp
    engines/lab/readdiff.cpp



diff --git a/engines/lab/diff.h b/engines/lab/diff.h
index 614148e..b4436b8 100644
--- a/engines/lab/diff.h
+++ b/engines/lab/diff.h
@@ -32,6 +32,7 @@
 #define LAB_DIFF_H
 
 #include "lab/stddefines.h"
+#include "common/file.h"
 
 namespace Lab {
 
@@ -74,7 +75,7 @@ void blackAllScreen();
 void whiteScreen();
 bool readDiff(bool playonce);
 void diffNextFrame();
-void readSound(bool waitTillFinished);
+void readSound(bool waitTillFinished, Common::File *file);
 void stopDiff();
 void stopDiffEnd();
 void stopSound();
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index c8d23e9..bc10e8f 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -97,12 +97,15 @@ bool readPict(const char *filename, bool PlayOnce) {
 /* Reads in a music file.  Ignores any graphics.                             */
 /*****************************************************************************/
 bool readMusic(const char *filename, bool waitTillFinished) {
-	byte **file = g_music->newOpen(filename);
+	Common::File *file = g_resource->openDataFile(filename, MKTAG('D', 'I', 'F', 'F'));
+	g_music->updateMusic();
+	if (!g_music->_doNotFilestopSoundEffect)
+		g_music->stopSoundEffect();
 	if (!file)
 		return false;
 
 	DoBlack = false;
-	readSound(waitTillFinished);
+	readSound(waitTillFinished, file);
 
 	return true;
 }
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index dacd4fb..e75d08e 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -434,48 +434,25 @@ bool readDiff(bool playonce) {
 }
 
 
-void readSound(bool waitTillFinished) {
-	uint32 header_ = 0, size_;
-	uint16 samplespeed_;
-	char temp_[5];
-	byte *storagefordifffile_, **difffile_ = &storagefordifffile_;
-
-	byte *mstart = *startoffile;            /* Make a copy of the pointer to the start of the file    */
-	*difffile_ = mstart;               /* Now can modify the file without modifying the original */
-
-	if (mstart == NULL)
-		return;
-
-	readBlock(temp_, 4L, difffile_);
-	temp_[4] = '\0';
-	readBlock(&header_, 4L, difffile_);
-	swapULong(&header_);
-
-	processed += 8L;
-
-	if (!((strcmp(temp_, "DIFF") == 0) && (header_ == 1219009121L)))
+void readSound(bool waitTillFinished, Common::File *file) {
+	uint32 magicBytes = file->readUint32LE();
+	if (magicBytes != 1219009121L)
 		return;
 
-	readBlock(&header_, 4L, difffile_);
-	swapULong(&header_);
-
-	readBlock(&size_, 4L, difffile_);
-	swapULong(&size_);
+	uint32 soundTag = file->readUint32LE();
+	uint32 soundSize = file->readUint32LE();
 
-	if (header_ == 0)
-		(*difffile_) += size_;
+	if (soundTag == 0)
+		file->skip(soundSize);	// skip the header
 	else
 		return;
 
-	while (header_ != 65535) {
+	while (soundTag != 65535) {
 		g_music->updateMusic();
-		readBlock(&header_, 4L, difffile_);
-		swapULong(&header_);
-
-		readBlock(&size_, 4L, difffile_);
-		swapULong(&size_);
+		soundTag = file->readUint32LE();
+		soundSize = file->readUint32LE() - 8;
 
-		if ((header_ == 30) || (header_ == 31)) {
+		if ((soundTag == 30) || (soundTag == 31)) {
 			if (waitTillFinished) {
 				while (g_music->isSoundEffectActive()) {
 					g_music->updateMusic();
@@ -483,20 +460,14 @@ void readSound(bool waitTillFinished) {
 				}
 			}
 
-			size_ -= 8L;
-
-			(*difffile_) += 4;
-			readBlock(&samplespeed_, 2L, difffile_);
-			swapUShortPtr(&samplespeed_, 1);
-
-			(*difffile_) += 2;
-
-			byte *music = *difffile_;
-			uint32 musicsize = size_;
-			(*difffile_) += size_;
+			file->skip(4);
 
-			g_music->playSoundEffect(samplespeed_, musicsize, music);
-		} else if (header_ == 65535L) {
+			uint16 sampleRate = file->readUint16LE();
+			file->skip(2);
+			byte *soundData = (byte *)malloc(soundSize);
+			file->read(soundData, soundSize);
+			g_music->playSoundEffect(sampleRate, soundSize, soundData);
+		} else if (soundTag == 65535L) {
 			if (waitTillFinished) {
 				while (g_music->isSoundEffectActive()) {
 					g_music->updateMusic();
@@ -504,7 +475,7 @@ void readSound(bool waitTillFinished) {
 				}
 			}
 		} else
-			(*difffile_) += size_;
+			file->skip(soundSize);
 	}
 }
 


Commit: f014218acad608ba7f589b580a89fe75e59c507e
    https://github.com/scummvm/scummvm/commit/f014218acad608ba7f589b580a89fe75e59c507e
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:40+01:00

Commit Message:
LAB: Remove dead code

Changed paths:
    engines/lab/readdiff.cpp



diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index e75d08e..15b55e5 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -38,7 +38,7 @@
 namespace Lab {
 
 static bool PlayOnce = false;
-static uint32 header, size, processed = 0L, WaitSec = 0L, WaitMicros = 0L, DelayMicros = 0L;
+static uint32 header, size, WaitSec = 0L, WaitMicros = 0L, DelayMicros = 0L;
 static uint16 CurBit = 0, framenumber = 0, samplespeed, numchunks = 1;
 static byte *Buffer, temp[5];
 static bool donepal = false;
@@ -176,10 +176,6 @@ void diffNextFrame() {
 		readBlock(&size, 4L, difffile);
 		swapULong(&size);
 
-		processed += 8L;
-
-		processed += size;
-
 		switch (header) {
 		case 8L:
 			readBlock(diffcmap, size, difffile);
@@ -296,7 +292,6 @@ void diffNextFrame() {
 /* A separate task launched by readDiff.  Plays the DIFF.                    */
 /*****************************************************************************/
 void playDiff() {
-	processed = 0L;
 	WaitSec   = 0L;
 	WaitMicros = 0L;
 	DelayMicros = 0L;
@@ -331,8 +326,6 @@ void playDiff() {
 	readBlock(&header, 4L, difffile);
 	swapULong(&header);
 
-	processed += 8L;
-
 	if (!((strcmp((char *)temp, "DIFF") == 0) && (header == 1219009121L))) {
 		IsPlaying = false;
 		return;
@@ -375,8 +368,6 @@ void playDiff() {
 		return;
 	}
 
-	processed += 8L + size;
-
 	for (header = 0; header < 8; header++)
 		RawDiffBM.Planes[header] = NULL;
 


Commit: 12f4a71c7335b99988839a80ed85c2f59c8f2c48
    https://github.com/scummvm/scummvm/commit/12f4a71c7335b99988839a80ed85c2f59c8f2c48
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:40+01:00

Commit Message:
LAB: Simplify getViewData, get rid of ViewDataPtr and ActionPtr

Changed paths:
    engines/lab/engine.cpp
    engines/lab/parsefun.h
    engines/lab/parsetypes.h
    engines/lab/processroom.cpp
    engines/lab/resource.cpp
    engines/lab/resource.h



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index f7f65e2..d45d9f1 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -665,7 +665,7 @@ static void mainGameLoop() {
 	uint16 OldRoomNum, OldDirection = 0, GadID = 0, NewDir;
 
 	CloseDataPtr OldCPtr, TempCPtr, HCPtr = NULL;
-	ViewDataPtr VPtr;
+	ViewData *VPtr;
 
 	VGASetPal(initcolors, 8);
 
diff --git a/engines/lab/parsefun.h b/engines/lab/parsefun.h
index b634e9c..672d19a 100644
--- a/engines/lab/parsefun.h
+++ b/engines/lab/parsefun.h
@@ -51,7 +51,7 @@ void allocRoom(void **Ptr, uint16 Size, uint16 RoomNum);
 
 /* From ProcessRoom.c */
 
-ViewDataPtr getViewData(uint16 RoomNum, uint16 Direction);
+ViewData *getViewData(uint16 RoomNum, uint16 Direction);
 char *getPictName(CloseDataPtr *LCPtr);
 void drawDirection(CloseDataPtr LCPtr);
 bool processArrow(uint16 *Direction, uint16 Arrow);
diff --git a/engines/lab/parsetypes.h b/engines/lab/parsetypes.h
index f185c11..a437df0 100644
--- a/engines/lab/parsetypes.h
+++ b/engines/lab/parsetypes.h
@@ -110,15 +110,13 @@ typedef struct closeData {
 
 typedef CloseData *CloseDataPtr;
 
-struct viewData {
+struct ViewData {
 	int16 *Condition;
 	char *GraphicName;
-	struct viewData *NextCondition;
+	struct ViewData *NextCondition;
 	CloseDataPtr closeUps;
 };
 
-typedef viewData *ViewDataPtr;
-
 
 struct Action {
 	int16 ActionType, Param1, Param2, Param3;
@@ -127,14 +125,11 @@ struct Action {
 	Action *NextAction;
 };
 
-typedef Action *ActionPtr;
-
-
 
 struct Rule {
 	int16 RuleType, Param1, Param2, *Condition;
 
-	ActionPtr ActionList;
+	Action * ActionList;
 	Rule *NextRule;
 };
 
@@ -145,7 +140,7 @@ struct RoomData {
 
 	byte WipeType;
 
-	ViewDataPtr NorthView, SouthView, EastView, WestView;
+	ViewData *NorthView, *SouthView, *EastView, *WestView;
 	RuleList *rules;
 	char *RoomMsg;
 };
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index ea0309a..0ef844c 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -94,40 +94,36 @@ static bool checkConditions(int16 *Condition) {
 /*****************************************************************************/
 /* Gets the current ViewDataPointer.                                         */
 /*****************************************************************************/
-ViewDataPtr getViewData(uint16 roomNum, uint16 direction) {
-	ViewDataPtr *VPtr = NULL, ViewPtr;
-	bool doit = true;
+ViewData *getViewData(uint16 roomNum, uint16 direction) {
+	ViewData *view = NULL;
+
+	if (!Rooms[roomNum].RoomMsg)
+		g_resource->readViews(roomNum);
 
 	if (direction == NORTH)
-		VPtr = &Rooms[roomNum].NorthView;
+		view = Rooms[roomNum].NorthView;
 	else if (direction == SOUTH)
-		VPtr = &Rooms[roomNum].SouthView;
+		view = Rooms[roomNum].SouthView;
 	else if (direction == EAST)
-		VPtr = &Rooms[roomNum].EastView;
+		view = Rooms[roomNum].EastView;
 	else if (direction == WEST)
-		VPtr = &Rooms[roomNum].WestView;
-
-	if (*VPtr == NULL)
-		g_resource->readViews(roomNum);
-
-	ViewPtr = *VPtr;
+		view = Rooms[roomNum].WestView;
 
 	do {
-		if (checkConditions(ViewPtr->Condition))
-			doit = false;
-		else
-			ViewPtr = ViewPtr->NextCondition;
+		if (checkConditions(view->Condition))
+			break;
 
-	} while (doit);
+		view = view->NextCondition;
+	} while (true);
 
-	return ViewPtr;
+	return view;
 }
 
 /*****************************************************************************/
 /* Gets an object, if any, from the user's click on the screen.              */
 /*****************************************************************************/
 static CloseData *getObject(uint16 x, uint16 y, CloseDataPtr LCPtr) {
-	ViewDataPtr VPtr;
+	ViewData *VPtr;
 
 	if (LCPtr == NULL) {
 		VPtr = getViewData(RoomNum, Direction);
@@ -179,7 +175,7 @@ static CloseDataPtr findCPtrMatch(CloseDataPtr Main, CloseDataPtr List) {
 /* Returns the current picture name.                                         */
 /*****************************************************************************/
 char *getPictName(CloseDataPtr *LCPtr) {
-	ViewDataPtr ViewPtr = getViewData(RoomNum, Direction);
+	ViewData *ViewPtr = getViewData(RoomNum, Direction);
 
 	if (*LCPtr != NULL) {
 		*LCPtr = findCPtrMatch(*LCPtr, ViewPtr->closeUps);
@@ -266,7 +262,7 @@ bool processArrow(uint16 *direction, uint16 Arrow) {
 /* Sets the current close up data.                                           */
 /*****************************************************************************/
 void setCurClose(uint16 x, uint16 y, CloseDataPtr *cptr, bool useAbsoluteCoords) {
-	ViewDataPtr VPtr;
+	ViewData *VPtr;
 	CloseDataPtr LCPtr;
 	uint16 x1, y1, x2, y2;
 
@@ -302,7 +298,7 @@ void setCurClose(uint16 x, uint16 y, CloseDataPtr *cptr, bool useAbsoluteCoords)
 /* Takes the currently selected item.                                        */
 /*****************************************************************************/
 bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
-	ViewDataPtr VPtr;
+	ViewData *VPtr;
 	CloseDataPtr LCPtr;
 
 	if (*cptr == NULL) {
@@ -332,7 +328,7 @@ bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
 /*****************************************************************************/
 /* Processes the action list.                                                */
 /*****************************************************************************/
-static void doActions(ActionPtr APtr, CloseDataPtr *LCPtr) {
+static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 	CloseDataPtr TLCPtr;
 	bool FirstLoaded = true;
 	char **str, *Test;
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 7ca59ba..e2afcc6 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -283,17 +283,17 @@ CloseData *Resource::readCloseUps(uint16 depth, Common::File *file) {
 	return head;
 }
 
-viewData *Resource::readView(Common::File *file) {
+ViewData *Resource::readView(Common::File *file) {
 	char c;
-	viewData *view = NULL;
-	viewData *prev = NULL;
-	viewData *head = NULL;
+	ViewData *view = NULL;
+	ViewData *prev = NULL;
+	ViewData *head = NULL;
 
 	do {
 		c = file->readByte();
 
 		if (c == 1) {
-			view = (viewData *)malloc(sizeof(viewData));
+			view = (ViewData *)malloc(sizeof(ViewData));
 			if (!head)
 				head = view;
 			if (prev)
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index d254cd0..d41859e 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -111,7 +111,7 @@ private:
 	RuleList *readRule(Common::File *file);
 	Action *readAction(Common::File *file);
 	CloseData *readCloseUps(uint16 depth, Common::File *file);
-	viewData *readView(Common::File *file);
+	ViewData *readView(Common::File *file);
 	void readStaticText();
 
 	Common::String _staticText[48];


Commit: 95d91d81e53955a47b7e0edd293be135331ca6f8
    https://github.com/scummvm/scummvm/commit/95d91d81e53955a47b7e0edd293be135331ca6f8
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:40+01:00

Commit Message:
LAB: Fix whitespace

Changed paths:
    engines/lab/parsetypes.h



diff --git a/engines/lab/parsetypes.h b/engines/lab/parsetypes.h
index a437df0..681bbe7 100644
--- a/engines/lab/parsetypes.h
+++ b/engines/lab/parsetypes.h
@@ -117,7 +117,6 @@ struct ViewData {
 	CloseDataPtr closeUps;
 };
 
-
 struct Action {
 	int16 ActionType, Param1, Param2, Param3;
 	byte *Data;            /* Message, or a pointer to array
@@ -125,11 +124,10 @@ struct Action {
 	Action *NextAction;
 };
 
-
 struct Rule {
 	int16 RuleType, Param1, Param2, *Condition;
 
-	Action * ActionList;
+	Action *ActionList;
 	Rule *NextRule;
 };
 


Commit: 09a7232daa00b5bcb039a3e3a06b3ee4d541460d
    https://github.com/scummvm/scummvm/commit/09a7232daa00b5bcb039a3e3a06b3ee4d541460d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:41+01:00

Commit Message:
LAB: Use Common::File to load map data

Changed paths:
    engines/lab/map.cpp



diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index ceddc4b..a096d28 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -188,13 +188,11 @@ static uint16 mapScaleY(uint16 y) {
 }
 
 
-
-
 /*****************************************************************************/
 /* Loads in the map data.                                                    */
 /*****************************************************************************/
 static bool loadMapData() {
-	byte **buffer, Temp[5];
+	byte **buffer;
 	uint32 Size;
 	Gadget *gptr;
 	uint16 counter;
@@ -254,28 +252,33 @@ static bool loadMapData() {
 		counter++;
 	}
 
-	uint32 bufferSize;
-	buffer = g_music->newOpen("Lab:Maps", bufferSize);
-	stealBufMem(bufferSize);  /* Freeze the memory for the maps */
-	readBlock(Temp, 4L, buffer);
-	Temp[4] = 0;
+	Common::File *mapFile = g_resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0'));
+	if (!mapFile)
+		error("Corrupt map file");
+	g_music->updateMusic();
+	if (!g_music->_doNotFilestopSoundEffect)
+		g_music->stopSoundEffect();
+
+	MaxRooms = mapFile->readUint16LE();
+	Maps = new MapData[MaxRooms];	// will be freed when the user exits the map
+	for (int i = 0; i < MaxRooms; i++) {
+		Maps[i].x = mapFile->readUint16LE();
+		Maps[i].y = mapFile->readUint16LE();
+		Maps[i].PageNumber = mapFile->readUint16LE();
+		Maps[i].SpecialID = mapFile->readUint16LE();
+		Maps[i].MapFlags = mapFile->readUint32LE();
+	}
 
-	if (strcmp((char *)Temp, "MAP0") == 0) {
-		readBlock(&MaxRooms, 2L, buffer);
-		swapUShortPtr(&MaxRooms, 1);
-		Maps = (MapData *)(*buffer);
-
-		for (counter = 1; counter <= MaxRooms; counter++) {
-			swapUShortPtr(&Maps[counter].x, 4);
-			swapULong(&Maps[counter].MapFlags);
-		}
-	} else
-		return false;
+	delete mapFile;
 
 	return true;
 }
 
 
+static void freeMapData() {
+	delete[] Maps;
+	Maps = NULL;
+}
 
 
 static uint16 fadeNumIn(uint16 num, uint16 res, uint16 counter) {
@@ -543,7 +546,7 @@ static void getDownFloor(uint16 *Floor, bool *isfloor) {
 			*isfloor = false;
 			return;
 		} else if (*Floor > UPPERFLOOR) {
-			/* LAB: Labyrinth specific code */
+			// Labyrinth specific code
 			if (*Floor == HEDGEMAZEFLOOR)
 				*Floor = UPPERFLOOR;
 			else if ((*Floor == CARNIVAL) || (*Floor == MEDMAZEFLOOR))
@@ -616,7 +619,7 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b
 	else
 		ghoastGadget(&downgadget, 12);
 
-	/* LAB: Labyrinth specific code */
+	// Labyrinth specific code
 	if (Floor == LOWERFLOOR) {
 		if (onFloor(SURMAZEFLOOR))
 			drawImage(Maze, mapScaleX(538), mapScaleY(277));
@@ -634,7 +637,6 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b
 		flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr);
 	}
 
-
 	switch (Floor) {
 	case LOWERFLOOR:
 		sptr = (char *)g_resource->getStaticText(kTextLowerFloor).c_str();
@@ -879,7 +881,7 @@ void doMap(uint16 CurRoom) {
 	mouseHide();
 	setAPen(0);
 	rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1);
-	freeAllStolenMem();
+	freeMapData();
 	blackAllScreen();
 	mouseShow();
 	WSDL_UpdateScreen();


Commit: 1feb0e4c2ce5d83701f4aff469d99b33ba1953dc
    https://github.com/scummvm/scummvm/commit/1feb0e4c2ce5d83701f4aff469d99b33ba1953dc
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:41+01:00

Commit Message:
LAB: Rename monpage -> monitorPage

Changed paths:
    engines/lab/special.cpp



diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 7e8bc96..978ce11 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -65,7 +65,7 @@ static Image JBackImage, ScreenImage;
 static uint16 JGadX[3] = { 80, 144, 194 }, JGadY[3] = { 162, 164, 162 };
 static Gadget ForwardG, CancelG, BackG;
 static bool GotBackImage = false;
-static uint16 monpage;
+static uint16 monitorPage;
 static const char *TextFileName;
 
 Image *MonButton, *AltMonButton, *MonQuit, *AltMonQuit, *MonBack, *AltMonBack,
@@ -918,14 +918,14 @@ static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2,
 		rectFill(x1, y1, x2, y2);
 	}
 
-	while (DrawingToPage < monpage) {
+	while (DrawingToPage < monitorPage) {
 		g_music->updateMusic();
 		CurText = (char *)(text + CharsDrawn);
 		CharsDrawn += flowText(BigMsgFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, CurText);
 		lastpage = (*CurText == 0);
 
 		if (lastpage)
-			monpage = DrawingToPage;
+			monitorPage = DrawingToPage;
 		else
 			DrawingToPage++;
 	}
@@ -963,7 +963,7 @@ static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1
 				Test = CPtr->GraphicName;
 
 			if (strcmp(Test, TextFileName)) {
-				monpage      = 0;
+				monitorPage      = 0;
 				TextFileName = Test;
 
 				ntext = getText(TextFileName);
@@ -993,26 +993,26 @@ static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1
 				if ((MouseY >= VGAScaleY(171)) && (MouseY <= VGAScaleY(200))) {
 					if ((MouseX >= VGAScaleX(259)) && (MouseX <= VGAScaleX(289))) {
 						if (!lastpage) {
-							monpage += 1;
+							monitorPage += 1;
 							drawMonText(ntext, x1, y1, x2, y2, isinteractive);
 						}
 					} else if ((MouseX >= VGAScaleX(0)) && (MouseX <= VGAScaleX(31))) {
 						return;
 					} else if ((MouseX >= VGAScaleX(290)) && (MouseX <= VGAScaleX(320))) {
-						if (monpage >= 1) {
-							monpage -= 1;
+						if (monitorPage >= 1) {
+							monitorPage -= 1;
 							drawMonText(ntext, x1, y1, x2, y2, isinteractive);
 						}
 					} else if ((MouseX >= VGAScaleX(31)) && (MouseX <= VGAScaleX(59))) {
 						if (isinteractive) {
-							monpage = 0;
+							monitorPage = 0;
 
 							if (depth) {
 								depth--;
 								CPtr = LastCPtr[depth];
 							}
-						} else if (monpage > 0) {
-							monpage = 0;
+						} else if (monitorPage > 0) {
+							monitorPage = 0;
 							drawMonText(ntext, x1, y1, x2, y2, isinteractive);
 						}
 					}
@@ -1054,7 +1054,7 @@ void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1,
 	blackAllScreen();
 
 	resetBuffer();
-	monpage = 0;
+	monitorPage = 0;
 	lastpage = false;
 	FadePalette = hipal;
 


Commit: ebff05e7e74cb10161c345c1b8532a5a2f417001
    https://github.com/scummvm/scummvm/commit/ebff05e7e74cb10161c345c1b8532a5a2f417001
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:41+01:00

Commit Message:
LAB: Simplify the file reading code for the movement control panel

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index d45d9f1..967bcf4 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -115,8 +115,6 @@ extern const char *NewFileName;  /* When ProcessRoom.c decides to change the fil
 #define LEVERSMONITOR        82
 
 
-static byte *MovePanelBuffer, *InvPanelBuffer;
-static uint32 MovePanelBufferSize, InvPanelBufferSize;
 static Image *MoveImages[20], *InvImages[10];
 static Gadget *MoveGadgetList, *InvGadgetList;
 
@@ -223,7 +221,8 @@ static void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr) {
 /******************************************************************************/
 bool setUpScreens() {
 	uint16 counter;
-	byte *bufferstorage, **buffer = &bufferstorage;
+	byte *buffer;
+	byte *MovePanelBuffer, *InvPanelBuffer;
 	Gadget *curgad;
 	uint16 y;
 
@@ -231,18 +230,18 @@ bool setUpScreens() {
 		return false;
 
 	/* Loads in the graphics for the movement control panel */
-	Common::File *file = openPartial("P:Control");
-	if (!file)
+	Common::File file;
+	file.open(translateFileName("P:Control"));
+	if (file.err() || file.size() == 0)
 		return false;
 
-	MovePanelBufferSize = file->size();
-	if (!MovePanelBufferSize || !(MovePanelBuffer = (byte *)calloc(MovePanelBufferSize, 1)))
+	if (!(MovePanelBuffer = (byte *)calloc(file.size(), 1)))
 		return false;
 
-	file->read(MovePanelBuffer, MovePanelBufferSize);
-	file->close();
+	file.read(MovePanelBuffer, file.size());
+	file.close();
 
-	*buffer = MovePanelBuffer;
+	buffer = MovePanelBuffer;
 
 	for (counter = 0; counter < 20; counter++)
 		readImage(buffer, &(MoveImages[counter]));
@@ -292,18 +291,17 @@ bool setUpScreens() {
 		curgad->NextGadget = createButton(289, y, 9, 0, MoveImages[10], MoveImages[11]);
 	}
 
-	file = openPartial("P:Inv");
-	if (!file)
+	file.open(translateFileName("P:Inv"));
+	if (file.err() || file.size() == 0)
 		return false;
 
-	InvPanelBufferSize = file->size();
-	if (!InvPanelBufferSize || !(InvPanelBuffer = (byte *)calloc(InvPanelBufferSize, 1)))
+	if (!(InvPanelBuffer = (byte *)calloc(file.size(), 1)))
 		return false;
 
-	file->read(InvPanelBuffer, InvPanelBufferSize);
-	file->close();
+	file.read(InvPanelBuffer, file.size());
+	file.close();
 
-	*buffer = InvPanelBuffer;
+	buffer = InvPanelBuffer;
 
 	if (g_lab->getPlatform() == Common::kPlatformWindows) {
 		for (counter = 0; counter < 10; counter++)


Commit: ad29493fa73cf40d3ba94fc5d58183ac355b4144
    https://github.com/scummvm/scummvm/commit/ad29493fa73cf40d3ba94fc5d58183ac355b4144
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:41+01:00

Commit Message:
LAB: Fix compilation

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 967bcf4..c93509a 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -244,7 +244,7 @@ bool setUpScreens() {
 	buffer = MovePanelBuffer;
 
 	for (counter = 0; counter < 20; counter++)
-		readImage(buffer, &(MoveImages[counter]));
+		readImage(&buffer, &(MoveImages[counter]));
 
 	/* Creates the gadgets for the movement control panel */
 	y = VGAScaleY(173) - SVGACord(2);
@@ -305,7 +305,7 @@ bool setUpScreens() {
 
 	if (g_lab->getPlatform() == Common::kPlatformWindows) {
 		for (counter = 0; counter < 10; counter++)
-			readImage(buffer, &(InvImages[counter]));
+			readImage(&buffer, &(InvImages[counter]));
 
 		InvGadgetList = createButton(24, y, 0, 'm', InvImages[0], InvImages[1]);
 		curgad = InvGadgetList;
@@ -325,7 +325,7 @@ bool setUpScreens() {
 		curgad = curgad->NextGadget;
 	} else {
 		for (counter = 0; counter < 6; counter++)
-			readImage(buffer, &(InvImages[counter]));
+			readImage(&buffer, &(InvImages[counter]));
 
 		InvGadgetList = createButton(58, y, 0, 0, InvImages[0], InvImages[1]);
 		curgad = InvGadgetList;
@@ -814,7 +814,7 @@ from_crumbs:
 					Class     = MOUSEBUTTONS;
 					Qualifier = IEQUALIFIER_LEFTBUTTON;
 					mouseXY(&MouseX, &MouseY);
-				} else if (g_lab->getPlatform() == Common::kPlatformWindows && 
+				} else if (g_lab->getPlatform() == Common::kPlatformWindows &&
 						(Code == 'b' || Code == 'B')) {  /* Start bread crumbs */
 					BreadCrumbs[0].RoomNum = 0;
 					NumCrumbs = 0;


Commit: 647b0355c9a8ea4f7eef36b12dfdc148799116ba
    https://github.com/scummvm/scummvm/commit/647b0355c9a8ea4f7eef36b12dfdc148799116ba
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:41+01:00

Commit Message:
LAB: Cleanup

Changed paths:
    engines/lab/graphics.cpp
    engines/lab/mouse.cpp
    engines/lab/text.cpp
    engines/lab/vga.cpp
    engines/lab/vga.h



diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index bc10e8f..7bd2af4 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -423,7 +423,7 @@ void drawMessage(const char *str) {
 static void doScrollBlack() {
 	byte *mem, *tempmem;
 	Image Im;
-	uint16 width, height, by, nheight, CurPage;
+	uint16 width, height, by, nheight;
 	uint32 size, copysize;
 	uint32 *BaseAddr;
 
@@ -459,7 +459,6 @@ static void doScrollBlack() {
 		mem += by * width;
 		nheight -= by;
 		size = (int32) nheight * (int32) width;
-		CurPage = 0;
 		tempmem = mem;
 
 		while (size) {
@@ -470,10 +469,8 @@ static void doScrollBlack() {
 
 			size -= copysize;
 
-			setPage(CurPage);
 			memcpy(BaseAddr, tempmem, copysize);
 			tempmem += copysize;
-			CurPage++;
 		}
 
 		setAPen(0);
@@ -524,7 +521,6 @@ static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startli
 
 		size -= copysize;
 
-		setPage(CurPage);
 		memcpy(BaseAddr + (OffSet >> 2), mem, copysize);
 		mem += copysize;
 		CurPage++;
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index 8636ad7..553b665 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -81,7 +81,6 @@ static Gadget *checkGadgetHit(Gadget *gadlist, uint16 x, uint16 y) {
 			if (IsHiRes) {
 				hitgad = gadlist;
 			} else {
-				VGAStorePage();
 				mouseHide();
 				drawImage(gadlist->ImAlt, gadlist->x, gadlist->y);
 				mouseShow();
@@ -92,7 +91,6 @@ static Gadget *checkGadgetHit(Gadget *gadlist, uint16 x, uint16 y) {
 				mouseHide();
 				drawImage(gadlist->Im, gadlist->x, gadlist->y);
 				mouseShow();
-				VGARestorePage();
 			}
 
 			return gadlist;
diff --git a/engines/lab/text.cpp b/engines/lab/text.cpp
index 807df45..c89cec3 100644
--- a/engines/lab/text.cpp
+++ b/engines/lab/text.cpp
@@ -90,7 +90,6 @@ void text(struct TextFont *tf, uint16 x, uint16 y, uint16 color, const char *tex
 		SegmentOffset = RealOffset - (curpage * VGABytesPerPage);
 		LeftInSegment = VGABytesPerPage - SegmentOffset;
 		VGACur = VGATop + SegmentOffset;
-		setPage(curpage);
 
 		if (tf->Widths[(uint)*text]) {
 			cdata = tf->data + tf->Offsets[(uint)*text];
@@ -120,7 +119,6 @@ void text(struct TextFont *tf, uint16 x, uint16 y, uint16 color, const char *tex
 						for (counterb = 0; counterb < 8; counterb++) {
 							if (templeft <= 0) {
 								curpage++;
-								setPage(curpage);
 								VGATemp = (byte *)(VGATop - templeft);
 								/* Set up VGATempLine for next line */
 								VGATempLine -= VGABytesPerPage;
@@ -148,7 +146,6 @@ void text(struct TextFont *tf, uint16 x, uint16 y, uint16 color, const char *tex
 
 				if (LeftInSegment <= 0) {
 					curpage++;
-					setPage(curpage);
 					VGATempLine -= VGABytesPerPage;
 					LeftInSegment += VGABytesPerPage;
 				}
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index aa31d19..013b6ee 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -88,19 +88,6 @@ bool createScreen(bool HiRes) {
 /*****************************************************************************/
 /* Sets the current page on the VGA card.                                    */
 /*****************************************************************************/
-void setPage(uint16 PageNum) {
-	// PageNum should always calculated out to zero for SDL.
-	assert(PageNum == 0);
-}
-
-void VGAStorePage() {
-	// does nothing in SDL
-}
-
-void VGARestorePage() {
-	// does nothing in SDL
-}
-
 void changeVolume(int delta) {
 	warning("STUB: changeVolume()");
 }
diff --git a/engines/lab/vga.h b/engines/lab/vga.h
index 376411a..aa5a26c 100644
--- a/engines/lab/vga.h
+++ b/engines/lab/vga.h
@@ -41,9 +41,6 @@ struct Image {
 	byte *ImageData;
 };
 
-void setPage(uint16 PageNum);
-void VGAStorePage();
-void VGARestorePage();
 bool createScreen(bool HiRes);
 void waitTOF();
 void quickWaitTOF();


Commit: 3160bb0bc3fbb001a3f7c97ef865eb951c02209a
    https://github.com/scummvm/scummvm/commit/3160bb0bc3fbb001a3f7c97ef865eb951c02209a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:41+01:00

Commit Message:
LAB: Fix warning

Changed paths:
    engines/lab/labmusic.cpp



diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index d4752c6..e169c96 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -346,7 +346,7 @@ byte **Music::newOpen(const char *name, uint32 &size) {
 	if (!name || !strcmp(name, "") || !strcmp(name, " "))
 		return NULL;
 
-	if (file = isBuffered(name))
+	if ((file = isBuffered(name)))
 		return file;
 
 	updateMusic();


Commit: d4e0c23ed311b3fc9b5ddfd2806a3c273f57c6d6
    https://github.com/scummvm/scummvm/commit/d4e0c23ed311b3fc9b5ddfd2806a3c273f57c6d6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:41+01:00

Commit Message:
LAB: Simplify code

Changed paths:
    engines/lab/undiff.cpp



diff --git a/engines/lab/undiff.cpp b/engines/lab/undiff.cpp
index d9d53a3..f7610d9 100644
--- a/engines/lab/undiff.cpp
+++ b/engines/lab/undiff.cpp
@@ -29,6 +29,7 @@
  */
 
 #include "lab/stddefines.h"
+#include "common/endian.h"
 
 namespace Lab {
 
@@ -107,9 +108,9 @@ static void unDIFFByteWord(uint16 *Dest, uint16 *diff) {
 
 		if (skip == 255) {
 			if (copy == 0) {
-				skip = swapUShort(*diff);
+				skip = READ_LE_UINT16(diff);
 				diff++;
-				copy = swapUShort(*diff);
+				copy = READ_LE_UINT16(diff);
 				diff++;
 			} else if (copy == 255)
 				return;
@@ -118,19 +119,19 @@ static void unDIFFByteWord(uint16 *Dest, uint16 *diff) {
 		Dest += skip;
 
 		while (copy > 3) {
-			*Dest = *diff; //swapUShort(*diff);
+			*Dest = READ_LE_UINT16(diff);
 			Dest++;
 			diff++;
 
-			*Dest = *diff; //swapUShort(*diff);
+			*Dest = READ_LE_UINT16(diff);
 			Dest++;
 			diff++;
 
-			*Dest = *diff; //swapUShort(*diff);
+			*Dest = READ_LE_UINT16(diff);
 			Dest++;
 			diff++;
 
-			*Dest = *diff; //swapUShort(*diff);
+			*Dest = READ_LE_UINT16(diff);
 			Dest++;
 			diff++;
 
@@ -138,7 +139,7 @@ static void unDIFFByteWord(uint16 *Dest, uint16 *diff) {
 		}
 
 		while (copy) {
-			*Dest = *diff; //swapUShort(*diff);
+			*Dest = READ_LE_UINT16(diff);
 			Dest++;
 			diff++;
 			copy--;


Commit: 36684eb1bab5b20c4052d89047b17c2f625666d1
    https://github.com/scummvm/scummvm/commit/36684eb1bab5b20c4052d89047b17c2f625666d1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:41+01:00

Commit Message:
LAB: get rid of timing.h

Changed paths:
  R engines/lab/timing.h
    engines/lab/engine.cpp
    engines/lab/interface.cpp
    engines/lab/intro.cpp
    engines/lab/lab.h
    engines/lab/labmusic.cpp
    engines/lab/mouse.cpp
    engines/lab/processroom.cpp
    engines/lab/readdiff.cpp
    engines/lab/special.cpp
    engines/lab/timing.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index c93509a..c2ab467 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -33,7 +33,6 @@
 #include "lab/labfun.h"
 #include "lab/diff.h"
 #include "lab/vga.h"
-#include "lab/timing.h"
 #include "lab/text.h"
 #include "lab/parsefun.h"
 #include "lab/interface.h"
@@ -829,7 +828,7 @@ from_crumbs:
 							FollowCrumbsFast = (Code == 'r' || Code == 'R');
 							IsCrumbTurning = false;
 							IsCrumbWaiting = false;
-							getTime(&CrumbSecs, &CrumbMicros);
+							g_lab->getTime(&CrumbSecs, &CrumbMicros);
 
 							if (Alternate) {
 								eatMessages();
@@ -1158,7 +1157,7 @@ from_crumbs:
 							FollowCrumbsFast = false;
 							IsCrumbTurning = false;
 							IsCrumbWaiting = false;
-							getTime(&CrumbSecs, &CrumbMicros);
+							g_lab->getTime(&CrumbSecs, &CrumbMicros);
 
 							eatMessages();
 							Alternate = false;
@@ -1417,7 +1416,7 @@ int followCrumbs() {
 		uint32 Secs;
 		uint32 Micros;
 
-		timeDiff(CrumbSecs, CrumbMicros, &Secs, &Micros);
+		g_lab->timeDiff(CrumbSecs, CrumbMicros, &Secs, &Micros);
 
 		if (Secs != 0 || Micros != 0)
 			return 0;
@@ -1460,7 +1459,7 @@ int followCrumbs() {
 		IsCrumbTurning = (MoveDir != VKEY_UPARROW);
 		IsCrumbWaiting = true;
 
-		addCurTime(theDelay / ONESECOND, theDelay % ONESECOND, &CrumbSecs, &CrumbMicros);
+		g_lab->addCurTime(theDelay / ONESECOND, theDelay % ONESECOND, &CrumbSecs, &CrumbMicros);
 	}
 
 	return MoveDir;
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index e2f7401..8d05e41 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -31,7 +31,6 @@
 #include "lab/labfun.h"
 #include "lab/stddefines.h"
 #include "lab/interface.h"
-#include "lab/timing.h"
 #include "lab/mouse.h"
 #include "lab/vga.h"
 #include "common/util.h"
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 2ffddf7..16ed20b 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -32,7 +32,6 @@
 #include "lab/stddefines.h"
 #include "lab/labfun.h"
 #include "lab/resource.h"
-#include "lab/timing.h"
 #include "lab/diff.h"
 #include "lab/text.h"
 #include "lab/interface.h"
@@ -142,7 +141,7 @@ static void doPictText(const char *Filename, bool isscreen) {
 				return;
 			}
 
-			getTime(&lastsecs, &lastmicros);
+			g_lab->getTime(&lastsecs, &lastmicros);
 		}
 
 		Msg = getMsg();
@@ -151,8 +150,8 @@ static void doPictText(const char *Filename, bool isscreen) {
 			g_music->updateMusic();
 			diffNextFrame();
 
-			getTime(&secs, &micros);
-			anyTimeDiff(lastsecs, lastmicros, secs, micros, &secs, &micros);
+			g_lab->getTime(&secs, &micros);
+			g_lab->anyTimeDiff(lastsecs, lastmicros, secs, micros, &secs, &micros);
 
 			if (secs > timedelay) {
 				if (End) {
@@ -258,7 +257,7 @@ static void NReadPict(const char *Filename, bool PlayOnce) {
 /*****************************************************************************/
 void introSequence() {
 	uint16 counter, counter1;
-	
+
 	uint16 Palette[16] = {
 		0x0000, 0x0855, 0x0FF9, 0x0EE7, 0x0ED5, 0x0DB4, 0x0CA2, 0x0C91, 0x0B80, 0x0B80, 0x0B91, 0x0CA2, 0x0CB3, 0x0DC4, 0x0DD6, 0x0EE7
 	};
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index c1bf433..989def2 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -45,6 +45,8 @@ enum GameFeatures {
 	GF_WINDOWS_TRIAL = 1 << 1
 };
 
+#define ONESECOND 1000
+
 class LabEngine : public Engine {
 public:
 	LabEngine(OSystem *syst, const ADGameDescription *gameDesc);
@@ -64,8 +66,18 @@ public:
 
 	LargeSet *_conditions, *_roomsFound;
 
+	// timing.cpp
+	void getTime(uint32 *secs, uint32 *micros);
+	void addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *timeMicros);
+	void anyTimeDiff(uint32 sec1, uint32 micros1, uint32 sec2, uint32 micros2, uint32 *diffSecs, uint32 *diffMicros);
+	void timeDiff(uint32 sec, uint32 micros, uint32 *diffSec, uint32 *diffMicros);
+	void waitForTime(uint32 sec, uint32 micros);
+
 private:
 	uint32 _extraGameFeatures;
+
+	// timing.cpp
+	void microDelay(uint32 secs, uint32 micros);
 };
 
 extern LabEngine *g_lab;
diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index e169c96..50ba48d 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -32,7 +32,6 @@
 
 #include "lab/stddefines.h"
 #include "lab/labfun.h"
-#include "lab/timing.h"
 #include "lab/mouse.h"
 #include "lab/vga.h"
 #include "lab/lab.h"
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index 553b665..c45ab5c 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -31,7 +31,6 @@
 #include "lab/mouse.h"
 #include "lab/vga.h"
 #include "lab/stddefines.h"
-#include "lab/timing.h"
 #include "lab/interface.h"
 
 namespace Lab {
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 0ef844c..d48a4ca 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -36,7 +36,6 @@
 #include "lab/parsetypes.h"
 #include "lab/parsefun.h"
 #include "lab/resource.h"
-#include "lab/timing.h"
 #include "lab/diff.h"
 #include "lab/vga.h"
 #include "lab/interface.h"
@@ -63,7 +62,7 @@ extern CloseDataPtr CPtr;
 uint16 getRandom(uint16 max) {
 	uint32 secs, micros;
 
-	getTime(&secs, &micros);
+	g_lab->getTime(&secs, &micros);
 	return ((micros + secs) % max);
 }
 
@@ -483,14 +482,14 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 			break;
 
 		case WAITSECS:
-			addCurTime(APtr->Param1, 0, &StartSecs, &StartMicros);
+			g_lab->addCurTime(APtr->Param1, 0, &StartSecs, &StartMicros);
 
 			WSDL_UpdateScreen();
 
 			while (1) {
 				g_music->updateMusic();
 				diffNextFrame();
-				getTime(&CurSecs, &CurMicros);
+				g_lab->getTime(&CurSecs, &CurMicros);
 
 				if ((CurSecs > StartSecs) || ((CurSecs == StartSecs) &&
 				                              (CurMicros >= StartMicros)))
@@ -615,7 +614,7 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr LCPtr, Clo
 
 	if (LCPtr) {
 		RuleList *rules = Rooms[RoomNum].rules;
-		
+
 		if ((rules == NULL) && (roomNum == 0)) {
 			g_resource->readViews(roomNum);
 			rules = Rooms[roomNum].rules;
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index 15b55e5..727a339 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -28,8 +28,7 @@
  *
  */
 
-#include "lab/stddefines.h"
-#include "lab/timing.h"
+#include "lab/lab.h"
 #include "lab/diff.h"
 #include "lab/labfun.h"
 #include "lab/vga.h"
@@ -137,8 +136,8 @@ void diffNextFrame() {
 
 			if (!IsBM) {
 				if (headerdata.fps) {
-					waitForTime(WaitSec, WaitMicros);
-					addCurTime(0L, DelayMicros, &WaitSec, &WaitMicros);
+					g_lab->waitForTime(WaitSec, WaitMicros);
+					g_lab->addCurTime(0L, DelayMicros, &WaitSec, &WaitMicros);
 				}
 
 				if (IsPal && !nopalchange) {
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 978ce11..377f8db 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -41,7 +41,6 @@
 #include "lab/vga.h"
 #include "lab/text.h"
 #include "lab/mouse.h"
-#include "lab/timing.h"
 #include "lab/stddefines.h"
 #include "lab/parsetypes.h"
 #include "lab/resource.h"
@@ -855,7 +854,7 @@ bool saveRestoreGame() {
 	}
 
 	WSDL_UpdateScreen();
-	
+
 	return isOK;
 }
 
diff --git a/engines/lab/timing.cpp b/engines/lab/timing.cpp
index a9f593e..ca76755 100644
--- a/engines/lab/timing.cpp
+++ b/engines/lab/timing.cpp
@@ -28,8 +28,7 @@
  *
  */
 
-#include "lab/stddefines.h"
-#include "lab/timing.h"
+#include "lab/lab.h"
 #include "lab/vga.h"
 
 namespace Lab {
@@ -37,7 +36,7 @@ namespace Lab {
 /*****************************************************************************/
 /* Waits for for Secs seconds and Micros microseconds to pass.               */
 /*****************************************************************************/
-void microDelay(uint32 secs, uint32 micros) {
+void LabEngine::microDelay(uint32 secs, uint32 micros) {
 	uint32 waitSecs, waitMicros;
 
 	addCurTime(secs, micros, &waitSecs, &waitMicros);
@@ -55,7 +54,7 @@ void microDelay(uint32 secs, uint32 micros) {
 /*****************************************************************************/
 /* Gets the current system time.                                             */
 /*****************************************************************************/
-void getTime(uint32 *secs, uint32 *micros) {
+void LabEngine::getTime(uint32 *secs, uint32 *micros) {
 	uint32 t = g_system->getMillis();
 
 	*secs   = t / 1000;
@@ -65,7 +64,7 @@ void getTime(uint32 *secs, uint32 *micros) {
 /*****************************************************************************/
 /* Adds seconds and microseconds to current time to get a new time.          */
 /*****************************************************************************/
-void addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *timeMicros) {
+void LabEngine::addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *timeMicros) {
 	getTime(timeSec, timeMicros);
 
 	(*timeSec)    += sec;
@@ -81,7 +80,7 @@ void addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *timeMicros)
 /* Finds the difference between time1 and time2.  If time1 is later than     */
 /* time2, returns 0.                                                         */
 /*****************************************************************************/
-void anyTimeDiff(uint32 sec1, uint32 micros1, uint32 sec2, uint32 micros2, uint32 *diffSecs, uint32 *diffMicros) {
+void LabEngine::anyTimeDiff(uint32 sec1, uint32 micros1, uint32 sec2, uint32 micros2, uint32 *diffSecs, uint32 *diffMicros) {
 	*diffSecs   = 0;
 	*diffMicros = 0;
 
@@ -103,7 +102,7 @@ void anyTimeDiff(uint32 sec1, uint32 micros1, uint32 sec2, uint32 micros2, uint3
 /* Finds the difference between the current time, and a future time. Returns */
 /* 0 if the future time is actually before the current time.                 */
 /*****************************************************************************/
-void timeDiff(uint32 sec, uint32 micros, uint32 *diffSec, uint32 *diffMicros) {
+void LabEngine::timeDiff(uint32 sec, uint32 micros, uint32 *diffSec, uint32 *diffMicros) {
 	uint32 curSec, curMicros;
 	getTime(&curSec, &curMicros);
 	anyTimeDiff(curSec, curMicros, sec, micros, diffSec, diffMicros);
@@ -112,7 +111,7 @@ void timeDiff(uint32 sec, uint32 micros, uint32 *diffSec, uint32 *diffMicros) {
 /*****************************************************************************/
 /* Waits for a specified time to occur.                                      */
 /*****************************************************************************/
-void waitForTime(uint32 sec, uint32 micros) {
+void LabEngine::waitForTime(uint32 sec, uint32 micros) {
 	uint32 curSec, curMicros;
 
 	getTime(&curSec, &curMicros);
diff --git a/engines/lab/timing.h b/engines/lab/timing.h
deleted file mode 100644
index adbaf95..0000000
--- a/engines/lab/timing.h
+++ /dev/null
@@ -1,47 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#ifndef LAB_TIMING_H
-#define LAB_TIMING_H
-
-namespace Lab {
-
-#define ONESECOND 1000
-
-void microDelay(uint32 secs, uint32 micros);
-void getTime(uint32 *secs, uint32 *micros);
-void addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *timeMicros);
-void anyTimeDiff(uint32 sec1, uint32 micros1, uint32 sec2, uint32 micros2, uint32 *diffSecs, uint32 *diffMicros);
-void timeDiff(uint32 sec, uint32 micros, uint32 *diffSec, uint32 *diffMicros);
-void waitForTime(uint32 sec, uint32 micros);
-
-} // End of namespace Lab
-
-#endif /* LAB_TIMING_H */


Commit: fd8215454cdccfe7d03229fa5c6914444a002114
    https://github.com/scummvm/scummvm/commit/fd8215454cdccfe7d03229fa5c6914444a002114
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:41+01:00

Commit Message:
LAB: Objectify intro code

Changed paths:
    engines/lab/engine.cpp
    engines/lab/intro.cpp
    engines/lab/labfun.h



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index c2ab467..8dd48d1 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -34,6 +34,7 @@
 #include "lab/diff.h"
 #include "lab/vga.h"
 #include "lab/text.h"
+#include "lab/intro.h"
 #include "lab/parsefun.h"
 #include "lab/interface.h"
 #include "lab/mouse.h"
@@ -1359,7 +1360,9 @@ void LabEngine::go() {
 	mouseHide();
 
 	if (dointro && mem) {
-		introSequence();
+		Intro intro;
+
+		intro.introSequence();
 	} else
 		DoBlack = true;
 
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 16ed20b..c3a8321 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -29,7 +29,7 @@
  */
 
 #include "lab/lab.h"
-#include "lab/stddefines.h"
+#include "lab/intro.h"
 #include "lab/labfun.h"
 #include "lab/resource.h"
 #include "lab/diff.h"
@@ -37,38 +37,36 @@
 #include "lab/interface.h"
 
 namespace Lab {
-
-static TextFont filler, *msgfont = &filler;
-static bool QuitIntro = false, IntroDoBlack;
-
 extern bool nopalchange, DoBlack, IsHiRes;
 extern char diffcmap[256 * 3];
 extern uint32 VGAScreenWidth, VGAScreenHeight;
 extern uint16 *FadePalette;
 
+Intro::Intro() {
+	_msgfont = &_filler;
+	_quitIntro = false;
+}
 
 /******************************************************************************/
 /* Goes thru, and responds to all the intuition messages currently in the     */
 /* the message port.                                                          */
 /******************************************************************************/
-void introEatMessages() {
-	IntuiMessage *Msg;
-
+void Intro::introEatMessages() {
 	while (1) {
-		Msg = getMsg();
+		IntuiMessage *msg = getMsg();
 
 		if (g_engine->shouldQuit()) {
-			QuitIntro = true;
+			_quitIntro = true;
 			return;
 		}
 
-		if (Msg == NULL)
+		if (msg == NULL)
 			return;
 		else {
-			if (((Msg->Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Msg->Qualifier)) ||
-			        ((Msg->Class == RAWKEY) && (Msg->Code == 27))
+			if (((msg->Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & msg->Qualifier)) ||
+			        ((msg->Class == RAWKEY) && (msg->Code == 27))
 				)
-				QuitIntro = true;
+				_quitIntro = true;
 		}
 	}
 }
@@ -79,18 +77,18 @@ void introEatMessages() {
 /*****************************************************************************/
 /* Reads in a picture.                                                       */
 /*****************************************************************************/
-static void doPictText(const char *Filename, bool isscreen) {
+void Intro::doPictText(const char *filename, bool isscreen) {
 	uint32 lastsecs = 0L, lastmicros = 0L, secs = 0L, micros = 0L;
-	IntuiMessage *Msg;
-	char filename[50] = "Lab:rooms/Intro/";
+	IntuiMessage *msg;
+	char path[50] = "Lab:rooms/Intro/";
 	byte *curplace, **tfile;
-	bool DrawNextText = true, End = false, Begin = true;
+	bool drawNextText = true, end = false, begin = true;
 
-	int32 Class, Code, Drawn;
-	int16 Qualifier;
+	int32 cls, code, Drawn;
+	int16 qualifier;
 	uint timedelay;
 
-	strcat(filename, Filename);
+	strcat(path, filename);
 
 	if (isscreen) {
 		g_music->updateMusic();
@@ -100,15 +98,15 @@ static void doPictText(const char *Filename, bool isscreen) {
 		timedelay = 7;
 	}
 
-	if (QuitIntro)
+	if (_quitIntro)
 		return;
 
 	while (1) {
-		if (DrawNextText) {
-			if (Begin) {
-				Begin = false;
+		if (drawNextText) {
+			if (begin) {
+				begin = false;
 
-				tfile = g_music->newOpen(filename);
+				tfile = g_music->newOpen(path);
 
 				if (!tfile)
 					return;
@@ -121,7 +119,7 @@ static void doPictText(const char *Filename, bool isscreen) {
 				setAPen(7L);
 				rectFill(VGAScaleX(10), VGAScaleY(10), VGAScaleX(310), VGAScaleY(190));
 
-				Drawn = flowText(msgfont, (!IsHiRes) * -1, 5, 7, false, false, true, true, VGAScaleX(14), VGAScaleY(11), VGAScaleX(306), VGAScaleY(189), (char *)curplace);
+				Drawn = flowText(_msgfont, (!IsHiRes) * -1, 5, 7, false, false, true, true, VGAScaleX(14), VGAScaleY(11), VGAScaleX(306), VGAScaleY(189), (char *)curplace);
 				fade(true, 0);
 			} else {
 				Drawn = longDrawMessage((char *)curplace);
@@ -129,12 +127,12 @@ static void doPictText(const char *Filename, bool isscreen) {
 
 			curplace += Drawn;
 
-			End = (*curplace == 0);
+			end = (*curplace == 0);
 
-			DrawNextText = false;
+			drawNextText = false;
 			introEatMessages();
 
-			if (QuitIntro) {
+			if (_quitIntro) {
 				if (isscreen)
 					fade(false, 0);
 
@@ -144,9 +142,9 @@ static void doPictText(const char *Filename, bool isscreen) {
 			g_lab->getTime(&lastsecs, &lastmicros);
 		}
 
-		Msg = getMsg();
+		msg = getMsg();
 
-		if (Msg == NULL) {
+		if (msg == NULL) {
 			g_music->updateMusic();
 			diffNextFrame();
 
@@ -154,25 +152,25 @@ static void doPictText(const char *Filename, bool isscreen) {
 			g_lab->anyTimeDiff(lastsecs, lastmicros, secs, micros, &secs, &micros);
 
 			if (secs > timedelay) {
-				if (End) {
+				if (end) {
 					if (isscreen)
 						fade(false, 0);
 
 					return;
 				} else {
-					DrawNextText = true;
+					drawNextText = true;
 				}
 			}
 
 			waitTOF();
 		} else {
-			Class     = Msg->Class;
-			Qualifier = Msg->Qualifier;
-			Code      = Msg->Code;
+			cls       = msg->Class;
+			qualifier = msg->Qualifier;
+			code      = msg->Code;
 
-			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) ||
-			        ((Class == RAWKEY) && (Code == 27))) {
-				QuitIntro = true;
+			if (((cls == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & qualifier)) ||
+			        ((cls == RAWKEY) && (code == 27))) {
+				_quitIntro = true;
 
 				if (isscreen)
 					fade(false, 0);
@@ -180,20 +178,20 @@ static void doPictText(const char *Filename, bool isscreen) {
 				return;
 			}
 
-			else if (Class == MOUSEBUTTONS) {
-				if (IEQUALIFIER_LEFTBUTTON & Qualifier) {
-					if (End) {
+			else if (cls == MOUSEBUTTONS) {
+				if (IEQUALIFIER_LEFTBUTTON & qualifier) {
+					if (end) {
 						if (isscreen)
 							fade(false, 0);
 
 						return;
 					} else
-						DrawNextText = true;
+						drawNextText = true;
 				}
 
 				introEatMessages();
 
-				if (QuitIntro) {
+				if (_quitIntro) {
 					if (isscreen)
 						fade(false, 0);
 
@@ -201,13 +199,13 @@ static void doPictText(const char *Filename, bool isscreen) {
 				}
 			}
 
-			if (End) {
+			if (end) {
 				if (isscreen)
 					fade(false, 0);
 
 				return;
 			} else
-				DrawNextText = true;
+				drawNextText = true;
 		}
 	}
 }
@@ -219,12 +217,12 @@ static void doPictText(const char *Filename, bool isscreen) {
 /*****************************************************************************/
 /* Does a one second delay, but checks the music while doing it.             */
 /*****************************************************************************/
-void musicDelay() {
+void Intro::musicDelay() {
 	int16 counter;
 
 	g_music->updateMusic();
 
-	if (QuitIntro)
+	if (_quitIntro)
 		return;
 
 	for (counter = 0; counter < 20; counter++) {
@@ -237,44 +235,47 @@ void musicDelay() {
 
 
 
-static void NReadPict(const char *Filename, bool PlayOnce) {
-	Common::String finalFileName = Common::String("P:Intro/") + Filename;
+void Intro::nReadPict(const char *filename, bool playOnce) {
+	Common::String finalFileName = Common::String("P:Intro/") + filename;
 
 	g_music->updateMusic();
 	introEatMessages();
 
-	if (QuitIntro)
+	if (_quitIntro)
 		return;
 
-	DoBlack = IntroDoBlack;
+	DoBlack = _introDoBlack;
 	stopDiffEnd();
-	readPict(finalFileName.c_str(), PlayOnce);
+	readPict(finalFileName.c_str(), playOnce);
 }
 
 
 /*****************************************************************************/
 /* Does the introduction sequence for Labyrinth.                             */
 /*****************************************************************************/
-void introSequence() {
+void Intro::introSequence() {
 	uint16 counter, counter1;
 
-	uint16 Palette[16] = {
-		0x0000, 0x0855, 0x0FF9, 0x0EE7, 0x0ED5, 0x0DB4, 0x0CA2, 0x0C91, 0x0B80, 0x0B80, 0x0B91, 0x0CA2, 0x0CB3, 0x0DC4, 0x0DD6, 0x0EE7
+	uint16 palette[16] = {
+		0x0000, 0x0855, 0x0FF9, 0x0EE7,
+		0x0ED5, 0x0DB4, 0x0CA2, 0x0C91,
+		0x0B80, 0x0B80, 0x0B91, 0x0CA2,
+		0x0CB3, 0x0DC4, 0x0DD6, 0x0EE7
 	};
 
 	DoBlack = true;
 
 	if (g_lab->getPlatform() != Common::kPlatformWindows) {
-		NReadPict("EA0", true);
-		NReadPict("EA1", true);
-		NReadPict("EA2", true);
-		NReadPict("EA3", true);
+		nReadPict("EA0", true);
+		nReadPict("EA1", true);
+		nReadPict("EA2", true);
+		nReadPict("EA3", true);
 	} else {
-		NReadPict("WYRMKEEP", true);
+		nReadPict("WYRMKEEP", true);
 		// Wait 4 seconds
 		for (counter = 0; counter < 4 * 1000 / 10; counter++) {
 			introEatMessages();
-			if (QuitIntro)
+			if (_quitIntro)
 				break;
 			g_system->delayMillis(10);
 		}
@@ -286,18 +287,18 @@ void introSequence() {
 
 	nopalchange = true;
 	if (g_lab->getPlatform() != Common::kPlatformWindows)
-		NReadPict("TNDcycle.pic", true);
+		nReadPict("TNDcycle.pic", true);
 	else
-		NReadPict("TNDcycle2.pic", true);
+		nReadPict("TNDcycle2.pic", true);
 	nopalchange = false;
 
-	FadePalette = Palette;
+	FadePalette = palette;
 
 	for (counter = 0; counter < 16; counter++) {
-		if (QuitIntro)
+		if (_quitIntro)
 			break;
 
-		Palette[counter] = ((diffcmap[counter * 3] >> 2) << 8) +
+		palette[counter] = ((diffcmap[counter * 3] >> 2) << 8) +
 		                   ((diffcmap[counter * 3 + 1] >> 2) << 4) +
 		                   (diffcmap[counter * 3 + 2] >> 2);
 	}
@@ -306,18 +307,18 @@ void introSequence() {
 	fade(true, 0);
 
 	for (int times = 0; times < 150; times++) {
-		if (QuitIntro)
+		if (_quitIntro)
 			break;
 
 		g_music->updateMusic();
-		uint16 temp = Palette[2];
+		uint16 temp = palette[2];
 
 		for (counter = 2; counter < 15; counter++)
-			Palette[counter] = Palette[counter + 1];
+			palette[counter] = palette[counter + 1];
 
-		Palette[15] = temp;
+		palette[15] = temp;
 
-		setAmigaPal(Palette, 16);
+		setAmigaPal(palette, 16);
 		waitTOF();
 	}
 
@@ -326,24 +327,24 @@ void introSequence() {
 
 	g_music->updateMusic();
 
-	NReadPict("Title.A", true);
-	NReadPict("AB", true);
+	nReadPict("Title.A", true);
+	nReadPict("AB", true);
 	musicDelay();
-	NReadPict("BA", true);
-	NReadPict("AC", true);
+	nReadPict("BA", true);
+	nReadPict("AC", true);
 	musicDelay();
 
 	if (g_lab->getPlatform() == Common::kPlatformWindows)
 		musicDelay(); // more credits on this page now
 
-	NReadPict("CA", true);
-	NReadPict("AD", true);
+	nReadPict("CA", true);
+	nReadPict("AD", true);
 	musicDelay();
 
 	if (g_lab->getPlatform() == Common::kPlatformWindows)
 		musicDelay(); // more credits on this page now
 
-	NReadPict("DA", true);
+	nReadPict("DA", true);
 	musicDelay();
 
 	g_music->newOpen("p:Intro/Intro.1");  /* load the picture into the buffer */
@@ -352,14 +353,14 @@ void introSequence() {
 	blackAllScreen();
 	g_music->updateMusic();
 
-	msgfont = g_resource->getFont("P:Map.fon");
+	_msgfont = g_resource->getFont("P:Map.fon");
 
 	nopalchange = true;
-	NReadPict("Intro.1", true);
+	nReadPict("Intro.1", true);
 	nopalchange = false;
 
 	for (counter = 0; counter < 16; counter++) {
-		Palette[counter] = ((diffcmap[counter * 3] >> 2) << 8) +
+		palette[counter] = ((diffcmap[counter * 3] >> 2) << 8) +
 		                   ((diffcmap[counter * 3 + 1] >> 2) << 4) +
 		                   (diffcmap[counter * 3 + 2] >> 2);
 	}
@@ -373,32 +374,32 @@ void introSequence() {
 	blackAllScreen();
 	g_music->updateMusic();
 
-	IntroDoBlack = true;
-	NReadPict("Station1", true);
+	_introDoBlack = true;
+	nReadPict("Station1", true);
 	doPictText("i.3", false);
 
-	NReadPict("Station2", true);
+	nReadPict("Station2", true);
 	doPictText("i.4", false);
 
-	NReadPict("Stiles4", true);
+	nReadPict("Stiles4", true);
 	doPictText("i.5", false);
 
-	NReadPict("Stiles3", true);
+	nReadPict("Stiles3", true);
 	doPictText("i.6", false);
 
-	NReadPict("Platform2", true);
+	nReadPict("Platform2", true);
 	doPictText("i.7", false);
 
-	NReadPict("Subway.1", true);
+	nReadPict("Subway.1", true);
 	doPictText("i.8", false);
 
-	NReadPict("Subway.2", true);
+	nReadPict("Subway.2", true);
 
 	doPictText("i.9", false);
 	doPictText("i.10", false);
 	doPictText("i.11", false);
 
-	if (!QuitIntro)
+	if (!_quitIntro)
 		for (counter = 0; counter < 50; counter++) {
 			for (counter1 = (8 * 3); counter1 < (255 * 3); counter1++)
 				diffcmap[counter1] = 255 - diffcmap[counter1];
@@ -413,57 +414,57 @@ void introSequence() {
 	doPictText("i.12", false);
 	doPictText("i.13", false);
 
-	IntroDoBlack = false;
-	NReadPict("Daed0", true);
+	_introDoBlack = false;
+	nReadPict("Daed0", true);
 	doPictText("i.14", false);
 
-	NReadPict("Daed1", true);
+	nReadPict("Daed1", true);
 	doPictText("i.15", false);
 
-	NReadPict("Daed2", true);
+	nReadPict("Daed2", true);
 	doPictText("i.16", false);
 	doPictText("i.17", false);
 	doPictText("i.18", false);
 
-	NReadPict("Daed3", true);
+	nReadPict("Daed3", true);
 	doPictText("i.19", false);
 	doPictText("i.20", false);
 
-	NReadPict("Daed4", true);
+	nReadPict("Daed4", true);
 	doPictText("i.21", false);
 
-	NReadPict("Daed5", true);
+	nReadPict("Daed5", true);
 	doPictText("i.22", false);
 	doPictText("i.23", false);
 	doPictText("i.24", false);
 
-	NReadPict("Daed6", true);
+	nReadPict("Daed6", true);
 	doPictText("i.25", false);
 	doPictText("i.26", false);
 
-	NReadPict("Daed7", false);
+	nReadPict("Daed7", false);
 	doPictText("i.27", false);
 	doPictText("i.28", false);
 	stopDiffEnd();
 
-	NReadPict("Daed8", true);
+	nReadPict("Daed8", true);
 	doPictText("i.29", false);
 	doPictText("i.30", false);
 
-	NReadPict("Daed9", true);
+	nReadPict("Daed9", true);
 	doPictText("i.31", false);
 	doPictText("i.32", false);
 	doPictText("i.33", false);
 
-	NReadPict("Daed9a", true);
-	NReadPict("Daed10", true);
+	nReadPict("Daed9a", true);
+	nReadPict("Daed10", true);
 	doPictText("i.34", false);
 	doPictText("i.35", false);
 	doPictText("i.36", false);
 
-	NReadPict("SubX", true);
+	nReadPict("SubX", true);
 
-	if (QuitIntro) {
+	if (_quitIntro) {
 		setAPen(0);
 		rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1);
 		DoBlack = true;
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index c9fa307..5fac2e1 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -118,12 +118,6 @@ Gadget *addGadButton(uint16 x, uint16 y, void *UpImage, void *DownImage, uint16
 void gadgetsOnOff(void *gptr, void *win, int32 num, bool on);
 
 /*----------------------*/
-/*---- From Intro.c ----*/
-/*----------------------*/
-
-void introSequence();
-
-/*----------------------*/
 /*----- From Lab.c -----*/
 /*----------------------*/
 


Commit: 158f623db8778ae8511bd94b7f5c6989230d4da5
    https://github.com/scummvm/scummvm/commit/158f623db8778ae8511bd94b7f5c6989230d4da5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:41+01:00

Commit Message:
LAB: Rename IntuiMessage struct members

Changed paths:
    engines/lab/engine.cpp
    engines/lab/interface.cpp
    engines/lab/interface.h
    engines/lab/intro.cpp
    engines/lab/map.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 8dd48d1..c706dca 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -797,12 +797,12 @@ static void mainGameLoop() {
 		} else {
 			GotMessage = true;
 
-			Class     = Msg->Class;
-			Code      = Msg->Code;
-			Qualifier = Msg->Qualifier;
-			MouseX    = Msg->MouseX;
-			MouseY    = Msg->MouseY;
-			GadID     = Msg->GadgetID;
+			Class     = Msg->msgClass;
+			Code      = Msg->code;
+			Qualifier = Msg->qualifier;
+			MouseX    = Msg->mouseX;
+			MouseY    = Msg->mouseY;
+			GadID     = Msg->gadgetID;
 
 			FollowingCrumbs = false;
 
@@ -868,14 +868,14 @@ from_crumbs:
 							g_music->updateMusic();
 							diffNextFrame();
 						} else {
-							if (Msg->Class == RAWKEY) {
-								if ((Msg->Code == 'Y') || (Msg->Code == 'y') || (Msg->Code == 'Q') || (Msg->Code == 'q')) {
+							if (Msg->msgClass == RAWKEY) {
+								if ((Msg->code == 'Y') || (Msg->code == 'y') || (Msg->code == 'Q') || (Msg->code == 'q')) {
 									doit = true;
 									break;
-								} else if (Msg->Code < 128) {
+								} else if (Msg->code < 128) {
 									break;
 								}
-							} else if (Msg->Class == MOUSEBUTTONS) {
+							} else if (Msg->msgClass == MOUSEBUTTONS) {
 								break;
 							}
 						}
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 8d05e41..1cd017d 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -177,30 +177,30 @@ IntuiMessage *getMsg() {
 
 	if ((curgad = mouseGadget()) != NULL) {
 		updateMouse();
-		IMessage.Class = GADGETUP;
-		IMessage.Code  = curgad->GadgetID;
-		IMessage.GadgetID = curgad->GadgetID;
-		IMessage.Qualifier = Qualifiers;
+		IMessage.msgClass = GADGETUP;
+		IMessage.code  = curgad->GadgetID;
+		IMessage.gadgetID = curgad->GadgetID;
+		IMessage.qualifier = Qualifiers;
 		return &IMessage;
-	} else if (mouseButton(&IMessage.MouseX, &IMessage.MouseY, true)) { /* Left Button */
-		IMessage.Qualifier = IEQUALIFIER_LEFTBUTTON | Qualifiers;
-		IMessage.Class = MOUSEBUTTONS;
+	} else if (mouseButton(&IMessage.mouseX, &IMessage.mouseY, true)) { /* Left Button */
+		IMessage.qualifier = IEQUALIFIER_LEFTBUTTON | Qualifiers;
+		IMessage.msgClass = MOUSEBUTTONS;
 		return &IMessage;
-	} else if (mouseButton(&IMessage.MouseX, &IMessage.MouseY, false)) { /* Right Button */
-		IMessage.Qualifier = IEQUALIFIER_RBUTTON | Qualifiers;
-		IMessage.Class = MOUSEBUTTONS;
+	} else if (mouseButton(&IMessage.mouseX, &IMessage.mouseY, false)) { /* Right Button */
+		IMessage.qualifier = IEQUALIFIER_RBUTTON | Qualifiers;
+		IMessage.msgClass = MOUSEBUTTONS;
 		return &IMessage;
-	} else if (keyPress(&IMessage.Code)) { /* Keyboard key */
-		curgad = checkNumGadgetHit(ScreenGadgetList, IMessage.Code);
+	} else if (keyPress(&IMessage.code)) { /* Keyboard key */
+		curgad = checkNumGadgetHit(ScreenGadgetList, IMessage.code);
 
 		if (curgad) {
-			IMessage.Class = GADGETUP;
-			IMessage.Code  = curgad->GadgetID;
-			IMessage.GadgetID = curgad->GadgetID;
+			IMessage.msgClass = GADGETUP;
+			IMessage.code  = curgad->GadgetID;
+			IMessage.gadgetID = curgad->GadgetID;
 		} else
-			IMessage.Class = RAWKEY;
+			IMessage.msgClass = RAWKEY;
 
-		IMessage.Qualifier = Qualifiers;
+		IMessage.qualifier = Qualifiers;
 		return &IMessage;
 	} else
 		return NULL;
diff --git a/engines/lab/interface.h b/engines/lab/interface.h
index ea110f4..84df28c 100644
--- a/engines/lab/interface.h
+++ b/engines/lab/interface.h
@@ -37,9 +37,9 @@
 namespace Lab {
 
 struct IntuiMessage {
-	uint32 Class;
-	uint16 Code, Qualifier, MouseX, MouseY, GadgetID;
-	uint32 Seconds, Micros;
+	uint32 msgClass;
+	uint16 code, qualifier, mouseX, mouseY, gadgetID;
+	uint32 seconds, micros;
 };
 
 
@@ -121,4 +121,3 @@ IntuiMessage *getMsg();
 } // End of namespace Lab
 
 #endif /* LAB_INTEFACE_H */
-
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index c3a8321..eacfd12 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -63,8 +63,8 @@ void Intro::introEatMessages() {
 		if (msg == NULL)
 			return;
 		else {
-			if (((msg->Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & msg->Qualifier)) ||
-			        ((msg->Class == RAWKEY) && (msg->Code == 27))
+			if (((msg->msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & msg->qualifier)) ||
+			        ((msg->msgClass == RAWKEY) && (msg->code == 27))
 				)
 				_quitIntro = true;
 		}
@@ -164,9 +164,9 @@ void Intro::doPictText(const char *filename, bool isscreen) {
 
 			waitTOF();
 		} else {
-			cls       = msg->Class;
-			qualifier = msg->Qualifier;
-			code      = msg->Code;
+			cls       = msg->msgClass;
+			qualifier = msg->qualifier;
+			code      = msg->code;
 
 			if (((cls == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & qualifier)) ||
 			        ((cls == RAWKEY) && (code == 27))) {
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index a096d28..f373fb8 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -725,12 +725,12 @@ void processMap(uint16 CurRoom) {
 				place = 1;
 
 		} else {
-			Class     = Msg->Class;
-			Code      = Msg->Code;
-			GadgetID  = Msg->GadgetID;
-			Qualifier = Msg->Qualifier;
-			MouseX    = Msg->MouseX;
-			MouseY    = Msg->MouseY;
+			Class     = Msg->msgClass;
+			Code      = Msg->code;
+			GadgetID  = Msg->gadgetID;
+			Qualifier = Msg->qualifier;
+			MouseX    = Msg->mouseX;
+			MouseY    = Msg->mouseY;
 
 			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) ||
 			        ((Class == RAWKEY) && (Code == 27)))
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 377f8db..9d9ccc7 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -745,14 +745,14 @@ static void processJournal() {
 
 	while (1) {
 		g_music->updateMusic();  /* Make sure we check the music at least after every message */
-		Msg = (IntuiMessage *) getMsg();
+		Msg = (IntuiMessage *)getMsg();
 
 		if (Msg == NULL) {
 			g_music->updateMusic();
 		} else {
-			Class     = Msg->Class;
-			Qualifier = Msg->Qualifier;
-			GadID     = Msg->Code;
+			Class     = Msg->msgClass;
+			Qualifier = Msg->qualifier;
+			GadID     = Msg->code;
 
 			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) ||
 			        ((Class == RAWKEY) && (GadID == 27)))
@@ -978,11 +978,11 @@ static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1
 		if (Msg == NULL) {
 			g_music->updateMusic();
 		} else {
-			Class     = Msg->Class;
-			Qualifier = Msg->Qualifier;
-			MouseX    = Msg->MouseX;
-			MouseY    = Msg->MouseY;
-			Code      = Msg->Code;
+			Class     = Msg->msgClass;
+			Qualifier = Msg->qualifier;
+			MouseX    = Msg->mouseX;
+			MouseY    = Msg->mouseY;
+			Code      = Msg->code;
 
 			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) ||
 			        ((Class == RAWKEY) && (Code == 27)))


Commit: c187a3bda9da38080ebd1bfc7401f84e62db0858
    https://github.com/scummvm/scummvm/commit/c187a3bda9da38080ebd1bfc7401f84e62db0858
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:41+01:00

Commit Message:
LAB: Add intro.h

Changed paths:
  A engines/lab/intro.h



diff --git a/engines/lab/intro.h b/engines/lab/intro.h
new file mode 100644
index 0000000..724feda
--- /dev/null
+++ b/engines/lab/intro.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.
+ *
+ */
+
+ /*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#ifndef LAB_INTRO_H
+#define LAB_INTRO_H
+
+#include "lab/intro.h"
+#include "lab/text.h"
+
+namespace Lab {
+
+class Intro {
+public:
+	Intro();
+	void introSequence();
+
+private:
+	void introEatMessages();
+	void doPictText(const char *Filename, bool isscreen);
+	void musicDelay();
+	void nReadPict(const char *Filename, bool PlayOnce);
+
+	TextFont _filler, *_msgfont;
+	bool _quitIntro, _introDoBlack;
+};
+
+} // End of namespace Lab
+
+#endif // LAB_INTRO_H


Commit: f56f2effb419533b7652d7a2152b832e29ebea09
    https://github.com/scummvm/scummvm/commit/f56f2effb419533b7652d7a2152b832e29ebea09
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:42+01:00

Commit Message:
LAB: Started vga code refactoring

Changed paths:
    engines/lab/graphics.cpp
    engines/lab/intro.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/readdiff.cpp
    engines/lab/special.cpp
    engines/lab/text.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 7bd2af4..40b9aa1 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -62,8 +62,6 @@ extern const char *CurFileName;
 /*---------------------------------------------------------------------------*/
 
 
-extern uint32 VGAScreenWidth, VGAScreenHeight, VGABytesPerPage;
-
 /*****************************************************************************/
 /* Reads in a picture into the dest bitmap.                                  */
 /*****************************************************************************/
@@ -81,8 +79,8 @@ bool readPict(const char *filename, bool PlayOnce) {
 		return false;
 	}
 
-	DispBitMap->BytesPerRow = VGAScreenWidth;
-	DispBitMap->Rows        = VGAScreenHeight;
+	DispBitMap->BytesPerRow = g_lab->_screenWidth;
+	DispBitMap->Rows        = g_lab->_screenHeight;
 	DispBitMap->Flags       = BITMAPF_VIDEO;
 
 	readDiff(PlayOnce);
@@ -292,7 +290,6 @@ uint32 flowText(void *font,      /* the TextAttr pointer */
 }
 
 
-extern uint32 VGABytesPerPage;
 extern byte *VGABASEADDRESS;
 
 
@@ -309,15 +306,15 @@ uint32 flowTextToMem(Image *DestIm, void *font,     /* the TextAttr pointer */
                      bool output,                  /* Whether to output any text */
                      uint16 x1,               /* Cords */
                      uint16 y1, uint16 x2, uint16 y2, const char *str) { /* The text itself */
-	uint32 res, vgabyte = VGABytesPerPage;
+	uint32 res, vgabyte = g_lab->_screenBytesPerPage;
 	byte *tmp = VGABASEADDRESS;
 
 	VGABASEADDRESS = DestIm->ImageData;
-	VGABytesPerPage = (uint32) DestIm->Width * (int32) DestIm->Height;
+	g_lab->_screenBytesPerPage = (uint32) DestIm->Width * (int32) DestIm->Height;
 
 	res = flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str);
 
-	VGABytesPerPage = vgabyte;
+	g_lab->_screenBytesPerPage = vgabyte;
 	VGABASEADDRESS = tmp;
 
 	return res;
@@ -462,8 +459,8 @@ static void doScrollBlack() {
 		tempmem = mem;
 
 		while (size) {
-			if (size > VGABytesPerPage)
-				copysize = VGABytesPerPage;
+			if (size > g_lab->_screenBytesPerPage)
+				copysize = g_lab->_screenBytesPerPage;
 			else
 				copysize = size;
 
@@ -510,12 +507,12 @@ static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startli
 
 	size = (int32)(height - nheight) * (int32) width;
 	mem += startline * width;
-	CurPage = ((int32) nheight * (int32) width) / VGABytesPerPage;
-	OffSet = ((int32) nheight * (int32) width) - (CurPage * VGABytesPerPage);
+	CurPage = ((int32) nheight * (int32) width) / g_lab->_screenBytesPerPage;
+	OffSet = ((int32) nheight * (int32) width) - (CurPage * g_lab->_screenBytesPerPage);
 
 	while (size) {
-		if (size > (VGABytesPerPage - OffSet))
-			copysize = VGABytesPerPage - OffSet;
+		if (size > (g_lab->_screenBytesPerPage - OffSet))
+			copysize = g_lab->_screenBytesPerPage - OffSet;
 		else
 			copysize = size;
 
@@ -665,7 +662,7 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
 				linesdone = 0;
 			}
 
-			ghoastRect(0, 0, CurY, VGAScreenWidth - 1, CurY + 1);
+			ghoastRect(0, 0, CurY, g_lab->_screenWidth - 1, CurY + 1);
 			CurY += 4;
 			linesdone++;
 		}
@@ -683,7 +680,7 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
 				linesdone = 0;
 			}
 
-			rectFill(0, CurY, VGAScreenWidth - 1, CurY + 1);
+			rectFill(0, CurY, g_lab->_screenWidth - 1, CurY + 1);
 			CurY += 4;
 			linesdone++;
 		}
@@ -696,16 +693,16 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
 	else
 		CurFileName = getPictName(CPtr);
 
-	byte *BitMapMem = readPictToMem(CurFileName, VGAScreenWidth, LastY + 5);
+	byte *BitMapMem = readPictToMem(CurFileName, g_lab->_screenWidth, LastY + 5);
 	VGASetPal(diffcmap, 256);
 
 	if (BitMapMem) {
-		ImSource.Width = VGAScreenWidth;
+		ImSource.Width = g_lab->_screenWidth;
 		ImSource.Height = LastY;
 		ImSource.ImageData = BitMapMem;
 
-		ImDest.Width = VGAScreenWidth;
-		ImDest.Height = VGAScreenHeight;
+		ImDest.Width = g_lab->_screenWidth;
+		ImDest.Height = g_lab->_screenHeight;
 		ImDest.ImageData = getVGABaseAddr();
 
 		for (counter = 0; counter < 2; counter++) {
@@ -720,8 +717,8 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
 
 				ImDest.ImageData = getVGABaseAddr();
 
-				bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, VGAScreenWidth, 2);
-				ghoastRect(0, 0, CurY, VGAScreenWidth - 1, CurY + 1);
+				bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, g_lab->_screenWidth, 2);
+				ghoastRect(0, 0, CurY, g_lab->_screenWidth - 1, CurY + 1);
 				CurY += 4;
 				linesdone++;
 			}
@@ -740,9 +737,9 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
 				ImDest.ImageData = getVGABaseAddr();
 
 				if (CurY == LastY)
-					bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, VGAScreenWidth, 1);
+					bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, g_lab->_screenWidth, 1);
 				else
-					bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, VGAScreenWidth, 2);
+					bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, g_lab->_screenWidth, 2);
 
 				CurY += 4;
 				linesdone++;
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index eacfd12..85c64c4 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -39,7 +39,6 @@
 namespace Lab {
 extern bool nopalchange, DoBlack, IsHiRes;
 extern char diffcmap[256 * 3];
-extern uint32 VGAScreenWidth, VGAScreenHeight;
 extern uint16 *FadePalette;
 
 Intro::Intro() {
@@ -466,7 +465,7 @@ void Intro::introSequence() {
 
 	if (_quitIntro) {
 		setAPen(0);
-		rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1);
+		rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
 		DoBlack = true;
 	}
 }
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index c13f5cd..c6f8006 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -55,6 +55,10 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
  : Engine(syst), _gameDescription(gameDesc), _extraGameFeatures(0) {
 	g_lab = this;
 
+    _screenWidth = 320;
+	_screenHeight = 200;
+	_screenBytesPerPage = 65536;
+
 	//const Common::FSNode gameDataDir(ConfMan.get("path"));
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game/pict");
@@ -100,7 +104,7 @@ Common::Error LabEngine::run() {
 			} else {
 				knownVersion = false;
 			}
-			
+
 			roomFile.close();
 
 			if (!knownVersion) {
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 989def2..e9d27ae 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -66,6 +66,11 @@ public:
 
 	LargeSet *_conditions, *_roomsFound;
 
+	int _screenWidth;
+	int _screenHeight;
+	int _screenBytesPerPage;
+
+
 	// timing.cpp
 	void getTime(uint32 *secs, uint32 *micros);
 	void addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *timeMicros);
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index f373fb8..4ad9ba2 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -49,7 +49,6 @@ static TextFont bmf;
 
 extern uint16 Direction;
 extern bool IsHiRes;
-extern uint32 VGAScreenWidth, VGAScreenHeight;
 
 extern CloseDataPtr CPtr;
 extern uint16 RoomNum;
@@ -584,7 +583,7 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b
 		fade(false, 0);
 
 	setAPen(0);
-	rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1);
+	rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
 
 	drawImage(Map, 0, 0);
 	drawGadgetList(MapGadgetList);
@@ -880,7 +879,7 @@ void doMap(uint16 CurRoom) {
 	blackAllScreen();
 	mouseHide();
 	setAPen(0);
-	rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1);
+	rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
 	freeMapData();
 	blackAllScreen();
 	mouseShow();
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index 727a339..421c2ce 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -64,7 +64,6 @@ char diffcmap[256 * 3];
 BitMap RawDiffBM;
 
 extern BitMap *DispBitMap, *DrawBitMap;
-extern uint32 VGABytesPerPage;
 extern byte **startoffile;
 
 #define CONTINUOUS      0xFFFF
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 9d9ccc7..41d938b 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -89,7 +89,6 @@ extern uint16 *FadePalette;
 extern bool nopalchange, DoBlack, IsHiRes;
 extern BitMap *DispBitMap, *DrawBitMap;
 extern char diffcmap[3 * 256];
-extern uint32 VGAScreenWidth, VGAScreenHeight;
 extern byte *TempScrollData;
 extern CloseDataPtr CPtr;
 extern InventoryData *Inventory;
@@ -120,7 +119,7 @@ static byte *loadBackPict(const char *fileName, bool tomem) {
 	nopalchange = true;
 
 	if (tomem)
-		res = readPictToMem(fileName, VGAScreenWidth, VGAScreenHeight);
+		res = readPictToMem(fileName, g_lab->_screenWidth, g_lab->_screenHeight);
 	else
 		readPict(fileName, true);
 
@@ -190,8 +189,8 @@ static void changeCombination(uint16 number) {
 	combnum = combination[number];
 
 	display.ImageData = getVGABaseAddr();
-	display.Width     = VGAScreenWidth;
-	display.Height    = VGAScreenHeight;
+	display.Width     = g_lab->_screenWidth;
+	display.Height    = g_lab->_screenHeight;
 
 	for (counter = 1; counter <= (Images[combnum]->Height / 2); counter++) {
 		if (IsHiRes) {
@@ -674,18 +673,18 @@ static void turnPage(bool FromLeft) {
 	uint16 counter;
 
 	if (FromLeft) {
-		for (counter = 0; counter < VGAScreenWidth; counter += 8) {
+		for (counter = 0; counter < g_lab->_screenWidth; counter += 8) {
 			g_music->updateMusic();
 			waitTOF();
 			ScreenImage.ImageData = getVGABaseAddr();
-			bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, VGAScreenHeight);
+			bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, g_lab->_screenHeight);
 		}
 	} else {
-		for (counter = (VGAScreenWidth - 8); counter > 0; counter -= 8) {
+		for (counter = (g_lab->_screenWidth - 8); counter > 0; counter -= 8) {
 			g_music->updateMusic();
 			waitTOF();
 			ScreenImage.ImageData = getVGABaseAddr();
-			bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, VGAScreenHeight);
+			bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, g_lab->_screenHeight);
 		}
 	}
 }
@@ -707,7 +706,7 @@ static void drawJournal(uint16 wipenum, bool needFade) {
 	ScreenImage.ImageData = getVGABaseAddr();
 
 	if (wipenum == 0)
-		bltBitMap(&JBackImage, 0, 0, &ScreenImage, 0, 0, VGAScreenWidth, VGAScreenHeight);
+		bltBitMap(&JBackImage, 0, 0, &ScreenImage, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight);
 	else
 		turnPage((bool)(wipenum == 1));
 
@@ -726,7 +725,7 @@ static void drawJournal(uint16 wipenum, bool needFade) {
 		fade(true, 0);
 
 	nopalchange = true;
-	JBackImage.ImageData = readPictToMem("P:Journal.pic", VGAScreenWidth, VGAScreenHeight);
+	JBackImage.ImageData = readPictToMem("P:Journal.pic", g_lab->_screenWidth, g_lab->_screenHeight);
 	GotBackImage = true;
 
 	eatMessages();
@@ -787,8 +786,8 @@ void doJournal() {
 	lastpage    = false;
 	GotBackImage = false;
 
-	JBackImage.Width = VGAScreenWidth;
-	JBackImage.Height = VGAScreenHeight;
+	JBackImage.Width = g_lab->_screenWidth;
+	JBackImage.Height = g_lab->_screenHeight;
 	JBackImage.ImageData   = NULL;
 
 	BackG.NextGadget = &CancelG;
@@ -812,7 +811,7 @@ void doJournal() {
 	ScreenImage.ImageData = getVGABaseAddr();
 
 	setAPen(0);
-	rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1);
+	rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
 	blackScreen();
 
 	freeAllStolenMem();
@@ -905,13 +904,13 @@ static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2,
 			MonGadHeight = fheight;
 
 		setAPen(0);
-		rectFill(0, 0, VGAScreenWidth - 1, y2);
+		rectFill(0, 0, g_lab->_screenWidth - 1, y2);
 
 		for (counter = 0; counter < numlines; counter++)
 			drawImage(MonButton, 0, counter * MonGadHeight);
 	} else if (isinteractive) {
 		setAPen(0);
-		rectFill(0, 0, VGAScreenWidth - 1, y2);
+		rectFill(0, 0, g_lab->_screenWidth - 1, y2);
 	} else {
 		setAPen(0);
 		rectFill(x1, y1, x2, y2);
@@ -1085,7 +1084,7 @@ void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1,
 	freeAllStolenMem();
 
 	setAPen(0);
-	rectFill(0, 0, VGAScreenWidth - 1, VGAScreenHeight - 1);
+	rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
 	blackAllScreen();
 }
 
diff --git a/engines/lab/text.cpp b/engines/lab/text.cpp
index c89cec3..36b0116 100644
--- a/engines/lab/text.cpp
+++ b/engines/lab/text.cpp
@@ -28,6 +28,7 @@
  *
  */
 
+#include "lab/lab.h"
 #include "lab/stddefines.h"
 #include "lab/labfun.h"
 #include "lab/text.h"
@@ -35,8 +36,6 @@
 
 namespace Lab {
 
-extern uint32 VGAScreenWidth, VGABytesPerPage;
-
 /*****************************************************************************/
 /* Closes a font and frees all memory associated with it.                    */
 /*****************************************************************************/
@@ -85,10 +84,10 @@ void text(struct TextFont *tf, uint16 x, uint16 y, uint16 color, const char *tex
 	VGATop = getVGABaseAddr();
 
 	for (counter = 0; counter < numchars; counter++) {
-		RealOffset = (VGAScreenWidth * y) + x;
-		curpage    = RealOffset / VGABytesPerPage;
-		SegmentOffset = RealOffset - (curpage * VGABytesPerPage);
-		LeftInSegment = VGABytesPerPage - SegmentOffset;
+		RealOffset = (g_lab->_screenWidth * y) + x;
+		curpage    = RealOffset / g_lab->_screenBytesPerPage;
+		SegmentOffset = RealOffset - (curpage * g_lab->_screenBytesPerPage);
+		LeftInSegment = g_lab->_screenBytesPerPage - SegmentOffset;
 		VGACur = VGATop + SegmentOffset;
 
 		if (tf->Widths[(uint)*text]) {
@@ -121,10 +120,10 @@ void text(struct TextFont *tf, uint16 x, uint16 y, uint16 color, const char *tex
 								curpage++;
 								VGATemp = (byte *)(VGATop - templeft);
 								/* Set up VGATempLine for next line */
-								VGATempLine -= VGABytesPerPage;
+								VGATempLine -= g_lab->_screenBytesPerPage;
 								/* Set up LeftInSegment for next line */
-								LeftInSegment += VGABytesPerPage + templeft;
-								templeft += VGABytesPerPage;
+								LeftInSegment += g_lab->_screenBytesPerPage + templeft;
+								templeft += g_lab->_screenBytesPerPage;
 							}
 
 							if (mask & data)
@@ -141,13 +140,13 @@ void text(struct TextFont *tf, uint16 x, uint16 y, uint16 color, const char *tex
 					}
 				}
 
-				VGATempLine += VGAScreenWidth;
-				LeftInSegment -= VGAScreenWidth;
+				VGATempLine += g_lab->_screenWidth;
+				LeftInSegment -= g_lab->_screenWidth;
 
 				if (LeftInSegment <= 0) {
 					curpage++;
-					VGATempLine -= VGABytesPerPage;
-					LeftInSegment += VGABytesPerPage;
+					VGATempLine -= g_lab->_screenBytesPerPage;
+					LeftInSegment += g_lab->_screenBytesPerPage;
 				}
 			}
 		}
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 013b6ee..5e1a1e8 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -28,6 +28,7 @@
  *
  */
 
+#include "lab/lab.h"
 #include "lab/vga.h"
 #include "lab/stddefines.h"
 #include "lab/mouse.h"
@@ -38,12 +39,8 @@
 
 namespace Lab {
 
-static byte curvgapal[256 * 3];
-static unsigned char curapen = 0;
-
-uint32 VGAScreenWidth = 320UL,
-              VGAScreenHeight = 200UL,
-              VGABytesPerPage = 65536UL;
+static byte _curvgapal[256 * 3];
+static unsigned char _curapen = 0;
 
 byte *VGABASEADDRESS = 0;
 
@@ -71,16 +68,16 @@ bool createScreen(bool HiRes) {
 	VGABASEADDRESS  = 0;
 
 	if (HiRes) {
-		VGAScreenWidth  = 640;
-		VGAScreenHeight = 480;
+		g_lab->_screenWidth  = 640;
+		g_lab->_screenHeight = 480;
 	} else {
-		VGAScreenWidth  = 320;
-		VGAScreenHeight = 200;
+		g_lab->_screenWidth  = 320;
+		g_lab->_screenHeight = 200;
 	}
-	VGABytesPerPage = VGAScreenWidth * VGAScreenHeight;
+	g_lab->_screenBytesPerPage = g_lab->_screenWidth * g_lab->_screenHeight;
 
-	g_DisplayBuffer = (byte *)malloc(VGABytesPerPage);
-	g_Pixels = (byte *)calloc(VGABytesPerPage, 4);
+	g_DisplayBuffer = (byte *)malloc(g_lab->_screenBytesPerPage);
+	g_Pixels = (byte *)calloc(g_lab->_screenBytesPerPage, 4);
 
 	return true;
 }
@@ -138,8 +135,8 @@ void WSDL_ProcessInput(bool can_delay) {
 					g_MouseX = 0;
 					g_MouseAtEdge = true;
 				}
-				if (g_MouseX > VGAScreenWidth - 1) {
-					g_MouseX = VGAScreenWidth;
+				if (g_MouseX > g_lab->_screenWidth - 1) {
+					g_MouseX = g_lab->_screenWidth;
 					g_MouseAtEdge = true;
 				}
 
@@ -148,8 +145,8 @@ void WSDL_ProcessInput(bool can_delay) {
 					g_MouseY = 0;
 					g_MouseAtEdge = true;
 				}
-				if (g_MouseY > VGAScreenHeight - 1) {
-					g_MouseY = VGAScreenHeight;
+				if (g_MouseY > g_lab->_screenHeight - 1) {
+					g_MouseY = g_lab->_screenHeight;
 					g_MouseAtEdge = true;
 				}
 
@@ -188,7 +185,7 @@ void WSDL_ProcessInput(bool can_delay) {
 				break;
 			}
 
-			g_system->copyRectToScreen(g_DisplayBuffer, VGAScreenWidth, 0, 0, VGAScreenWidth, VGAScreenHeight);
+			g_system->copyRectToScreen(g_DisplayBuffer, g_lab->_screenWidth, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight);
 			g_system->updateScreen();
 		}
 	}
@@ -208,7 +205,7 @@ void waitTOF() {
 	int untilOutOfRefresh = 1;
 
   	if (g_ScreenWasLocked || untilOutOfRefresh) {
-		g_system->copyRectToScreen(g_DisplayBuffer, VGAScreenWidth, 0, 0, VGAScreenWidth, VGAScreenHeight);
+		g_system->copyRectToScreen(g_DisplayBuffer, g_lab->_screenWidth, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight);
 		g_system->updateScreen();
   	}
 
@@ -249,12 +246,12 @@ void WSDL_SetColors(byte *buf, uint16 first, uint16 numreg, uint16 slow) {
 /*****************************************************************************/
 void writeColorRegs(byte *buf, uint16 first, uint16 numreg) {
 	WSDL_SetColors(buf, first, numreg, 0);
-	memcpy(&(curvgapal[first * 3]), buf, numreg * 3);
+	memcpy(&(_curvgapal[first * 3]), buf, numreg * 3);
 }
 
 void writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg) {
 	WSDL_SetColors(buf, first, numreg, 1);
-	memcpy(&(curvgapal[first * 3]), buf, numreg * 3);
+	memcpy(&(_curvgapal[first * 3]), buf, numreg * 3);
 }
 
 /*****************************************************************************/
@@ -267,7 +264,7 @@ void writeColorReg(byte *buf, uint16 regnum) {
 }
 
 void VGASetPal(void *cmap, uint16 numcolors) {
-	if (memcmp(cmap, curvgapal, numcolors * 3) != 0)
+	if (memcmp(cmap, _curvgapal, numcolors * 3) != 0)
 		writeColorRegs((byte *)cmap, 0, numcolors);
 }
 
@@ -283,7 +280,7 @@ void WSDL_IgnoreUpdateDisplay(int state) {
 
 void WSDL_UpdateScreen() {
 	if (g_ScreenWasLocked && !g_IgnoreUpdateDisplay) {
-		g_system->copyRectToScreen(g_DisplayBuffer, VGAScreenWidth, 0, 0, VGAScreenWidth, VGAScreenHeight);
+		g_system->copyRectToScreen(g_DisplayBuffer, g_lab->_screenWidth, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight);
   		g_system->updateScreen();
   	}
 
@@ -326,20 +323,20 @@ void drawImage(Image *Im, uint16 x, uint16 y) {
 		dy = 0;
 	}
 
-	if ((uint)(dx + w) > VGAScreenWidth)
-		w = VGAScreenWidth - dx;
+	if ((uint)(dx + w) > g_lab->_screenWidth)
+		w = g_lab->_screenWidth - dx;
 
-	if ((uint)(dy + h) > VGAScreenHeight)
-		h = VGAScreenHeight - dy;
+	if ((uint)(dy + h) > g_lab->_screenHeight)
+		h = g_lab->_screenHeight - dy;
 
 	if (w > 0 && h > 0) {
 		byte *s = Im->ImageData + sy * Im->Width + sx;
-		byte *d = getVGABaseAddr() + dy * VGAScreenWidth + dx;
+		byte *d = getVGABaseAddr() + dy * g_lab->_screenWidth + dx;
 
 		while (h-- > 0) {
 			memcpy(d, s, w);
 			s += Im->Width;
-			d += VGAScreenWidth;
+			d += g_lab->_screenWidth;
 		}
 	}
 }
@@ -369,15 +366,15 @@ void drawMaskImage(Image *Im, uint16 x, uint16 y) {
 		dy = 0;
 	}
 
-	if ((uint)(dx + w) > VGAScreenWidth)
-		w = VGAScreenWidth - dx;
+	if ((uint)(dx + w) > g_lab->_screenWidth)
+		w = g_lab->_screenWidth - dx;
 
-	if ((uint)(dy + h) > VGAScreenHeight)
-		h = VGAScreenHeight - dy;
+	if ((uint)(dy + h) > g_lab->_screenHeight)
+		h = g_lab->_screenHeight - dy;
 
 	if (w > 0 && h > 0) {
 		byte *s = Im->ImageData + sy * Im->Width + sx;
-		byte *d = getVGABaseAddr() + dy * VGAScreenWidth + dx;
+		byte *d = getVGABaseAddr() + dy * g_lab->_screenWidth + dx;
 
 		while (h-- > 0) {
 			byte *ss = s;
@@ -392,7 +389,7 @@ void drawMaskImage(Image *Im, uint16 x, uint16 y) {
 			}
 
 			s += Im->Width;
-			d += VGAScreenWidth;
+			d += g_lab->_screenWidth;
 		}
 	}
 }
@@ -422,20 +419,20 @@ void readScreenImage(Image *Im, uint16 x, uint16 y) {
 		dy = 0;
 	}
 
-	if ((uint)(dx + w) > VGAScreenWidth)
-		w = VGAScreenWidth - dx;
+	if ((uint)(dx + w) > g_lab->_screenWidth)
+		w = g_lab->_screenWidth - dx;
 
-	if ((uint)(dy + h) > VGAScreenHeight)
-		h = VGAScreenHeight - dy;
+	if ((uint)(dy + h) > g_lab->_screenHeight)
+		h = g_lab->_screenHeight - dy;
 
 	if (w > 0 && h > 0) {
 		byte *s = Im->ImageData + sy * Im->Width + sx;
-		byte *d = getVGABaseAddr() + dy * VGAScreenWidth + dx;
+		byte *d = getVGABaseAddr() + dy * g_lab->_screenWidth + dx;
 
 		while (h-- > 0) {
 			memcpy(s, d, w);
 			s += Im->Width;
-			d += VGAScreenWidth;
+			d += g_lab->_screenWidth;
 		}
 	}
 }
@@ -575,7 +572,7 @@ void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 /* Sets the pen number to use on all the drawing operations.                 */
 /*****************************************************************************/
 void setAPen(uint16 pennum) {
-	curapen = (unsigned char)pennum;
+	_curapen = (unsigned char)pennum;
 }
 
 /*****************************************************************************/
@@ -599,24 +596,24 @@ void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 		dy = 0;
 	}
 
-	if ((uint)(dx + w) > VGAScreenWidth)
-		w = VGAScreenWidth - dx;
+	if ((uint)(dx + w) > g_lab->_screenWidth)
+		w = g_lab->_screenWidth - dx;
 
-	if ((uint)(dy + h) > VGAScreenHeight)
-		h = VGAScreenHeight - dy;
+	if ((uint)(dy + h) > g_lab->_screenHeight)
+		h = g_lab->_screenHeight - dy;
 
 	if (w > 0 && h > 0) {
-		char *d = (char *)getVGABaseAddr() + dy * VGAScreenWidth + dx;
+		char *d = (char *)getVGABaseAddr() + dy * g_lab->_screenWidth + dx;
 
 		while (h-- > 0) {
 			char *dd = d;
 			int ww = w;
 
 			while (ww-- > 0) {
-				*dd++ = curapen;
+				*dd++ = _curapen;
 			}
 
-			d += VGAScreenWidth;
+			d += g_lab->_screenWidth;
 		}
 	}
 }
@@ -656,14 +653,14 @@ void ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 		dy = 0;
 	}
 
-	if ((uint)(dx + w) > VGAScreenWidth)
-		w = VGAScreenWidth - dx;
+	if ((uint)(dx + w) > g_lab->_screenWidth)
+		w = g_lab->_screenWidth - dx;
 
-	if ((uint)(dy + h) > VGAScreenHeight)
-		h = VGAScreenHeight - dy;
+	if ((uint)(dy + h) > g_lab->_screenHeight)
+		h = g_lab->_screenHeight - dy;
 
 	if (w > 0 && h > 0) {
-		char *d = (char *)getVGABaseAddr() + dy * VGAScreenWidth + dx;
+		char *d = (char *)getVGABaseAddr() + dy * g_lab->_screenWidth + dx;
 
 		while (h-- > 0) {
 			char *dd = d;
@@ -680,7 +677,7 @@ void ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 				ww -= 2;
 			}
 
-			d += VGAScreenWidth;
+			d += g_lab->_screenWidth;
 			dy++;
 		}
 	}


Commit: 06c2e60cf050c8be47043c792c3a5b39fc3ac899
    https://github.com/scummvm/scummvm/commit/06c2e60cf050c8be47043c792c3a5b39fc3ac899
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:43+01:00

Commit Message:
LAB: Further renaming of vga code

Changed paths:
    engines/lab/mouse.cpp
    engines/lab/vga.cpp
    engines/lab/vga.h



diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index c45ab5c..292ac3c 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -199,16 +199,16 @@ void mouseHide() {
 }
 
 
-extern uint32 g_MouseX;
-extern uint32 g_MouseY;
+extern uint32 _mouseX;
+extern uint32 _mouseY;
 
 /*****************************************************************************/
 /* Gets the current mouse co-ordinates.  NOTE: On IBM version, will scale    */
 /* from virtual to screen co-ordinates automatically.                        */
 /*****************************************************************************/
 void mouseXY(uint16 *x, uint16 *y) {
-	*x = (uint16)g_MouseX;
-	*y = (uint16)g_MouseY;
+	*x = (uint16)_mouseX;
+	*y = (uint16)_mouseY;
 
 	if (!IsHiRes)
 		(*x) /= 2;
@@ -237,15 +237,15 @@ void mouseMove(uint16 x, uint16 y) {
 bool mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
 	if (leftbutton) {
 		if (LeftClick) {
-			*x = (!IsHiRes) ? (uint16)g_MouseX / 2 : (uint16)g_MouseX;
-			*y = (uint16)g_MouseY;
+			*x = (!IsHiRes) ? (uint16)_mouseX / 2 : (uint16)_mouseX;
+			*y = (uint16)_mouseY;
 			LeftClick = false;
 			return true;
 		}
 	} else {
 		if (RightClick) {
-			*x = (!IsHiRes) ? (uint16)g_MouseX / 2 : (uint16)g_MouseX;
-			*y = (uint16)g_MouseY;
+			*x = (!IsHiRes) ? (uint16)_mouseX / 2 : (uint16)_mouseX;
+			*y = (uint16)_mouseY;
 			RightClick = false;
 			return true;
 		}
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 5e1a1e8..cf4ccc7 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -43,30 +43,23 @@ static byte _curvgapal[256 * 3];
 static unsigned char _curapen = 0;
 
 byte *VGABASEADDRESS = 0;
+byte *_displayBuffer = 0;
 
-byte *g_DisplayBuffer = 0;
-byte *g_Pixels = 0;
-
-int g_ScreenWasLocked = 0;
-int g_IgnoreUpdateDisplay = 0;
 int g_LastWaitTOFTicks = 0;
 
-uint32 g_MouseX = 0;
-uint32 g_MouseY = 0;
+uint32 _mouseX = 0;
+uint32 _mouseY = 0;
 
 uint16 g_NextKeyIn = 0;
 uint16 g_KeyBuf[64];
 uint16 g_NextKeyOut = 0;
-bool g_MouseAtEdge = false;
+bool _mouseAtEdge = false;
 byte *TempScrollData;
 
 /*****************************************************************************/
 /* Sets up either a low-res or a high-res 256 color screen.                  */
 /*****************************************************************************/
 bool createScreen(bool HiRes) {
-	//VGABASEADDRESS  = (unsigned long)malloc(640 * 480);
-	VGABASEADDRESS  = 0;
-
 	if (HiRes) {
 		g_lab->_screenWidth  = 640;
 		g_lab->_screenHeight = 480;
@@ -76,8 +69,7 @@ bool createScreen(bool HiRes) {
 	}
 	g_lab->_screenBytesPerPage = g_lab->_screenWidth * g_lab->_screenHeight;
 
-	g_DisplayBuffer = (byte *)malloc(g_lab->_screenBytesPerPage);
-	g_Pixels = (byte *)calloc(g_lab->_screenBytesPerPage, 4);
+	_displayBuffer = (byte *)malloc(g_lab->_screenBytesPerPage);
 
 	return true;
 }
@@ -119,39 +111,39 @@ void WSDL_ProcessInput(bool can_delay) {
 			switch (event.type) {
 			case Common::EVENT_RBUTTONDOWN:
 				flags |= 8;
-				mouseHandler(flags, g_MouseX, g_MouseY);
+				mouseHandler(flags, _mouseX, _mouseY);
 				break;
 
 			case Common::EVENT_LBUTTONDOWN:
 				flags |= 2;
-				mouseHandler(flags, g_MouseX, g_MouseY);
+				mouseHandler(flags, _mouseX, _mouseY);
 				break;
 
 			case Common::EVENT_MOUSEMOVE:
-				lastMouseAtEdge = g_MouseAtEdge;
-				g_MouseAtEdge = false;
-				g_MouseX = event.mouse.x;
+				lastMouseAtEdge = _mouseAtEdge;
+				_mouseAtEdge = false;
+				_mouseX = event.mouse.x;
 				if (event.mouse.x <= 0) {
-					g_MouseX = 0;
-					g_MouseAtEdge = true;
+					_mouseX = 0;
+					_mouseAtEdge = true;
 				}
-				if (g_MouseX > g_lab->_screenWidth - 1) {
-					g_MouseX = g_lab->_screenWidth;
-					g_MouseAtEdge = true;
+				if (_mouseX > g_lab->_screenWidth - 1) {
+					_mouseX = g_lab->_screenWidth;
+					_mouseAtEdge = true;
 				}
 
-				g_MouseY = event.mouse.y;
+				_mouseY = event.mouse.y;
 				if (event.mouse.y <= 0) {
-					g_MouseY = 0;
-					g_MouseAtEdge = true;
+					_mouseY = 0;
+					_mouseAtEdge = true;
 				}
-				if (g_MouseY > g_lab->_screenHeight - 1) {
-					g_MouseY = g_lab->_screenHeight;
-					g_MouseAtEdge = true;
+				if (_mouseY > g_lab->_screenHeight - 1) {
+					_mouseY = g_lab->_screenHeight;
+					_mouseAtEdge = true;
 				}
 
-				if (!lastMouseAtEdge || !g_MouseAtEdge)
-					mouseHandler(1, g_MouseX, g_MouseY);
+				if (!lastMouseAtEdge || !_mouseAtEdge)
+					mouseHandler(1, _mouseX, _mouseY);
 
 				break;
 
@@ -185,7 +177,7 @@ void WSDL_ProcessInput(bool can_delay) {
 				break;
 			}
 
-			g_system->copyRectToScreen(g_DisplayBuffer, g_lab->_screenWidth, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight);
+			g_system->copyRectToScreen(_displayBuffer, g_lab->_screenWidth, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight);
 			g_system->updateScreen();
 		}
 	}
@@ -197,19 +189,14 @@ void WSDL_ProcessInput(bool can_delay) {
 void WSDL_GetMousePos(int *x, int *y) {
 	WSDL_ProcessInput(0);
 
-	*x = g_MouseX;
-	*y = g_MouseY;
+	*x = _mouseX;
+	*y = _mouseY;
 }
 
 void waitTOF() {
-	int untilOutOfRefresh = 1;
+	g_system->copyRectToScreen(_displayBuffer, g_lab->_screenWidth, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight);
+	g_system->updateScreen();
 
-  	if (g_ScreenWasLocked || untilOutOfRefresh) {
-		g_system->copyRectToScreen(g_DisplayBuffer, g_lab->_screenWidth, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight);
-		g_system->updateScreen();
-  	}
-
-  	g_ScreenWasLocked = 0;
   	WSDL_ProcessInput(0);
 
   	uint32 now;
@@ -268,23 +255,10 @@ void VGASetPal(void *cmap, uint16 numcolors) {
 		writeColorRegs((byte *)cmap, 0, numcolors);
 }
 
-byte *WSDL_LockVideo() {
-	g_ScreenWasLocked = 1;
-
-	return g_DisplayBuffer;
-}
-
-void WSDL_IgnoreUpdateDisplay(int state) {
-	g_IgnoreUpdateDisplay = state;
-}
-
 void WSDL_UpdateScreen() {
-	if (g_ScreenWasLocked && !g_IgnoreUpdateDisplay) {
-		g_system->copyRectToScreen(g_DisplayBuffer, g_lab->_screenWidth, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight);
-  		g_system->updateScreen();
-  	}
+	g_system->copyRectToScreen(_displayBuffer, g_lab->_screenWidth, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight);
+	g_system->updateScreen();
 
-	g_ScreenWasLocked = 0;
 	WSDL_ProcessInput(0);
 }
 
@@ -295,7 +269,7 @@ byte *getVGABaseAddr() {
 	if (VGABASEADDRESS)
 		return VGABASEADDRESS;
 
-	return WSDL_LockVideo();
+	return _displayBuffer;
 }
 
 /*****************************************************************************/
diff --git a/engines/lab/vga.h b/engines/lab/vga.h
index aa5a26c..ade6a2a 100644
--- a/engines/lab/vga.h
+++ b/engines/lab/vga.h
@@ -64,7 +64,6 @@ void drawVLine(uint16 x1, uint16 y, uint16 x2);
 void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 void ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 void WSDL_UpdateScreen();
-void WSDL_IgnoreUpdateDisplay(int state);
 void WSDL_GetMousePos(int *x, int *y);
 uint16 WSDL_GetNextChar();
 bool WSDL_HasNextChar();


Commit: 4b65faaa632d309f02f6c25d38d9b6afc0648cbd
    https://github.com/scummvm/scummvm/commit/4b65faaa632d309f02f6c25d38d9b6afc0648cbd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:43+01:00

Commit Message:
LAB: More renames in vga.cpp

Changed paths:
    engines/lab/graphics.cpp
    engines/lab/special.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 40b9aa1..6296313 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -290,7 +290,7 @@ uint32 flowText(void *font,      /* the TextAttr pointer */
 }
 
 
-extern byte *VGABASEADDRESS;
+extern byte *_currentDsplayBuffer;
 
 
 /******************************************************************************/
@@ -307,15 +307,15 @@ uint32 flowTextToMem(Image *DestIm, void *font,     /* the TextAttr pointer */
                      uint16 x1,               /* Cords */
                      uint16 y1, uint16 x2, uint16 y2, const char *str) { /* The text itself */
 	uint32 res, vgabyte = g_lab->_screenBytesPerPage;
-	byte *tmp = VGABASEADDRESS;
+	byte *tmp = _currentDsplayBuffer;
 
-	VGABASEADDRESS = DestIm->ImageData;
+	_currentDsplayBuffer = DestIm->ImageData;
 	g_lab->_screenBytesPerPage = (uint32) DestIm->Width * (int32) DestIm->Height;
 
 	res = flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str);
 
 	g_lab->_screenBytesPerPage = vgabyte;
-	VGABASEADDRESS = tmp;
+	_currentDsplayBuffer = tmp;
 
 	return res;
 }
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 41d938b..0104e3e 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -89,7 +89,7 @@ extern uint16 *FadePalette;
 extern bool nopalchange, DoBlack, IsHiRes;
 extern BitMap *DispBitMap, *DrawBitMap;
 extern char diffcmap[3 * 256];
-extern byte *TempScrollData;
+extern byte *_tempScrollData;
 extern CloseDataPtr CPtr;
 extern InventoryData *Inventory;
 extern uint16 RoomNum, Direction;
@@ -164,7 +164,7 @@ void showCombination(const char *filename) {
 	for (CurBit = 0; CurBit < 10; CurBit++)
 		readImage(buffer, &(Images[CurBit]));
 
-	allocFile((void **)&TempScrollData, Images[0]->Width * Images[0]->Height * 2L, "tempdata");
+	allocFile((void **)&_tempScrollData, Images[0]->Width * Images[0]->Height * 2L, "tempdata");
 
 	doCombination();
 
@@ -315,7 +315,7 @@ void showTile(const char *filename, bool showsolution) {
 	for (CurBit = start; CurBit < 16; CurBit++)
 		readImage(buffer, &(Tiles[CurBit]));
 
-	allocFile((void **)&TempScrollData, Tiles[1]->Width * Tiles[1]->Height * 2L, "tempdata");
+	allocFile((void **)&_tempScrollData, Tiles[1]->Width * Tiles[1]->Height * 2L, "tempdata");
 
 	doTile(showsolution);
 
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index cf4ccc7..54cb507 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -42,19 +42,19 @@ namespace Lab {
 static byte _curvgapal[256 * 3];
 static unsigned char _curapen = 0;
 
-byte *VGABASEADDRESS = 0;
+byte *_currentDsplayBuffer = 0;
 byte *_displayBuffer = 0;
 
-int g_LastWaitTOFTicks = 0;
+int _lastWaitTOFTicks = 0;
 
 uint32 _mouseX = 0;
 uint32 _mouseY = 0;
 
-uint16 g_NextKeyIn = 0;
-uint16 g_KeyBuf[64];
-uint16 g_NextKeyOut = 0;
+uint16 _nextKeyIn = 0;
+uint16 _keyBuf[64];
+uint16 _nextKeyOut = 0;
 bool _mouseAtEdge = false;
-byte *TempScrollData;
+byte *_tempScrollData;
 
 /*****************************************************************************/
 /* Sets up either a low-res or a high-res 256 color screen.                  */
@@ -85,10 +85,10 @@ uint16 WSDL_GetNextChar() {
 	uint16 c = 0;
 
 	WSDL_ProcessInput(0);
-	if (g_NextKeyIn != g_NextKeyOut) {
-		c = g_KeyBuf[g_NextKeyOut];
-		g_NextKeyOut = ((((unsigned int)((g_NextKeyOut + 1) >> 31) >> 26) + (byte)g_NextKeyOut + 1) & 0x3F)
-                 - ((unsigned int)((g_NextKeyOut + 1) >> 31) >> 26);
+	if (_nextKeyIn != _nextKeyOut) {
+		c = _keyBuf[_nextKeyOut];
+		_nextKeyOut = ((((unsigned int)((_nextKeyOut + 1) >> 31) >> 26) + (byte)_nextKeyOut + 1) & 0x3F)
+                 - ((unsigned int)((_nextKeyOut + 1) >> 31) >> 26);
   	}
 
 	return c;
@@ -96,7 +96,7 @@ uint16 WSDL_GetNextChar() {
 
 bool WSDL_HasNextChar() {
 	WSDL_ProcessInput(0);
-	return g_NextKeyIn != g_NextKeyOut;
+	return _nextKeyIn != _nextKeyOut;
 }
 
 void WSDL_ProcessInput(bool can_delay) {
@@ -162,11 +162,11 @@ void WSDL_ProcessInput(bool can_delay) {
 					break;
 
 				default:
-					n = ((((unsigned int)((g_NextKeyIn + 1) >> 31) >> 26) + (byte)g_NextKeyIn + 1) & 0x3F)
-					- ((unsigned int)((g_NextKeyIn + 1) >> 31) >> 26);
-					if (n != g_NextKeyOut) {
-						g_KeyBuf[g_NextKeyIn] = event.kbd.keycode;
-						g_NextKeyIn = n;
+					n = ((((unsigned int)((_nextKeyIn + 1) >> 31) >> 26) + (byte)_nextKeyIn + 1) & 0x3F)
+					- ((unsigned int)((_nextKeyIn + 1) >> 31) >> 26);
+					if (n != _nextKeyOut) {
+						_keyBuf[_nextKeyIn] = event.kbd.keycode;
+						_nextKeyIn = n;
 					}
 				}
 				break;
@@ -201,10 +201,10 @@ void waitTOF() {
 
   	uint32 now;
 
-  	for (now = g_system->getMillis(); now - g_LastWaitTOFTicks <= 0xF; now = g_system->getMillis() )
-  		g_system->delayMillis(g_LastWaitTOFTicks - now + 17);
+	for (now = g_system->getMillis(); now - _lastWaitTOFTicks <= 0xF; now = g_system->getMillis() )
+		g_system->delayMillis(_lastWaitTOFTicks - now + 17);
 
-  	g_LastWaitTOFTicks = now;
+	_lastWaitTOFTicks = now;
 }
 
 void WSDL_SetColors(byte *buf, uint16 first, uint16 numreg, uint16 slow) {
@@ -266,8 +266,8 @@ void WSDL_UpdateScreen() {
 /* Returns the base address of the current VGA display.                      */
 /*****************************************************************************/
 byte *getVGABaseAddr() {
-	if (VGABASEADDRESS)
-		return VGABASEADDRESS;
+	if (_currentDsplayBuffer)
+		return _currentDsplayBuffer;
 
 	return _displayBuffer;
 }
@@ -458,14 +458,14 @@ void bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest,
 
 /*****************************************************************************/
 /* Scrolls the display in the x direction by blitting.                       */
-/* The TempScrollData variable must be initialized to some memory, or this   */
+/* The _tempScrollData variable must be initialized to some memory, or this   */
 /* function will fail.                                                       */
 /*****************************************************************************/
 void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	Image Im;
 	uint16 temp;
 
-	Im.ImageData = TempScrollData;
+	Im.ImageData = _tempScrollData;
 
 	if (x1 > x2) {
 		temp = x2;
@@ -507,7 +507,7 @@ void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	Image Im;
 	uint16 temp;
 
-	Im.ImageData = TempScrollData;
+	Im.ImageData = _tempScrollData;
 
 	if (x1 > x2) {
 		temp = x2;


Commit: 93e3ba9eddc7c50db7f6475305a24cd30f2893fa
    https://github.com/scummvm/scummvm/commit/93e3ba9eddc7c50db7f6475305a24cd30f2893fa
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:43+01:00

Commit Message:
LAB: Put vga.cpp into LabEngine class

Changed paths:
  R engines/lab/vga.h
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/interface.cpp
    engines/lab/interface.h
    engines/lab/intro.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/labfun.h
    engines/lab/labmusic.cpp
    engines/lab/map.cpp
    engines/lab/mouse.cpp
    engines/lab/processroom.cpp
    engines/lab/readdiff.cpp
    engines/lab/special.cpp
    engines/lab/text.cpp
    engines/lab/timing.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index c706dca..18178d3 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -32,7 +32,6 @@
 #include "lab/stddefines.h"
 #include "lab/labfun.h"
 #include "lab/diff.h"
-#include "lab/vga.h"
 #include "lab/text.h"
 #include "lab/intro.h"
 #include "lab/parsefun.h"
@@ -132,7 +131,7 @@ static char initcolors[] = { '\x00', '\x00', '\x00', '\x30',
 /******************************************************************************/
 /* Draws the control panel display.                                           */
 /******************************************************************************/
-void drawPanel() {
+void LabEngine::drawPanel() {
 	mouseHide();
 
 	setAPen(3);                 /* Clear Area */
@@ -219,7 +218,7 @@ static void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr) {
 /******************************************************************************/
 /* Sets up the Labyrinth screens, and opens up the initial windows.           */
 /******************************************************************************/
-bool setUpScreens() {
+bool LabEngine::setUpScreens() {
 	uint16 counter;
 	byte *buffer;
 	byte *MovePanelBuffer, *InvPanelBuffer;
@@ -349,7 +348,7 @@ bool setUpScreens() {
 /******************************************************************************/
 /* Permanently flips the imagry of a gadget.                                  */
 /******************************************************************************/
-static void perFlipGadget(uint16 GadID) {
+void LabEngine::perFlipGadget(uint16 GadID) {
 	Image *Temp;
 	Gadget *TopGad;
 
@@ -391,7 +390,7 @@ void eatMessages() {
 /******************************************************************************/
 /* Checks whether the close up is one of the special case closeups.           */
 /******************************************************************************/
-static bool doCloseUp(CloseDataPtr cptr) {
+bool LabEngine::doCloseUp(CloseDataPtr cptr) {
 	if (cptr == NULL)
 		return false;
 
@@ -527,8 +526,7 @@ static const char *Test;
 /******************************************************************************/
 /* If the user hits the "Use" gadget; things that can get used on themselves. */
 /******************************************************************************/
-static bool doUse(uint16 CurInv) {
-
+bool LabEngine::doUse(uint16 CurInv) {
 	if (CurInv == MAPNUM) {                  /* LAB: Labyrinth specific */
 		drawStaticMessage(kTextUseMap);
 		interfaceOff();
@@ -539,9 +537,7 @@ static bool doUse(uint16 CurInv) {
 		VGASetPal(initcolors, 8);
 		drawMessage(NULL);
 		drawPanel();
-	}
-
-	else if (CurInv == JOURNALNUM) {         /* LAB: Labyrinth specific */
+	} else if (CurInv == JOURNALNUM) {         /* LAB: Labyrinth specific */
 		drawStaticMessage(kTextUseJournal);
 		interfaceOff();
 		stopDiff();
@@ -550,17 +546,15 @@ static bool doUse(uint16 CurInv) {
 		doJournal();
 		drawPanel();
 		drawMessage(NULL);
-	}
-
-	else if (CurInv == LAMPNUM) {            /* LAB: Labyrinth specific */
+	} else if (CurInv == LAMPNUM) {            /* LAB: Labyrinth specific */
 		interfaceOff();
 
-		if (g_lab->_conditions->in(LAMPON)) {
+		if (_conditions->in(LAMPON)) {
 			drawStaticMessage(kTextTurnLampOff);
-			g_lab->_conditions->exclElement(LAMPON);
+			_conditions->exclElement(LAMPON);
 		} else {
 			drawStaticMessage(kTextTurnLampOn);
-			g_lab->_conditions->inclElement(LAMPON);
+			_conditions->inclElement(LAMPON);
 		}
 
 		DoBlack = false;
@@ -570,32 +564,22 @@ static bool doUse(uint16 CurInv) {
 
 		DoBlack = false;
 		Test = getInvName(CurInv);
-	}
-
-	else if (CurInv == BELTNUM) {                    /* LAB: Labyrinth specific */
-		if (!g_lab->_conditions->in(BELTGLOW))
-			g_lab->_conditions->inclElement(BELTGLOW);
+	} else if (CurInv == BELTNUM) {                    /* LAB: Labyrinth specific */
+		if (!_conditions->in(BELTGLOW))
+			_conditions->inclElement(BELTGLOW);
 
 		DoBlack = false;
 		Test = getInvName(CurInv);
-	}
-
-	else if (CurInv == WHISKEYNUM) {                 /* LAB: Labyrinth specific */
-		g_lab->_conditions->inclElement(USEDHELMET);
+	} else if (CurInv == WHISKEYNUM) {                 /* LAB: Labyrinth specific */
+		_conditions->inclElement(USEDHELMET);
 		drawStaticMessage(kTextUseWhiskey);
-	}
-
-	else if (CurInv == PITHHELMETNUM) {              /* LAB: Labyrinth specific */
-		g_lab->_conditions->inclElement(USEDHELMET);
+	} else if (CurInv == PITHHELMETNUM) {              /* LAB: Labyrinth specific */
+		_conditions->inclElement(USEDHELMET);
 		drawStaticMessage(kTextUsePith);
-	}
-
-	else if (CurInv == HELMETNUM) {                  /* LAB: Labyrinth specific */
-		g_lab->_conditions->inclElement(USEDHELMET);
+	} else if (CurInv == HELMETNUM) {                  /* LAB: Labyrinth specific */
+		_conditions->inclElement(USEDHELMET);
 		drawStaticMessage(kTextUseHelmet);
-	}
-
-	else
+	} else
 		return false;
 
 	return true;
@@ -651,7 +635,7 @@ static void decIncInv(uint16 *CurInv, bool dec) {
 /******************************************************************************/
 /* The main game loop                                                         */
 /******************************************************************************/
-static void mainGameLoop() {
+void LabEngine::mainGameLoop() {
 	IntuiMessage *Msg;
 	uint32 Class;
 
@@ -1474,8 +1458,8 @@ byte dropCrumbsOff[] = { 0x00 };
 Image DropCrumbsImage = { 24, 24, dropCrumbs };
 Image DropCrumbsOffImage = { 24, 24, dropCrumbsOff };
 
-void mayShowCrumbIndicator() {
-	if (g_lab->getPlatform() != Common::kPlatformWindows)
+void LabEngine::mayShowCrumbIndicator() {
+	if (getPlatform() != Common::kPlatformWindows)
 		return;
 
 	if (DroppingCrumbs && MainDisplay) {
@@ -1485,8 +1469,8 @@ void mayShowCrumbIndicator() {
 	}
 }
 
-void mayShowCrumbIndicatorOff() {
-	if (g_lab->getPlatform() != Common::kPlatformWindows)
+void LabEngine::mayShowCrumbIndicatorOff() {
+	if (getPlatform() != Common::kPlatformWindows)
 		return;
 
 	if (MainDisplay) {
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 6296313..b21c4f6 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -35,7 +35,6 @@
 #include "lab/labfun.h"
 #include "lab/parsefun.h"
 #include "lab/mouse.h"
-#include "lab/vga.h"
 #include "lab/text.h"
 #include "lab/resource.h"
 
@@ -242,14 +241,14 @@ uint32 flowText(void *font,      /* the TextAttr pointer */
 	uint16 x, y;
 
 	if (fillback) {
-		setAPen(backpen);
-		rectFill(x1, y1, x2, y2);
+		g_lab->setAPen(backpen);
+		g_lab->rectFill(x1, y1, x2, y2);
 	}
 
 	if (str == NULL)
 		return 0L;
 
-	setAPen(pencolor);
+	g_lab->setAPen(pencolor);
 
 	fontheight = textHeight(msgfont) + spacing;
 	numlines   = (y2 - y1 + 1) / fontheight;
@@ -289,10 +288,6 @@ uint32 flowText(void *font,      /* the TextAttr pointer */
 	return (str - temp);
 }
 
-
-extern byte *_currentDsplayBuffer;
-
-
 /******************************************************************************/
 /* Calls flowText, but flows it to memory.  Same restrictions as flowText.    */
 /******************************************************************************/
@@ -307,15 +302,15 @@ uint32 flowTextToMem(Image *DestIm, void *font,     /* the TextAttr pointer */
                      uint16 x1,               /* Cords */
                      uint16 y1, uint16 x2, uint16 y2, const char *str) { /* The text itself */
 	uint32 res, vgabyte = g_lab->_screenBytesPerPage;
-	byte *tmp = _currentDsplayBuffer;
+	byte *tmp = g_lab->_currentDsplayBuffer;
 
-	_currentDsplayBuffer = DestIm->ImageData;
+	g_lab->_currentDsplayBuffer = DestIm->ImageData;
 	g_lab->_screenBytesPerPage = (uint32) DestIm->Width * (int32) DestIm->Height;
 
 	res = flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str);
 
 	g_lab->_screenBytesPerPage = vgabyte;
-	_currentDsplayBuffer = tmp;
+	g_lab->_currentDsplayBuffer = tmp;
 
 	return res;
 }
@@ -328,14 +323,14 @@ uint32 flowTextToMem(Image *DestIm, void *font,     /* the TextAttr pointer */
 
 
 void createBox(uint16 y2) {
-	setAPen(7);                 /* Message box area */
-	rectFill(VGAScaleX(4), VGAScaleY(154), VGAScaleX(315), VGAScaleY(y2 - 2));
-
-	setAPen(0);                 /* Box around message area */
-	drawHLine(VGAScaleX(2), VGAScaleY(152), VGAScaleX(317));
-	drawVLine(VGAScaleX(317), VGAScaleY(152), VGAScaleY(y2));
-	drawHLine(VGAScaleX(2), VGAScaleY(y2), VGAScaleX(317));
-	drawVLine(VGAScaleX(2), VGAScaleY(152), VGAScaleY(y2));
+	g_lab->setAPen(7);                 /* Message box area */
+	g_lab->rectFill(VGAScaleX(4), VGAScaleY(154), VGAScaleX(315), VGAScaleY(y2 - 2));
+
+	g_lab->setAPen(0);                 /* Box around message area */
+	g_lab->drawHLine(VGAScaleX(2), VGAScaleY(152), VGAScaleX(317));
+	g_lab->drawVLine(VGAScaleX(317), VGAScaleY(152), VGAScaleY(y2));
+	g_lab->drawHLine(VGAScaleX(2), VGAScaleY(y2), VGAScaleX(317));
+	g_lab->drawVLine(VGAScaleX(2), VGAScaleY(152), VGAScaleY(y2));
 }
 
 
@@ -355,8 +350,8 @@ int32 longDrawMessage(const char *str) {
 
 	if (!LongWinInFront) {
 		LongWinInFront = true;
-		setAPen(3);                 /* Clear Area */
-		rectFill(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319), VGAScaleY(199));
+		g_lab->setAPen(3);                 /* Clear Area */
+		g_lab->rectFill(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319), VGAScaleY(199));
 	}
 
 	createBox(198);
@@ -387,7 +382,7 @@ void drawMessage(const char *str) {
 		} else {
 			if (LongWinInFront) {
 				LongWinInFront = false;
-				drawPanel();
+				g_lab->drawPanel();
 			}
 
 			mouseHide();
@@ -434,10 +429,10 @@ static void doScrollBlack() {
 	Im.Height = height;
 	Im.ImageData = mem;
 	g_music->updateMusic();
-	readScreenImage(&Im, 0, 0);
+	g_lab->readScreenImage(&Im, 0, 0);
 	g_music->updateMusic();
 
-	BaseAddr = (uint32 *) getVGABaseAddr();
+	BaseAddr = (uint32 *)g_lab->getVGABaseAddr();
 
 	by      = VGAScaleX(4);
 	nheight = height;
@@ -446,9 +441,9 @@ static void doScrollBlack() {
 		g_music->updateMusic();
 
 		if (!IsHiRes)
-			waitTOF();
+			g_lab->waitTOF();
 
-		BaseAddr = (uint32 *) getVGABaseAddr();
+		BaseAddr = (uint32 *)g_lab->getVGABaseAddr();
 
 		if (by > nheight)
 			by = nheight;
@@ -470,10 +465,10 @@ static void doScrollBlack() {
 			tempmem += copysize;
 		}
 
-		setAPen(0);
-		rectFill(0, nheight, width - 1, nheight + by - 1);
+		g_lab->setAPen(0);
+		g_lab->rectFill(0, nheight, width - 1, nheight + by - 1);
 
-		WSDL_UpdateScreen();
+		g_lab->WSDL_UpdateScreen();
 
 		if (!IsHiRes) {
 			if (nheight <= (height / 8))
@@ -503,7 +498,7 @@ static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startli
 	uint16 CurPage;
 	uint32 *BaseAddr;
 
-	BaseAddr = (uint32 *)getVGABaseAddr();
+	BaseAddr = (uint32 *)g_lab->getVGABaseAddr();
 
 	size = (int32)(height - nheight) * (int32) width;
 	mem += startline * width;
@@ -539,12 +534,12 @@ static void doScrollWipe(char *filename) {
 
 	while (g_music->isSoundEffectActive()) {
 		g_music->updateMusic();
-		waitTOF();
+		g_lab->waitTOF();
 	}
 
 	IsBM = true;
 	readPict(filename, true);
-	VGASetPal(diffcmap, 256);
+	g_lab->VGASetPal(diffcmap, 256);
 	IsBM = false;
 	mem = RawDiffBM.Planes[0];
 
@@ -566,7 +561,7 @@ static void doScrollWipe(char *filename) {
 
 		copyPage(width, height, nheight, startline, mem);
 
-		WSDL_UpdateScreen();
+		g_lab->WSDL_UpdateScreen();
 
 		if (!nheight)
 			startline += by;
@@ -618,8 +613,8 @@ static void doScrollBounce() {
 		startline -= newby[counter];
 		copyPage(width, height, 0, startline, mem);
 
-		WSDL_UpdateScreen();
-		waitTOF();
+		g_lab->WSDL_UpdateScreen();
+		g_lab->waitTOF();
 	}
 
 	for (int counter = 8; counter > 0; counter--) {
@@ -627,8 +622,8 @@ static void doScrollBounce() {
 		startline += newby1[counter - 1];
 		copyPage(width, height, 0, startline, mem);
 
-		WSDL_UpdateScreen();
-		waitTOF();
+		g_lab->WSDL_UpdateScreen();
+		g_lab->waitTOF();
 
 	}
 
@@ -658,17 +653,17 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
 		while (CurY < LastY) {
 			if (linesdone >= lineslast) {
 				g_music->updateMusic();
-				waitTOF();
+				g_lab->waitTOF();
 				linesdone = 0;
 			}
 
-			ghoastRect(0, 0, CurY, g_lab->_screenWidth - 1, CurY + 1);
+			g_lab->ghoastRect(0, 0, CurY, g_lab->_screenWidth - 1, CurY + 1);
 			CurY += 4;
 			linesdone++;
 		}
 	}
 
-	setAPen(0);
+	g_lab->setAPen(0);
 
 	for (counter = 0; counter < 2; counter++) {
 		CurY = counter * 2;
@@ -676,11 +671,11 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
 		while (CurY <= LastY) {
 			if (linesdone >= lineslast) {
 				g_music->updateMusic();
-				waitTOF();
+				g_lab->waitTOF();
 				linesdone = 0;
 			}
 
-			rectFill(0, CurY, g_lab->_screenWidth - 1, CurY + 1);
+			g_lab->rectFill(0, CurY, g_lab->_screenWidth - 1, CurY + 1);
 			CurY += 4;
 			linesdone++;
 		}
@@ -694,7 +689,7 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
 		CurFileName = getPictName(CPtr);
 
 	byte *BitMapMem = readPictToMem(CurFileName, g_lab->_screenWidth, LastY + 5);
-	VGASetPal(diffcmap, 256);
+	g_lab->VGASetPal(diffcmap, 256);
 
 	if (BitMapMem) {
 		ImSource.Width = g_lab->_screenWidth;
@@ -703,7 +698,7 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
 
 		ImDest.Width = g_lab->_screenWidth;
 		ImDest.Height = g_lab->_screenHeight;
-		ImDest.ImageData = getVGABaseAddr();
+		ImDest.ImageData = g_lab->getVGABaseAddr();
 
 		for (counter = 0; counter < 2; counter++) {
 			CurY = counter * 2;
@@ -711,14 +706,14 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
 			while (CurY < LastY) {
 				if (linesdone >= lineslast) {
 					g_music->updateMusic();
-					waitTOF();
+					g_lab->waitTOF();
 					linesdone = 0;
 				}
 
-				ImDest.ImageData = getVGABaseAddr();
+				ImDest.ImageData = g_lab->getVGABaseAddr();
 
-				bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, g_lab->_screenWidth, 2);
-				ghoastRect(0, 0, CurY, g_lab->_screenWidth - 1, CurY + 1);
+				g_lab->bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, g_lab->_screenWidth, 2);
+				g_lab->ghoastRect(0, 0, CurY, g_lab->_screenWidth - 1, CurY + 1);
 				CurY += 4;
 				linesdone++;
 			}
@@ -730,16 +725,16 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
 			while (CurY <= LastY) {
 				if (linesdone >= lineslast) {
 					g_music->updateMusic();
-					waitTOF();
+					g_lab->waitTOF();
 					linesdone = 0;
 				}
 
-				ImDest.ImageData = getVGABaseAddr();
+				ImDest.ImageData = g_lab->getVGABaseAddr();
 
 				if (CurY == LastY)
-					bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, g_lab->_screenWidth, 1);
+					g_lab->bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, g_lab->_screenWidth, 1);
 				else
-					bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, g_lab->_screenWidth, 2);
+					g_lab->bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, g_lab->_screenWidth, 2);
 
 				CurY += 4;
 				linesdone++;
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 1cd017d..54a7e13 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -28,11 +28,11 @@
  *
  */
 
+#include "lab/lab.h"
 #include "lab/labfun.h"
 #include "lab/stddefines.h"
 #include "lab/interface.h"
 #include "lab/mouse.h"
-#include "lab/vga.h"
 #include "common/util.h"
 
 namespace Lab {
@@ -82,7 +82,7 @@ void freeButtonList(Gadget *gptrlist) {
 /*****************************************************************************/
 void drawGadgetList(Gadget *gadlist) {
 	while (gadlist) {
-		drawImage(gadlist->Im, gadlist->x, gadlist->y);
+		g_lab->drawImage(gadlist->Im, gadlist->x, gadlist->y);
 
 		if (GADGETOFF & gadlist->GadgetFlags)
 			ghoastGadget(gadlist, 1);
@@ -96,7 +96,7 @@ void drawGadgetList(Gadget *gadlist) {
 /* Ghoasts a gadget, and makes it unavailable for using.                     */
 /*****************************************************************************/
 void ghoastGadget(Gadget *curgad, uint16 pencolor) {
-	ghoastRect(pencolor, curgad->x, curgad->y, curgad->x + curgad->Im->Width - 1, curgad->y + curgad->Im->Height - 1);
+	g_lab->ghoastRect(pencolor, curgad->x, curgad->y, curgad->x + curgad->Im->Width - 1, curgad->y + curgad->Im->Height - 1);
 	curgad->GadgetFlags |= GADGETOFF;
 }
 
@@ -106,7 +106,7 @@ void ghoastGadget(Gadget *curgad, uint16 pencolor) {
 /* Unghoasts a gadget, and makes it available again.                         */
 /*****************************************************************************/
 void unGhoastGadget(Gadget *curgad) {
-	drawImage(curgad->Im, curgad->x, curgad->y);
+	g_lab->drawImage(curgad->Im, curgad->x, curgad->y);
 	curgad->GadgetFlags &= !(GADGETOFF);
 }
 
@@ -133,11 +133,11 @@ static Gadget *checkNumGadgetHit(Gadget *gadlist, uint16 key) {
 		        (gadlist->KeyEquiv != 0 && makeGadgetKeyEquiv(key) == gadlist->KeyEquiv))
 		        && !(GADGETOFF & gadlist->GadgetFlags)) {
 			mouseHide();
-			drawImage(gadlist->ImAlt, gadlist->x, gadlist->y);
+			g_lab->drawImage(gadlist->ImAlt, gadlist->x, gadlist->y);
 			mouseShow();
 			g_system->delayMillis(80);
 			mouseHide();
-			drawImage(gadlist->Im, gadlist->x, gadlist->y);
+			g_lab->drawImage(gadlist->Im, gadlist->x, gadlist->y);
 			mouseShow();
 
 			return gadlist;
@@ -155,8 +155,8 @@ static Gadget *checkNumGadgetHit(Gadget *gadlist, uint16 key) {
 /* Checks whether or not a key has been pressed.                             */
 /*****************************************************************************/
 static bool keyPress(uint16 *KeyCode) {
-	if (WSDL_HasNextChar()) {
-        *KeyCode = WSDL_GetNextChar();
+	if (g_lab->WSDL_HasNextChar()) {
+        *KeyCode = g_lab->WSDL_GetNextChar();
 		return true;
 	}
 
diff --git a/engines/lab/interface.h b/engines/lab/interface.h
index 84df28c..524c4ff 100644
--- a/engines/lab/interface.h
+++ b/engines/lab/interface.h
@@ -28,7 +28,6 @@
  *
  */
 
-#include "lab/vga.h"
 #include "common/keyboard.h"
 
 #ifndef LAB_INTEFACE_H
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 85c64c4..feb4905 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -115,8 +115,8 @@ void Intro::doPictText(const char *filename, bool isscreen) {
 				fade(false, 0);
 
 			if (isscreen) {
-				setAPen(7L);
-				rectFill(VGAScaleX(10), VGAScaleY(10), VGAScaleX(310), VGAScaleY(190));
+				g_lab->setAPen(7L);
+				g_lab->rectFill(VGAScaleX(10), VGAScaleY(10), VGAScaleX(310), VGAScaleY(190));
 
 				Drawn = flowText(_msgfont, (!IsHiRes) * -1, 5, 7, false, false, true, true, VGAScaleX(14), VGAScaleY(11), VGAScaleX(306), VGAScaleY(189), (char *)curplace);
 				fade(true, 0);
@@ -161,7 +161,7 @@ void Intro::doPictText(const char *filename, bool isscreen) {
 				}
 			}
 
-			waitTOF();
+			g_lab->waitTOF();
 		} else {
 			cls       = msg->msgClass;
 			qualifier = msg->qualifier;
@@ -226,9 +226,9 @@ void Intro::musicDelay() {
 
 	for (counter = 0; counter < 20; counter++) {
 		g_music->updateMusic();
-		waitTOF();
-		waitTOF();
-		waitTOF();
+		g_lab->waitTOF();
+		g_lab->waitTOF();
+		g_lab->waitTOF();
 	}
 }
 
@@ -318,7 +318,7 @@ void Intro::introSequence() {
 		palette[15] = temp;
 
 		setAmigaPal(palette, 16);
-		waitTOF();
+		g_lab->waitTOF();
 	}
 
 	fade(false, 0);
@@ -404,10 +404,10 @@ void Intro::introSequence() {
 				diffcmap[counter1] = 255 - diffcmap[counter1];
 
 			g_music->updateMusic();
-			waitTOF();
-			VGASetPal(diffcmap, 256);
-			waitTOF();
-			waitTOF();
+			g_lab->waitTOF();
+			g_lab->VGASetPal(diffcmap, 256);
+			g_lab->	waitTOF();
+			g_lab->waitTOF();
 		}
 
 	doPictText("i.12", false);
@@ -464,8 +464,8 @@ void Intro::introSequence() {
 	nReadPict("SubX", true);
 
 	if (_quitIntro) {
-		setAPen(0);
-		rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
+		g_lab->setAPen(0);
+		g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
 		DoBlack = true;
 	}
 }
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index c6f8006..fcd826b 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -59,6 +59,20 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_screenHeight = 200;
 	_screenBytesPerPage = 65536;
 
+    _curapen = 0;
+
+    _currentDsplayBuffer = 0;
+    _displayBuffer = 0;
+
+    _lastWaitTOFTicks = 0;
+
+    _mouseX = 0;
+    _mouseY = 0;
+
+     _nextKeyIn = 0;
+    _nextKeyOut = 0;
+    _mouseAtEdge = false;
+
 	//const Common::FSNode gameDataDir(ConfMan.get("path"));
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game/pict");
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index e9d27ae..36e2a43 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -45,6 +45,12 @@ enum GameFeatures {
 	GF_WINDOWS_TRIAL = 1 << 1
 };
 
+struct Image {
+	uint16 Width;
+	uint16 Height;
+	byte *ImageData;
+};
+
 #define ONESECOND 1000
 
 class LabEngine : public Engine {
@@ -83,6 +89,74 @@ private:
 
 	// timing.cpp
 	void microDelay(uint32 secs, uint32 micros);
+
+	// vga.cpp
+	byte _curvgapal[256 * 3];
+	byte _curapen;
+
+public:
+	byte *_currentDsplayBuffer;
+
+	uint32 _mouseX;
+	uint32 _mouseY;
+
+private:
+	byte *_displayBuffer;
+
+	int _lastWaitTOFTicks;
+
+	uint16 _nextKeyIn;
+	uint16 _keyBuf[64];
+	uint16 _nextKeyOut;
+	bool _mouseAtEdge;
+public:
+	byte *_tempScrollData;
+
+private:
+	bool createScreen(bool HiRes);
+
+public:
+	void waitTOF();
+	void setAPen(uint16 pennum);
+	void writeColorRegs(byte *buf, uint16 first, uint16 numreg);
+	byte *getVGABaseAddr();
+	void readScreenImage(Image *Im, uint16 x, uint16 y);
+	void WSDL_UpdateScreen();
+	void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest, uint16 xd, uint16 yd, uint16 width, uint16 height);
+	void VGASetPal(void *cmap, uint16 numcolors);
+	void drawHLine(uint16 x, uint16 y1, uint16 y2);
+	void drawVLine(uint16 x1, uint16 y, uint16 x2);
+	void drawImage(Image *Im, uint16 x, uint16 y);
+	bool WSDL_HasNextChar();
+	uint16 WSDL_GetNextChar();
+	void WSDL_ProcessInput(bool can_delay);
+	void writeColorReg(byte *buf, uint16 regnum);
+	void writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg);
+
+	void drawPanel();
+
+private:
+	void quickWaitTOF();
+
+	/*---------- Drawing Routines ----------*/
+
+	void drawMaskImage(Image *Im, uint16 x, uint16 y);
+	void WSDL_GetMousePos(int *x, int *y);
+	void changeVolume(int delta);
+	void WSDL_SetColors(byte *buf, uint16 first, uint16 numreg, uint16 slow);
+
+	// engine.cpp
+	bool setUpScreens();
+	void perFlipGadget(uint16 gadID);
+	bool doCloseUp(CloseDataPtr cptr);
+	void mainGameLoop();
+	bool doUse(uint16 curInv);
+	void mayShowCrumbIndicator();
+	void mayShowCrumbIndicatorOff();
 };
 
 extern LabEngine *g_lab;
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 5fac2e1..1d2b5c6 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -122,8 +122,6 @@ void gadgetsOnOff(void *gptr, void *win, int32 num, bool on);
 /*----------------------*/
 
 void eatMessages();
-bool setUpScreens();
-void drawPanel();
 bool quitPlaying();
 
 /*---------------------------*/
diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index 50ba48d..ed45bfa 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -33,7 +33,6 @@
 #include "lab/stddefines.h"
 #include "lab/labfun.h"
 #include "lab/mouse.h"
-#include "lab/vga.h"
 #include "lab/lab.h"
 
 namespace Lab {
@@ -72,7 +71,7 @@ Music::Music() {
 /* it from the Audio device.                                                 */
 /*****************************************************************************/
 void Music::updateMusic() {
-	WSDL_ProcessInput(0);
+	g_lab->WSDL_ProcessInput(0);
 
 	updateMouse();
 
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 4ad9ba2..fdec095 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -32,7 +32,6 @@
 #include "lab/stddefines.h"
 #include "lab/labfun.h"
 #include "lab/diff.h"
-#include "lab/vga.h"
 #include "lab/text.h"
 #include "lab/mouse.h"
 #include "lab/parsefun.h"
@@ -70,7 +69,7 @@ void setAmigaPal(uint16 *pal, uint16 numcolors) {
 		vgapal[vgacount++] = (byte)(((pal[counter] & 0x00f)) << 2);
 	}
 
-	writeColorRegsSmooth(vgapal, 0, 16);
+	g_lab->writeColorRegsSmooth(vgapal, 0, 16);
 }
 
 void decrypt(byte *text) {
@@ -310,7 +309,7 @@ void fade(bool fadein, uint16 res) {
 		}
 
 		setAmigaPal(newpal, 16);
-		waitTOF();
+		g_lab->waitTOF();
 		g_music->updateMusic();
 	}
 }
@@ -371,27 +370,27 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
 	case UPARROWROOM:
 	case DOWNARROWROOM:
 		if (Maps[CurRoom].SpecialID == NORMAL)
-			drawImage(Room, x, y);
+			g_lab->drawImage(Room, x, y);
 		else if (Maps[CurRoom].SpecialID == DOWNARROWROOM)
-			drawImage(DownArrowRoom, x, y);
+			g_lab->drawImage(DownArrowRoom, x, y);
 		else
-			drawImage(UpArrowRoom, x, y);
+			g_lab->drawImage(UpArrowRoom, x, y);
 
 		offset = (Room->Width - Path->Width) / 2;
 
 		if ((NORTHDOOR & flags) && (y >= Path->Height))
-			drawImage(Path, x + offset, y - Path->Height);
+			g_lab->drawImage(Path, x + offset, y - Path->Height);
 
 		if (SOUTHDOOR & flags)
-			drawImage(Path, x + offset, y + Room->Height);
+			g_lab->drawImage(Path, x + offset, y + Room->Height);
 
 		offset = (Room->Height - Path->Height) / 2;
 
 		if (EASTDOOR & flags)
-			drawImage(Path, x + Room->Width, y + offset);
+			g_lab->drawImage(Path, x + Room->Width, y + offset);
 
 		if (WESTDOOR & flags)
-			drawImage(Path, x - Path->Width, y + offset);
+			g_lab->drawImage(Path, x - Path->Width, y + offset);
 
 		xx = x + (Room->Width - XMark->Width) / 2;
 		xy = y + (Room->Height - XMark->Height) / 2;
@@ -399,7 +398,7 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
 		break;
 
 	case BRIDGEROOM:
-		drawImage(Bridge, x, y);
+		g_lab->drawImage(Bridge, x, y);
 
 		xx = x + (Bridge->Width - XMark->Width) / 2;
 		xy = y + (Bridge->Height - XMark->Height) / 2;
@@ -407,37 +406,37 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
 		break;
 
 	case VCORRIDOR:
-		drawImage(VRoom, x, y);
+		g_lab->drawImage(VRoom, x, y);
 
 		offset = (VRoom->Width - Path->Width) / 2;
 
 		if (NORTHDOOR & flags)
-			drawImage(Path, x + offset, y - Path->Height);
+			g_lab->drawImage(Path, x + offset, y - Path->Height);
 
 		if (SOUTHDOOR & flags)
-			drawImage(Path, x + offset, y + VRoom->Height);
+			g_lab->drawImage(Path, x + offset, y + VRoom->Height);
 
 		offset = (Room->Height - Path->Height) / 2;
 
 		if (EASTDOOR & flags)
-			drawImage(Path, x + VRoom->Width, y + offset);
+			g_lab->drawImage(Path, x + VRoom->Width, y + offset);
 
 		if (WESTDOOR & flags)
-			drawImage(Path, x - Path->Width, y + offset);
+			g_lab->drawImage(Path, x - Path->Width, y + offset);
 
 		if (EASTBDOOR & flags)
-			drawImage(Path, x + VRoom->Width, y - offset - Path->Height + VRoom->Height);
+			g_lab->drawImage(Path, x + VRoom->Width, y - offset - Path->Height + VRoom->Height);
 
 		if (WESTBDOOR & flags)
-			drawImage(Path, x - Path->Width, y - offset - Path->Height + VRoom->Height);
+			g_lab->drawImage(Path, x - Path->Width, y - offset - Path->Height + VRoom->Height);
 
 		offset = (VRoom->Height - Path->Height) / 2;
 
 		if (EASTMDOOR & flags)
-			drawImage(Path, x + VRoom->Width, y - offset - Path->Height + VRoom->Height);
+			g_lab->drawImage(Path, x + VRoom->Width, y - offset - Path->Height + VRoom->Height);
 
 		if (WESTMDOOR & flags)
-			drawImage(Path, x - Path->Width, y - offset - Path->Height + VRoom->Height);
+			g_lab->drawImage(Path, x - Path->Width, y - offset - Path->Height + VRoom->Height);
 
 		xx = x + (VRoom->Width - XMark->Width) / 2;
 		xy = y + (VRoom->Height - XMark->Height) / 2;
@@ -445,37 +444,37 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
 		break;
 
 	case HCORRIDOR:
-		drawImage(HRoom, x, y);
+		g_lab->drawImage(HRoom, x, y);
 
 		offset = (Room->Width - Path->Width) / 2;
 
 		if (NORTHDOOR & flags)
-			drawImage(Path, x + offset, y - Path->Height);
+			g_lab->drawImage(Path, x + offset, y - Path->Height);
 
 		if (SOUTHDOOR & flags)
-			drawImage(Path, x + offset, y + Room->Height);
+			g_lab->drawImage(Path, x + offset, y + Room->Height);
 
 		if (NORTHRDOOR & flags)
-			drawImage(Path, x - offset - Path->Width + HRoom->Width, y - Path->Height);
+			g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y - Path->Height);
 
 		if (SOUTHRDOOR & flags)
-			drawImage(Path, x - offset - Path->Width + HRoom->Width, y + Room->Height);
+			g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y + Room->Height);
 
 		offset = (HRoom->Width - Path->Width) / 2;
 
 		if (NORTHMDOOR & flags)
-			drawImage(Path, x - offset - Path->Width + HRoom->Width, y - Path->Height);
+			g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y - Path->Height);
 
 		if (SOUTHMDOOR & flags)
-			drawImage(Path, x - offset - Path->Width + HRoom->Width, y + Room->Height);
+			g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y + Room->Height);
 
 		offset = (Room->Height - Path->Height) / 2;
 
 		if (EASTDOOR & flags)
-			drawImage(Path, x + HRoom->Width, y + offset);
+			g_lab->drawImage(Path, x + HRoom->Width, y + offset);
 
 		if (WESTDOOR & flags)
-			drawImage(Path, x - Path->Width, y + offset);
+			g_lab->drawImage(Path, x - Path->Width, y + offset);
 
 		xx = x + (HRoom->Width - XMark->Width) / 2;
 		xy = y + (HRoom->Height - XMark->Height) / 2;
@@ -487,7 +486,7 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
 	}
 
 	if (drawx)
-		drawImage(XMark, xx, xy);
+		g_lab->drawImage(XMark, xx, xy);
 }
 
 
@@ -582,10 +581,10 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b
 	if (fadeout)
 		fade(false, 0);
 
-	setAPen(0);
-	rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
+	g_lab->setAPen(0);
+	g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
 
-	drawImage(Map, 0, 0);
+	g_lab->drawImage(Map, 0, 0);
 	drawGadgetList(MapGadgetList);
 
 	for (drawroom = 1; drawroom <= MaxRooms; drawroom++) {
@@ -621,16 +620,16 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b
 	// Labyrinth specific code
 	if (Floor == LOWERFLOOR) {
 		if (onFloor(SURMAZEFLOOR))
-			drawImage(Maze, mapScaleX(538), mapScaleY(277));
+			g_lab->drawImage(Maze, mapScaleX(538), mapScaleY(277));
 	} else if (Floor == MIDDLEFLOOR) {
 		if (onFloor(CARNIVAL))
-			drawImage(Maze, mapScaleX(358), mapScaleY(72));
+			g_lab->drawImage(Maze, mapScaleX(358), mapScaleY(72));
 
 		if (onFloor(MEDMAZEFLOOR))
-			drawImage(Maze, mapScaleX(557), mapScaleY(325));
+			g_lab->drawImage(Maze, mapScaleX(557), mapScaleY(325));
 	} else if (Floor == UPPERFLOOR) {
 		if (onFloor(HEDGEMAZEFLOOR))
-			drawImage(HugeMaze, mapScaleX(524), mapScaleY(97));
+			g_lab->drawImage(HugeMaze, mapScaleX(524), mapScaleY(97));
 	} else if (Floor == SURMAZEFLOOR) {
 		sptr = (char *)g_resource->getStaticText(kTextSurmazeMessage).c_str();
 		flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr);
@@ -708,14 +707,14 @@ void processMap(uint16 CurRoom) {
 				newcolor[2] = newcolor[1];
 			}
 
-			waitTOF();
-			writeColorReg(newcolor, 1);
+			g_lab->waitTOF();
+			g_lab->writeColorReg(newcolor, 1);
 			updateMouse();
-			waitTOF();
+			g_lab->waitTOF();
 			updateMouse();
-			waitTOF();
+			g_lab->waitTOF();
 			updateMouse();
-			waitTOF();
+			g_lab->waitTOF();
 			updateMouse();
 
 			place++;
@@ -822,8 +821,8 @@ void processMap(uint16 CurRoom) {
 
 						if ((sptr = Rooms[CurMsg].RoomMsg)) {
 							mouseHide();
-							setAPen(3);
-							rectFill(VGAScaleX(13), VGAScaleY(148), VGAScaleX(135), VGAScaleY(186));
+							g_lab->setAPen(3);
+							g_lab->rectFill(VGAScaleX(13), VGAScaleY(148), VGAScaleX(135), VGAScaleY(186));
 							flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr);
 
 							if (Maps[OldMsg].PageNumber == CurFloor)
@@ -834,8 +833,8 @@ void processMap(uint16 CurRoom) {
 							y1 = (y1 + y2) / 2;
 
 							if ((CurMsg != CurRoom) && (Maps[CurMsg].PageNumber == CurFloor)) {
-								setAPen(1);
-								rectFill(x1 - 1, y1, x1, y1);
+								g_lab->setAPen(1);
+								g_lab->rectFill(x1 - 1, y1, x1, y1);
 							}
 
 							mouseShow();
@@ -844,7 +843,7 @@ void processMap(uint16 CurRoom) {
 				}
 			}
 
-			WSDL_UpdateScreen();
+			g_lab->WSDL_UpdateScreen();
 		}
 	}
 }
@@ -872,18 +871,18 @@ void doMap(uint16 CurRoom) {
 	drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true);
 	mouseShow();
 	attachGadgetList(MapGadgetList);
-	WSDL_UpdateScreen();
+	g_lab->WSDL_UpdateScreen();
 	processMap(CurRoom);
 	attachGadgetList(NULL);
 	fade(false, 0);
 	blackAllScreen();
 	mouseHide();
-	setAPen(0);
-	rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
+	g_lab->setAPen(0);
+	g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
 	freeMapData();
 	blackAllScreen();
 	mouseShow();
-	WSDL_UpdateScreen();
+	g_lab->WSDL_UpdateScreen();
 }
 
 } // End of namespace Lab
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index 292ac3c..ef483f7 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -28,8 +28,8 @@
  *
  */
 
+#include "lab/lab.h"
 #include "lab/mouse.h"
-#include "lab/vga.h"
 #include "lab/stddefines.h"
 #include "lab/interface.h"
 
@@ -81,14 +81,14 @@ static Gadget *checkGadgetHit(Gadget *gadlist, uint16 x, uint16 y) {
 				hitgad = gadlist;
 			} else {
 				mouseHide();
-				drawImage(gadlist->ImAlt, gadlist->x, gadlist->y);
+				g_lab->drawImage(gadlist->ImAlt, gadlist->x, gadlist->y);
 				mouseShow();
 
 				for (counter = 0; counter < 3; counter++)
-					waitTOF();
+					g_lab->waitTOF();
 
 				mouseHide();
-				drawImage(gadlist->Im, gadlist->x, gadlist->y);
+				g_lab->drawImage(gadlist->Im, gadlist->x, gadlist->y);
 				mouseShow();
 			}
 
@@ -141,21 +141,21 @@ void updateMouse() {
 
 	if (hitgad) {
 		mouseHide();
-		drawImage(hitgad->ImAlt, hitgad->x, hitgad->y);
+		g_lab->drawImage(hitgad->ImAlt, hitgad->x, hitgad->y);
 		mouseShow();
 
 		for (counter = 0; counter < 3; counter++)
-			waitTOF();
+			g_lab->waitTOF();
 
 		mouseHide();
-		drawImage(hitgad->Im, hitgad->x, hitgad->y);
+		g_lab->drawImage(hitgad->Im, hitgad->x, hitgad->y);
 		mouseShow();
 		doUpdateDisplay = true;
 		hitgad = NULL;
 	}
 
 	if (doUpdateDisplay)
-		WSDL_UpdateScreen();
+		g_lab->WSDL_UpdateScreen();
 }
 
 
@@ -178,7 +178,7 @@ void mouseShow() {
 		NumHidden--;
 
 	if ((NumHidden == 0) && MouseHidden) {
-		WSDL_ProcessInput(0);
+		g_lab->WSDL_ProcessInput(0);
 		MouseHidden = false;
 	}
 
@@ -198,17 +198,13 @@ void mouseHide() {
 	}
 }
 
-
-extern uint32 _mouseX;
-extern uint32 _mouseY;
-
 /*****************************************************************************/
 /* Gets the current mouse co-ordinates.  NOTE: On IBM version, will scale    */
 /* from virtual to screen co-ordinates automatically.                        */
 /*****************************************************************************/
 void mouseXY(uint16 *x, uint16 *y) {
-	*x = (uint16)_mouseX;
-	*y = (uint16)_mouseY;
+	*x = (uint16)g_lab->_mouseX;
+	*y = (uint16)g_lab->_mouseY;
 
 	if (!IsHiRes)
 		(*x) /= 2;
@@ -225,7 +221,7 @@ void mouseMove(uint16 x, uint16 y) {
 	g_system->warpMouse(x, y);
 
 	if (!MouseHidden)
-		WSDL_ProcessInput(0);
+		g_lab->WSDL_ProcessInput(0);
 }
 
 
@@ -237,15 +233,15 @@ void mouseMove(uint16 x, uint16 y) {
 bool mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
 	if (leftbutton) {
 		if (LeftClick) {
-			*x = (!IsHiRes) ? (uint16)_mouseX / 2 : (uint16)_mouseX;
-			*y = (uint16)_mouseY;
+			*x = (!IsHiRes) ? (uint16)g_lab->_mouseX / 2 : (uint16)g_lab->_mouseX;
+			*y = (uint16)g_lab->_mouseY;
 			LeftClick = false;
 			return true;
 		}
 	} else {
 		if (RightClick) {
-			*x = (!IsHiRes) ? (uint16)_mouseX / 2 : (uint16)_mouseX;
-			*y = (uint16)_mouseY;
+			*x = (!IsHiRes) ? (uint16)g_lab->_mouseX / 2 : (uint16)g_lab->_mouseX;
+			*y = (uint16)g_lab->_mouseY;
 			RightClick = false;
 			return true;
 		}
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index d48a4ca..e6e9d91 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -37,7 +37,6 @@
 #include "lab/parsefun.h"
 #include "lab/resource.h"
 #include "lab/diff.h"
-#include "lab/vga.h"
 #include "lab/interface.h"
 
 namespace Lab {
@@ -484,7 +483,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 		case WAITSECS:
 			g_lab->addCurTime(APtr->Param1, 0, &StartSecs, &StartMicros);
 
-			WSDL_UpdateScreen();
+			g_lab->WSDL_UpdateScreen();
 
 			while (1) {
 				g_music->updateMusic();
@@ -524,7 +523,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 			while (g_music->isSoundEffectActive()) {
 				g_music->updateMusic();
 				diffNextFrame();
-				waitTOF();
+				g_lab->waitTOF();
 			}
 
 			break;
@@ -567,23 +566,23 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 				for (counter = (8 * 3); counter < (255 * 3); counter++)
 					diffcmap[counter] = 255 - diffcmap[counter];
 
-				waitTOF();
-				VGASetPal(diffcmap, 256);
-				waitTOF();
-				waitTOF();
+				g_lab->waitTOF();
+				g_lab->VGASetPal(diffcmap, 256);
+				g_lab->waitTOF();
+				g_lab->waitTOF();
 			} else if (APtr->Param1 == 4) { /* white the palette */
 				whiteScreen();
-				waitTOF();
-				waitTOF();
+				g_lab->waitTOF();
+				g_lab->waitTOF();
 			} else if (APtr->Param1 == 6) { /* Restore the palette */
-				waitTOF();
-				VGASetPal(diffcmap, 256);
-				waitTOF();
-				waitTOF();
+				g_lab->waitTOF();
+				g_lab->VGASetPal(diffcmap, 256);
+				g_lab->waitTOF();
+				g_lab->waitTOF();
 			} else if (APtr->Param1 == 7) { /* Quick pause */
-				waitTOF();
-				waitTOF();
-				waitTOF();
+				g_lab->waitTOF();
+				g_lab->waitTOF();
+				g_lab->waitTOF();
 			}
 
 			break;
@@ -599,7 +598,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 		while (g_music->isSoundEffectActive()) {
 			g_music->updateMusic();
 			diffNextFrame();
-			waitTOF();
+			g_lab->waitTOF();
 		}
 	}
 
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index 421c2ce..852b9c6 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -31,7 +31,6 @@
 #include "lab/lab.h"
 #include "lab/diff.h"
 #include "lab/labfun.h"
-#include "lab/vga.h"
 #include "lab/mouse.h"
 
 namespace Lab {
@@ -91,7 +90,7 @@ void unDiff(byte *NewBuf, byte *OldBuf, byte *DiffData, uint16 bytesperrow, bool
 /*****************************************************************************/
 void blackScreen() {
 	memset(blackbuffer, 0, 248 * 3);
-	writeColorRegs(blackbuffer, 8, 248);
+	g_lab->writeColorRegs(blackbuffer, 8, 248);
 
 	g_system->delayMillis(32);
 }
@@ -101,7 +100,7 @@ void blackScreen() {
 /*****************************************************************************/
 void whiteScreen() {
 	memset(blackbuffer, 255, 248 * 3);
-	writeColorRegs(blackbuffer, 8, 248);
+	g_lab->writeColorRegs(blackbuffer, 8, 248);
 }
 
 /*****************************************************************************/
@@ -109,7 +108,7 @@ void whiteScreen() {
 /*****************************************************************************/
 void blackAllScreen() {
 	memset(blackbuffer, 0, 256 * 3);
-	writeColorRegs(blackbuffer, 0, 256);
+	g_lab->writeColorRegs(blackbuffer, 0, 256);
 
 	g_system->delayMillis(32);
 }
@@ -120,7 +119,7 @@ void diffNextFrame() {
 		return;
 
 	if (DispBitMap->Flags & BITMAPF_VIDEO) {
-		DispBitMap->Planes[0] = getVGABaseAddr();
+		DispBitMap->Planes[0] = g_lab->getVGABaseAddr();
 		DispBitMap->Planes[1] = DispBitMap->Planes[0] + 0x10000;
 		DispBitMap->Planes[2] = DispBitMap->Planes[1] + 0x10000;
 		DispBitMap->Planes[3] = DispBitMap->Planes[2] + 0x10000;
@@ -140,7 +139,7 @@ void diffNextFrame() {
 				}
 
 				if (IsPal && !nopalchange) {
-					VGASetPal(diffcmap, 256);
+					g_lab->VGASetPal(diffcmap, 256);
 					IsPal = false;
 				}
 
@@ -148,7 +147,7 @@ void diffNextFrame() {
 			}
 
 			if (IsPal && !nopalchange && !IsBM && !donepal) {
-				VGASetPal(diffcmap, 256);
+				g_lab->VGASetPal(diffcmap, 256);
 				IsPal = false;
 			}
 
@@ -163,7 +162,7 @@ void diffNextFrame() {
 			CurBit = 0;
 
 			if (DispBitMap->Flags & BITMAPF_VIDEO)
-				WSDL_UpdateScreen();
+				g_lab->WSDL_UpdateScreen();
 
 			return; /* done with the next frame. */
 		}
@@ -231,7 +230,7 @@ void diffNextFrame() {
 			if (waitForEffect) {
 				while (g_music->isSoundEffectActive()) {
 					g_music->updateMusic();
-					waitTOF();
+					g_lab->waitTOF();
 				}
 			}
 
@@ -257,7 +256,7 @@ void diffNextFrame() {
 				if (waitForEffect) {
 					while (g_music->isSoundEffectActive()) {
 						g_music->updateMusic();
-						waitTOF();
+						g_lab->waitTOF();
 
 						if (DispBitMap->Flags & BITMAPF_VIDEO)
 							didTOF = 1;
@@ -268,7 +267,7 @@ void diffNextFrame() {
 				mouseShow();
 
 				if (!didTOF)
-					WSDL_UpdateScreen();
+					g_lab->WSDL_UpdateScreen();
 
 				return;
 			}
@@ -445,7 +444,7 @@ void readSound(bool waitTillFinished, Common::File *file) {
 			if (waitTillFinished) {
 				while (g_music->isSoundEffectActive()) {
 					g_music->updateMusic();
-					waitTOF();
+					g_lab->waitTOF();
 				}
 			}
 
@@ -460,7 +459,7 @@ void readSound(bool waitTillFinished, Common::File *file) {
 			if (waitTillFinished) {
 				while (g_music->isSoundEffectActive()) {
 					g_music->updateMusic();
-					waitTOF();
+					g_lab->waitTOF();
 				}
 			}
 		} else
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 0104e3e..16940e1 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -38,7 +38,6 @@
 #include "lab/parsefun.h"
 #include "lab/interface.h"
 #include "lab/diff.h"
-#include "lab/vga.h"
 #include "lab/text.h"
 #include "lab/mouse.h"
 #include "lab/stddefines.h"
@@ -89,7 +88,6 @@ extern uint16 *FadePalette;
 extern bool nopalchange, DoBlack, IsHiRes;
 extern BitMap *DispBitMap, *DrawBitMap;
 extern char diffcmap[3 * 256];
-extern byte *_tempScrollData;
 extern CloseDataPtr CPtr;
 extern InventoryData *Inventory;
 extern uint16 RoomNum, Direction;
@@ -141,7 +139,7 @@ static void doCombination() {
 	uint16 counter;
 
 	for (counter = 0; counter <= 5; counter++)
-		drawImage(Images[combination[counter]], VGAScaleX(combx[counter]), VGAScaleY(65));
+		g_lab->drawImage(Images[combination[counter]], VGAScaleX(combx[counter]), VGAScaleY(65));
 }
 
 /*****************************************************************************/
@@ -164,11 +162,11 @@ void showCombination(const char *filename) {
 	for (CurBit = 0; CurBit < 10; CurBit++)
 		readImage(buffer, &(Images[CurBit]));
 
-	allocFile((void **)&_tempScrollData, Images[0]->Width * Images[0]->Height * 2L, "tempdata");
+	allocFile((void **)&g_lab->_tempScrollData, Images[0]->Width * Images[0]->Height * 2L, "tempdata");
 
 	doCombination();
 
-	VGASetPal(diffcmap, 256);
+	g_lab->VGASetPal(diffcmap, 256);
 }
 
 
@@ -188,22 +186,22 @@ static void changeCombination(uint16 number) {
 
 	combnum = combination[number];
 
-	display.ImageData = getVGABaseAddr();
+	display.ImageData = g_lab->getVGABaseAddr();
 	display.Width     = g_lab->_screenWidth;
 	display.Height    = g_lab->_screenHeight;
 
 	for (counter = 1; counter <= (Images[combnum]->Height / 2); counter++) {
 		if (IsHiRes) {
 			if (counter & 1)
-				waitTOF();
+				g_lab->waitTOF();
 		} else
-			waitTOF();
+			g_lab->waitTOF();
 
-		display.ImageData = getVGABaseAddr();
+		display.ImageData = g_lab->getVGABaseAddr();
 
-		scrollDisplayY(2, VGAScaleX(combx[number]), VGAScaleY(65), VGAScaleX(combx[number]) + (Images[combnum])->Width - 1, VGAScaleY(65) + (Images[combnum])->Height);
+		g_lab->scrollDisplayY(2, VGAScaleX(combx[number]), VGAScaleY(65), VGAScaleX(combx[number]) + (Images[combnum])->Width - 1, VGAScaleY(65) + (Images[combnum])->Height);
 
-		bltBitMap(Images[combnum], 0, (Images[combnum])->Height - (2 * counter), &(display), VGAScaleX(combx[number]), VGAScaleY(65), (Images[combnum])->Width, 2);
+		g_lab->bltBitMap(Images[combnum], 0, (Images[combnum])->Height - (2 * counter), &(display), VGAScaleX(combx[number]), VGAScaleY(65), (Images[combnum])->Width, 2);
 	}
 
 	for (counter = 0; counter < 6; counter++)
@@ -259,8 +257,8 @@ static void doTile(bool showsolution) {
 		rows = VGAScaleY(31);
 		cols = VGAScaleX(105);
 	} else {
-		setAPen(0);
-		rectFill(VGAScaleX(97), VGAScaleY(22), VGAScaleX(220), VGAScaleY(126));
+		g_lab->setAPen(0);
+		g_lab->rectFill(VGAScaleX(97), VGAScaleY(22), VGAScaleX(220), VGAScaleY(126));
 
 		rowm = VGAScaleY(25);
 		colm = VGAScaleX(30);
@@ -277,7 +275,7 @@ static void doTile(bool showsolution) {
 				num = CurTile[col] [row];
 
 			if (showsolution || num)
-				drawImage(Tiles[num], cols + (col * colm), rows + (row * rowm));
+				g_lab->drawImage(Tiles[num], cols + (col * colm), rows + (row * rowm));
 
 			col++;
 		}
@@ -315,19 +313,19 @@ void showTile(const char *filename, bool showsolution) {
 	for (CurBit = start; CurBit < 16; CurBit++)
 		readImage(buffer, &(Tiles[CurBit]));
 
-	allocFile((void **)&_tempScrollData, Tiles[1]->Width * Tiles[1]->Height * 2L, "tempdata");
+	allocFile((void **)&g_lab->_tempScrollData, Tiles[1]->Width * Tiles[1]->Height * 2L, "tempdata");
 
 	doTile(showsolution);
 
-	VGASetPal(diffcmap, 256);
+	g_lab->VGASetPal(diffcmap, 256);
 }
 
 static void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	if (dx)
-		scrollDisplayX(dx, x1, y1, x2, y2);
+		g_lab->scrollDisplayX(dx, x1, y1, x2, y2);
 
 	if (dy)
-		scrollDisplayY(dy, x1, y1, x2, y2);
+		g_lab->scrollDisplayY(dy, x1, y1, x2, y2);
 }
 
 /*****************************************************************************/
@@ -364,7 +362,7 @@ static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 	y1 = VGAScaleY(25) + (row * VGAScaleY(25)) + dy;
 
 	for (counter = 0; counter < last; counter++) {
-		waitTOF();
+		g_lab->waitTOF();
 		scrollRaster(dX, dY, x1, y1, x1 + VGAScaleX(28) + sx, y1 + VGAScaleY(23) + sy);
 		x1 += dX;
 		y1 += dY;
@@ -479,7 +477,7 @@ void doNotes() {
 
 	flowText(BigMsgFont, -2 + SVGACord(1), 0, 0, false, false, true, true, VGAScaleX(25) + SVGACord(15), VGAScaleY(50), VGAScaleX(295) - SVGACord(15), VGAScaleY(148), ntext);
 
-	VGASetPal(diffcmap, 256);
+	g_lab->VGASetPal(diffcmap, 256);
 	freeAllStolenMem();
 }
 
@@ -541,7 +539,7 @@ void doWestPaper() {
 
 	CharsPrinted = flowText(BigMsgFont, -4, 0, 0, false, false, false, true, VGAScaleX(162), VGAScaleY(y), VGAScaleX(275), VGAScaleY(148), ntext);
 
-	VGASetPal(diffcmap, 256);
+	g_lab->VGASetPal(diffcmap, 256);
 	freeAllStolenMem();
 }
 
@@ -675,16 +673,16 @@ static void turnPage(bool FromLeft) {
 	if (FromLeft) {
 		for (counter = 0; counter < g_lab->_screenWidth; counter += 8) {
 			g_music->updateMusic();
-			waitTOF();
-			ScreenImage.ImageData = getVGABaseAddr();
-			bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, g_lab->_screenHeight);
+			g_lab->waitTOF();
+			ScreenImage.ImageData = g_lab->getVGABaseAddr();
+			g_lab->bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, g_lab->_screenHeight);
 		}
 	} else {
 		for (counter = (g_lab->_screenWidth - 8); counter > 0; counter -= 8) {
 			g_music->updateMusic();
-			waitTOF();
-			ScreenImage.ImageData = getVGABaseAddr();
-			bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, g_lab->_screenHeight);
+			g_lab->waitTOF();
+			ScreenImage.ImageData = g_lab->getVGABaseAddr();
+			g_lab->bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, g_lab->_screenHeight);
 		}
 	}
 }
@@ -703,10 +701,10 @@ static void drawJournal(uint16 wipenum, bool needFade) {
 
 	drawJournalText();
 
-	ScreenImage.ImageData = getVGABaseAddr();
+	ScreenImage.ImageData = g_lab->getVGABaseAddr();
 
 	if (wipenum == 0)
-		bltBitMap(&JBackImage, 0, 0, &ScreenImage, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight);
+		g_lab->bltBitMap(&JBackImage, 0, 0, &ScreenImage, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight);
 	else
 		turnPage((bool)(wipenum == 1));
 
@@ -794,7 +792,7 @@ void doJournal() {
 	CancelG.NextGadget = &ForwardG;
 
 	ScreenImage = JBackImage;
-	ScreenImage.ImageData = getVGABaseAddr();
+	ScreenImage.ImageData = g_lab->getVGABaseAddr();
 
 	g_music->updateMusic();
 	loadJournalData();
@@ -808,10 +806,10 @@ void doJournal() {
 	fade(false, 0);
 	mouseHide();
 
-	ScreenImage.ImageData = getVGABaseAddr();
+	ScreenImage.ImageData = g_lab->getVGABaseAddr();
 
-	setAPen(0);
-	rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
+	g_lab->setAPen(0);
+	g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
 	blackScreen();
 
 	freeAllStolenMem();
@@ -852,7 +850,7 @@ bool saveRestoreGame() {
 		}
 	}
 
-	WSDL_UpdateScreen();
+	g_lab->WSDL_UpdateScreen();
 
 	return isOK;
 }
@@ -903,17 +901,17 @@ static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2,
 		else
 			MonGadHeight = fheight;
 
-		setAPen(0);
-		rectFill(0, 0, g_lab->_screenWidth - 1, y2);
+		g_lab->setAPen(0);
+		g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, y2);
 
 		for (counter = 0; counter < numlines; counter++)
-			drawImage(MonButton, 0, counter * MonGadHeight);
+			g_lab->drawImage(MonButton, 0, counter * MonGadHeight);
 	} else if (isinteractive) {
-		setAPen(0);
-		rectFill(0, 0, g_lab->_screenWidth - 1, y2);
+		g_lab->setAPen(0);
+		g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, y2);
 	} else {
-		setAPen(0);
-		rectFill(x1, y1, x2, y2);
+		g_lab->setAPen(0);
+		g_lab->rectFill(x1, y1, x2, y2);
 	}
 
 	while (DrawingToPage < monitorPage) {
@@ -1083,8 +1081,8 @@ void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1,
 
 	freeAllStolenMem();
 
-	setAPen(0);
-	rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
+	g_lab->setAPen(0);
+	g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
 	blackAllScreen();
 }
 
diff --git a/engines/lab/text.cpp b/engines/lab/text.cpp
index 36b0116..cf920d3 100644
--- a/engines/lab/text.cpp
+++ b/engines/lab/text.cpp
@@ -32,7 +32,6 @@
 #include "lab/stddefines.h"
 #include "lab/labfun.h"
 #include "lab/text.h"
-#include "lab/vga.h"
 
 namespace Lab {
 
@@ -81,7 +80,7 @@ void text(struct TextFont *tf, uint16 x, uint16 y, uint16 color, const char *tex
 	int32 templeft, LeftInSegment;
 	uint16 counter, counterb, bwidth, mask, curpage, rows, cols, data;
 
-	VGATop = getVGABaseAddr();
+	VGATop = g_lab->getVGABaseAddr();
 
 	for (counter = 0; counter < numchars; counter++) {
 		RealOffset = (g_lab->_screenWidth * y) + x;
diff --git a/engines/lab/timing.cpp b/engines/lab/timing.cpp
index ca76755..ba3dd40 100644
--- a/engines/lab/timing.cpp
+++ b/engines/lab/timing.cpp
@@ -29,7 +29,6 @@
  */
 
 #include "lab/lab.h"
-#include "lab/vga.h"
 
 namespace Lab {
 
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 54cb507..c1d526b 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -29,7 +29,6 @@
  */
 
 #include "lab/lab.h"
-#include "lab/vga.h"
 #include "lab/stddefines.h"
 #include "lab/mouse.h"
 
@@ -39,27 +38,10 @@
 
 namespace Lab {
 
-static byte _curvgapal[256 * 3];
-static unsigned char _curapen = 0;
-
-byte *_currentDsplayBuffer = 0;
-byte *_displayBuffer = 0;
-
-int _lastWaitTOFTicks = 0;
-
-uint32 _mouseX = 0;
-uint32 _mouseY = 0;
-
-uint16 _nextKeyIn = 0;
-uint16 _keyBuf[64];
-uint16 _nextKeyOut = 0;
-bool _mouseAtEdge = false;
-byte *_tempScrollData;
-
 /*****************************************************************************/
 /* Sets up either a low-res or a high-res 256 color screen.                  */
 /*****************************************************************************/
-bool createScreen(bool HiRes) {
+bool LabEngine::createScreen(bool HiRes) {
 	if (HiRes) {
 		g_lab->_screenWidth  = 640;
 		g_lab->_screenHeight = 480;
@@ -77,11 +59,11 @@ bool createScreen(bool HiRes) {
 /*****************************************************************************/
 /* Sets the current page on the VGA card.                                    */
 /*****************************************************************************/
-void changeVolume(int delta) {
+void LabEngine::changeVolume(int delta) {
 	warning("STUB: changeVolume()");
 }
 
-uint16 WSDL_GetNextChar() {
+uint16 LabEngine::WSDL_GetNextChar() {
 	uint16 c = 0;
 
 	WSDL_ProcessInput(0);
@@ -94,12 +76,12 @@ uint16 WSDL_GetNextChar() {
 	return c;
 }
 
-bool WSDL_HasNextChar() {
+bool LabEngine::WSDL_HasNextChar() {
 	WSDL_ProcessInput(0);
 	return _nextKeyIn != _nextKeyOut;
 }
 
-void WSDL_ProcessInput(bool can_delay) {
+void LabEngine::WSDL_ProcessInput(bool can_delay) {
 	int n;
 	int lastMouseAtEdge;
 	int flags = 0;
@@ -186,14 +168,14 @@ void WSDL_ProcessInput(bool can_delay) {
 		g_system->delayMillis(10);
 }
 
-void WSDL_GetMousePos(int *x, int *y) {
+void LabEngine::WSDL_GetMousePos(int *x, int *y) {
 	WSDL_ProcessInput(0);
 
 	*x = _mouseX;
 	*y = _mouseY;
 }
 
-void waitTOF() {
+void LabEngine::waitTOF() {
 	g_system->copyRectToScreen(_displayBuffer, g_lab->_screenWidth, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight);
 	g_system->updateScreen();
 
@@ -207,7 +189,7 @@ void waitTOF() {
 	_lastWaitTOFTicks = now;
 }
 
-void WSDL_SetColors(byte *buf, uint16 first, uint16 numreg, uint16 slow) {
+void LabEngine::WSDL_SetColors(byte *buf, uint16 first, uint16 numreg, uint16 slow) {
 	byte tmp[256 * 3];
 
 	for (int i = 0; i < 256 * 3; i++) {
@@ -231,12 +213,12 @@ void WSDL_SetColors(byte *buf, uint16 first, uint16 numreg, uint16 slow) {
 /*           The length of the buffer is 3 times the number of registers     */
 /*           selected.                                                       */
 /*****************************************************************************/
-void writeColorRegs(byte *buf, uint16 first, uint16 numreg) {
+void LabEngine::writeColorRegs(byte *buf, uint16 first, uint16 numreg) {
 	WSDL_SetColors(buf, first, numreg, 0);
 	memcpy(&(_curvgapal[first * 3]), buf, numreg * 3);
 }
 
-void writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg) {
+void LabEngine::writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg) {
 	WSDL_SetColors(buf, first, numreg, 1);
 	memcpy(&(_curvgapal[first * 3]), buf, numreg * 3);
 }
@@ -246,16 +228,16 @@ void writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg) {
 /* the first character in the string is the red value, then green, then      */
 /* blue.  Each color value is a 6 bit value.                                 */
 /*****************************************************************************/
-void writeColorReg(byte *buf, uint16 regnum) {
+void LabEngine::writeColorReg(byte *buf, uint16 regnum) {
 	writeColorRegs(buf, regnum, 1);
 }
 
-void VGASetPal(void *cmap, uint16 numcolors) {
+void LabEngine::VGASetPal(void *cmap, uint16 numcolors) {
 	if (memcmp(cmap, _curvgapal, numcolors * 3) != 0)
 		writeColorRegs((byte *)cmap, 0, numcolors);
 }
 
-void WSDL_UpdateScreen() {
+void LabEngine::WSDL_UpdateScreen() {
 	g_system->copyRectToScreen(_displayBuffer, g_lab->_screenWidth, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight);
 	g_system->updateScreen();
 
@@ -265,7 +247,7 @@ void WSDL_UpdateScreen() {
 /*****************************************************************************/
 /* Returns the base address of the current VGA display.                      */
 /*****************************************************************************/
-byte *getVGABaseAddr() {
+byte *LabEngine::getVGABaseAddr() {
 	if (_currentDsplayBuffer)
 		return _currentDsplayBuffer;
 
@@ -275,7 +257,7 @@ byte *getVGABaseAddr() {
 /*****************************************************************************/
 /* Draws an image to the screen.                                             */
 /*****************************************************************************/
-void drawImage(Image *Im, uint16 x, uint16 y) {
+void LabEngine::drawImage(Image *Im, uint16 x, uint16 y) {
 	int sx, sy, dx, dy, w, h;
 
 	sx = 0;
@@ -318,7 +300,7 @@ void drawImage(Image *Im, uint16 x, uint16 y) {
 /*****************************************************************************/
 /* Draws an image to the screen.                                             */
 /*****************************************************************************/
-void drawMaskImage(Image *Im, uint16 x, uint16 y) {
+void LabEngine::drawMaskImage(Image *Im, uint16 x, uint16 y) {
 	int sx, sy, dx, dy, w, h;
 
 	sx = 0;
@@ -371,7 +353,7 @@ void drawMaskImage(Image *Im, uint16 x, uint16 y) {
 /*****************************************************************************/
 /* Reads an image from the screen.                                           */
 /*****************************************************************************/
-void readScreenImage(Image *Im, uint16 x, uint16 y) {
+void LabEngine::readScreenImage(Image *Im, uint16 x, uint16 y) {
 	int sx, sy, dx, dy, w, h;
 
 	sx = 0;
@@ -415,7 +397,7 @@ void readScreenImage(Image *Im, uint16 x, uint16 y) {
 /* Blits a piece of one image to another.                                    */
 /* NOTE: for our purposes, assumes that ImDest is to be in VGA memory.       */
 /*****************************************************************************/
-void bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest,
+void LabEngine::bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest,
 					uint16 xd, uint16 yd, uint16 width, uint16 height) {
 	// I think the old code assumed that the source image data was valid for the given box.
 	// I will proceed on that assumption.
@@ -461,7 +443,7 @@ void bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest,
 /* The _tempScrollData variable must be initialized to some memory, or this   */
 /* function will fail.                                                       */
 /*****************************************************************************/
-void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+void LabEngine::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	Image Im;
 	uint16 temp;
 
@@ -503,7 +485,7 @@ void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 /*****************************************************************************/
 /* Scrolls the display in the y direction by blitting.                       */
 /*****************************************************************************/
-void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+void LabEngine::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	Image Im;
 	uint16 temp;
 
@@ -545,14 +527,14 @@ void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 /*****************************************************************************/
 /* Sets the pen number to use on all the drawing operations.                 */
 /*****************************************************************************/
-void setAPen(uint16 pennum) {
+void LabEngine::setAPen(uint16 pennum) {
 	_curapen = (unsigned char)pennum;
 }
 
 /*****************************************************************************/
 /* Fills in a rectangle.                                                     */
 /*****************************************************************************/
-void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+void LabEngine::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	int dx, dy, w, h;
 
 	dx = x1;
@@ -595,21 +577,21 @@ void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 /*****************************************************************************/
 /* Draws a horizontal line.                                                  */
 /*****************************************************************************/
-void drawVLine(uint16 x, uint16 y1, uint16 y2) {
+void LabEngine::drawVLine(uint16 x, uint16 y1, uint16 y2) {
 	rectFill(x, y1, x, y2);
 }
 
 /*****************************************************************************/
 /* Draws a vertical line.                                                    */
 /*****************************************************************************/
-void drawHLine(uint16 x1, uint16 y, uint16 x2) {
+void LabEngine::drawHLine(uint16 x1, uint16 y, uint16 x2) {
 	rectFill(x1, y, x2, y);
 }
 
 /*****************************************************************************/
 /* Ghoasts a region on the screen using the desired pen color.               */
 /*****************************************************************************/
-void ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+void LabEngine::ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	int dx, dy, w, h;
 
 	dx = x1;
diff --git a/engines/lab/vga.h b/engines/lab/vga.h
deleted file mode 100644
index ade6a2a..0000000
--- a/engines/lab/vga.h
+++ /dev/null
@@ -1,74 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "lab/stddefines.h"
-
-#ifndef LAB_VGA_H
-#define LAB_VGA_H
-
-namespace Lab {
-
-struct Image {
-	uint16 Width;
-	uint16 Height;
-	byte *ImageData;
-};
-
-bool createScreen(bool HiRes);
-void waitTOF();
-void quickWaitTOF();
-byte *getVGABaseAddr();
-void writeColorReg(byte *buf, uint16 regnum);
-void writeColorRegs(byte *buf, uint16 first, uint16 numreg);
-void writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg);
-void VGASetPal(void *cmap, uint16 numcolors);
-
-/*---------- Drawing Routines ----------*/
-
-void drawImage(Image *Im, uint16 x, uint16 y);
-void drawMaskImage(Image *Im, uint16 x, uint16 y);
-void readScreenImage(Image *Im, uint16 x, uint16 y);
-void bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest, uint16 xd, uint16 yd, uint16 width, uint16 height);
-void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-void setAPen(uint16 pennum);
-void drawHLine(uint16 x, uint16 y1, uint16 y2);
-void drawVLine(uint16 x1, uint16 y, uint16 x2);
-void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-void ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-void WSDL_UpdateScreen();
-void WSDL_GetMousePos(int *x, int *y);
-uint16 WSDL_GetNextChar();
-bool WSDL_HasNextChar();
-void WSDL_ProcessInput(bool can_delay);
-
-} // End of namespace Lab
-
-#endif /* LAB_VGA_H */


Commit: b76a624c9ae59aac7df11ad5df7d39879d3344c8
    https://github.com/scummvm/scummvm/commit/b76a624c9ae59aac7df11ad5df7d39879d3344c8
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:43+01:00

Commit Message:
LAB: Fix several cppcheck errors

Changed paths:
    engines/lab/allocroom.cpp
    engines/lab/detection.cpp
    engines/lab/engine.cpp
    engines/lab/interface.cpp
    engines/lab/processroom.cpp
    engines/lab/special.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/allocroom.cpp b/engines/lab/allocroom.cpp
index 2d7016d..22dfae6 100644
--- a/engines/lab/allocroom.cpp
+++ b/engines/lab/allocroom.cpp
@@ -99,7 +99,7 @@ static void freeRoom(uint16 RMarker) {
 		Rooms[RoomNum].WestView  = NULL;
 
 		RuleList *rules = Rooms[RoomNum].rules;
-		for (RuleList::iterator rule = rules->begin(); rule != rules->end(); rule++)
+		for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule)
 			delete *rule;
 		Rooms[RoomNum].rules->clear();
 		delete Rooms[RoomNum].rules;
@@ -119,28 +119,25 @@ static void freeRoom(uint16 RMarker) {
 /* Gets a chunk of memory from the buffer.                                   */
 /*****************************************************************************/
 static void *getCurMem(uint16 Size) {
-	uint16 counter;
-	void *Ptr, *Start0, *Start1, *End0, *End1;
-
 	if (((int32) Size) > MemLeftInBuffer) {
 		MemPlace = RoomBuffer;
 		MemLeftInBuffer = ROOMBUFFERSIZE;
 		NextMemPlace = NULL;
 	}
 
-	Ptr = MemPlace;
+	void *Ptr = MemPlace;
 	MemPlace = (char *)MemPlace + Size;
 	MemLeftInBuffer -= Size;
 
 	if (MemPlace > NextMemPlace) {
 		NextMemPlace = NULL;
 
-		for (counter = 0; counter < MAXMARKERS; counter++) {
+		for (uint16 counter = 0; counter < MAXMARKERS; counter++) {
 			if (RoomMarkers[counter].RoomNum != EMPTYROOM) {
-				Start0 = RoomMarkers[counter].Start0;
-				Start1 = RoomMarkers[counter].Start1;
-				End0   = RoomMarkers[counter].End0;
-				End1   = RoomMarkers[counter].End1;
+				void *Start0 = RoomMarkers[counter].Start0;
+				void *Start1 = RoomMarkers[counter].Start1;
+				void *End0   = RoomMarkers[counter].End0;
+				void *End1   = RoomMarkers[counter].End1;
 
 				if (((Start0 >= Ptr) && (Start0 < MemPlace))  ||
 				        ((End0 >= Ptr) && (End0 < MemPlace))    ||
diff --git a/engines/lab/detection.cpp b/engines/lab/detection.cpp
index 1da269e..ddb6aa3 100644
--- a/engines/lab/detection.cpp
+++ b/engines/lab/detection.cpp
@@ -186,7 +186,7 @@ SaveStateList LabMetaEngine::listSaves(const char *target) const {
 
 	SaveStateList saveList;
 
-	for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); file++) {
+	for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
 	        // Obtain the last 3 digits of the filename, since they correspond to the save slot
 	        int slotNum = atoi(file->c_str() + file->size() - 3);
 
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 18178d3..2c56f5f 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -1307,10 +1307,8 @@ from_crumbs:
 
 
 void LabEngine::go() {
-	bool mem, dointro = false;
 	uint16 counter;
-
-	dointro = true;
+	bool dointro = true;
 
 	IsHiRes = ((getFeatures() & GF_LOWRES) == 0);
 
@@ -1320,6 +1318,8 @@ void LabEngine::go() {
 	else
 		warning("Running in LowRes mode");
 #endif
+
+	bool mem = false;
 	if (initBuffer(BUFFERSIZE, true)) {
 		mem = true;
 	} else {
@@ -1345,7 +1345,6 @@ void LabEngine::go() {
 
 	if (dointro && mem) {
 		Intro intro;
-
 		intro.introSequence();
 	} else
 		DoBlack = true;
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 54a7e13..36891d7 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -64,10 +64,10 @@ Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image
 
 
 void freeButtonList(Gadget *gptrlist) {
-	Gadget *gptr, *next = gptrlist;
+	Gadget *next = gptrlist;
 
 	while (next) {
-		gptr = next;
+		Gadget *gptr = next;
 		next = next->NextGadget;
 
 		free(gptr);
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index e6e9d91..fd5ec73 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -619,7 +619,7 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr LCPtr, Clo
 			rules = Rooms[roomNum].rules;
 		}
 
-		for (RuleList::iterator rule = rules->begin(); rule != rules->end(); rule++) {
+		for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 			if (((*rule)->RuleType == ACTION) &&
 				(((*rule)->Param1 == action) || (((*rule)->Param1 == 0) && AllowDefaults))) {
 				if ((((*rule)->Param2 == LCPtr->CloseUpType) ||
@@ -676,7 +676,7 @@ static bool doOperateRuleSub(int16 ItemNum, int16 roomNum, CloseDataPtr LCPtr, C
 				rules = Rooms[roomNum].rules;
 			}
 
-			for (RuleList::iterator rule = rules->begin(); rule != rules->end(); rule++) {
+			for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 				if (((*rule)->RuleType == OPERATE) &&
 				        (((*rule)->Param1 == ItemNum) || (((*rule)->Param1 == 0) && AllowDefaults)) &&
 						(((*rule)->Param2 == LCPtr->CloseUpType) || (((*rule)->Param2 == 0) && AllowDefaults))) {
@@ -731,7 +731,7 @@ bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *LCPtr) {
 bool doGoForward(CloseDataPtr *LCPtr) {
 	RuleList *rules = Rooms[RoomNum].rules;
 
-	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); rule++) {
+	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 		if (((*rule)->RuleType == GOFORWARD) && ((*rule)->Param1 == (Direction + 1))) {
 			if (checkConditions((*rule)->Condition)) {
 				doActions((*rule)->ActionList, LCPtr);
@@ -752,7 +752,7 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *LCPtr) {
 
 	RuleList *rules = Rooms[RoomNum].rules;
 
-	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); rule++) {
+	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 		if (((*rule)->RuleType == TURN) ||
 		        (((*rule)->RuleType == TURNFROMTO) &&
 		         ((*rule)->Param1   == from) && ((*rule)->Param2 == to))) {
@@ -771,7 +771,7 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *LCPtr) {
 /*****************************************************************************/
 bool doMainView(CloseDataPtr *LCPtr) {
 	RuleList *rules = Rooms[RoomNum].rules;
-	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); rule++) {
+	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 		if ((*rule)->RuleType == GOMAINVIEW) {
 			if (checkConditions((*rule)->Condition)) {
 				doActions((*rule)->ActionList, LCPtr);
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 16940e1..1ee539f 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -373,7 +373,6 @@ static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 /* Changes the combination number of one of the slots                        */
 /*****************************************************************************/
 static void changeTile(uint16 col, uint16 row) {
-	bool check;
 	int16 scrolltype = -1;
 
 	if (row > 0) {
@@ -417,7 +416,7 @@ static void changeTile(uint16 col, uint16 row) {
 			return;
 		}
 
-		check = true;
+		bool check = true;
 		row   = 0;
 		col   = 0;
 
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index c1d526b..73d8cf3 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -82,13 +82,10 @@ bool LabEngine::WSDL_HasNextChar() {
 }
 
 void LabEngine::WSDL_ProcessInput(bool can_delay) {
-	int n;
-	int lastMouseAtEdge;
-	int flags = 0;
-
 	Common::Event event;
 
 	if (1 /*!g_IgnoreProcessInput*/) {
+		int flags = 0;
 		while (g_system->getEventManager()->pollEvent(event)) {
 			switch (event.type) {
 			case Common::EVENT_RBUTTONDOWN:
@@ -101,8 +98,8 @@ void LabEngine::WSDL_ProcessInput(bool can_delay) {
 				mouseHandler(flags, _mouseX, _mouseY);
 				break;
 
-			case Common::EVENT_MOUSEMOVE:
-				lastMouseAtEdge = _mouseAtEdge;
+			case Common::EVENT_MOUSEMOVE: {
+				int lastMouseAtEdge = _mouseAtEdge;
 				_mouseAtEdge = false;
 				_mouseX = event.mouse.x;
 				if (event.mouse.x <= 0) {
@@ -127,6 +124,7 @@ void LabEngine::WSDL_ProcessInput(bool can_delay) {
 				if (!lastMouseAtEdge || !_mouseAtEdge)
 					mouseHandler(1, _mouseX, _mouseY);
 
+				}
 				break;
 
 			case Common::EVENT_KEYDOWN:
@@ -143,14 +141,15 @@ void LabEngine::WSDL_ProcessInput(bool can_delay) {
 					//saveSettings();
 					break;
 
-				default:
-					n = ((((unsigned int)((_nextKeyIn + 1) >> 31) >> 26) + (byte)_nextKeyIn + 1) & 0x3F)
+				default: {
+					int n = ((((unsigned int)((_nextKeyIn + 1) >> 31) >> 26) + (byte)_nextKeyIn + 1) & 0x3F)
 					- ((unsigned int)((_nextKeyIn + 1) >> 31) >> 26);
 					if (n != _nextKeyOut) {
 						_keyBuf[_nextKeyIn] = event.kbd.keycode;
 						_nextKeyIn = n;
 					}
 				}
+				}
 				break;
 
 			case Common::EVENT_QUIT:


Commit: ff2def7da187c5160443fc6166728f1fc59ff66e
    https://github.com/scummvm/scummvm/commit/ff2def7da187c5160443fc6166728f1fc59ff66e
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:43+01:00

Commit Message:
LAB: Check all the 'for' loops, reduce the scope of variable accordingly

Changed paths:
    engines/lab/allocroom.cpp
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/intro.cpp
    engines/lab/labfile.cpp
    engines/lab/map.cpp
    engines/lab/mouse.cpp
    engines/lab/processroom.cpp
    engines/lab/special.cpp
    engines/lab/text.cpp
    engines/lab/undiff.cpp



diff --git a/engines/lab/allocroom.cpp b/engines/lab/allocroom.cpp
index 22dfae6..2b80967 100644
--- a/engines/lab/allocroom.cpp
+++ b/engines/lab/allocroom.cpp
@@ -56,25 +56,20 @@ static int32 MemLeftInBuffer = 0L;
 /* Allocates the memory for the room buffers.                                */
 /*****************************************************************************/
 bool initRoomBuffer() {
-	uint16 counter;
-
 	CurMarker = 0;
 
 	if ((RoomBuffer = calloc(ROOMBUFFERSIZE, 1))) {
 		MemPlace = RoomBuffer;
 		MemLeftInBuffer = ROOMBUFFERSIZE;
 
-		for (counter = 0; counter < MAXMARKERS; counter++)
-			RoomMarkers[counter].RoomNum = EMPTYROOM;
+		for (uint16 i = 0; i < MAXMARKERS; i++)
+			RoomMarkers[i].RoomNum = EMPTYROOM;
 
 		return true;
 	} else
 		return false;
 }
 
-
-
-
 /*****************************************************************************/
 /* Frees the memory for the room buffers.                                    */
 /*****************************************************************************/
@@ -83,7 +78,6 @@ void freeRoomBuffer() {
 		free(RoomBuffer);
 }
 
-
 /*****************************************************************************/
 /* Frees a room's resources.                                                 */
 /*****************************************************************************/
@@ -132,12 +126,12 @@ static void *getCurMem(uint16 Size) {
 	if (MemPlace > NextMemPlace) {
 		NextMemPlace = NULL;
 
-		for (uint16 counter = 0; counter < MAXMARKERS; counter++) {
-			if (RoomMarkers[counter].RoomNum != EMPTYROOM) {
-				void *Start0 = RoomMarkers[counter].Start0;
-				void *Start1 = RoomMarkers[counter].Start1;
-				void *End0   = RoomMarkers[counter].End0;
-				void *End1   = RoomMarkers[counter].End1;
+		for (uint16 i = 0; i < MAXMARKERS; i++) {
+			if (RoomMarkers[i].RoomNum != EMPTYROOM) {
+				void *Start0 = RoomMarkers[i].Start0;
+				void *Start1 = RoomMarkers[i].Start1;
+				void *End0   = RoomMarkers[i].End0;
+				void *End1   = RoomMarkers[i].End1;
 
 				if (((Start0 >= Ptr) && (Start0 < MemPlace))  ||
 				        ((End0 >= Ptr) && (End0 < MemPlace))    ||
@@ -146,7 +140,7 @@ static void *getCurMem(uint16 Size) {
 				        ((Start1 >= Ptr) && (Start1 < MemPlace))  ||
 				        ((End1 >= Ptr) && (End1 < MemPlace))    ||
 				        ((Ptr >= Start1) && (Ptr <= End1))) {
-					freeRoom(counter);
+					freeRoom(i);
 				} else {
 					if (Start0 >= MemPlace)
 						if ((NextMemPlace == NULL) || (Start0 < NextMemPlace))
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 2c56f5f..2d85dda 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -219,7 +219,6 @@ static void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr) {
 /* Sets up the Labyrinth screens, and opens up the initial windows.           */
 /******************************************************************************/
 bool LabEngine::setUpScreens() {
-	uint16 counter;
 	byte *buffer;
 	byte *MovePanelBuffer, *InvPanelBuffer;
 	Gadget *curgad;
@@ -242,8 +241,8 @@ bool LabEngine::setUpScreens() {
 
 	buffer = MovePanelBuffer;
 
-	for (counter = 0; counter < 20; counter++)
-		readImage(&buffer, &(MoveImages[counter]));
+	for (uint16 i = 0; i < 20; i++)
+		readImage(&buffer, &(MoveImages[i]));
 
 	/* Creates the gadgets for the movement control panel */
 	y = VGAScaleY(173) - SVGACord(2);
@@ -303,8 +302,8 @@ bool LabEngine::setUpScreens() {
 	buffer = InvPanelBuffer;
 
 	if (g_lab->getPlatform() == Common::kPlatformWindows) {
-		for (counter = 0; counter < 10; counter++)
-			readImage(&buffer, &(InvImages[counter]));
+		for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++)
+			readImage(&buffer, &(InvImages[imgIdx]));
 
 		InvGadgetList = createButton(24, y, 0, 'm', InvImages[0], InvImages[1]);
 		curgad = InvGadgetList;
@@ -323,8 +322,8 @@ bool LabEngine::setUpScreens() {
 		curgad->NextGadget = createButton(266, y, 7, 'f', InvImages[8], InvImages[9]);
 		curgad = curgad->NextGadget;
 	} else {
-		for (counter = 0; counter < 6; counter++)
-			readImage(&buffer, &(InvImages[counter]));
+		for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++)
+			readImage(&buffer, &(InvImages[imgIdx]));
 
 		InvGadgetList = createButton(58, y, 0, 0, InvImages[0], InvImages[1]);
 		curgad = InvGadgetList;
@@ -639,7 +638,7 @@ void LabEngine::mainGameLoop() {
 	IntuiMessage *Msg;
 	uint32 Class;
 
-	uint16 Code = 0, Qualifier, MouseX, MouseY, ActionMode = 4;
+	uint16 Qualifier, MouseX, MouseY, ActionMode = 4;
 	uint16 CurInv = MAPNUM, LastInv = MAPNUM, Old;
 
 	bool ForceDraw = false, doit, GotMessage = true;
@@ -673,6 +672,7 @@ void LabEngine::mainGameLoop() {
 
 	/* Set up initial picture. */
 
+	uint16 code = 0;
 	while (1) {
 		WSDL_ProcessInput(1);
 
@@ -762,11 +762,11 @@ void LabEngine::mainGameLoop() {
 					MouseY    = y;
 
 					if (result == VKEY_UPARROW) {
-						Code = GadID = 7;
+						code = GadID = 7;
 					} else if (result == VKEY_LTARROW) {
-						Code = GadID = 6;
+						code = GadID = 6;
 					} else if (result == VKEY_RTARROW) {
-						Code = GadID = 8;
+						code = GadID = 8;
 					}
 
 					GotMessage = true;
@@ -782,7 +782,7 @@ void LabEngine::mainGameLoop() {
 			GotMessage = true;
 
 			Class     = Msg->msgClass;
-			Code      = Msg->code;
+			code      = Msg->code;
 			Qualifier = Msg->qualifier;
 			MouseX    = Msg->mouseX;
 			MouseY    = Msg->mouseY;
@@ -794,23 +794,23 @@ from_crumbs:
 			DoBlack = false;
 
 			if ((Class == RAWKEY) && (!LongWinInFront)) {
-				if (Code == 13) { /* The return key */
+				if (code == 13) { /* The return key */
 					Class     = MOUSEBUTTONS;
 					Qualifier = IEQUALIFIER_LEFTBUTTON;
 					mouseXY(&MouseX, &MouseY);
 				} else if (g_lab->getPlatform() == Common::kPlatformWindows &&
-						(Code == 'b' || Code == 'B')) {  /* Start bread crumbs */
+						(code == 'b' || code == 'B')) {  /* Start bread crumbs */
 					BreadCrumbs[0].RoomNum = 0;
 					NumCrumbs = 0;
 					DroppingCrumbs = true;
 					mayShowCrumbIndicator();
 					WSDL_UpdateScreen();
-				} else if (Code == 'f' || Code == 'F' ||
-				         Code == 'r' || Code == 'R') {  /* Follow bread crumbs */
+				} else if (code == 'f' || code == 'F' ||
+				         code == 'r' || code == 'R') {  /* Follow bread crumbs */
 					if (DroppingCrumbs) {
 						if (NumCrumbs > 0) {
 							FollowingCrumbs = true;
-							FollowCrumbsFast = (Code == 'r' || Code == 'R');
+							FollowCrumbsFast = (code == 'r' || code == 'R');
 							IsCrumbTurning = false;
 							IsCrumbWaiting = false;
 							g_lab->getTime(&CrumbSecs, &CrumbMicros);
@@ -836,8 +836,8 @@ from_crumbs:
 							WSDL_UpdateScreen();
 						}
 					}
-				} else if ((Code == 315) || (Code == 'x') || (Code == 'X')
-				         || (Code == 'q') || (Code == 'Q')) {  /* Quit? */
+				} else if ((code == 315) || (code == 'x') || (code == 'X')
+				         || (code == 'q') || (code == 'Q')) {  /* Quit? */
 					DoNotDrawMessage = false;
 					drawMessage("Do you want to quit? (Y/N)");
 					doit = false;
@@ -872,9 +872,9 @@ from_crumbs:
 						ForceDraw = true;
 						interfaceOn();
 					}
-				} else if (Code == 9) { /* TAB key */
+				} else if (code == 9) { /* TAB key */
 					Class = DELTAMOVE;
-				} else if (Code == 27) { /* ESC key */
+				} else if (code == 27) { /* ESC key */
 					CPtr = NULL;
 				}
 
@@ -1015,11 +1015,9 @@ from_crumbs:
 								BreadCrumbs[0].RoomNum = 0;
 							} else {
 								bool intersect = false;
-								int i;
-
-								for (i = 0; i < NumCrumbs; i++) {
-									if (BreadCrumbs[i].RoomNum == RoomNum) {
-										NumCrumbs = i + 1;
+								for (int idx = 0; idx < NumCrumbs; idx++) {
+									if (BreadCrumbs[idx].RoomNum == RoomNum) {
+										NumCrumbs = idx + 1;
 										BreadCrumbs[NumCrumbs].RoomNum = 0;
 										intersect = true;
 									}
@@ -1293,21 +1291,19 @@ from_crumbs:
 		free(Rooms);
 
 	if (Inventory) {
-		for (Code = 1; Code <= NumInv; Code++) {
-			if (Inventory[Code].name)
-				free(Inventory[Code].name);
+		for (code = 1; code <= NumInv; code++) {
+			if (Inventory[code].name)
+				free(Inventory[code].name);
 
-			if (Inventory[Code].BInvName)
-				free(Inventory[Code].BInvName);
+			if (Inventory[code].BInvName)
+				free(Inventory[code].BInvName);
 		}
 
 		free(Inventory);
 	}
 }
 
-
 void LabEngine::go() {
-	uint16 counter;
 	bool dointro = true;
 
 	IsHiRes = ((getFeatures() & GF_LOWRES) == 0);
@@ -1359,7 +1355,7 @@ void LabEngine::go() {
 		blackAllScreen();
 		readPict("P:End/L2In.1", true);
 
-		for (counter = 0; counter < 120; counter++) {
+		for (uint16 i = 0; i < 120; i++) {
 			g_music->updateMusic();
 			waitTOF();
 		}
@@ -1395,9 +1391,6 @@ int followCrumbs() {
 		{ VKEY_RTARROW, VKEY_LTARROW, VKEY_RTARROW, VKEY_UPARROW }
 	};
 
-	int ExitDir;
-	int MoveDir;
-
 	if (IsCrumbWaiting) {
 		uint32 Secs;
 		uint32 Micros;
@@ -1422,6 +1415,8 @@ int followCrumbs() {
 		return 0;
 	}
 
+	int ExitDir;
+
 	// which direction is last crumb
 	if (BreadCrumbs[NumCrumbs].Direction == EAST)
 		ExitDir = WEST;
@@ -1432,7 +1427,7 @@ int followCrumbs() {
 	else
 		ExitDir = NORTH;
 
-	MoveDir = movement[Direction][ExitDir];
+	int MoveDir = movement[Direction][ExitDir];
 
 	if (NumCrumbs == 0) {
 		IsCrumbTurning = false;
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index b21c4f6..fbf8c45 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -608,18 +608,18 @@ static void doScrollBounce() {
 	g_music->updateMusic();
 	int startline = headerdata.y - height - 1;
 
-	for (int counter = 0; counter < 5; counter++) {
+	for (int i = 0; i < 5; i++) {
 		g_music->updateMusic();
-		startline -= newby[counter];
+		startline -= newby[i];
 		copyPage(width, height, 0, startline, mem);
 
 		g_lab->WSDL_UpdateScreen();
 		g_lab->waitTOF();
 	}
 
-	for (int counter = 8; counter > 0; counter--) {
+	for (int i = 8; i > 0; i--) {
 		g_music->updateMusic();
-		startline += newby1[counter - 1];
+		startline += newby1[i - 1];
 		copyPage(width, height, 0, startline, mem);
 
 		g_lab->WSDL_UpdateScreen();
@@ -636,7 +636,7 @@ static void doScrollBounce() {
 /* Does the transporter wipe.                                                */
 /*****************************************************************************/
 static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
-	uint16 LastY, CurY, counter, linesdone = 0, lineslast;
+	uint16 LastY, CurY, linesdone = 0, lineslast;
 	Image ImSource, ImDest;
 
 	if (IsHiRes) {
@@ -647,8 +647,8 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
 		LastY = 148;
 	}
 
-	for (counter = 0; counter < 2; counter++) {
-		CurY = counter * 2;
+	for (uint16 i = 0; i < 2; i++) {
+		CurY = i * 2;
 
 		while (CurY < LastY) {
 			if (linesdone >= lineslast) {
@@ -665,8 +665,8 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
 
 	g_lab->setAPen(0);
 
-	for (counter = 0; counter < 2; counter++) {
-		CurY = counter * 2;
+	for (uint16 i = 0; i < 2; i++) {
+		CurY = i * 2;
 
 		while (CurY <= LastY) {
 			if (linesdone >= lineslast) {
@@ -700,8 +700,8 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
 		ImDest.Height = g_lab->_screenHeight;
 		ImDest.ImageData = g_lab->getVGABaseAddr();
 
-		for (counter = 0; counter < 2; counter++) {
-			CurY = counter * 2;
+		for (uint16 i = 0; i < 2; i++) {
+			CurY = i * 2;
 
 			while (CurY < LastY) {
 				if (linesdone >= lineslast) {
@@ -719,8 +719,8 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
 			}
 		}
 
-		for (counter = 0; counter < 2; counter++) {
-			CurY = counter * 2;
+		for (uint16 i = 0; i < 2; i++) {
+			CurY = i * 2;
 
 			while (CurY <= LastY) {
 				if (linesdone >= lineslast) {
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index feb4905..b3a5ccd 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -217,14 +217,12 @@ void Intro::doPictText(const char *filename, bool isscreen) {
 /* Does a one second delay, but checks the music while doing it.             */
 /*****************************************************************************/
 void Intro::musicDelay() {
-	int16 counter;
-
 	g_music->updateMusic();
 
 	if (_quitIntro)
 		return;
 
-	for (counter = 0; counter < 20; counter++) {
+	for (uint16 i = 0; i < 20; i++) {
 		g_music->updateMusic();
 		g_lab->waitTOF();
 		g_lab->waitTOF();
@@ -253,8 +251,6 @@ void Intro::nReadPict(const char *filename, bool playOnce) {
 /* Does the introduction sequence for Labyrinth.                             */
 /*****************************************************************************/
 void Intro::introSequence() {
-	uint16 counter, counter1;
-
 	uint16 palette[16] = {
 		0x0000, 0x0855, 0x0FF9, 0x0EE7,
 		0x0ED5, 0x0DB4, 0x0CA2, 0x0C91,
@@ -272,7 +268,7 @@ void Intro::introSequence() {
 	} else {
 		nReadPict("WYRMKEEP", true);
 		// Wait 4 seconds
-		for (counter = 0; counter < 4 * 1000 / 10; counter++) {
+		for (uint16 i = 0; i < 4 * 1000 / 10; i++) {
 			introEatMessages();
 			if (_quitIntro)
 				break;
@@ -293,13 +289,13 @@ void Intro::introSequence() {
 
 	FadePalette = palette;
 
-	for (counter = 0; counter < 16; counter++) {
+	for (uint16 i = 0; i < 16; i++) {
 		if (_quitIntro)
 			break;
 
-		palette[counter] = ((diffcmap[counter * 3] >> 2) << 8) +
-		                   ((diffcmap[counter * 3 + 1] >> 2) << 4) +
-		                   (diffcmap[counter * 3 + 2] >> 2);
+		palette[i] = ((diffcmap[i * 3] >> 2) << 8) +
+		                   ((diffcmap[i * 3 + 1] >> 2) << 4) +
+		                   (diffcmap[i * 3 + 2] >> 2);
 	}
 
 	g_music->updateMusic();
@@ -312,8 +308,8 @@ void Intro::introSequence() {
 		g_music->updateMusic();
 		uint16 temp = palette[2];
 
-		for (counter = 2; counter < 15; counter++)
-			palette[counter] = palette[counter + 1];
+		for (uint16 i = 2; i < 15; i++)
+			palette[i] = palette[i + 1];
 
 		palette[15] = temp;
 
@@ -358,10 +354,10 @@ void Intro::introSequence() {
 	nReadPict("Intro.1", true);
 	nopalchange = false;
 
-	for (counter = 0; counter < 16; counter++) {
-		palette[counter] = ((diffcmap[counter * 3] >> 2) << 8) +
-		                   ((diffcmap[counter * 3 + 1] >> 2) << 4) +
-		                   (diffcmap[counter * 3 + 2] >> 2);
+	for (uint16 i = 0; i < 16; i++) {
+		palette[i] = ((diffcmap[i * 3] >> 2) << 8) +
+		             ((diffcmap[i * 3 + 1] >> 2) << 4) +
+		             (diffcmap[i * 3 + 2] >> 2);
 	}
 
 	doPictText("i.1", true);
@@ -399,9 +395,9 @@ void Intro::introSequence() {
 	doPictText("i.11", false);
 
 	if (!_quitIntro)
-		for (counter = 0; counter < 50; counter++) {
-			for (counter1 = (8 * 3); counter1 < (255 * 3); counter1++)
-				diffcmap[counter1] = 255 - diffcmap[counter1];
+		for (uint16 i = 0; i < 50; i++) {
+			for (uint16 idx = (8 * 3); idx < (255 * 3); idx++)
+				diffcmap[idx] = 255 - diffcmap[idx];
 
 			g_music->updateMusic();
 			g_lab->waitTOF();
diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
index 231c63a..fb6b17e 100644
--- a/engines/lab/labfile.cpp
+++ b/engines/lab/labfile.cpp
@@ -86,16 +86,12 @@ static void *getCurMemLabFile(uint32 size) {
 	ptr = MemPlace;
 	MemPlace = (char *)MemPlace + size;
 
-	for (int counter = 0; counter < MAXMARKERS; counter++) {
-		if (FileMarkers[counter].name[0]) {
-			if (((FileMarkers[counter].Start >= ptr) &&
-			        (FileMarkers[counter].Start < MemPlace))  ||
-			        ((FileMarkers[counter].End >= ptr) &&
-			         (FileMarkers[counter].End < MemPlace))    ||
-			        ((ptr >= FileMarkers[counter].Start) &&
-			         (ptr <= FileMarkers[counter].End)))
-
-				freeFile(counter);
+	for (int i = 0; i < MAXMARKERS; i++) {
+		if (FileMarkers[i].name[0]) {
+			if ( ((FileMarkers[i].Start >= ptr) && (FileMarkers[i].Start < MemPlace))
+			  || ((FileMarkers[i].End >= ptr) && (FileMarkers[i].End < MemPlace))
+			  || ((ptr >= FileMarkers[i].Start) && (ptr <= FileMarkers[i].End)))
+				freeFile(i);
 		}
 	}
 
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index fdec095..50a5514 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -63,10 +63,10 @@ void setAmigaPal(uint16 *pal, uint16 numcolors) {
 	if (numcolors > 16)
 		numcolors = 16;
 
-	for (uint16 counter = 0; counter < numcolors; counter++) {
-		vgapal[vgacount++] = (byte)(((pal[counter] & 0xf00) >> 8) << 2);
-		vgapal[vgacount++] = (byte)(((pal[counter] & 0x0f0) >> 4) << 2);
-		vgapal[vgacount++] = (byte)(((pal[counter] & 0x00f)) << 2);
+	for (uint16 i = 0; i < numcolors; i++) {
+		vgapal[vgacount++] = (byte)(((pal[i] & 0xf00) >> 8) << 2);
+		vgapal[vgacount++] = (byte)(((pal[i] & 0x0f0) >> 4) << 2);
+		vgapal[vgacount++] = (byte)(((pal[i] & 0x00f)) << 2);
 	}
 
 	g_lab->writeColorRegsSmooth(vgapal, 0, 16);
@@ -294,18 +294,18 @@ static uint16 fadeNumOut(uint16 num, uint16 res, uint16 counter) {
 /* Does the fading of the Palette on the screen.                             */
 /*****************************************************************************/
 void fade(bool fadein, uint16 res) {
-	uint16 pennum, counter, newpal[16];
+	uint16 newpal[16];
 
-	for (counter = 0; counter < 16; counter++) {
-		for (pennum = 0; pennum < 16; pennum++) {
+	for (uint16 i = 0; i < 16; i++) {
+		for (uint16 palIdx = 0; palIdx < 16; palIdx++) {
 			if (fadein)
-				newpal[pennum] = (0x00F & fadeNumIn(0x00F & FadePalette[pennum], 0x00F & res, counter)) +
-				                 (0x0F0 & fadeNumIn(0x0F0 & FadePalette[pennum], 0x0F0 & res, counter)) +
-				                 (0xF00 & fadeNumIn(0xF00 & FadePalette[pennum], 0xF00 & res, counter));
+				newpal[palIdx] = (0x00F & fadeNumIn(0x00F & FadePalette[palIdx], 0x00F & res, i)) +
+				                 (0x0F0 & fadeNumIn(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) +
+				                 (0xF00 & fadeNumIn(0xF00 & FadePalette[palIdx], 0xF00 & res, i));
 			else
-				newpal[pennum] = (0x00F & fadeNumOut(0x00F & FadePalette[pennum], 0x00F & res, counter)) +
-				                 (0x0F0 & fadeNumOut(0x0F0 & FadePalette[pennum], 0x0F0 & res, counter)) +
-				                 (0xF00 & fadeNumOut(0xF00 & FadePalette[pennum], 0xF00 & res, counter));
+				newpal[palIdx] = (0x00F & fadeNumOut(0x00F & FadePalette[palIdx], 0x00F & res, i)) +
+				                 (0x0F0 & fadeNumOut(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) +
+				                 (0xF00 & fadeNumOut(0xF00 & FadePalette[palIdx], 0xF00 & res, i));
 		}
 
 		setAmigaPal(newpal, 16);
@@ -314,8 +314,6 @@ void fade(bool fadein, uint16 res) {
 	}
 }
 
-
-
 /*****************************************************************************/
 /* Figures out what a room's coordinates should be.                          */
 /*****************************************************************************/
@@ -350,10 +348,6 @@ static void roomCords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16
 	}
 }
 
-
-
-
-
 /*****************************************************************************/
 /* Draws a room to the bitmap.                                               */
 /*****************************************************************************/
@@ -489,28 +483,18 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
 		g_lab->drawImage(XMark, xx, xy);
 }
 
-
-
 /*****************************************************************************/
 /* Checks if a floor has been visitted.                                      */
 /*****************************************************************************/
 static bool onFloor(uint16 Floor) {
-	uint16 drawroom;
-
-	for (drawroom = 1; drawroom <= MaxRooms; drawroom++) {
-		if ((Maps[drawroom].PageNumber == Floor)
-		        && g_lab->_roomsFound->in(drawroom)
-		        && Maps[drawroom].x) {
+	for (uint16 i = 1; i <= MaxRooms; i++) {
+		if ((Maps[i].PageNumber == Floor) && g_lab->_roomsFound->in(i) && Maps[i].x)
 			return true;
-		}
 	}
 
 	return false;
 }
 
-
-
-
 /*****************************************************************************/
 /* Figures out which floor, if any, should be gone to if the up arrow is hit */
 /*****************************************************************************/
@@ -570,7 +554,6 @@ static void getDownFloor(uint16 *Floor, bool *isfloor) {
 /* Draws the map                                                             */
 /*****************************************************************************/
 static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein) {
-	uint16 drawroom;
 	char *sptr;
 
 	uint16 tempfloor;
@@ -587,11 +570,9 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b
 	g_lab->drawImage(Map, 0, 0);
 	drawGadgetList(MapGadgetList);
 
-	for (drawroom = 1; drawroom <= MaxRooms; drawroom++) {
-		if ((Maps[drawroom].PageNumber == Floor)
-		        && g_lab->_roomsFound->in(drawroom)
-		        && Maps[drawroom].x) {
-			drawRoom(drawroom, (bool)(drawroom == CurRoom));
+	for (uint16 i = 1; i <= MaxRooms; i++) {
+		if ((Maps[i].PageNumber == Floor) && g_lab->_roomsFound->in(i) && Maps[i].x) {
+			drawRoom(i, (bool)(i == CurRoom));
 			g_music->updateMusic();
 		}
 	}
@@ -674,14 +655,12 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b
 	mouseShow();
 }
 
-
-
 /*****************************************************************************/
 /* Processes the map.                                                        */
 /*****************************************************************************/
 void processMap(uint16 CurRoom) {
 	uint32 Class, place = 1;
-	uint16 Code, Qualifier, MouseX, MouseY, GadgetID, CurFloor, OldFloor, OldMsg, CurMsg, drawroom, x1, y1, x2, y2;
+	uint16 Code, Qualifier, MouseX, MouseY, GadgetID, CurFloor, OldFloor, OldMsg, CurMsg, x1, y1, x2, y2;
 	char *sptr;
 	byte newcolor[3];
 	bool drawmap;
@@ -804,14 +783,14 @@ void processMap(uint16 CurRoom) {
 				else if (MouseX > mapScaleX(314)) {
 					OldMsg = CurMsg;
 
-					for (drawroom = 1; drawroom <= MaxRooms; drawroom++) {
-						roomCords(drawroom, &x1, &y1, &x2, &y2);
+					for (uint16 i = 1; i <= MaxRooms; i++) {
+						roomCords(i, &x1, &y1, &x2, &y2);
 
-						if ((Maps[drawroom].PageNumber == CurFloor)
-						        && g_lab->_roomsFound->in(drawroom)
+						if ((Maps[i].PageNumber == CurFloor)
+						        && g_lab->_roomsFound->in(i)
 						        && (MouseX >= x1) && (MouseX <= x2)
 						        && (MouseY >= y1) && (MouseY <= y2)) {
-							CurMsg = drawroom;
+							CurMsg = i;
 						}
 					}
 
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index ef483f7..bdfb3fc 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -70,8 +70,6 @@ static Gadget *hitgad = NULL;
 /* of gadgets.                                                               */
 /*****************************************************************************/
 static Gadget *checkGadgetHit(Gadget *gadlist, uint16 x, uint16 y) {
-	uint16 counter;
-
 	while (gadlist != NULL) {
 		if ((x >= gadlist->x) && (y >= gadlist->y) &&
 		        (x <= (gadlist->x + gadlist->Im->Width)) &&
@@ -84,7 +82,7 @@ static Gadget *checkGadgetHit(Gadget *gadlist, uint16 x, uint16 y) {
 				g_lab->drawImage(gadlist->ImAlt, gadlist->x, gadlist->y);
 				mouseShow();
 
-				for (counter = 0; counter < 3; counter++)
+				for (uint16 i = 0; i < 3; i++)
 					g_lab->waitTOF();
 
 				mouseHide();
@@ -133,7 +131,6 @@ void mouseHandler(int32 flag, int32 mouseX, int32 mouseY) {
 }
 
 void updateMouse() {
-	uint16 counter;
 	bool doUpdateDisplay = false;
 
 	if (!MouseHidden)
@@ -144,7 +141,7 @@ void updateMouse() {
 		g_lab->drawImage(hitgad->ImAlt, hitgad->x, hitgad->y);
 		mouseShow();
 
-		for (counter = 0; counter < 3; counter++)
+		for (uint16 i = 0; i < 3; i++)
 			g_lab->waitTOF();
 
 		mouseHide();
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index fd5ec73..ccce27a 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -330,7 +330,6 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 	CloseDataPtr TLCPtr;
 	bool FirstLoaded = true;
 	char **str, *Test;
-	uint16 counter;
 	uint32 StartSecs, StartMicros, CurSecs, CurMicros;
 
 	while (APtr) {
@@ -563,8 +562,8 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 			else if (APtr->Param1 == 2)
 				DoBlack = (CPtr != NULL);
 			else if (APtr->Param1 == 5) { /* inverse the palette */
-				for (counter = (8 * 3); counter < (255 * 3); counter++)
-					diffcmap[counter] = 255 - diffcmap[counter];
+				for (uint16 idx = (8 * 3); idx < (255 * 3); idx++)
+					diffcmap[idx] = 255 - diffcmap[idx];
 
 				g_lab->waitTOF();
 				g_lab->VGASetPal(diffcmap, 256);
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 1ee539f..ea9df4f 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -110,7 +110,6 @@ extern uint16 RoomNum, Direction;
 
 
 static byte *loadBackPict(const char *fileName, bool tomem) {
-	uint16 counter;
 	byte *res = NULL;
 
 	FadePalette = hipal;
@@ -121,10 +120,10 @@ static byte *loadBackPict(const char *fileName, bool tomem) {
 	else
 		readPict(fileName, true);
 
-	for (counter = 0; counter < 16; counter++) {
-		hipal[counter] = ((diffcmap[counter * 3] >> 2) << 8) +
-		                 ((diffcmap[counter * 3 + 1] >> 2) << 4) +
-		                 ((diffcmap[counter * 3 + 2] >> 2));
+	for (uint16 i = 0; i < 16; i++) {
+		hipal[i] = ((diffcmap[i * 3] >> 2) << 8) +
+		           ((diffcmap[i * 3 + 1] >> 2) << 4) +
+		           ((diffcmap[i * 3 + 2] >> 2));
 	}
 
 	nopalchange = false;
@@ -136,17 +135,14 @@ static byte *loadBackPict(const char *fileName, bool tomem) {
 /* Draws the images of the combination lock to the display bitmap.           */
 /*****************************************************************************/
 static void doCombination() {
-	uint16 counter;
-
-	for (counter = 0; counter <= 5; counter++)
-		g_lab->drawImage(Images[combination[counter]], VGAScaleX(combx[counter]), VGAScaleY(65));
+	for (uint16 i = 0; i <= 5; i++)
+		g_lab->drawImage(Images[combination[i]], VGAScaleX(combx[i]), VGAScaleY(65));
 }
 
 /*****************************************************************************/
 /* Reads in a backdrop picture.                                              */
 /*****************************************************************************/
 void showCombination(const char *filename) {
-	uint16 CurBit;
 	byte **buffer;
 
 	resetBuffer();
@@ -159,7 +155,7 @@ void showCombination(const char *filename) {
 
 	buffer = g_music->newOpen("P:Numbers");
 
-	for (CurBit = 0; CurBit < 10; CurBit++)
+	for (uint16 CurBit = 0; CurBit < 10; CurBit++)
 		readImage(buffer, &(Images[CurBit]));
 
 	allocFile((void **)&g_lab->_tempScrollData, Images[0]->Width * Images[0]->Height * 2L, "tempdata");
@@ -176,7 +172,7 @@ void showCombination(const char *filename) {
 /*****************************************************************************/
 static void changeCombination(uint16 number) {
 	Image display;
-	uint16 counter, combnum;
+	uint16 combnum;
 	bool unlocked = true;
 
 	if (combination[number] < 9)
@@ -190,9 +186,9 @@ static void changeCombination(uint16 number) {
 	display.Width     = g_lab->_screenWidth;
 	display.Height    = g_lab->_screenHeight;
 
-	for (counter = 1; counter <= (Images[combnum]->Height / 2); counter++) {
+	for (uint16 i = 1; i <= (Images[combnum]->Height / 2); i++) {
 		if (IsHiRes) {
-			if (counter & 1)
+			if (i & 1)
 				g_lab->waitTOF();
 		} else
 			g_lab->waitTOF();
@@ -201,11 +197,11 @@ static void changeCombination(uint16 number) {
 
 		g_lab->scrollDisplayY(2, VGAScaleX(combx[number]), VGAScaleY(65), VGAScaleX(combx[number]) + (Images[combnum])->Width - 1, VGAScaleY(65) + (Images[combnum])->Height);
 
-		g_lab->bltBitMap(Images[combnum], 0, (Images[combnum])->Height - (2 * counter), &(display), VGAScaleX(combx[number]), VGAScaleY(65), (Images[combnum])->Width, 2);
+		g_lab->bltBitMap(Images[combnum], 0, (Images[combnum])->Height - (2 * i), &(display), VGAScaleX(combx[number]), VGAScaleY(65), (Images[combnum])->Width, 2);
 	}
 
-	for (counter = 0; counter < 6; counter++)
-		unlocked = (combination[counter] == solution[counter]) && unlocked;
+	for (uint16 i = 0; i < 6; i++)
+		unlocked = (combination[i] == solution[i]) && unlocked;
 
 	if (unlocked)
 		g_lab->_conditions->inclElement(COMBINATIONUNLOCKED);
@@ -289,7 +285,7 @@ static void doTile(bool showsolution) {
 /* Reads in a backdrop picture.                                              */
 /*****************************************************************************/
 void showTile(const char *filename, bool showsolution) {
-	uint16 CurBit, start;
+	uint16 start;
 	byte **buffer;
 
 	resetBuffer();
@@ -310,8 +306,8 @@ void showTile(const char *filename, bool showsolution) {
 	if (!buffer)
 		return;
 
-	for (CurBit = start; CurBit < 16; CurBit++)
-		readImage(buffer, &(Tiles[CurBit]));
+	for (uint16 curBit = start; curBit < 16; curBit++)
+		readImage(buffer, &(Tiles[curBit]));
 
 	allocFile((void **)&g_lab->_tempScrollData, Tiles[1]->Width * Tiles[1]->Height * 2L, "tempdata");
 
@@ -334,7 +330,6 @@ static void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, ui
 static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 	int16 dX = 0, dY = 0, dx = 0, dy = 0, sx = 0, sy = 0;
 	uint16 last = 0, x1, y1;
-	uint16 counter;
 
 	if (scrolltype == LEFTSCROLL) {
 		dX =  VGAScaleX(5);
@@ -361,7 +356,7 @@ static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 	x1 = VGAScaleX(100) + (col * VGAScaleX(30)) + dx;
 	y1 = VGAScaleY(25) + (row * VGAScaleY(25)) + dy;
 
-	for (counter = 0; counter < last; counter++) {
+	for (uint16 i = 0; i < last; i++) {
 		g_lab->waitTOF();
 		scrollRaster(dX, dY, x1, y1, x1 + VGAScaleX(28) + sx, y1 + VGAScaleY(23) + sy);
 		x1 += dX;
@@ -549,7 +544,6 @@ static bool loadJournalData() {
 	byte **buffer;
 	char filename[20];
 	Gadget *TopGadget = &BackG;
-	uint16 counter;
 	bool bridge, dirty, news, clean;
 
 	BigMsgFont = &bmfont;
@@ -607,7 +601,7 @@ static bool loadJournalData() {
 	BackG.KeyEquiv = VKEY_LTARROW;
 	ForwardG.KeyEquiv = VKEY_RTARROW;
 
-	counter = 0;
+	uint16 counter = 0;
 
 	while (TopGadget) {
 		TopGadget->x = VGAScaleX(JGadX[counter]);
@@ -667,21 +661,19 @@ static void drawJournalText() {
 /* Does the turn page wipe.                                                  */
 /*****************************************************************************/
 static void turnPage(bool FromLeft) {
-	uint16 counter;
-
 	if (FromLeft) {
-		for (counter = 0; counter < g_lab->_screenWidth; counter += 8) {
+		for (int i = 0; i < g_lab->_screenWidth; i += 8) {
 			g_music->updateMusic();
 			g_lab->waitTOF();
 			ScreenImage.ImageData = g_lab->getVGABaseAddr();
-			g_lab->bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, g_lab->_screenHeight);
+			g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight);
 		}
 	} else {
-		for (counter = (g_lab->_screenWidth - 8); counter > 0; counter -= 8) {
+		for (int i = (g_lab->_screenWidth - 8); i > 0; i -= 8) {
 			g_music->updateMusic();
 			g_lab->waitTOF();
 			ScreenImage.ImageData = g_lab->getVGABaseAddr();
-			g_lab->bltBitMap(&JBackImage, counter, 0, &ScreenImage, counter, 0, 8, g_lab->_screenHeight);
+			g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight);
 		}
 	}
 }
@@ -878,7 +870,7 @@ static void getMonImages() {
 /* Draws the text for the monitor.                                           */
 /*****************************************************************************/
 static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) {
-	uint16 DrawingToPage = 0, yspacing = 0, numlines, fheight, counter;
+	uint16 DrawingToPage = 0, yspacing = 0, numlines, fheight;
 	int32 CharsDrawn    = 0L;
 	char *CurText = text;
 
@@ -903,8 +895,8 @@ static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2,
 		g_lab->setAPen(0);
 		g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, y2);
 
-		for (counter = 0; counter < numlines; counter++)
-			g_lab->drawImage(MonButton, 0, counter * MonGadHeight);
+		for (uint16 i = 0; i < numlines; i++)
+			g_lab->drawImage(MonButton, 0, i * MonGadHeight);
 	} else if (isinteractive) {
 		g_lab->setAPen(0);
 		g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, y2);
diff --git a/engines/lab/text.cpp b/engines/lab/text.cpp
index cf920d3..10e4ac8 100644
--- a/engines/lab/text.cpp
+++ b/engines/lab/text.cpp
@@ -51,19 +51,18 @@ void closeFont(struct TextFont *tf) {
 /* Returns the length of a text in the specified font.                       */
 /*****************************************************************************/
 uint16 textLength(struct TextFont *tf, const char *text, uint16 numchars) {
-	uint16 counter, length = 0;
+	uint16 length = 0;
 
-	if (tf)
-		for (counter = 0; counter < numchars; counter++) {
+	if (tf) {
+		for (uint16 i = 0; i < numchars; i++) {
 			length += tf->Widths[(uint)*text];
 			text++;
 		}
+	}
 
 	return length;
 }
 
-
-
 /*****************************************************************************/
 /* Returns the height of a specified font.                                   */
 /*****************************************************************************/
@@ -78,11 +77,11 @@ void text(struct TextFont *tf, uint16 x, uint16 y, uint16 color, const char *tex
 	byte *VGATop, *VGACur, *VGATemp, *VGATempLine, *cdata;
 	uint32 RealOffset, SegmentOffset;
 	int32 templeft, LeftInSegment;
-	uint16 counter, counterb, bwidth, mask, curpage, rows, cols, data;
+	uint16 bwidth, mask, curpage, data;
 
 	VGATop = g_lab->getVGABaseAddr();
 
-	for (counter = 0; counter < numchars; counter++) {
+	for (uint16 i = 0; i < numchars; i++) {
 		RealOffset = (g_lab->_screenWidth * y) + x;
 		curpage    = RealOffset / g_lab->_screenBytesPerPage;
 		SegmentOffset = RealOffset - (curpage * g_lab->_screenBytesPerPage);
@@ -95,16 +94,16 @@ void text(struct TextFont *tf, uint16 x, uint16 y, uint16 color, const char *tex
 			VGATemp = VGACur;
 			VGATempLine = VGACur;
 
-			for (rows = 0; rows < tf->Height; rows++) {
+			for (uint16 rows = 0; rows < tf->Height; rows++) {
 				VGATemp = VGATempLine;
 				templeft = LeftInSegment;
 
-				for (cols = 0; cols < bwidth; cols++) {
+				for (uint16 cols = 0; cols < bwidth; cols++) {
 					data = *cdata++;
 
 					if (data && (templeft >= 8)) {
-						for (int i = 7; i >= 0; i--) {
-							if ((1 << i) & data)
+						for (int j = 7; j >= 0; j--) {
+							if ((1 << j) & data)
 								*VGATemp = color;
 							VGATemp++;
 						}
@@ -114,7 +113,7 @@ void text(struct TextFont *tf, uint16 x, uint16 y, uint16 color, const char *tex
 						mask = 0x80;
 						templeft = LeftInSegment;
 
-						for (counterb = 0; counterb < 8; counterb++) {
+						for (uint16 counterb = 0; counterb < 8; counterb++) {
 							if (templeft <= 0) {
 								curpage++;
 								VGATemp = (byte *)(VGATop - templeft);
diff --git a/engines/lab/undiff.cpp b/engines/lab/undiff.cpp
index f7610d9..2b22496 100644
--- a/engines/lab/undiff.cpp
+++ b/engines/lab/undiff.cpp
@@ -371,14 +371,11 @@ void runLengthDecode(byte *Dest, byte *Source) {
 void VRunLengthDecode(byte *Dest, byte *Source, uint16 bytesperrow) {
 	int8 num;
 	int16 count;
-	uint16 Counter;
-	byte *Top;
+	byte *Top = Dest;
 
-	Top = Dest;
-
-	for (Counter = 0; Counter < DataBytesPerRow; Counter++) {
+	for (uint16 i = 0; i < DataBytesPerRow; i++) {
 		Dest = Top;
-		Dest += Counter;
+		Dest += i;
 
 		num = (int8)*Source;
 		Source++;


Commit: c485d9e8a616d475f9155de084012062fe9e5dc8
    https://github.com/scummvm/scummvm/commit/c485d9e8a616d475f9155de084012062fe9e5dc8
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:43+01:00

Commit Message:
LAB: Some rework related to the mouse code

Changed paths:
    engines/lab/engine.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/labfun.h
    engines/lab/machine.cpp
    engines/lab/mouse.cpp
    engines/lab/mouse.h
    engines/lab/parsefun.h
    engines/lab/processroom.cpp
    engines/lab/special.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 2d85dda..837529b 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -638,7 +638,7 @@ void LabEngine::mainGameLoop() {
 	IntuiMessage *Msg;
 	uint32 Class;
 
-	uint16 Qualifier, MouseX, MouseY, ActionMode = 4;
+	uint16 Qualifier, ActionMode = 4;
 	uint16 CurInv = MAPNUM, LastInv = MAPNUM, Old;
 
 	bool ForceDraw = false, doit, GotMessage = true;
@@ -742,6 +742,7 @@ void LabEngine::mainGameLoop() {
 		interfaceOn();
 		Msg = getMsg();
 
+		Common::Point curPos;
 		if (Msg == NULL) { /* Does music load and next animation frame when you've run out of messages */
 			GotMessage = false;
 			g_music->checkRoomMusic();
@@ -752,22 +753,16 @@ void LabEngine::mainGameLoop() {
 				int result = followCrumbs();
 
 				if (result != 0) {
-					int x = 0, y = 0;
-
-					WSDL_GetMousePos(&x, &y);
-
+					curPos = WSDL_GetMousePos();
 					Class     = GADGETUP;
 					Qualifier = 0;
-					MouseX    = x;
-					MouseY    = y;
 
-					if (result == VKEY_UPARROW) {
+					if (result == VKEY_UPARROW)
 						code = GadID = 7;
-					} else if (result == VKEY_LTARROW) {
+					else if (result == VKEY_LTARROW)
 						code = GadID = 6;
-					} else if (result == VKEY_RTARROW) {
+					else if (result == VKEY_RTARROW)
 						code = GadID = 8;
-					}
 
 					GotMessage = true;
 					mayShowCrumbIndicator();
@@ -784,8 +779,8 @@ void LabEngine::mainGameLoop() {
 			Class     = Msg->msgClass;
 			code      = Msg->code;
 			Qualifier = Msg->qualifier;
-			MouseX    = Msg->mouseX;
-			MouseY    = Msg->mouseY;
+			curPos.x  = Msg->mouseX;
+			curPos.y  = Msg->mouseY;
 			GadID     = Msg->gadgetID;
 
 			FollowingCrumbs = false;
@@ -797,7 +792,7 @@ from_crumbs:
 				if (code == 13) { /* The return key */
 					Class     = MOUSEBUTTONS;
 					Qualifier = IEQUALIFIER_LEFTBUTTON;
-					mouseXY(&MouseX, &MouseY);
+					curPos = getMousePos();
 				} else if (g_lab->getPlatform() == Common::kPlatformWindows &&
 						(code == 'b' || code == 'B')) {  /* Start bread crumbs */
 					BreadCrumbs[0].RoomNum = 0;
@@ -1169,10 +1164,10 @@ from_crumbs:
 				doit = false;
 
 				if (CPtr) {
-					if ((CPtr->CloseUpType == SPECIALLOCK) && MainDisplay) /* LAB: Labrinth specific code */
-						mouseCombination(MouseX, MouseY);
+					if ((CPtr->CloseUpType == SPECIALLOCK) && MainDisplay) /* LAB: Labyrinth specific code */
+						mouseCombination(curPos);
 					else if ((CPtr->CloseUpType == SPECIALBRICK) && MainDisplay)
-						mouseTile(MouseX, MouseY);
+						mouseTile(curPos);
 					else
 						doit = true;
 				} else
@@ -1184,48 +1179,48 @@ from_crumbs:
 					eatMessages();
 
 					if (ActionMode == 0) { /* Take something. */
-						if (doActionRule(MouseX, MouseY, ActionMode, RoomNum, &CPtr))
+						if (doActionRule(Common::Point(curPos.x, curPos.y), ActionMode, RoomNum, &CPtr))
 							CurFileName = NewFileName;
-						else if (takeItem(MouseX, MouseY, &CPtr))
+						else if (takeItem(curPos.x, curPos.y, &CPtr))
 							drawStaticMessage(kTextTakeItem);
-						else if (doActionRule(MouseX, MouseY, TAKEDEF - 1, RoomNum, &CPtr))
+						else if (doActionRule(curPos, TAKEDEF - 1, RoomNum, &CPtr))
 							CurFileName = NewFileName;
-						else if (doActionRule(MouseX, MouseY, TAKE - 1, 0, &CPtr))
+						else if (doActionRule(curPos, TAKE - 1, 0, &CPtr))
 							CurFileName = NewFileName;
-						else if (MouseY < (VGAScaleY(149) + SVGACord(2)))
+						else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
 							drawStaticMessage(kTextNothing);
 					} else if ((ActionMode == 1) /* Manipulate an object */  ||
 					         (ActionMode == 2) /* Open up a "door" */      ||
 					         (ActionMode == 3)) { /* Close a "door" */
-						if (doActionRule(MouseX, MouseY, ActionMode, RoomNum, &CPtr))
+						if (doActionRule(curPos, ActionMode, RoomNum, &CPtr))
 							CurFileName = NewFileName;
-						else if (!doActionRule(MouseX, MouseY, ActionMode, 0, &CPtr)) {
-							if (MouseY < (VGAScaleY(149) + SVGACord(2)))
+						else if (!doActionRule(curPos, ActionMode, 0, &CPtr)) {
+							if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
 								drawStaticMessage(kTextNothing);
 						}
 					} else if (ActionMode == 4) { /* Look at closeups */
 						TempCPtr = CPtr;
-						setCurClose(MouseX, MouseY, &TempCPtr);
+						setCurClose(curPos, &TempCPtr);
 
 						if (CPtr == TempCPtr) {
-							if (MouseY < (VGAScaleY(149) + SVGACord(2)))
+							if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
 								drawStaticMessage(kTextNothing);
 						} else if (TempCPtr->GraphicName) {
 							if (*(TempCPtr->GraphicName)) {
 								DoBlack = true;
 								CPtr = TempCPtr;
-							} else if (MouseY < (VGAScaleY(149) + SVGACord(2)))
+							} else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
 								drawStaticMessage(kTextNothing);
-						} else if (MouseY < (VGAScaleY(149) + SVGACord(2)))
+						} else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
 							drawStaticMessage(kTextNothing);
 					} else if ((ActionMode == 5)  &&
 					         g_lab->_conditions->in(CurInv)) { /* Use an item on something else */
-						if (doOperateRule(MouseX, MouseY, CurInv, &CPtr)) {
+						if (doOperateRule(curPos.x, curPos.y, CurInv, &CPtr)) {
 							CurFileName = NewFileName;
 
 							if (!g_lab->_conditions->in(CurInv))
 								decIncInv(&CurInv, false);
-						} else if (MouseY < (VGAScaleY(149) + SVGACord(2)))
+						} else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
 							drawStaticMessage(kTextNothing);
 					}
 				}
@@ -1238,7 +1233,7 @@ from_crumbs:
 
 				if (HCPtr == NULL) {
 					TempCPtr = CPtr;
-					setCurClose(MouseX, MouseY, &TempCPtr);
+					setCurClose(curPos, &TempCPtr);
 
 					if ((TempCPtr == NULL) || (TempCPtr == CPtr)) {
 						if (CPtr == NULL)
@@ -1259,7 +1254,7 @@ from_crumbs:
 				}
 
 				if (HCPtr)
-					mouseMove(scaleX((HCPtr->x1 + HCPtr->x2) / 2), scaleY((HCPtr->y1 + HCPtr->y2) / 2));
+					setMousePos(Common::Point(scaleX((HCPtr->x1 + HCPtr->x2) / 2), scaleY((HCPtr->y1 + HCPtr->y2) / 2)));
 			} else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) {
 				eatMessages();
 				Alternate = !Alternate;
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index fcd826b..92607d4 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -66,12 +66,11 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 
     _lastWaitTOFTicks = 0;
 
-    _mouseX = 0;
-    _mouseY = 0;
+	_mousePos = Common::Point(0, 0);
+	_mouseAtEdge = false;
 
-     _nextKeyIn = 0;
+    _nextKeyIn = 0;
     _nextKeyOut = 0;
-    _mouseAtEdge = false;
 
 	//const Common::FSNode gameDataDir(ConfMan.get("path"));
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 36e2a43..659637d 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -32,6 +32,7 @@
 #define LAB_H
 
 #include "common/array.h"
+#include "common/events.h"
 
 #include "engines/engine.h"
 #include "lab/labfun.h"
@@ -96,9 +97,7 @@ private:
 
 public:
 	byte *_currentDsplayBuffer;
-
-	uint32 _mouseX;
-	uint32 _mouseY;
+	Common::Point _mousePos;
 
 private:
 	byte *_displayBuffer;
@@ -145,7 +144,7 @@ private:
 	/*---------- Drawing Routines ----------*/
 
 	void drawMaskImage(Image *Im, uint16 x, uint16 y);
-	void WSDL_GetMousePos(int *x, int *y);
+	Common::Point WSDL_GetMousePos();
 	void changeVolume(int delta);
 	void WSDL_SetColors(byte *buf, uint16 first, uint16 numreg, uint16 slow);
 
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 1d2b5c6..f602d60 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -31,6 +31,7 @@
 #ifndef LAB_LABFUN_H
 #define LAB_LABFUN_H
 
+#include "common/events.h"
 #include "lab/stddefines.h"
 #include "lab/parsetypes.h"
 
@@ -228,8 +229,8 @@ uint16 scaleY(uint16 y);
 int16 VGAScaleX(int16 x);
 int16 VGAScaleY(int16 y);
 uint16 SVGACord(uint16 cord);
-uint16 VGAUnScaleX(uint16 x);
-uint16 VGAUnScaleY(uint16 y);
+int VGAUnScaleX(int x);
+int VGAUnScaleY(int y);
 char *translateFileName(const char *filename);
 
 /*---------------------------*/
@@ -260,9 +261,9 @@ bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header);
 /*--------------------------*/
 
 void showCombination(const char *filename);
-void mouseCombination(uint16 x, uint16 y);
+void mouseCombination(Common::Point pos);
 void showTile(const char *filename, bool showsolution);
-void mouseTile(uint16 x, uint16 y);
+void mouseTile(Common::Point pos);
 
 } // End of namespace Lab
 
diff --git a/engines/lab/machine.cpp b/engines/lab/machine.cpp
index ede75e0..b2ce65e 100644
--- a/engines/lab/machine.cpp
+++ b/engines/lab/machine.cpp
@@ -88,7 +88,7 @@ uint16 SVGACord(uint16 cord) {
 /*****************************************************************************/
 /* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
 /*****************************************************************************/
-uint16 VGAUnScaleX(uint16 x) {
+int VGAUnScaleX(int x) {
 	if (IsHiRes)
 		return (x / 2);
 	else
@@ -98,7 +98,7 @@ uint16 VGAUnScaleX(uint16 x) {
 /*****************************************************************************/
 /* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
 /*****************************************************************************/
-uint16 VGAUnScaleY(uint16 y) {
+int VGAUnScaleY(int y) {
 	if (IsHiRes)
 		return ((y * 5) / 12);
 	else
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index bdfb3fc..4fc8644 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -69,12 +69,12 @@ static Gadget *hitgad = NULL;
 /* Checks whether or not the cords fall within one of the gadgets in a list  */
 /* of gadgets.                                                               */
 /*****************************************************************************/
-static Gadget *checkGadgetHit(Gadget *gadlist, uint16 x, uint16 y) {
+static Gadget *checkGadgetHit(Gadget *gadlist, Common::Point pos) {
 	while (gadlist != NULL) {
-		if ((x >= gadlist->x) && (y >= gadlist->y) &&
-		        (x <= (gadlist->x + gadlist->Im->Width)) &&
-		        (y <= (gadlist->y + gadlist->Im->Height)) &&
-		        !(GADGETOFF & gadlist->GadgetFlags)) {
+		if ((pos.x >= gadlist->x) && (pos.y >= gadlist->y) &&
+		    (pos.x <= (gadlist->x + gadlist->Im->Width)) &&
+		    (pos.y <= (gadlist->y + gadlist->Im->Height)) &&
+		     !(GADGETOFF & gadlist->GadgetFlags)) {
 			if (IsHiRes) {
 				hitgad = gadlist;
 			} else {
@@ -108,17 +108,14 @@ void attachGadgetList(Gadget *GadList) {
 	ScreenGadgetList = GadList;
 }
 
-void mouseHandler(int32 flag, int32 mouseX, int32 mouseY) {
+void mouseHandler(int flag, Common::Point pos) {
 	if (NumHidden >= 2)
 		return;
 
-	if (!IsHiRes)
-		mouseX /= 2;
-
 	if (flag & 0x02) { /* Left mouse button click */
 		Gadget *tmp = NULL;
 		if (ScreenGadgetList)
-			tmp = checkGadgetHit(ScreenGadgetList, mouseX, mouseY);
+			tmp = checkGadgetHit(ScreenGadgetList, IsHiRes ? pos : Common::Point(pos.x / 2, pos.y));
 
 		if (tmp)
 			LastGadgetHit = tmp;
@@ -163,7 +160,7 @@ void initMouse() {
 	g_system->setMouseCursor(MouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0);
 	g_system->showMouse(false);
 
-	mouseMove(0, 0);
+	setMousePos(Common::Point(0, 0));
 }
 
 
@@ -199,23 +196,22 @@ void mouseHide() {
 /* Gets the current mouse co-ordinates.  NOTE: On IBM version, will scale    */
 /* from virtual to screen co-ordinates automatically.                        */
 /*****************************************************************************/
-void mouseXY(uint16 *x, uint16 *y) {
-	*x = (uint16)g_lab->_mouseX;
-	*y = (uint16)g_lab->_mouseY;
-
-	if (!IsHiRes)
-		(*x) /= 2;
+Common::Point getMousePos() {
+	if (IsHiRes)
+		return g_lab->_mousePos;
+	else
+		return Common::Point(g_lab->_mousePos.x / 2, g_lab->_mousePos.y);
 }
 
 
 /*****************************************************************************/
 /* Moves the mouse to new co-ordinates.                                      */
 /*****************************************************************************/
-void mouseMove(uint16 x, uint16 y) {
-	if (!IsHiRes)
-		x *= 2;
-
-	g_system->warpMouse(x, y);
+void setMousePos(Common::Point pos) {
+	if (IsHiRes)
+		g_system->warpMouse(pos.x, pos.y);
+	else
+		g_system->warpMouse(pos.x * 2, pos.y);
 
 	if (!MouseHidden)
 		g_lab->WSDL_ProcessInput(0);
@@ -230,15 +226,15 @@ void mouseMove(uint16 x, uint16 y) {
 bool mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
 	if (leftbutton) {
 		if (LeftClick) {
-			*x = (!IsHiRes) ? (uint16)g_lab->_mouseX / 2 : (uint16)g_lab->_mouseX;
-			*y = (uint16)g_lab->_mouseY;
+			*x = (!IsHiRes) ? (uint16)g_lab->_mousePos.x / 2 : (uint16)g_lab->_mousePos.x;
+			*y = (uint16)g_lab->_mousePos.y;
 			LeftClick = false;
 			return true;
 		}
 	} else {
 		if (RightClick) {
-			*x = (!IsHiRes) ? (uint16)g_lab->_mouseX / 2 : (uint16)g_lab->_mouseX;
-			*y = (uint16)g_lab->_mouseY;
+			*x = (!IsHiRes) ? (uint16)g_lab->_mousePos.x / 2 : (uint16)g_lab->_mousePos.x;
+			*y = (uint16)g_lab->_mousePos.y;
 			RightClick = false;
 			return true;
 		}
diff --git a/engines/lab/mouse.h b/engines/lab/mouse.h
index 5dd77fb..489bb1e 100644
--- a/engines/lab/mouse.h
+++ b/engines/lab/mouse.h
@@ -28,6 +28,7 @@
  *
  */
 
+#include "common/events.h"
 #include "lab/stddefines.h"
 
 #ifndef LAB_MOUSE_H
@@ -45,9 +46,9 @@ void mouseShow();
 
 void mouseHide();
 
-void mouseXY(uint16 *x, uint16 *y);
+Common::Point getMousePos();
 
-void mouseMove(uint16 x, uint16 y);
+void setMousePos(Common::Point pos);
 
 bool mouseButton(uint16 *x, uint16 *y, bool leftbutton);
 
@@ -55,7 +56,7 @@ Gadget *mouseGadget();
 
 void attachGadgetList(Gadget *GadList);
 
-void mouseHandler(int32 flag, int32 mouseX, int32 mouseY);
+void mouseHandler(int flag, Common::Point pos);
 
 } // End of namespace Lab
 
diff --git a/engines/lab/parsefun.h b/engines/lab/parsefun.h
index 672d19a..f376a23 100644
--- a/engines/lab/parsefun.h
+++ b/engines/lab/parsefun.h
@@ -55,9 +55,9 @@ ViewData *getViewData(uint16 RoomNum, uint16 Direction);
 char *getPictName(CloseDataPtr *LCPtr);
 void drawDirection(CloseDataPtr LCPtr);
 bool processArrow(uint16 *Direction, uint16 Arrow);
-void setCurClose(uint16 x, uint16 y, CloseDataPtr *cptr, bool useAbsoluteCoords = false);
+void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords = false);
 bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr);
-bool doActionRule(int16 x, int16 y, int16 action, int16 RoomNum, CloseDataPtr *LCPtr);
+bool doActionRule(Common::Point pos, int16 action, int16 RoomNum, CloseDataPtr *LCPtr);
 bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *LCPtr);
 bool doGoForward(CloseDataPtr *LCPtr);
 bool doTurn(uint16 from, uint16 to, CloseDataPtr *LCPtr);
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index ccce27a..37c21d8 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -259,7 +259,7 @@ bool processArrow(uint16 *direction, uint16 Arrow) {
 /*****************************************************************************/
 /* Sets the current close up data.                                           */
 /*****************************************************************************/
-void setCurClose(uint16 x, uint16 y, CloseDataPtr *cptr, bool useAbsoluteCoords) {
+void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords) {
 	ViewData *VPtr;
 	CloseDataPtr LCPtr;
 	uint16 x1, y1, x2, y2;
@@ -283,7 +283,7 @@ void setCurClose(uint16 x, uint16 y, CloseDataPtr *cptr, bool useAbsoluteCoords)
 			y2 = scaleY(LCPtr->y2);
 		}
 
-		if (x >= x1 && y >= y1 && x <= x2 && y <= y2 && LCPtr->GraphicName) {
+		if (pos.x >= x1 && pos.y >= y1 && pos.x <= x2 && pos.y <= y2 && LCPtr->GraphicName) {
 			*cptr = LCPtr;
 			return;
 		}
@@ -640,7 +640,7 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr LCPtr, Clo
 /*****************************************************************************/
 /* Goes through the rules if an action is taken.                             */
 /*****************************************************************************/
-bool doActionRule(int16 x, int16 y, int16 action, int16 roomNum, CloseDataPtr *LCPtr) {
+bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *LCPtr) {
 	CloseDataPtr TLCPtr;
 
 	if (roomNum)
@@ -648,7 +648,7 @@ bool doActionRule(int16 x, int16 y, int16 action, int16 roomNum, CloseDataPtr *L
 	else
 		NewFileName = CurFileName;
 
-	TLCPtr = getObject(x, y, *LCPtr);
+	TLCPtr = getObject(pos.x, pos.y, *LCPtr);
 
 	if (doActionRuleSub(action, roomNum, TLCPtr, LCPtr, false))
 		return true;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index ea9df4f..00ac19f 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -213,11 +213,11 @@ static void changeCombination(uint16 number) {
 /*****************************************************************************/
 /* Processes mouse clicks and changes the combination.                       */
 /*****************************************************************************/
-void mouseCombination(uint16 x, uint16 y) {
+void mouseCombination(Common::Point pos) {
 	uint16 number;
 
-	x = VGAUnScaleX(x);
-	y = VGAUnScaleY(y);
+	int x = VGAUnScaleX(pos.x);
+	int y = VGAUnScaleY(pos.y);
 
 	if ((y >= 63) && (y <= 99)) {
 		if ((x >= 44) && (x < 83))
@@ -437,9 +437,9 @@ static void changeTile(uint16 col, uint16 row) {
 /*****************************************************************************/
 /* Processes mouse clicks and changes the combination.                       */
 /*****************************************************************************/
-void mouseTile(uint16 x, uint16 y) {
-	x = VGAUnScaleX(x);
-	y = VGAUnScaleY(y);
+void mouseTile(Common::Point pos) {
+	int x = VGAUnScaleX(pos.x);
+	int y = VGAUnScaleY(pos.y);
 
 	if ((x < 101) || (y < 26))
 		return;
@@ -1007,7 +1007,7 @@ static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1
 					TestCPtr = CPtr;
 					MouseY = 64 + (MouseY / MonGadHeight) * 42;
 					MouseX = 101;
-					setCurClose(MouseX, MouseY, &CPtr, true);
+					setCurClose(Common::Point(MouseX, MouseY), &CPtr, true);
 
 					if (TestCPtr != CPtr) {
 						LastCPtr[depth] = TestCPtr;
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 73d8cf3..63443ca 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -90,40 +90,39 @@ void LabEngine::WSDL_ProcessInput(bool can_delay) {
 			switch (event.type) {
 			case Common::EVENT_RBUTTONDOWN:
 				flags |= 8;
-				mouseHandler(flags, _mouseX, _mouseY);
+				mouseHandler(flags, _mousePos);
 				break;
 
 			case Common::EVENT_LBUTTONDOWN:
 				flags |= 2;
-				mouseHandler(flags, _mouseX, _mouseY);
+				mouseHandler(flags, _mousePos);
 				break;
 
 			case Common::EVENT_MOUSEMOVE: {
 				int lastMouseAtEdge = _mouseAtEdge;
 				_mouseAtEdge = false;
-				_mouseX = event.mouse.x;
+				_mousePos.x = event.mouse.x;
 				if (event.mouse.x <= 0) {
-					_mouseX = 0;
+					_mousePos.x = 0;
 					_mouseAtEdge = true;
 				}
-				if (_mouseX > g_lab->_screenWidth - 1) {
-					_mouseX = g_lab->_screenWidth;
+				if (_mousePos.x > g_lab->_screenWidth - 1) {
+					_mousePos.x = g_lab->_screenWidth;
 					_mouseAtEdge = true;
 				}
 
-				_mouseY = event.mouse.y;
+				_mousePos.y = event.mouse.y;
 				if (event.mouse.y <= 0) {
-					_mouseY = 0;
+					_mousePos.y = 0;
 					_mouseAtEdge = true;
 				}
-				if (_mouseY > g_lab->_screenHeight - 1) {
-					_mouseY = g_lab->_screenHeight;
+				if (_mousePos.y > g_lab->_screenHeight - 1) {
+					_mousePos.y = g_lab->_screenHeight;
 					_mouseAtEdge = true;
 				}
 
 				if (!lastMouseAtEdge || !_mouseAtEdge)
-					mouseHandler(1, _mouseX, _mouseY);
-
+					mouseHandler(1, _mousePos);
 				}
 				break;
 
@@ -167,11 +166,10 @@ void LabEngine::WSDL_ProcessInput(bool can_delay) {
 		g_system->delayMillis(10);
 }
 
-void LabEngine::WSDL_GetMousePos(int *x, int *y) {
+Common::Point LabEngine::WSDL_GetMousePos() {
 	WSDL_ProcessInput(0);
 
-	*x = _mouseX;
-	*y = _mouseY;
+	return _mousePos;
 }
 
 void LabEngine::waitTOF() {
@@ -278,13 +276,13 @@ void LabEngine::drawImage(Image *Im, uint16 x, uint16 y) {
 		dy = 0;
 	}
 
-	if ((uint)(dx + w) > g_lab->_screenWidth)
+	if (dx + w > g_lab->_screenWidth)
 		w = g_lab->_screenWidth - dx;
 
-	if ((uint)(dy + h) > g_lab->_screenHeight)
+	if (dy + h > g_lab->_screenHeight)
 		h = g_lab->_screenHeight - dy;
 
-	if (w > 0 && h > 0) {
+	if ((w > 0) && (h > 0)) {
 		byte *s = Im->ImageData + sy * Im->Width + sx;
 		byte *d = getVGABaseAddr() + dy * g_lab->_screenWidth + dx;
 
@@ -321,13 +319,13 @@ void LabEngine::drawMaskImage(Image *Im, uint16 x, uint16 y) {
 		dy = 0;
 	}
 
-	if ((uint)(dx + w) > g_lab->_screenWidth)
+	if (dx + w > g_lab->_screenWidth)
 		w = g_lab->_screenWidth - dx;
 
-	if ((uint)(dy + h) > g_lab->_screenHeight)
+	if (dy + h > g_lab->_screenHeight)
 		h = g_lab->_screenHeight - dy;
 
-	if (w > 0 && h > 0) {
+	if ((w > 0) && (h > 0)) {
 		byte *s = Im->ImageData + sy * Im->Width + sx;
 		byte *d = getVGABaseAddr() + dy * g_lab->_screenWidth + dx;
 
@@ -374,13 +372,13 @@ void LabEngine::readScreenImage(Image *Im, uint16 x, uint16 y) {
 		dy = 0;
 	}
 
-	if ((uint)(dx + w) > g_lab->_screenWidth)
+	if (dx + w > g_lab->_screenWidth)
 		w = g_lab->_screenWidth - dx;
 
-	if ((uint)(dy + h) > g_lab->_screenHeight)
+	if (dy + h > g_lab->_screenHeight)
 		h = g_lab->_screenHeight - dy;
 
-	if (w > 0 && h > 0) {
+	if ((w > 0) && (h > 0)) {
 		byte *s = Im->ImageData + sy * Im->Width + sx;
 		byte *d = getVGABaseAddr() + dy * g_lab->_screenWidth + dx;
 
@@ -551,13 +549,13 @@ void LabEngine::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 		dy = 0;
 	}
 
-	if ((uint)(dx + w) > g_lab->_screenWidth)
+	if (dx + w > g_lab->_screenWidth)
 		w = g_lab->_screenWidth - dx;
 
-	if ((uint)(dy + h) > g_lab->_screenHeight)
+	if (dy + h > g_lab->_screenHeight)
 		h = g_lab->_screenHeight - dy;
 
-	if (w > 0 && h > 0) {
+	if ((w > 0) && (h > 0)) {
 		char *d = (char *)getVGABaseAddr() + dy * g_lab->_screenWidth + dx;
 
 		while (h-- > 0) {
@@ -608,13 +606,13 @@ void LabEngine::ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uin
 		dy = 0;
 	}
 
-	if ((uint)(dx + w) > g_lab->_screenWidth)
+	if (dx + w > g_lab->_screenWidth)
 		w = g_lab->_screenWidth - dx;
 
-	if ((uint)(dy + h) > g_lab->_screenHeight)
+	if (dy + h > g_lab->_screenHeight)
 		h = g_lab->_screenHeight - dy;
 
-	if (w > 0 && h > 0) {
+	if ((w > 0) && (h > 0)) {
 		char *d = (char *)getVGABaseAddr() + dy * g_lab->_screenWidth + dx;
 
 		while (h-- > 0) {


Commit: 8d70f33efe09b01f6f3d48c83f7fbc5c6835d50e
    https://github.com/scummvm/scummvm/commit/8d70f33efe09b01f6f3d48c83f7fbc5c6835d50e
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:43+01:00

Commit Message:
LAB: Rename RoomData members

Changed paths:
    engines/lab/allocroom.cpp
    engines/lab/engine.cpp
    engines/lab/map.cpp
    engines/lab/parsetypes.h
    engines/lab/processroom.cpp
    engines/lab/resource.cpp



diff --git a/engines/lab/allocroom.cpp b/engines/lab/allocroom.cpp
index 2b80967..b98bd24 100644
--- a/engines/lab/allocroom.cpp
+++ b/engines/lab/allocroom.cpp
@@ -39,7 +39,7 @@ namespace Lab {
 #define EMPTYROOM      ((uint16) -1)
 #define MAXMARKERS     10
 
-extern RoomData *Rooms;
+extern RoomData *_rooms;
 
 typedef struct {
 	uint16 RoomNum;
@@ -87,19 +87,19 @@ static void freeRoom(uint16 RMarker) {
 	RoomNum = RoomMarkers[RMarker].RoomNum;
 
 	if (RoomNum != EMPTYROOM) {
-		Rooms[RoomNum].NorthView = NULL;
-		Rooms[RoomNum].SouthView = NULL;
-		Rooms[RoomNum].EastView  = NULL;
-		Rooms[RoomNum].WestView  = NULL;
+		_rooms[RoomNum]._northView = nullptr;
+		_rooms[RoomNum]._southView = nullptr;
+		_rooms[RoomNum]._eastView = nullptr;
+		_rooms[RoomNum]._westView = nullptr;
 
-		RuleList *rules = Rooms[RoomNum].rules;
+		RuleList *rules = _rooms[RoomNum]._rules;
 		for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule)
 			delete *rule;
-		Rooms[RoomNum].rules->clear();
-		delete Rooms[RoomNum].rules;
-		Rooms[RoomNum].rules  = NULL;
+		_rooms[RoomNum]._rules->clear();
+		delete _rooms[RoomNum]._rules;
+		_rooms[RoomNum]._rules = nullptr;
 
-		Rooms[RoomNum].RoomMsg   = NULL;
+		_rooms[RoomNum]._roomMsg = nullptr;
 	}
 
 	RoomMarkers[RMarker].RoomNum = EMPTYROOM;
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 837529b..417cffe 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -51,7 +51,7 @@ extern bool DoBlack, waitForEffect, stopsound, DoNotDrawMessage, IsHiRes, nopalc
 
 /* Global parser data */
 
-extern RoomData *Rooms;
+extern RoomData *_rooms;
 extern InventoryData *Inventory;
 extern uint16 NumInv, RoomNum, ManyRooms, HighestCondition, Direction;
 CloseDataPtr CPtr;
@@ -1282,8 +1282,10 @@ from_crumbs:
 	delete g_lab->_conditions;
 	delete g_lab->_roomsFound;
 
-	if (Rooms)
-		free(Rooms);
+	if (_rooms) {
+		free(_rooms);
+		_rooms = nullptr;
+	}
 
 	if (Inventory) {
 		for (code = 1; code <= NumInv; code++) {
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 50a5514..8cb1eaf 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -127,7 +127,7 @@ void readImage(byte **buffer, Image **im) {
 /*------------------------------ The Map stuff ------------------------------*/
 /*---------------------------------------------------------------------------*/
 
-extern RoomData *Rooms;
+extern RoomData *_rooms;
 
 static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge,
 			 *HRoom, *VRoom, *Maze, *HugeMaze, *Path, *MapNorth,
@@ -646,7 +646,7 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b
 	if (sptr)
 		flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(75), VGAScaleX(134), VGAScaleY(97), sptr);
 
-	if ((sptr = Rooms[CurMsg].RoomMsg))
+	if ((sptr = _rooms[CurMsg]._roomMsg))
 		flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr);
 
 	if (fadein)
@@ -795,10 +795,10 @@ void processMap(uint16 CurRoom) {
 					}
 
 					if (OldMsg != CurMsg) {
-						if (Rooms[CurMsg].RoomMsg == NULL)
+						if (_rooms[CurMsg]._roomMsg == nullptr)
 							g_resource->readViews(CurMsg);
 
-						if ((sptr = Rooms[CurMsg].RoomMsg)) {
+						if ((sptr = _rooms[CurMsg]._roomMsg)) {
 							mouseHide();
 							g_lab->setAPen(3);
 							g_lab->rectFill(VGAScaleX(13), VGAScaleY(148), VGAScaleX(135), VGAScaleY(186));
diff --git a/engines/lab/parsetypes.h b/engines/lab/parsetypes.h
index 681bbe7..e482775 100644
--- a/engines/lab/parsetypes.h
+++ b/engines/lab/parsetypes.h
@@ -134,13 +134,13 @@ struct Rule {
 typedef Common::List<Rule *> RuleList;
 
 struct RoomData {
-	uint16 NorthDoor, SouthDoor, EastDoor, WestDoor;
+	uint16 _northDoor, _southDoor, _eastDoor, _westDoor;
 
-	byte WipeType;
+	byte _wipeType;
 
-	ViewData *NorthView, *SouthView, *EastView, *WestView;
-	RuleList *rules;
-	char *RoomMsg;
+	ViewData *_northView, *_southView, *_eastView, *_westView;
+	RuleList *_rules;
+	char *_roomMsg;
 };
 
 struct InventoryData {
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 37c21d8..645e202 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -45,7 +45,7 @@ namespace Lab {
 
 #define NOFILE         "no file"
 
-RoomData *Rooms;
+RoomData *_rooms;
 InventoryData *Inventory;
 uint16 NumInv, RoomNum, ManyRooms, HighestCondition, Direction;
 const char *NewFileName;
@@ -95,17 +95,17 @@ static bool checkConditions(int16 *Condition) {
 ViewData *getViewData(uint16 roomNum, uint16 direction) {
 	ViewData *view = NULL;
 
-	if (!Rooms[roomNum].RoomMsg)
+	if (!_rooms[roomNum]._roomMsg)
 		g_resource->readViews(roomNum);
 
 	if (direction == NORTH)
-		view = Rooms[roomNum].NorthView;
+		view = _rooms[roomNum]._northView;
 	else if (direction == SOUTH)
-		view = Rooms[roomNum].SouthView;
+		view = _rooms[roomNum]._southView;
 	else if (direction == EAST)
-		view = Rooms[roomNum].EastView;
+		view = _rooms[roomNum]._eastView;
 	else if (direction == WEST)
-		view = Rooms[roomNum].WestView;
+		view = _rooms[roomNum]._westView;
 
 	do {
 		if (checkConditions(view->Condition))
@@ -196,8 +196,8 @@ void drawDirection(CloseDataPtr LCPtr) {
 
 	Common::String message;
 
-	if (Rooms[RoomNum].RoomMsg) {
-		message += Rooms[RoomNum].RoomMsg;
+	if (_rooms[RoomNum]._roomMsg) {
+		message += _rooms[RoomNum]._roomMsg;
 		message += ", ";
 	}
 
@@ -221,13 +221,13 @@ bool processArrow(uint16 *direction, uint16 Arrow) {
 
 	if (Arrow == 1) { /* Forward */
 		if (*direction == NORTH)
-			room = Rooms[RoomNum].NorthDoor;
+			room = _rooms[RoomNum]._northDoor;
 		else if (*direction == SOUTH)
-			room = Rooms[RoomNum].SouthDoor;
+			room = _rooms[RoomNum]._southDoor;
 		else if (*direction == EAST)
-			room = Rooms[RoomNum].EastDoor;
+			room = _rooms[RoomNum]._eastDoor;
 		else if (*direction == WEST)
-			room = Rooms[RoomNum].WestDoor;
+			room = _rooms[RoomNum]._westDoor;
 
 		if (room == 0)
 			return false;
@@ -611,11 +611,11 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr LCPtr, Clo
 	action++;
 
 	if (LCPtr) {
-		RuleList *rules = Rooms[RoomNum].rules;
+		RuleList *rules = _rooms[RoomNum]._rules;
 
 		if ((rules == NULL) && (roomNum == 0)) {
 			g_resource->readViews(roomNum);
-			rules = Rooms[roomNum].rules;
+			rules = _rooms[roomNum]._rules;
 		}
 
 		for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
@@ -668,11 +668,11 @@ bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *
 static bool doOperateRuleSub(int16 ItemNum, int16 roomNum, CloseDataPtr LCPtr, CloseDataPtr *Set, bool AllowDefaults) {
 	if (LCPtr)
 		if (LCPtr->CloseUpType > 0) {
-			RuleList *rules = Rooms[roomNum].rules;
+			RuleList *rules = _rooms[roomNum]._rules;
 
 			if ((rules == NULL) && (roomNum == 0)) {
 				g_resource->readViews(roomNum);
-				rules = Rooms[roomNum].rules;
+				rules = _rooms[roomNum]._rules;
 			}
 
 			for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
@@ -728,7 +728,7 @@ bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *LCPtr) {
 /* Goes thru the rules if the user tries to go forward.                      */
 /*****************************************************************************/
 bool doGoForward(CloseDataPtr *LCPtr) {
-	RuleList *rules = Rooms[RoomNum].rules;
+	RuleList *rules = _rooms[RoomNum]._rules;
 
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 		if (((*rule)->RuleType == GOFORWARD) && ((*rule)->Param1 == (Direction + 1))) {
@@ -749,7 +749,7 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *LCPtr) {
 	from++;
 	to++;
 
-	RuleList *rules = Rooms[RoomNum].rules;
+	RuleList *rules = _rooms[RoomNum]._rules;
 
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 		if (((*rule)->RuleType == TURN) ||
@@ -769,7 +769,7 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *LCPtr) {
 /* Goes thru the rules if the user tries to go to the main view              */
 /*****************************************************************************/
 bool doMainView(CloseDataPtr *LCPtr) {
-	RuleList *rules = Rooms[RoomNum].rules;
+	RuleList *rules = _rooms[RoomNum]._rules;
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 		if ((*rule)->RuleType == GOMAINVIEW) {
 			if (checkConditions((*rule)->Condition)) {
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index e2afcc6..180152e 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -35,7 +35,7 @@ namespace Lab {
 
 static uint16 allocroom;
 
-extern RoomData *Rooms;
+extern RoomData *_rooms;
 extern InventoryData *Inventory;
 extern uint16 NumInv, ManyRooms, HighestCondition;
 
@@ -87,22 +87,22 @@ bool Resource::readRoomData(const char *fileName) {
 
 	ManyRooms = dataFile->readUint16LE();
 	HighestCondition = dataFile->readUint16LE();
-	Rooms = (RoomData *)malloc((ManyRooms + 1) * sizeof(RoomData));
-	memset(Rooms, 0, (ManyRooms + 1) * sizeof(RoomData));
+	_rooms = (RoomData *)malloc((ManyRooms + 1) * sizeof(RoomData));
+	memset(_rooms, 0, (ManyRooms + 1) * sizeof(RoomData));
 
 	for (uint16 i = 1; i <= ManyRooms; i++) {
-		Rooms[i].NorthDoor = dataFile->readUint16LE();
-		Rooms[i].SouthDoor = dataFile->readUint16LE();
-		Rooms[i].EastDoor = dataFile->readUint16LE();
-		Rooms[i].WestDoor = dataFile->readUint16LE();
-		Rooms[i].WipeType = dataFile->readByte();
-
-		Rooms[i].NorthView = NULL;
-		Rooms[i].SouthView = NULL;
-		Rooms[i].EastView = NULL;
-		Rooms[i].WestView = NULL;
-		Rooms[i].rules = NULL;
-		Rooms[i].RoomMsg = NULL;
+		_rooms[i]._northDoor = dataFile->readUint16LE();
+		_rooms[i]._southDoor = dataFile->readUint16LE();
+		_rooms[i]._eastDoor = dataFile->readUint16LE();
+		_rooms[i]._westDoor = dataFile->readUint16LE();
+		_rooms[i]._wipeType = dataFile->readByte();
+
+		_rooms[i]._northView = nullptr;
+		_rooms[i]._southView = nullptr;
+		_rooms[i]._eastView = nullptr;
+		_rooms[i]._westView = nullptr;
+		_rooms[i]._rules = nullptr;
+		_rooms[i]._roomMsg = nullptr;
 	}
 
 	delete dataFile;
@@ -135,12 +135,12 @@ bool Resource::readViews(uint16 roomNum) {
 
 	allocroom = roomNum;
 
-	Rooms[roomNum].RoomMsg = readString(dataFile);
-	Rooms[roomNum].NorthView = readView(dataFile);
-	Rooms[roomNum].SouthView = readView(dataFile);
-	Rooms[roomNum].EastView = readView(dataFile);
-	Rooms[roomNum].WestView = readView(dataFile);
-	Rooms[roomNum].rules = readRule(dataFile);
+	_rooms[roomNum]._roomMsg = readString(dataFile);
+	_rooms[roomNum]._northView = readView(dataFile);
+	_rooms[roomNum]._southView = readView(dataFile);
+	_rooms[roomNum]._eastView = readView(dataFile);
+	_rooms[roomNum]._westView = readView(dataFile);
+	_rooms[roomNum]._rules = readRule(dataFile);
 
 	g_music->updateMusic();
 


Commit: d96484d81c2645b7b714845a9176ba264f52bbc0
    https://github.com/scummvm/scummvm/commit/d96484d81c2645b7b714845a9176ba264f52bbc0
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:43+01:00

Commit Message:
LAB: Move mouse code in separate class, move some functions to LabEngine. (WIP)

Changed paths:
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/interface.cpp
    engines/lab/intro.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/labmusic.cpp
    engines/lab/map.cpp
    engines/lab/mouse.cpp
    engines/lab/mouse.h
    engines/lab/processroom.cpp
    engines/lab/readdiff.cpp
    engines/lab/special.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 417cffe..edf23f3 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -132,7 +132,7 @@ static char initcolors[] = { '\x00', '\x00', '\x00', '\x30',
 /* Draws the control panel display.                                           */
 /******************************************************************************/
 void LabEngine::drawPanel() {
-	mouseHide();
+	_event->mouseHide();
 
 	setAPen(3);                 /* Clear Area */
 	rectFill(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319), VGAScaleY(199));
@@ -178,7 +178,7 @@ void LabEngine::drawPanel() {
 		drawGadgetList(InvGadgetList);
 	}
 
-	mouseShow();
+	_event->mouseShow();
 }
 
 
@@ -192,7 +192,7 @@ static bool LastTooLong = false;
 /******************************************************************************/
 /* Draws the message for the room.                                            */
 /******************************************************************************/
-static void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr) {
+void LabEngine::drawRoomMessage(uint16 CurInv, CloseDataPtr cptr) {
 	if (LastTooLong) {
 		LastTooLong = false;
 		return;
@@ -360,9 +360,9 @@ void LabEngine::perFlipGadget(uint16 GadID) {
 			TopGad->ImAlt = Temp;
 
 			if (!Alternate) {
-				mouseHide();
+				_event->mouseHide();
 				drawImage(TopGad->Im, TopGad->x, TopGad->y);
-				mouseShow();
+				_event->mouseShow();
 			}
 
 			return;
@@ -376,7 +376,7 @@ void LabEngine::perFlipGadget(uint16 GadID) {
 /******************************************************************************/
 /* Eats all the available messages.                                           */
 /******************************************************************************/
-void eatMessages() {
+void LabEngine::eatMessages() {
 	IntuiMessage *Msg;
 
 	do {
@@ -479,49 +479,39 @@ static const char *getInvName(uint16 CurInv) {
 	return Inventory[CurInv].BInvName;
 }
 
-
-
-
 static bool interfaceisoff = false;
 
-
 /******************************************************************************/
 /* Turns the interface off.                                                   */
 /******************************************************************************/
-static void interfaceOff() {
+void LabEngine::interfaceOff() {
 	if (!interfaceisoff) {
-		attachGadgetList(NULL);
-		mouseHide();
+		_event->attachGadgetList(NULL);
+		_event->mouseHide();
 		interfaceisoff = true;
 	}
 }
 
-
-
-
 /******************************************************************************/
 /* Turns the interface on.                                                    */
 /******************************************************************************/
-static void interfaceOn() {
+void LabEngine::interfaceOn() {
 	if (interfaceisoff) {
 		interfaceisoff = false;
 
-		mouseShow();
+		_event->mouseShow();
 	}
 
 	if (LongWinInFront)
-		attachGadgetList(NULL);
+		_event->attachGadgetList(NULL);
 	else if (Alternate)
-		attachGadgetList(InvGadgetList);
+		_event->attachGadgetList(InvGadgetList);
 	else
-		attachGadgetList(MoveGadgetList);
+		_event->attachGadgetList(MoveGadgetList);
 }
 
-
-
 static const char *Test;
 
-
 /******************************************************************************/
 /* If the user hits the "Use" gadget; things that can get used on themselves. */
 /******************************************************************************/
@@ -590,7 +580,7 @@ bool LabEngine::doUse(uint16 CurInv) {
 /******************************************************************************/
 /* Decrements the current inventory number.                                   */
 /******************************************************************************/
-static void decIncInv(uint16 *CurInv, bool dec) {
+void LabEngine::decIncInv(uint16 *CurInv, bool dec) {
 	interfaceOff();
 
 	if (dec)
@@ -792,7 +782,7 @@ from_crumbs:
 				if (code == 13) { /* The return key */
 					Class     = MOUSEBUTTONS;
 					Qualifier = IEQUALIFIER_LEFTBUTTON;
-					curPos = getMousePos();
+					curPos = _event->getMousePos();
 				} else if (g_lab->getPlatform() == Common::kPlatformWindows &&
 						(code == 'b' || code == 'B')) {  /* Start bread crumbs */
 					BreadCrumbs[0].RoomNum = 0;
@@ -1254,7 +1244,7 @@ from_crumbs:
 				}
 
 				if (HCPtr)
-					setMousePos(Common::Point(scaleX((HCPtr->x1 + HCPtr->x2) / 2), scaleY((HCPtr->y1 + HCPtr->y2) / 2)));
+					_event->setMousePos(Common::Point(scaleX((HCPtr->x1 + HCPtr->x2) / 2), scaleY((HCPtr->y1 + HCPtr->y2) / 2)));
 			} else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) {
 				eatMessages();
 				Alternate = !Alternate;
@@ -1325,7 +1315,7 @@ void LabEngine::go() {
 		mem = mem && setUpScreens();
 	}
 
-	initMouse();
+	_event->initMouse();
 
 	mem = mem && initRoomBuffer();
 
@@ -1334,7 +1324,7 @@ void LabEngine::go() {
 
 	MsgFont = g_resource->getFont("P:AvanteG.12");
 
-	mouseHide();
+	_event->mouseHide();
 
 	if (dointro && mem) {
 		Intro intro;
@@ -1343,7 +1333,7 @@ void LabEngine::go() {
 		DoBlack = true;
 
 	if (mem) {
-		mouseShow();
+		_event->mouseShow();
 		mainGameLoop();
 	} else
 		debug("\n\nNot enough memory to start game.\n\n");
@@ -1454,9 +1444,9 @@ void LabEngine::mayShowCrumbIndicator() {
 		return;
 
 	if (DroppingCrumbs && MainDisplay) {
-		mouseHide();
+		_event->mouseHide();
 		drawMaskImage(&DropCrumbsImage, 612, 4);
-		mouseShow();
+		_event->mouseShow();
 	}
 }
 
@@ -1465,9 +1455,9 @@ void LabEngine::mayShowCrumbIndicatorOff() {
 		return;
 
 	if (MainDisplay) {
-		mouseHide();
+		_event->mouseHide();
 		drawMaskImage(&DropCrumbsOffImage, 612, 4);
-		mouseShow();
+		_event->mouseShow();
 	}
 }
 
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index fbf8c45..ab04c3e 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -338,14 +338,14 @@ void createBox(uint16 y2) {
 
 bool LastMessageLong = false;
 
-int32 longDrawMessage(const char *str) {
+int32 LabEngine::longDrawMessage(const char *str) {
 	char NewText[512];
 
 	if (str == NULL)
 		return 0;
 
-	attachGadgetList(NULL);
-	mouseHide();
+	_event->attachGadgetList(NULL);
+	_event->mouseHide();
 	strcpy(NewText, str);
 
 	if (!LongWinInFront) {
@@ -355,21 +355,19 @@ int32 longDrawMessage(const char *str) {
 	}
 
 	createBox(198);
-	mouseShow();
+	_event->mouseShow();
 
 	return flowText(MsgFont, 0, 1, 7, false, true, true, true, VGAScaleX(6), VGAScaleY(155), VGAScaleX(313), VGAScaleY(195), str);
 }
 
-
-
-void drawStaticMessage(byte index) {
+void LabEngine::drawStaticMessage(byte index) {
 	drawMessage(g_resource->getStaticText((StaticText)index).c_str());
 }
 
 /******************************************************************************/
 /* Draws a message to the message box.                                        */
 /******************************************************************************/
-void drawMessage(const char *str) {
+void LabEngine::drawMessage(const char *str) {
 	if (DoNotDrawMessage) {
 		DoNotDrawMessage = false;
 		return;
@@ -385,10 +383,10 @@ void drawMessage(const char *str) {
 				g_lab->drawPanel();
 			}
 
-			mouseHide();
+			_event->mouseHide();
 			createBox(168);
 			text(MsgFont, VGAScaleX(7), VGAScaleY(155) + SVGACord(2), 1, str, strlen(str));
-			mouseShow();
+			_event->mouseShow();
 			LastMessageLong = false;
 		}
 	}
@@ -412,14 +410,14 @@ void drawMessage(const char *str) {
 /*****************************************************************************/
 /* Scrolls the display to black.                                             */
 /*****************************************************************************/
-static void doScrollBlack() {
+void LabEngine::doScrollBlack() {
 	byte *mem, *tempmem;
 	Image Im;
 	uint16 width, height, by, nheight;
 	uint32 size, copysize;
 	uint32 *BaseAddr;
 
-	mouseHide();
+	_event->mouseHide();
 	width = VGAScaleX(320);
 	height = VGAScaleY(149) + SVGACord(2);
 
@@ -481,18 +479,12 @@ static void doScrollBlack() {
 	}
 
 	freeAllStolenMem();
-	mouseShow();
+	_event->mouseShow();
 }
 
-
-
-
 extern BitMap RawDiffBM;
 extern DIFFHeader headerdata;
 
-
-
-
 static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem) {
 	uint32 size, OffSet, copysize;
 	uint16 CurPage;
@@ -524,11 +516,11 @@ static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startli
 /*****************************************************************************/
 /* Scrolls the display to a new picture from a black screen.                 */
 /*****************************************************************************/
-static void doScrollWipe(char *filename) {
+void LabEngine::doScrollWipe(char *filename) {
 	byte *mem;
 	uint16 width, height, by, nheight, startline = 0, onrow = 0;
 
-	mouseHide();
+	_event->mouseHide();
 	width = VGAScaleX(320);
 	height = VGAScaleY(149) + SVGACord(2);
 
@@ -576,16 +568,13 @@ static void doScrollWipe(char *filename) {
 			by = VGAScaleX(3);
 	}
 
-	mouseShow();
+	_event->mouseShow();
 }
 
-
-
-
 /*****************************************************************************/
 /* Does the scroll bounce.  Assumes bitmap already in memory.                */
 /*****************************************************************************/
-static void doScrollBounce() {
+void LabEngine::doScrollBounce() {
 	const uint16 *newby, *newby1;
 
 	const uint16 newbyd[5] = {5, 4, 3, 2, 1}, newby1d[8] = {3, 3, 2, 2, 2, 1, 1, 1};
@@ -600,7 +589,7 @@ static void doScrollBounce() {
 	}
 
 
-	mouseHide();
+	_event->mouseHide();
 	int width = VGAScaleX(320);
 	int height = VGAScaleY(149) + SVGACord(2);
 	byte *mem = RawDiffBM.Planes[0];
@@ -627,15 +616,13 @@ static void doScrollBounce() {
 
 	}
 
-	mouseShow();
+	_event->mouseShow();
 }
 
-
-
 /*****************************************************************************/
 /* Does the transporter wipe.                                                */
 /*****************************************************************************/
-static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
+void LabEngine::doTransWipe(CloseDataPtr *CPtr, char *filename) {
 	uint16 LastY, CurY, linesdone = 0, lineslast;
 	Image ImSource, ImDest;
 
@@ -743,12 +730,10 @@ static void doTransWipe(CloseDataPtr *CPtr, char *filename) {
 	}
 }
 
-
-
 /*****************************************************************************/
 /* Does a certain number of pre-programmed wipes.                            */
 /*****************************************************************************/
-void doWipe(uint16 WipeType, CloseDataPtr *CPtr, char *filename) {
+void LabEngine::doWipe(uint16 WipeType, CloseDataPtr *CPtr, char *filename) {
 	if ((WipeType == TRANSWIPE) || (WipeType == TRANSPORTER))
 		doTransWipe(CPtr, filename);
 	else if (WipeType == SCROLLWIPE)
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 36891d7..d9ea459 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -125,20 +125,20 @@ uint16 makeGadgetKeyEquiv(uint16 key) {
 /* Checks whether or not the cords fall within one of the gadgets in a list  */
 /* of gadgets.                                                               */
 /*****************************************************************************/
-static Gadget *checkNumGadgetHit(Gadget *gadlist, uint16 key) {
+Gadget *LabEngine::checkNumGadgetHit(Gadget *gadlist, uint16 key) {
 	uint16 gkey = key - '0';
 
 	while (gadlist != NULL) {
 		if ((gkey - 1 == gadlist->GadgetID || (gkey == 0 && gadlist->GadgetID == 9) ||
 		        (gadlist->KeyEquiv != 0 && makeGadgetKeyEquiv(key) == gadlist->KeyEquiv))
 		        && !(GADGETOFF & gadlist->GadgetFlags)) {
-			mouseHide();
+			_event->mouseHide();
 			g_lab->drawImage(gadlist->ImAlt, gadlist->x, gadlist->y);
-			mouseShow();
+			_event->mouseShow();
 			g_system->delayMillis(80);
-			mouseHide();
+			_event->mouseHide();
 			g_lab->drawImage(gadlist->Im, gadlist->x, gadlist->y);
-			mouseShow();
+			_event->mouseShow();
 
 			return gadlist;
 		} else {
@@ -163,30 +163,29 @@ static bool keyPress(uint16 *KeyCode) {
 	return false;
 }
 
-
 IntuiMessage IMessage;
 extern Gadget *ScreenGadgetList;
 
-IntuiMessage *getMsg() {
+IntuiMessage *LabEngine::getMsg() {
 	Gadget *curgad;
 	int Qualifiers;
 
-	updateMouse();
+	_event->updateMouse();
 
 	Qualifiers = _keyPressed.flags;
 
-	if ((curgad = mouseGadget()) != NULL) {
-		updateMouse();
+	if ((curgad = _event->mouseGadget()) != NULL) {
+		_event->updateMouse();
 		IMessage.msgClass = GADGETUP;
 		IMessage.code  = curgad->GadgetID;
 		IMessage.gadgetID = curgad->GadgetID;
 		IMessage.qualifier = Qualifiers;
 		return &IMessage;
-	} else if (mouseButton(&IMessage.mouseX, &IMessage.mouseY, true)) { /* Left Button */
+	} else if (_event->mouseButton(&IMessage.mouseX, &IMessage.mouseY, true)) { /* Left Button */
 		IMessage.qualifier = IEQUALIFIER_LEFTBUTTON | Qualifiers;
 		IMessage.msgClass = MOUSEBUTTONS;
 		return &IMessage;
-	} else if (mouseButton(&IMessage.mouseX, &IMessage.mouseY, false)) { /* Right Button */
+	} else if (_event->mouseButton(&IMessage.mouseX, &IMessage.mouseY, false)) { /* Right Button */
 		IMessage.qualifier = IEQUALIFIER_RBUTTON | Qualifiers;
 		IMessage.msgClass = MOUSEBUTTONS;
 		return &IMessage;
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index b3a5ccd..43bb7c6 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -52,7 +52,7 @@ Intro::Intro() {
 /******************************************************************************/
 void Intro::introEatMessages() {
 	while (1) {
-		IntuiMessage *msg = getMsg();
+		IntuiMessage *msg = g_lab->getMsg();
 
 		if (g_engine->shouldQuit()) {
 			_quitIntro = true;
@@ -121,7 +121,7 @@ void Intro::doPictText(const char *filename, bool isscreen) {
 				Drawn = flowText(_msgfont, (!IsHiRes) * -1, 5, 7, false, false, true, true, VGAScaleX(14), VGAScaleY(11), VGAScaleX(306), VGAScaleY(189), (char *)curplace);
 				fade(true, 0);
 			} else {
-				Drawn = longDrawMessage((char *)curplace);
+				Drawn = g_lab->longDrawMessage((char *)curplace);
 			}
 
 			curplace += Drawn;
@@ -141,12 +141,11 @@ void Intro::doPictText(const char *filename, bool isscreen) {
 			g_lab->getTime(&lastsecs, &lastmicros);
 		}
 
-		msg = getMsg();
+		msg = g_lab->getMsg();
 
 		if (msg == NULL) {
 			g_music->updateMusic();
-			diffNextFrame();
-
+			g_lab->diffNextFrame();
 			g_lab->getTime(&secs, &micros);
 			g_lab->anyTimeDiff(lastsecs, lastmicros, secs, micros, &secs, &micros);
 
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 92607d4..5cc49b0 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -90,6 +90,8 @@ Common::Error LabEngine::run() {
 	else
 		initGraphics(640, 480, true);
 
+	_event = new EventManager(this);
+
 	g_music = new Music();
 	g_resource = new Resource();
 
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 659637d..4b5f5d1 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -36,6 +36,8 @@
 
 #include "engines/engine.h"
 #include "lab/labfun.h"
+#include "lab/interface.h"
+#include "lab/mouse.h"
 
 struct ADGameDescription;
 
@@ -96,6 +98,7 @@ private:
 	byte _curapen;
 
 public:
+	EventManager *_event;
 	byte *_currentDsplayBuffer;
 	Common::Point _mousePos;
 
@@ -137,6 +140,32 @@ public:
 	void writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg);
 
 	void drawPanel();
+	void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr);
+	void interfaceOff();
+	void interfaceOn();
+	void decIncInv(uint16 *CurInv, bool dec);
+	int32 longDrawMessage(const char *str);
+	void drawMessage(const char *str);
+	void doScrollBlack();
+	void doScrollWipe(char *filename);
+	void doScrollBounce();
+	void doWipe(uint16 WipeType, CloseDataPtr *CPtr, char *filename);
+	void doTransWipe(CloseDataPtr *CPtr, char *filename);
+	Gadget *checkNumGadgetHit(Gadget *gadlist, uint16 key);
+	IntuiMessage *getMsg();
+	void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein);
+	void processMap(uint16 CurRoom);
+	void doMap(uint16 CurRoom);
+	void diffNextFrame();
+	void drawJournal(uint16 wipenum, bool needFade);
+	void processJournal();
+	void doJournal();
+	void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive);
+	void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void eatMessages();
+	void drawStaticMessage(byte index);
+	void drawDirection(CloseDataPtr LCPtr);
 
 private:
 	void quickWaitTOF();
diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index ed45bfa..a7043dc 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -73,7 +73,7 @@ Music::Music() {
 void Music::updateMusic() {
 	g_lab->WSDL_ProcessInput(0);
 
-	updateMouse();
+	g_lab->_event->updateMouse();
 
 	if (_musicOn && getPlayingBufferCount() < MAXBUFFERS) {
 		// NOTE: We need to use malloc(), cause this will be freed with free()
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 8cb1eaf..98082b7 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -553,13 +553,13 @@ static void getDownFloor(uint16 *Floor, bool *isfloor) {
 /*****************************************************************************/
 /* Draws the map                                                             */
 /*****************************************************************************/
-static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein) {
+void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein) {
 	char *sptr;
 
 	uint16 tempfloor;
 	bool noghoast;
 
-	mouseHide();
+	_event->mouseHide();
 
 	if (fadeout)
 		fade(false, 0);
@@ -652,13 +652,13 @@ static void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, b
 	if (fadein)
 		fade(true, 0);
 
-	mouseShow();
+	_event->mouseShow();
 }
 
 /*****************************************************************************/
 /* Processes the map.                                                        */
 /*****************************************************************************/
-void processMap(uint16 CurRoom) {
+void LabEngine::processMap(uint16 CurRoom) {
 	uint32 Class, place = 1;
 	uint16 Code, Qualifier, MouseX, MouseY, GadgetID, CurFloor, OldFloor, OldMsg, CurMsg, x1, y1, x2, y2;
 	char *sptr;
@@ -688,13 +688,13 @@ void processMap(uint16 CurRoom) {
 
 			g_lab->waitTOF();
 			g_lab->writeColorReg(newcolor, 1);
-			updateMouse();
+			_event->updateMouse();
 			g_lab->waitTOF();
-			updateMouse();
+			_event->updateMouse();
 			g_lab->waitTOF();
-			updateMouse();
+			_event->updateMouse();
 			g_lab->waitTOF();
-			updateMouse();
+			_event->updateMouse();
 
 			place++;
 
@@ -799,7 +799,7 @@ void processMap(uint16 CurRoom) {
 							g_resource->readViews(CurMsg);
 
 						if ((sptr = _rooms[CurMsg]._roomMsg)) {
-							mouseHide();
+							_event->mouseHide();
 							g_lab->setAPen(3);
 							g_lab->rectFill(VGAScaleX(13), VGAScaleY(148), VGAScaleX(135), VGAScaleY(186));
 							flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr);
@@ -816,7 +816,7 @@ void processMap(uint16 CurRoom) {
 								g_lab->rectFill(x1 - 1, y1, x1, y1);
 							}
 
-							mouseShow();
+							_event->mouseShow();
 						}
 					}
 				}
@@ -831,7 +831,7 @@ void processMap(uint16 CurRoom) {
 /*****************************************************************************/
 /* Does the map processing.                                                  */
 /*****************************************************************************/
-void doMap(uint16 CurRoom) {
+void LabEngine::doMap(uint16 CurRoom) {
 	FadePalette = AmigaMapPalette;
 
 	g_music->updateMusic();
@@ -848,19 +848,19 @@ void doMap(uint16 CurRoom) {
 		XMark = MapWest;
 
 	drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true);
-	mouseShow();
-	attachGadgetList(MapGadgetList);
+	_event->mouseShow();
+	_event->attachGadgetList(MapGadgetList);
 	g_lab->WSDL_UpdateScreen();
 	processMap(CurRoom);
-	attachGadgetList(NULL);
+	_event->attachGadgetList(NULL);
 	fade(false, 0);
 	blackAllScreen();
-	mouseHide();
+	_event->mouseHide();
 	g_lab->setAPen(0);
 	g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
 	freeMapData();
 	blackAllScreen();
-	mouseShow();
+	_event->mouseShow();
 	g_lab->WSDL_UpdateScreen();
 }
 
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index 4fc8644..73fdd2e 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -69,7 +69,7 @@ static Gadget *hitgad = NULL;
 /* Checks whether or not the cords fall within one of the gadgets in a list  */
 /* of gadgets.                                                               */
 /*****************************************************************************/
-static Gadget *checkGadgetHit(Gadget *gadlist, Common::Point pos) {
+Gadget *EventManager::checkGadgetHit(Gadget *gadlist, Common::Point pos) {
 	while (gadlist != NULL) {
 		if ((pos.x >= gadlist->x) && (pos.y >= gadlist->y) &&
 		    (pos.x <= (gadlist->x + gadlist->Im->Width)) &&
@@ -101,14 +101,17 @@ static Gadget *checkGadgetHit(Gadget *gadlist, Common::Point pos) {
 
 
 
-void attachGadgetList(Gadget *GadList) {
+void EventManager::attachGadgetList(Gadget *GadList) {
 	if (ScreenGadgetList != GadList)
 		LastGadgetHit = NULL;
 
 	ScreenGadgetList = GadList;
 }
 
-void mouseHandler(int flag, Common::Point pos) {
+EventManager::EventManager(LabEngine *vm) : _vm(vm) {
+}
+
+void EventManager::mouseHandler(int flag, Common::Point pos) {
 	if (NumHidden >= 2)
 		return;
 
@@ -127,7 +130,7 @@ void mouseHandler(int flag, Common::Point pos) {
 		RightClick = true;
 }
 
-void updateMouse() {
+void EventManager::updateMouse() {
 	bool doUpdateDisplay = false;
 
 	if (!MouseHidden)
@@ -156,7 +159,7 @@ void updateMouse() {
 /*****************************************************************************/
 /* Initializes the mouse.                                                    */
 /*****************************************************************************/
-void initMouse() {
+void EventManager::initMouse() {
 	g_system->setMouseCursor(MouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0);
 	g_system->showMouse(false);
 
@@ -167,7 +170,7 @@ void initMouse() {
 /*****************************************************************************/
 /* Shows the mouse.                                                          */
 /*****************************************************************************/
-void mouseShow() {
+void EventManager::mouseShow() {
 	if (NumHidden)
 		NumHidden--;
 
@@ -182,7 +185,7 @@ void mouseShow() {
 /*****************************************************************************/
 /* Hides the mouse.                                                          */
 /*****************************************************************************/
-void mouseHide() {
+void EventManager::mouseHide() {
 	NumHidden++;
 
 	if (NumHidden && !MouseHidden) {
@@ -196,7 +199,7 @@ void mouseHide() {
 /* Gets the current mouse co-ordinates.  NOTE: On IBM version, will scale    */
 /* from virtual to screen co-ordinates automatically.                        */
 /*****************************************************************************/
-Common::Point getMousePos() {
+Common::Point EventManager::getMousePos() {
 	if (IsHiRes)
 		return g_lab->_mousePos;
 	else
@@ -207,7 +210,7 @@ Common::Point getMousePos() {
 /*****************************************************************************/
 /* Moves the mouse to new co-ordinates.                                      */
 /*****************************************************************************/
-void setMousePos(Common::Point pos) {
+void EventManager::setMousePos(Common::Point pos) {
 	if (IsHiRes)
 		g_system->warpMouse(pos.x, pos.y);
 	else
@@ -223,7 +226,7 @@ void setMousePos(Common::Point pos) {
 /* co-ordinates of the button press.  leftbutton tells whether to check the  */
 /* left or right button.                                                     */
 /*****************************************************************************/
-bool mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
+bool EventManager::mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
 	if (leftbutton) {
 		if (LeftClick) {
 			*x = (!IsHiRes) ? (uint16)g_lab->_mousePos.x / 2 : (uint16)g_lab->_mousePos.x;
@@ -243,10 +246,7 @@ bool mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
 	return false;
 }
 
-
-
-
-Gadget *mouseGadget() {
+Gadget *EventManager::mouseGadget() {
 	Gadget *Temp = LastGadgetHit;
 
 	LastGadgetHit = NULL;
diff --git a/engines/lab/mouse.h b/engines/lab/mouse.h
index 489bb1e..6468ba9 100644
--- a/engines/lab/mouse.h
+++ b/engines/lab/mouse.h
@@ -38,25 +38,27 @@ namespace Lab {
 
 struct Gadget;
 
-void initMouse();
-
-void updateMouse();
-
-void mouseShow();
-
-void mouseHide();
-
-Common::Point getMousePos();
-
-void setMousePos(Common::Point pos);
-
-bool mouseButton(uint16 *x, uint16 *y, bool leftbutton);
-
-Gadget *mouseGadget();
-
-void attachGadgetList(Gadget *GadList);
-
-void mouseHandler(int flag, Common::Point pos);
+class LabEngine;
+
+class EventManager {
+private:
+	LabEngine *_vm;
+
+public:
+	EventManager (LabEngine *vm);
+
+	Gadget *checkGadgetHit(Gadget *gadlist, Common::Point pos);
+	void initMouse();
+	void updateMouse();
+	void mouseShow();
+	void mouseHide();
+	Common::Point getMousePos();
+	void setMousePos(Common::Point pos);
+	bool mouseButton(uint16 *x, uint16 *y, bool leftbutton);
+	Gadget *mouseGadget();
+	void attachGadgetList(Gadget *GadList);
+	void mouseHandler(int flag, Common::Point pos);
+};
 
 } // End of namespace Lab
 
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 645e202..1932d48 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -188,7 +188,7 @@ char *getPictName(CloseDataPtr *LCPtr) {
 /*****************************************************************************/
 /* Draws the current direction to the screen.                                */
 /*****************************************************************************/
-void drawDirection(CloseDataPtr LCPtr) {
+void LabEngine::drawDirection(CloseDataPtr LCPtr) {
 	if (LCPtr != NULL && LCPtr->Message) {
 		drawMessage(LCPtr->Message);
 		return;
@@ -375,7 +375,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 			break;
 
 		case WIPECMD:
-			doWipe(APtr->Param1, LCPtr, (char *)APtr->Data);
+			g_lab->doWipe(APtr->Param1, LCPtr, (char *)APtr->Data);
 			break;
 
 		case NOUPDATE:
@@ -409,9 +409,9 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 			DoNotDrawMessage = false;
 
 			if (LongWinInFront)
-				longDrawMessage((char *)APtr->Data);
+				g_lab->longDrawMessage((char *)APtr->Data);
 			else
-				drawMessage((char *)APtr->Data);
+				g_lab->drawMessage((char *)APtr->Data);
 
 			DoNotDrawMessage = true;
 			break;
@@ -419,7 +419,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 		case CSHOWMESSAGE:
 			if (*LCPtr == NULL) {
 				DoNotDrawMessage = false;
-				drawMessage((char *)APtr->Data);
+				g_lab->drawMessage((char *)APtr->Data);
 				DoNotDrawMessage = true;
 			}
 
@@ -428,7 +428,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 		case SHOWMESSAGES:
 			str = (char **)APtr->Data;
 			DoNotDrawMessage = false;
-			drawMessage(str[getRandom(APtr->Param1)]);
+			g_lab->drawMessage(str[getRandom(APtr->Param1)]);
 			DoNotDrawMessage = true;
 			break;
 
@@ -486,7 +486,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 
 			while (1) {
 				g_music->updateMusic();
-				diffNextFrame();
+				g_lab->diffNextFrame();
 				g_lab->getTime(&CurSecs, &CurMicros);
 
 				if ((CurSecs > StartSecs) || ((CurSecs == StartSecs) &&
@@ -521,7 +521,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 		case WAITSOUND:
 			while (g_music->isSoundEffectActive()) {
 				g_music->updateMusic();
-				diffNextFrame();
+				g_lab->diffNextFrame();
 				g_lab->waitTOF();
 			}
 
@@ -596,7 +596,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 	} else {
 		while (g_music->isSoundEffectActive()) {
 			g_music->updateMusic();
-			diffNextFrame();
+			g_lab->diffNextFrame();
 			g_lab->waitTOF();
 		}
 	}
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index 852b9c6..61edf32 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -113,8 +113,7 @@ void blackAllScreen() {
 	g_system->delayMillis(32);
 }
 
-
-void diffNextFrame() {
+void LabEngine::diffNextFrame() {
 	if (header == 65535)  /* Already done. */
 		return;
 
@@ -126,11 +125,11 @@ void diffNextFrame() {
 		DispBitMap->Planes[4] = DispBitMap->Planes[3] + 0x10000;
 	}
 
-	mouseHide();
+	_event->mouseHide();
 
 	while (1) {
 		if (CurBit >= numchunks) {
-			mouseShow();
+			_event->mouseShow();
 
 			if (!IsBM) {
 				if (headerdata.fps) {
@@ -264,7 +263,7 @@ void diffNextFrame() {
 				}
 
 				IsPlaying = false;
-				mouseShow();
+				_event->mouseShow();
 
 				if (!didTOF)
 					g_lab->WSDL_UpdateScreen();
@@ -283,8 +282,6 @@ void diffNextFrame() {
 	}
 }
 
-
-
 /*****************************************************************************/
 /* A separate task launched by readDiff.  Plays the DIFF.                    */
 /*****************************************************************************/
@@ -306,11 +303,9 @@ void playDiff() {
 		blackScreen();
 	}
 
-
 	start = *startoffile;            /* Make a copy of the pointer to the start of the file    */
 	*difffile = start;               /* Now can modify the file without modifying the original */
 
-
 	if (start == NULL) {
 		IsPlaying = false;
 		return;
@@ -373,9 +368,9 @@ void playDiff() {
 
 	if (PlayOnce) {
 		while (header != 65535)
-			diffNextFrame();
+			g_lab->diffNextFrame();
 	} else
-		diffNextFrame();
+		g_lab->diffNextFrame();
 }
 
 
@@ -399,7 +394,7 @@ void stopDiffEnd() {
 	if (IsPlaying) {
 		while (IsPlaying) {
 			g_music->updateMusic();
-			diffNextFrame();
+			g_lab->diffNextFrame();
 		}
 	}
 }
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 00ac19f..4e61b3c 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -682,8 +682,8 @@ static void turnPage(bool FromLeft) {
 /*****************************************************************************/
 /* Draws the journal from page x.                                            */
 /*****************************************************************************/
-static void drawJournal(uint16 wipenum, bool needFade) {
-	mouseHide();
+void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
+	_event->mouseHide();
 
 	g_music->updateMusic();
 
@@ -718,7 +718,7 @@ static void drawJournal(uint16 wipenum, bool needFade) {
 	GotBackImage = true;
 
 	eatMessages();
-	mouseShow();
+	_event->mouseShow();
 
 	nopalchange = false;
 }
@@ -726,14 +726,14 @@ static void drawJournal(uint16 wipenum, bool needFade) {
 /*****************************************************************************/
 /* Processes user input.                                                     */
 /*****************************************************************************/
-static void processJournal() {
+void LabEngine::processJournal() {
 	IntuiMessage *Msg;
 	uint32 Class;
 	uint16 Qualifier, GadID;
 
 	while (1) {
 		g_music->updateMusic();  /* Make sure we check the music at least after every message */
-		Msg = (IntuiMessage *)getMsg();
+		Msg = getMsg();
 
 		if (Msg == NULL) {
 			g_music->updateMusic();
@@ -768,7 +768,7 @@ static void processJournal() {
 /*****************************************************************************/
 /* Does the journal processing.                                              */
 /*****************************************************************************/
-void doJournal() {
+void LabEngine::doJournal() {
 	resetBuffer();
 	blackAllScreen();
 
@@ -790,12 +790,12 @@ void doJournal() {
 
 	drawJournal(0, true);
 
-	attachGadgetList(&BackG);
-	mouseShow();
+	_event->attachGadgetList(&BackG);
+	_event->mouseShow();
 	processJournal();
-	attachGadgetList(NULL);
+	_event->attachGadgetList(NULL);
 	fade(false, 0);
-	mouseHide();
+	_event->mouseHide();
 
 	ScreenImage.ImageData = g_lab->getVGABaseAddr();
 
@@ -869,12 +869,12 @@ static void getMonImages() {
 /*****************************************************************************/
 /* Draws the text for the monitor.                                           */
 /*****************************************************************************/
-static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) {
+void LabEngine::drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) {
 	uint16 DrawingToPage = 0, yspacing = 0, numlines, fheight;
 	int32 CharsDrawn    = 0L;
 	char *CurText = text;
 
-	mouseHide();
+	_event->mouseHide();
 
 	if (*text == '%') {
 		text++;
@@ -923,13 +923,13 @@ static void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2,
 	CurText += CharsDrawn;
 	lastpage = lastpage || (*CurText == 0);
 
-	mouseShow();
+	_event->mouseShow();
 }
 
 /*****************************************************************************/
 /* Processes user input.                                                     */
 /*****************************************************************************/
-static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+void LabEngine::processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	IntuiMessage *Msg;
 	uint32 Class;
 	uint16 Qualifier, Code, MouseX, MouseY;
@@ -1022,7 +1022,7 @@ static void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1
 /*****************************************************************************/
 /* Does what's necessary for the monitor.                                    */
 /*****************************************************************************/
-void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	char *ntext;
 
 	x1 = VGAScaleX(x1);
@@ -1064,11 +1064,11 @@ void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1,
 
 	drawMonText(ntext, x1, y1, x2, y2, isinteractive);
 
-	mouseShow();
+	_event->mouseShow();
 	fade(true, 0);
 	processMonitor(ntext, isinteractive, x1, y1, x2, y2);
 	fade(false, 0);
-	mouseHide();
+	_event->mouseHide();
 
 	freeAllStolenMem();
 
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 63443ca..3ed26e1 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -90,12 +90,12 @@ void LabEngine::WSDL_ProcessInput(bool can_delay) {
 			switch (event.type) {
 			case Common::EVENT_RBUTTONDOWN:
 				flags |= 8;
-				mouseHandler(flags, _mousePos);
+				_event->mouseHandler(flags, _mousePos);
 				break;
 
 			case Common::EVENT_LBUTTONDOWN:
 				flags |= 2;
-				mouseHandler(flags, _mousePos);
+				_event->mouseHandler(flags, _mousePos);
 				break;
 
 			case Common::EVENT_MOUSEMOVE: {
@@ -122,7 +122,7 @@ void LabEngine::WSDL_ProcessInput(bool can_delay) {
 				}
 
 				if (!lastMouseAtEdge || !_mouseAtEdge)
-					mouseHandler(1, _mousePos);
+					_event->mouseHandler(1, _mousePos);
 				}
 				break;
 


Commit: 18fc6fd10207ccf425f85e98da23c121ee75af98
    https://github.com/scummvm/scummvm/commit/18fc6fd10207ccf425f85e98da23c121ee75af98
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:43+01:00

Commit Message:
LAB: Add some feedback when a file isn't found

Changed paths:
    engines/lab/engine.cpp
    engines/lab/labfile.cpp
    engines/lab/resource.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index edf23f3..7af3719 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -230,6 +230,9 @@ bool LabEngine::setUpScreens() {
 	/* Loads in the graphics for the movement control panel */
 	Common::File file;
 	file.open(translateFileName("P:Control"));
+	if (!file.isOpen())
+		warning("setUpScreens couldn't open %s", translateFileName("P:Control"));
+
 	if (file.err() || file.size() == 0)
 		return false;
 
@@ -290,6 +293,9 @@ bool LabEngine::setUpScreens() {
 	}
 
 	file.open(translateFileName("P:Inv"));
+	if (!file.isOpen())
+		warning("setUpScreens couldn't open %s", translateFileName("P:Inv"));
+
 	if (file.err() || file.size() == 0)
 		return false;
 
diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
index fb6b17e..31d1090 100644
--- a/engines/lab/labfile.cpp
+++ b/engines/lab/labfile.cpp
@@ -289,6 +289,7 @@ Common::File *openPartial(const char *name) {
 	f->open(translateFileName(name));
 
 	if (!f->isOpen()) {
+		warning("openPartial skipped %s", translateFileName(name));
 		delete f;
 		return 0;
 	}
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 180152e..2f11515 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -48,6 +48,8 @@ Resource::Resource() {
 void Resource::readStaticText() {
 	Common::File labTextFile;
 	labTextFile.open(translateFileName("Lab:Rooms/LabText"));
+	if (!labTextFile.isOpen())
+		error("Unable to open file %s (Lab:Rooms/LabText)", translateFileName("Lab:Rooms/LabText"));
 
 	for (int i = 0; i < 48; i++)
 		_staticText[i] = labTextFile.readLine();
@@ -151,9 +153,12 @@ bool Resource::readViews(uint16 roomNum) {
 Common::File *Resource::openDataFile(const char *fileName, uint32 fileHeader) {
 	Common::File *dataFile = new Common::File();
 	dataFile->open(translateFileName(fileName));
+	if (!dataFile->isOpen())
+		error("openDataFile couldn't open %s (%s)", translateFileName(fileName), fileName);
+
 	if (dataFile->readUint32BE() != fileHeader) {
 		dataFile->close();
-		return NULL;
+		return nullptr;
 	}
 
 	return dataFile;


Commit: db773d92b7f035244538316a02d109671cdf8944
    https://github.com/scummvm/scummvm/commit/db773d92b7f035244538316a02d109671cdf8944
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:43+01:00

Commit Message:
LAB: Remove useless redirections

Changed paths:
    engines/lab/engine.cpp
    engines/lab/map.cpp
    engines/lab/mouse.cpp
    engines/lab/readdiff.cpp
    engines/lab/special.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 7af3719..c3aa5f4 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -151,7 +151,7 @@ void LabEngine::drawPanel() {
 		drawHLine(0, VGAScaleY(170) + 1, VGAScaleX(319)); /* The horizontal lines under the black one */
 		drawGadgetList(MoveGadgetList);
 	} else {
-		if (g_lab->getPlatform() != Common::kPlatformWindows) {
+		if (getPlatform() != Common::kPlatformWindows) {
 			drawVLine(VGAScaleX(124), VGAScaleY(170) + 1, VGAScaleY(199)); /* Vertical Black lines */
 			drawVLine(VGAScaleX(194), VGAScaleY(170) + 1, VGAScaleY(199));
 		} else {
@@ -166,7 +166,7 @@ void LabEngine::drawPanel() {
 		drawHLine(VGAScaleX(196), VGAScaleY(170) + 1, VGAScaleX(319));
 
 		drawVLine(VGAScaleX(1), VGAScaleY(170) + 2, VGAScaleY(198)); /* The vertical high light lines */
-		if (g_lab->getPlatform() != Common::kPlatformWindows) {
+		if (getPlatform() != Common::kPlatformWindows) {
 			drawVLine(VGAScaleX(126), VGAScaleY(170) + 2, VGAScaleY(198));
 			drawVLine(VGAScaleX(196), VGAScaleY(170) + 2, VGAScaleY(198));
 		} else {
@@ -199,8 +199,8 @@ void LabEngine::drawRoomMessage(uint16 CurInv, CloseDataPtr cptr) {
 	}
 
 	if (Alternate) {
-		if ((CurInv <= NumInv) && g_lab->_conditions->in(CurInv) && Inventory[CurInv].BInvName) {
-			if ((CurInv == LAMPNUM) && g_lab->_conditions->in(LAMPON))  /* LAB: Labyrith specific */
+		if ((CurInv <= NumInv) && _conditions->in(CurInv) && Inventory[CurInv].BInvName) {
+			if ((CurInv == LAMPNUM) && _conditions->in(LAMPON))  /* LAB: Labyrith specific */
 				drawStaticMessage(kTextLampOn);
 			else if (Inventory[CurInv].Many > 1) {
 				Common::String roomMessage = Common::String(Inventory[CurInv].name) + "  (" + Common::String::format("%d", Inventory[CurInv].Many) + ")";
@@ -250,7 +250,7 @@ bool LabEngine::setUpScreens() {
 	/* Creates the gadgets for the movement control panel */
 	y = VGAScaleY(173) - SVGACord(2);
 
-	if (g_lab->getPlatform() == Common::kPlatformWindows) {
+	if (getPlatform() == Common::kPlatformWindows) {
 		MoveGadgetList = createButton(1, y, 0, 't', MoveImages[0], MoveImages[1]);
 		curgad = MoveGadgetList;
 		curgad->NextGadget = createButton(33, y, 1, 'm', MoveImages[2], MoveImages[3]);
@@ -307,7 +307,7 @@ bool LabEngine::setUpScreens() {
 
 	buffer = InvPanelBuffer;
 
-	if (g_lab->getPlatform() == Common::kPlatformWindows) {
+	if (getPlatform() == Common::kPlatformWindows) {
 		for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++)
 			readImage(&buffer, &(InvImages[imgIdx]));
 
@@ -401,7 +401,7 @@ bool LabEngine::doCloseUp(CloseDataPtr cptr) {
 
 	int monltmargin, monrtmargin, montopmargin, lutertmargin;
 
-	if (g_lab->getPlatform() != Common::kPlatformWindows) {
+	if (getPlatform() != Common::kPlatformWindows) {
 		monltmargin = 0;
 		monrtmargin = 319;
 		montopmargin = 0;
@@ -595,7 +595,7 @@ void LabEngine::decIncInv(uint16 *CurInv, bool dec) {
 		(*CurInv)++;
 
 	while (*CurInv && (*CurInv <= NumInv)) {
-		if (g_lab->_conditions->in(*CurInv) && Inventory[*CurInv].BInvName) {
+		if (_conditions->in(*CurInv) && Inventory[*CurInv].BInvName) {
 			Test = getInvName(*CurInv);
 			break;
 		}
@@ -613,7 +613,7 @@ void LabEngine::decIncInv(uint16 *CurInv, bool dec) {
 			*CurInv = 1;
 
 		while (*CurInv && (*CurInv <= NumInv)) {
-			if (g_lab->_conditions->in(*CurInv) && Inventory[*CurInv].BInvName) {
+			if (_conditions->in(*CurInv) && Inventory[*CurInv].BInvName) {
 				Test = getInvName(*CurInv);
 				break;
 			}
@@ -653,13 +653,13 @@ void LabEngine::mainGameLoop() {
 	g_resource->readRoomData("LAB:Doors");
 	g_resource->readInventory("LAB:Inventor");
 
-	if (!(g_lab->_conditions = new LargeSet(HighestCondition + 1)))
+	if (!(_conditions = new LargeSet(HighestCondition + 1)))
 		return;
 
-	if (!(g_lab->_roomsFound = new LargeSet(ManyRooms + 1)))
+	if (!(_roomsFound = new LargeSet(ManyRooms + 1)))
 		return;
 
-	g_lab->_conditions->readInitialConditions("LAB:Conditio");
+	_conditions->readInitialConditions("LAB:Conditio");
 
 	LongWinInFront = false;
 	drawPanel();
@@ -693,7 +693,7 @@ void LabEngine::mainGameLoop() {
 				Test = getPictName(&CPtr);
 
 			if (noupdatediff) {
-				g_lab->_roomsFound->inclElement(RoomNum); /* Potentially entered another room */
+				_roomsFound->inclElement(RoomNum); /* Potentially entered another room */
 				ForceDraw = (strcmp(Test, CurFileName) != 0) || ForceDraw;
 
 				noupdatediff = false;
@@ -702,7 +702,7 @@ void LabEngine::mainGameLoop() {
 
 			else if (strcmp(Test, CurFileName) != 0) {
 				interfaceOff();
-				g_lab->_roomsFound->inclElement(RoomNum); /* Potentially entered another room */
+				_roomsFound->inclElement(RoomNum); /* Potentially entered another room */
 				CurFileName = Test;
 
 				if (CPtr) {
@@ -789,7 +789,7 @@ from_crumbs:
 					Class     = MOUSEBUTTONS;
 					Qualifier = IEQUALIFIER_LEFTBUTTON;
 					curPos = _event->getMousePos();
-				} else if (g_lab->getPlatform() == Common::kPlatformWindows &&
+				} else if (getPlatform() == Common::kPlatformWindows &&
 						(code == 'b' || code == 'B')) {  /* Start bread crumbs */
 					BreadCrumbs[0].RoomNum = 0;
 					NumCrumbs = 0;
@@ -804,7 +804,7 @@ from_crumbs:
 							FollowCrumbsFast = (code == 'r' || code == 'R');
 							IsCrumbTurning = false;
 							IsCrumbWaiting = false;
-							g_lab->getTime(&CrumbSecs, &CrumbMicros);
+							getTime(&CrumbSecs, &CrumbMicros);
 
 							if (Alternate) {
 								eatMessages();
@@ -903,7 +903,7 @@ from_crumbs:
 
 						MainDisplay = false;
 
-						if (LastInv && g_lab->_conditions->in(LastInv)) {
+						if (LastInv && _conditions->in(LastInv)) {
 							CurInv = LastInv;
 							Test = getInvName(CurInv);
 						} else
@@ -976,7 +976,7 @@ from_crumbs:
 
 							if (OldRoomNum != RoomNum) {
 								drawStaticMessage(kTextGoForward);
-								g_lab->_roomsFound->inclElement(RoomNum); /* Potentially entered a new room */
+								_roomsFound->inclElement(RoomNum); /* Potentially entered a new room */
 								CurFileName = " ";
 								ForceDraw = true;
 							} else {
@@ -1095,11 +1095,11 @@ from_crumbs:
 					if ((CurInv == 0) || (CurInv > NumInv)) {
 						CurInv = 1;
 
-						while ((CurInv <= NumInv) && (!g_lab->_conditions->in(CurInv)))
+						while ((CurInv <= NumInv) && (!_conditions->in(CurInv)))
 							CurInv++;
 					}
 
-					if ((CurInv <= NumInv) && g_lab->_conditions->in(CurInv) &&
+					if ((CurInv <= NumInv) && _conditions->in(CurInv) &&
 					        Inventory[CurInv].BInvName)
 						Test = getInvName(CurInv);
 
@@ -1131,7 +1131,7 @@ from_crumbs:
 							FollowCrumbsFast = false;
 							IsCrumbTurning = false;
 							IsCrumbWaiting = false;
-							g_lab->getTime(&CrumbSecs, &CrumbMicros);
+							getTime(&CrumbSecs, &CrumbMicros);
 
 							eatMessages();
 							Alternate = false;
@@ -1210,11 +1210,11 @@ from_crumbs:
 						} else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
 							drawStaticMessage(kTextNothing);
 					} else if ((ActionMode == 5)  &&
-					         g_lab->_conditions->in(CurInv)) { /* Use an item on something else */
+					         _conditions->in(CurInv)) { /* Use an item on something else */
 						if (doOperateRule(curPos.x, curPos.y, CurInv, &CPtr)) {
 							CurFileName = NewFileName;
 
-							if (!g_lab->_conditions->in(CurInv))
+							if (!_conditions->in(CurInv))
 								decIncInv(&CurInv, false);
 						} else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
 							drawStaticMessage(kTextNothing);
@@ -1260,7 +1260,7 @@ from_crumbs:
 				interfaceOn(); /* Sets the correct gadget list */
 
 				if (Alternate) {
-					if (LastInv && g_lab->_conditions->in(LastInv))
+					if (LastInv && _conditions->in(LastInv))
 						CurInv = LastInv;
 					else
 						decIncInv(&CurInv, false);
@@ -1275,8 +1275,8 @@ from_crumbs:
 		}
 	}
 
-	delete g_lab->_conditions;
-	delete g_lab->_roomsFound;
+	delete _conditions;
+	delete _roomsFound;
 
 	if (_rooms) {
 		free(_rooms);
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 98082b7..d41322f 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -564,21 +564,21 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 	if (fadeout)
 		fade(false, 0);
 
-	g_lab->setAPen(0);
-	g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
+	setAPen(0);
+	rectFill(0, 0, _screenWidth - 1, _screenHeight - 1);
 
-	g_lab->drawImage(Map, 0, 0);
+	drawImage(Map, 0, 0);
 	drawGadgetList(MapGadgetList);
 
 	for (uint16 i = 1; i <= MaxRooms; i++) {
-		if ((Maps[i].PageNumber == Floor) && g_lab->_roomsFound->in(i) && Maps[i].x) {
+		if ((Maps[i].PageNumber == Floor) && _roomsFound->in(i) && Maps[i].x) {
 			drawRoom(i, (bool)(i == CurRoom));
 			g_music->updateMusic();
 		}
 	}
 
 	if ((Maps[CurRoom].PageNumber == Floor)   /* Makes sure the X is drawn in corridors */
-	        && g_lab->_roomsFound->in(CurRoom) /* NOTE: this here on purpose just in case there's some weird condition, like the surreal maze where there are no rooms */
+	        && _roomsFound->in(CurRoom) /* NOTE: this here on purpose just in case there's some weird condition, like the surreal maze where there are no rooms */
 	        && Maps[CurRoom].x)
 		drawRoom(CurRoom, true);
 
@@ -601,16 +601,16 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 	// Labyrinth specific code
 	if (Floor == LOWERFLOOR) {
 		if (onFloor(SURMAZEFLOOR))
-			g_lab->drawImage(Maze, mapScaleX(538), mapScaleY(277));
+			drawImage(Maze, mapScaleX(538), mapScaleY(277));
 	} else if (Floor == MIDDLEFLOOR) {
 		if (onFloor(CARNIVAL))
-			g_lab->drawImage(Maze, mapScaleX(358), mapScaleY(72));
+			drawImage(Maze, mapScaleX(358), mapScaleY(72));
 
 		if (onFloor(MEDMAZEFLOOR))
-			g_lab->drawImage(Maze, mapScaleX(557), mapScaleY(325));
+			drawImage(Maze, mapScaleX(557), mapScaleY(325));
 	} else if (Floor == UPPERFLOOR) {
 		if (onFloor(HEDGEMAZEFLOOR))
-			g_lab->drawImage(HugeMaze, mapScaleX(524), mapScaleY(97));
+			drawImage(HugeMaze, mapScaleX(524), mapScaleY(97));
 	} else if (Floor == SURMAZEFLOOR) {
 		sptr = (char *)g_resource->getStaticText(kTextSurmazeMessage).c_str();
 		flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr);
@@ -686,14 +686,14 @@ void LabEngine::processMap(uint16 CurRoom) {
 				newcolor[2] = newcolor[1];
 			}
 
-			g_lab->waitTOF();
-			g_lab->writeColorReg(newcolor, 1);
+			waitTOF();
+			writeColorReg(newcolor, 1);
 			_event->updateMouse();
-			g_lab->waitTOF();
+			waitTOF();
 			_event->updateMouse();
-			g_lab->waitTOF();
+			waitTOF();
 			_event->updateMouse();
-			g_lab->waitTOF();
+			waitTOF();
 			_event->updateMouse();
 
 			place++;
@@ -787,7 +787,7 @@ void LabEngine::processMap(uint16 CurRoom) {
 						roomCords(i, &x1, &y1, &x2, &y2);
 
 						if ((Maps[i].PageNumber == CurFloor)
-						        && g_lab->_roomsFound->in(i)
+						        && _roomsFound->in(i)
 						        && (MouseX >= x1) && (MouseX <= x2)
 						        && (MouseY >= y1) && (MouseY <= y2)) {
 							CurMsg = i;
@@ -800,8 +800,8 @@ void LabEngine::processMap(uint16 CurRoom) {
 
 						if ((sptr = _rooms[CurMsg]._roomMsg)) {
 							_event->mouseHide();
-							g_lab->setAPen(3);
-							g_lab->rectFill(VGAScaleX(13), VGAScaleY(148), VGAScaleX(135), VGAScaleY(186));
+							setAPen(3);
+							rectFill(VGAScaleX(13), VGAScaleY(148), VGAScaleX(135), VGAScaleY(186));
 							flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr);
 
 							if (Maps[OldMsg].PageNumber == CurFloor)
@@ -812,8 +812,8 @@ void LabEngine::processMap(uint16 CurRoom) {
 							y1 = (y1 + y2) / 2;
 
 							if ((CurMsg != CurRoom) && (Maps[CurMsg].PageNumber == CurFloor)) {
-								g_lab->setAPen(1);
-								g_lab->rectFill(x1 - 1, y1, x1, y1);
+								setAPen(1);
+								rectFill(x1 - 1, y1, x1, y1);
 							}
 
 							_event->mouseShow();
@@ -822,7 +822,7 @@ void LabEngine::processMap(uint16 CurRoom) {
 				}
 			}
 
-			g_lab->WSDL_UpdateScreen();
+			WSDL_UpdateScreen();
 		}
 	}
 }
@@ -850,18 +850,18 @@ void LabEngine::doMap(uint16 CurRoom) {
 	drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true);
 	_event->mouseShow();
 	_event->attachGadgetList(MapGadgetList);
-	g_lab->WSDL_UpdateScreen();
+	WSDL_UpdateScreen();
 	processMap(CurRoom);
 	_event->attachGadgetList(NULL);
 	fade(false, 0);
 	blackAllScreen();
 	_event->mouseHide();
-	g_lab->setAPen(0);
-	g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
+	setAPen(0);
+	rectFill(0, 0, _screenWidth - 1, _screenHeight - 1);
 	freeMapData();
 	blackAllScreen();
 	_event->mouseShow();
-	g_lab->WSDL_UpdateScreen();
+	WSDL_UpdateScreen();
 }
 
 } // End of namespace Lab
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index 73fdd2e..ace6459 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -79,14 +79,14 @@ Gadget *EventManager::checkGadgetHit(Gadget *gadlist, Common::Point pos) {
 				hitgad = gadlist;
 			} else {
 				mouseHide();
-				g_lab->drawImage(gadlist->ImAlt, gadlist->x, gadlist->y);
+				_vm->drawImage(gadlist->ImAlt, gadlist->x, gadlist->y);
 				mouseShow();
 
 				for (uint16 i = 0; i < 3; i++)
-					g_lab->waitTOF();
+					_vm->waitTOF();
 
 				mouseHide();
-				g_lab->drawImage(gadlist->Im, gadlist->x, gadlist->y);
+				_vm->drawImage(gadlist->Im, gadlist->x, gadlist->y);
 				mouseShow();
 			}
 
@@ -138,21 +138,21 @@ void EventManager::updateMouse() {
 
 	if (hitgad) {
 		mouseHide();
-		g_lab->drawImage(hitgad->ImAlt, hitgad->x, hitgad->y);
+		_vm->drawImage(hitgad->ImAlt, hitgad->x, hitgad->y);
 		mouseShow();
 
 		for (uint16 i = 0; i < 3; i++)
-			g_lab->waitTOF();
+			_vm->waitTOF();
 
 		mouseHide();
-		g_lab->drawImage(hitgad->Im, hitgad->x, hitgad->y);
+		_vm->drawImage(hitgad->Im, hitgad->x, hitgad->y);
 		mouseShow();
 		doUpdateDisplay = true;
 		hitgad = NULL;
 	}
 
 	if (doUpdateDisplay)
-		g_lab->WSDL_UpdateScreen();
+		_vm->WSDL_UpdateScreen();
 }
 
 
@@ -175,7 +175,7 @@ void EventManager::mouseShow() {
 		NumHidden--;
 
 	if ((NumHidden == 0) && MouseHidden) {
-		g_lab->WSDL_ProcessInput(0);
+		_vm->WSDL_ProcessInput(0);
 		MouseHidden = false;
 	}
 
@@ -201,9 +201,9 @@ void EventManager::mouseHide() {
 /*****************************************************************************/
 Common::Point EventManager::getMousePos() {
 	if (IsHiRes)
-		return g_lab->_mousePos;
+		return _vm->_mousePos;
 	else
-		return Common::Point(g_lab->_mousePos.x / 2, g_lab->_mousePos.y);
+		return Common::Point(_vm->_mousePos.x / 2, _vm->_mousePos.y);
 }
 
 
@@ -217,7 +217,7 @@ void EventManager::setMousePos(Common::Point pos) {
 		g_system->warpMouse(pos.x * 2, pos.y);
 
 	if (!MouseHidden)
-		g_lab->WSDL_ProcessInput(0);
+		_vm->WSDL_ProcessInput(0);
 }
 
 
@@ -229,15 +229,15 @@ void EventManager::setMousePos(Common::Point pos) {
 bool EventManager::mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
 	if (leftbutton) {
 		if (LeftClick) {
-			*x = (!IsHiRes) ? (uint16)g_lab->_mousePos.x / 2 : (uint16)g_lab->_mousePos.x;
-			*y = (uint16)g_lab->_mousePos.y;
+			*x = (!IsHiRes) ? (uint16)_vm->_mousePos.x / 2 : (uint16)_vm->_mousePos.x;
+			*y = (uint16)_vm->_mousePos.y;
 			LeftClick = false;
 			return true;
 		}
 	} else {
 		if (RightClick) {
-			*x = (!IsHiRes) ? (uint16)g_lab->_mousePos.x / 2 : (uint16)g_lab->_mousePos.x;
-			*y = (uint16)g_lab->_mousePos.y;
+			*x = (!IsHiRes) ? (uint16)_vm->_mousePos.x / 2 : (uint16)_vm->_mousePos.x;
+			*y = (uint16)_vm->_mousePos.y;
 			RightClick = false;
 			return true;
 		}
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index 61edf32..ca7d390 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -118,7 +118,7 @@ void LabEngine::diffNextFrame() {
 		return;
 
 	if (DispBitMap->Flags & BITMAPF_VIDEO) {
-		DispBitMap->Planes[0] = g_lab->getVGABaseAddr();
+		DispBitMap->Planes[0] = getVGABaseAddr();
 		DispBitMap->Planes[1] = DispBitMap->Planes[0] + 0x10000;
 		DispBitMap->Planes[2] = DispBitMap->Planes[1] + 0x10000;
 		DispBitMap->Planes[3] = DispBitMap->Planes[2] + 0x10000;
@@ -133,12 +133,12 @@ void LabEngine::diffNextFrame() {
 
 			if (!IsBM) {
 				if (headerdata.fps) {
-					g_lab->waitForTime(WaitSec, WaitMicros);
-					g_lab->addCurTime(0L, DelayMicros, &WaitSec, &WaitMicros);
+					waitForTime(WaitSec, WaitMicros);
+					addCurTime(0L, DelayMicros, &WaitSec, &WaitMicros);
 				}
 
 				if (IsPal && !nopalchange) {
-					g_lab->VGASetPal(diffcmap, 256);
+					VGASetPal(diffcmap, 256);
 					IsPal = false;
 				}
 
@@ -146,7 +146,7 @@ void LabEngine::diffNextFrame() {
 			}
 
 			if (IsPal && !nopalchange && !IsBM && !donepal) {
-				g_lab->VGASetPal(diffcmap, 256);
+				VGASetPal(diffcmap, 256);
 				IsPal = false;
 			}
 
@@ -161,7 +161,7 @@ void LabEngine::diffNextFrame() {
 			CurBit = 0;
 
 			if (DispBitMap->Flags & BITMAPF_VIDEO)
-				g_lab->WSDL_UpdateScreen();
+				WSDL_UpdateScreen();
 
 			return; /* done with the next frame. */
 		}
@@ -229,7 +229,7 @@ void LabEngine::diffNextFrame() {
 			if (waitForEffect) {
 				while (g_music->isSoundEffectActive()) {
 					g_music->updateMusic();
-					g_lab->waitTOF();
+					waitTOF();
 				}
 			}
 
@@ -255,7 +255,7 @@ void LabEngine::diffNextFrame() {
 				if (waitForEffect) {
 					while (g_music->isSoundEffectActive()) {
 						g_music->updateMusic();
-						g_lab->waitTOF();
+						waitTOF();
 
 						if (DispBitMap->Flags & BITMAPF_VIDEO)
 							didTOF = 1;
@@ -266,7 +266,7 @@ void LabEngine::diffNextFrame() {
 				_event->mouseShow();
 
 				if (!didTOF)
-					g_lab->WSDL_UpdateScreen();
+					WSDL_UpdateScreen();
 
 				return;
 			}
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 4e61b3c..9b0ed42 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -692,10 +692,10 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 
 	drawJournalText();
 
-	ScreenImage.ImageData = g_lab->getVGABaseAddr();
+	ScreenImage.ImageData = getVGABaseAddr();
 
 	if (wipenum == 0)
-		g_lab->bltBitMap(&JBackImage, 0, 0, &ScreenImage, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight);
+		bltBitMap(&JBackImage, 0, 0, &ScreenImage, 0, 0, _screenWidth, _screenHeight);
 	else
 		turnPage((bool)(wipenum == 1));
 
@@ -714,7 +714,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 		fade(true, 0);
 
 	nopalchange = true;
-	JBackImage.ImageData = readPictToMem("P:Journal.pic", g_lab->_screenWidth, g_lab->_screenHeight);
+	JBackImage.ImageData = readPictToMem("P:Journal.pic", _screenWidth, _screenHeight);
 	GotBackImage = true;
 
 	eatMessages();
@@ -775,15 +775,15 @@ void LabEngine::doJournal() {
 	lastpage    = false;
 	GotBackImage = false;
 
-	JBackImage.Width = g_lab->_screenWidth;
-	JBackImage.Height = g_lab->_screenHeight;
+	JBackImage.Width = _screenWidth;
+	JBackImage.Height = _screenHeight;
 	JBackImage.ImageData   = NULL;
 
 	BackG.NextGadget = &CancelG;
 	CancelG.NextGadget = &ForwardG;
 
 	ScreenImage = JBackImage;
-	ScreenImage.ImageData = g_lab->getVGABaseAddr();
+	ScreenImage.ImageData = getVGABaseAddr();
 
 	g_music->updateMusic();
 	loadJournalData();
@@ -797,10 +797,10 @@ void LabEngine::doJournal() {
 	fade(false, 0);
 	_event->mouseHide();
 
-	ScreenImage.ImageData = g_lab->getVGABaseAddr();
+	ScreenImage.ImageData = getVGABaseAddr();
 
-	g_lab->setAPen(0);
-	g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
+	setAPen(0);
+	rectFill(0, 0, _screenWidth - 1, _screenHeight - 1);
 	blackScreen();
 
 	freeAllStolenMem();
@@ -892,17 +892,17 @@ void LabEngine::drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16
 		else
 			MonGadHeight = fheight;
 
-		g_lab->setAPen(0);
-		g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, y2);
+		setAPen(0);
+		rectFill(0, 0, _screenWidth - 1, y2);
 
 		for (uint16 i = 0; i < numlines; i++)
-			g_lab->drawImage(MonButton, 0, i * MonGadHeight);
+			drawImage(MonButton, 0, i * MonGadHeight);
 	} else if (isinteractive) {
-		g_lab->setAPen(0);
-		g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, y2);
+		setAPen(0);
+		rectFill(0, 0, _screenWidth - 1, y2);
 	} else {
-		g_lab->setAPen(0);
-		g_lab->rectFill(x1, y1, x2, y2);
+		setAPen(0);
+		rectFill(x1, y1, x2, y2);
 	}
 
 	while (DrawingToPage < monitorPage) {
@@ -1072,8 +1072,8 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 
 	freeAllStolenMem();
 
-	g_lab->setAPen(0);
-	g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
+	setAPen(0);
+	rectFill(0, 0, _screenWidth - 1, _screenHeight - 1);
 	blackAllScreen();
 }
 
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 3ed26e1..c7252d4 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -43,15 +43,15 @@ namespace Lab {
 /*****************************************************************************/
 bool LabEngine::createScreen(bool HiRes) {
 	if (HiRes) {
-		g_lab->_screenWidth  = 640;
-		g_lab->_screenHeight = 480;
+		_screenWidth  = 640;
+		_screenHeight = 480;
 	} else {
-		g_lab->_screenWidth  = 320;
-		g_lab->_screenHeight = 200;
+		_screenWidth  = 320;
+		_screenHeight = 200;
 	}
-	g_lab->_screenBytesPerPage = g_lab->_screenWidth * g_lab->_screenHeight;
+	_screenBytesPerPage = _screenWidth * _screenHeight;
 
-	_displayBuffer = (byte *)malloc(g_lab->_screenBytesPerPage);
+	_displayBuffer = (byte *)malloc(_screenBytesPerPage);
 
 	return true;
 }
@@ -106,8 +106,8 @@ void LabEngine::WSDL_ProcessInput(bool can_delay) {
 					_mousePos.x = 0;
 					_mouseAtEdge = true;
 				}
-				if (_mousePos.x > g_lab->_screenWidth - 1) {
-					_mousePos.x = g_lab->_screenWidth;
+				if (_mousePos.x > _screenWidth - 1) {
+					_mousePos.x = _screenWidth;
 					_mouseAtEdge = true;
 				}
 
@@ -116,8 +116,8 @@ void LabEngine::WSDL_ProcessInput(bool can_delay) {
 					_mousePos.y = 0;
 					_mouseAtEdge = true;
 				}
-				if (_mousePos.y > g_lab->_screenHeight - 1) {
-					_mousePos.y = g_lab->_screenHeight;
+				if (_mousePos.y > _screenHeight - 1) {
+					_mousePos.y = _screenHeight;
 					_mouseAtEdge = true;
 				}
 
@@ -157,7 +157,7 @@ void LabEngine::WSDL_ProcessInput(bool can_delay) {
 				break;
 			}
 
-			g_system->copyRectToScreen(_displayBuffer, g_lab->_screenWidth, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight);
+			g_system->copyRectToScreen(_displayBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight);
 			g_system->updateScreen();
 		}
 	}
@@ -173,7 +173,7 @@ Common::Point LabEngine::WSDL_GetMousePos() {
 }
 
 void LabEngine::waitTOF() {
-	g_system->copyRectToScreen(_displayBuffer, g_lab->_screenWidth, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight);
+	g_system->copyRectToScreen(_displayBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight);
 	g_system->updateScreen();
 
   	WSDL_ProcessInput(0);
@@ -235,7 +235,7 @@ void LabEngine::VGASetPal(void *cmap, uint16 numcolors) {
 }
 
 void LabEngine::WSDL_UpdateScreen() {
-	g_system->copyRectToScreen(_displayBuffer, g_lab->_screenWidth, 0, 0, g_lab->_screenWidth, g_lab->_screenHeight);
+	g_system->copyRectToScreen(_displayBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight);
 	g_system->updateScreen();
 
 	WSDL_ProcessInput(0);
@@ -276,20 +276,20 @@ void LabEngine::drawImage(Image *Im, uint16 x, uint16 y) {
 		dy = 0;
 	}
 
-	if (dx + w > g_lab->_screenWidth)
-		w = g_lab->_screenWidth - dx;
+	if (dx + w > _screenWidth)
+		w = _screenWidth - dx;
 
-	if (dy + h > g_lab->_screenHeight)
-		h = g_lab->_screenHeight - dy;
+	if (dy + h > _screenHeight)
+		h = _screenHeight - dy;
 
 	if ((w > 0) && (h > 0)) {
 		byte *s = Im->ImageData + sy * Im->Width + sx;
-		byte *d = getVGABaseAddr() + dy * g_lab->_screenWidth + dx;
+		byte *d = getVGABaseAddr() + dy * _screenWidth + dx;
 
 		while (h-- > 0) {
 			memcpy(d, s, w);
 			s += Im->Width;
-			d += g_lab->_screenWidth;
+			d += _screenWidth;
 		}
 	}
 }
@@ -319,15 +319,15 @@ void LabEngine::drawMaskImage(Image *Im, uint16 x, uint16 y) {
 		dy = 0;
 	}
 
-	if (dx + w > g_lab->_screenWidth)
-		w = g_lab->_screenWidth - dx;
+	if (dx + w > _screenWidth)
+		w = _screenWidth - dx;
 
-	if (dy + h > g_lab->_screenHeight)
-		h = g_lab->_screenHeight - dy;
+	if (dy + h > _screenHeight)
+		h = _screenHeight - dy;
 
 	if ((w > 0) && (h > 0)) {
 		byte *s = Im->ImageData + sy * Im->Width + sx;
-		byte *d = getVGABaseAddr() + dy * g_lab->_screenWidth + dx;
+		byte *d = getVGABaseAddr() + dy * _screenWidth + dx;
 
 		while (h-- > 0) {
 			byte *ss = s;
@@ -342,7 +342,7 @@ void LabEngine::drawMaskImage(Image *Im, uint16 x, uint16 y) {
 			}
 
 			s += Im->Width;
-			d += g_lab->_screenWidth;
+			d += _screenWidth;
 		}
 	}
 }
@@ -372,20 +372,20 @@ void LabEngine::readScreenImage(Image *Im, uint16 x, uint16 y) {
 		dy = 0;
 	}
 
-	if (dx + w > g_lab->_screenWidth)
-		w = g_lab->_screenWidth - dx;
+	if (dx + w > _screenWidth)
+		w = _screenWidth - dx;
 
-	if (dy + h > g_lab->_screenHeight)
-		h = g_lab->_screenHeight - dy;
+	if (dy + h > _screenHeight)
+		h = _screenHeight - dy;
 
 	if ((w > 0) && (h > 0)) {
 		byte *s = Im->ImageData + sy * Im->Width + sx;
-		byte *d = getVGABaseAddr() + dy * g_lab->_screenWidth + dx;
+		byte *d = getVGABaseAddr() + dy * _screenWidth + dx;
 
 		while (h-- > 0) {
 			memcpy(s, d, w);
 			s += Im->Width;
-			d += g_lab->_screenWidth;
+			d += _screenWidth;
 		}
 	}
 }
@@ -549,14 +549,14 @@ void LabEngine::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 		dy = 0;
 	}
 
-	if (dx + w > g_lab->_screenWidth)
-		w = g_lab->_screenWidth - dx;
+	if (dx + w > _screenWidth)
+		w = _screenWidth - dx;
 
-	if (dy + h > g_lab->_screenHeight)
-		h = g_lab->_screenHeight - dy;
+	if (dy + h > _screenHeight)
+		h = _screenHeight - dy;
 
 	if ((w > 0) && (h > 0)) {
-		char *d = (char *)getVGABaseAddr() + dy * g_lab->_screenWidth + dx;
+		char *d = (char *)getVGABaseAddr() + dy * _screenWidth + dx;
 
 		while (h-- > 0) {
 			char *dd = d;
@@ -566,7 +566,7 @@ void LabEngine::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 				*dd++ = _curapen;
 			}
 
-			d += g_lab->_screenWidth;
+			d += _screenWidth;
 		}
 	}
 }
@@ -606,14 +606,14 @@ void LabEngine::ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uin
 		dy = 0;
 	}
 
-	if (dx + w > g_lab->_screenWidth)
-		w = g_lab->_screenWidth - dx;
+	if (dx + w > _screenWidth)
+		w = _screenWidth - dx;
 
-	if (dy + h > g_lab->_screenHeight)
-		h = g_lab->_screenHeight - dy;
+	if (dy + h > _screenHeight)
+		h = _screenHeight - dy;
 
 	if ((w > 0) && (h > 0)) {
-		char *d = (char *)getVGABaseAddr() + dy * g_lab->_screenWidth + dx;
+		char *d = (char *)getVGABaseAddr() + dy * _screenWidth + dx;
 
 		while (h-- > 0) {
 			char *dd = d;
@@ -630,7 +630,7 @@ void LabEngine::ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uin
 				ww -= 2;
 			}
 
-			d += g_lab->_screenWidth;
+			d += _screenWidth;
 			dy++;
 		}
 	}


Commit: 0c84355f4ae5651e7667b9aa0d2d3c6c28f21496
    https://github.com/scummvm/scummvm/commit/0c84355f4ae5651e7667b9aa0d2d3c6c28f21496
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:43+01:00

Commit Message:
LAB: Move IsHiRes to main engine class

Changed paths:
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/intro.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/machine.cpp
    engines/lab/map.cpp
    engines/lab/mouse.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index c3aa5f4..e246d6d 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -47,7 +47,7 @@ bool LongWinInFront = false;
 
 TextFont *MsgFont;
 
-extern bool DoBlack, waitForEffect, stopsound, DoNotDrawMessage, IsHiRes, nopalchange;
+extern bool DoBlack, waitForEffect, stopsound, DoNotDrawMessage, nopalchange;
 
 /* Global parser data */
 
@@ -224,7 +224,7 @@ bool LabEngine::setUpScreens() {
 	Gadget *curgad;
 	uint16 y;
 
-	if (!createScreen(IsHiRes))
+	if (!createScreen(_isHiRes))
 		return false;
 
 	/* Loads in the graphics for the movement control panel */
@@ -1299,10 +1299,10 @@ from_crumbs:
 void LabEngine::go() {
 	bool dointro = true;
 
-	IsHiRes = ((getFeatures() & GF_LOWRES) == 0);
+	_isHiRes = ((getFeatures() & GF_LOWRES) == 0);
 
 #if 0
-	if (IsHiRes)
+	if (_isHiRes)
 		warning("Running in HiRes mode");
 	else
 		warning("Running in LowRes mode");
@@ -1317,7 +1317,7 @@ void LabEngine::go() {
 	}
 
 	if (!setUpScreens()) {
-		IsHiRes = false;
+		_isHiRes = false;
 		mem = mem && setUpScreens();
 	}
 
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index ab04c3e..218f3c6 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -48,7 +48,6 @@ extern char diffcmap[256 * 3];
 extern bool IsBM, nopalchange;
 
 extern bool DoBlack, stopsound;
-extern bool IsHiRes;
 extern TextFont *MsgFont;
 extern const char *CurFileName;
 
@@ -438,7 +437,7 @@ void LabEngine::doScrollBlack() {
 	while (nheight) {
 		g_music->updateMusic();
 
-		if (!IsHiRes)
+		if (!_isHiRes)
 			g_lab->waitTOF();
 
 		BaseAddr = (uint32 *)g_lab->getVGABaseAddr();
@@ -468,7 +467,7 @@ void LabEngine::doScrollBlack() {
 
 		g_lab->WSDL_UpdateScreen();
 
-		if (!IsHiRes) {
+		if (!_isHiRes) {
 			if (nheight <= (height / 8))
 				by = 1;
 			else if (nheight <= (height / 4))
@@ -626,7 +625,7 @@ void LabEngine::doTransWipe(CloseDataPtr *CPtr, char *filename) {
 	uint16 LastY, CurY, linesdone = 0, lineslast;
 	Image ImSource, ImDest;
 
-	if (IsHiRes) {
+	if (_isHiRes) {
 		lineslast = 3;
 		LastY = 358;
 	} else {
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 43bb7c6..269922b 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -37,7 +37,7 @@
 #include "lab/interface.h"
 
 namespace Lab {
-extern bool nopalchange, DoBlack, IsHiRes;
+extern bool nopalchange, DoBlack;
 extern char diffcmap[256 * 3];
 extern uint16 *FadePalette;
 
@@ -118,7 +118,7 @@ void Intro::doPictText(const char *filename, bool isscreen) {
 				g_lab->setAPen(7L);
 				g_lab->rectFill(VGAScaleX(10), VGAScaleY(10), VGAScaleX(310), VGAScaleY(190));
 
-				Drawn = flowText(_msgfont, (!IsHiRes) * -1, 5, 7, false, false, true, true, VGAScaleX(14), VGAScaleY(11), VGAScaleX(306), VGAScaleY(189), (char *)curplace);
+				Drawn = flowText(_msgfont, (!g_lab->_isHiRes) * -1, 5, 7, false, false, true, true, VGAScaleX(14), VGAScaleY(11), VGAScaleX(306), VGAScaleY(189), (char *)curplace);
 				fade(true, 0);
 			} else {
 				Drawn = g_lab->longDrawMessage((char *)curplace);
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 5cc49b0..b2e779f 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -72,6 +72,7 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
     _nextKeyIn = 0;
     _nextKeyOut = 0;
 
+	_isHiRes = false;
 	//const Common::FSNode gameDataDir(ConfMan.get("path"));
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game/pict");
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 4b5f5d1..8ead009 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -113,6 +113,7 @@ private:
 	bool _mouseAtEdge;
 public:
 	byte *_tempScrollData;
+	bool _isHiRes;
 
 private:
 	bool createScreen(bool HiRes);
diff --git a/engines/lab/machine.cpp b/engines/lab/machine.cpp
index b2ce65e..2bef80d 100644
--- a/engines/lab/machine.cpp
+++ b/engines/lab/machine.cpp
@@ -30,18 +30,17 @@
 
 #include "common/str.h"
 
+#include "lab/lab.h"
 #include "lab/stddefines.h"
 
 namespace Lab {
 
-bool IsHiRes = false;
-
 /*****************************************************************************/
 /* Scales the x co-ordinates to that of the new display.  In the room parser */
 /* file, co-ordinates are set up on a 360x336 display.                       */
 /*****************************************************************************/
 uint16 scaleX(uint16 x) {
-	if (IsHiRes)
+	if (g_lab->_isHiRes)
 		return (uint16)((x * 16) / 9);
 	else
 		return (uint16)((x * 8) / 9);
@@ -52,7 +51,7 @@ uint16 scaleX(uint16 x) {
 /* file, co-ordinates are set up on a 368x336 display.                       */
 /*****************************************************************************/
 uint16 scaleY(uint16 y) {
-	if (IsHiRes)
+	if (g_lab->_isHiRes)
 		return (y + (y / 14));
 	else
 		return ((y * 10) / 24);
@@ -62,7 +61,7 @@ uint16 scaleY(uint16 y) {
 /* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
 /*****************************************************************************/
 int16 VGAScaleX(int16 x) {
-	if (IsHiRes)
+	if (g_lab->_isHiRes)
 		return (x * 2);
 	else
 		return x;
@@ -72,14 +71,14 @@ int16 VGAScaleX(int16 x) {
 /* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
 /*****************************************************************************/
 int16 VGAScaleY(int16 y) {
-	if (IsHiRes)
+	if (g_lab->_isHiRes)
 		return ((y * 12) / 5);
 	else
 		return y;
 }
 
 uint16 SVGACord(uint16 cord) {
-	if (IsHiRes)
+	if (g_lab->_isHiRes)
 		return cord;
 	else
 		return 0;
@@ -89,7 +88,7 @@ uint16 SVGACord(uint16 cord) {
 /* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
 /*****************************************************************************/
 int VGAUnScaleX(int x) {
-	if (IsHiRes)
+	if (g_lab->_isHiRes)
 		return (x / 2);
 	else
 		return x;
@@ -99,7 +98,7 @@ int VGAUnScaleX(int x) {
 /* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
 /*****************************************************************************/
 int VGAUnScaleY(int y) {
-	if (IsHiRes)
+	if (g_lab->_isHiRes)
 		return ((y * 5) / 12);
 	else
 		return y;
@@ -108,7 +107,7 @@ int VGAUnScaleY(int y) {
 static char NewFileName[255];
 
 /*****************************************************************************/
-/* Modifes the filename so that paths and stuff are correct.  Should mostly  */
+/* Modifies the filename so that paths and stuff are correct.  Should mostly  */
 /* deal with assigns and the '/' instead of '\' on IBM systems.              */
 /*                                                                           */
 /* NOTE: Make a *copy* of the string, and modify that.  It would be a real   */
@@ -122,7 +121,7 @@ char *translateFileName(const char *filename) {
 	Common::String fileNameStrFinal;
 
 	if (fileNameStr.hasPrefix("P:")) {
-		if (IsHiRes)
+		if (g_lab->_isHiRes)
 			fileNameStrFinal = "GAME/SPICT/";
 		else
 			fileNameStrFinal = "GAME/PICT/";
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index d41322f..e4b8b32 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -47,7 +47,6 @@ static TextFont bmf;
 
 
 extern uint16 Direction;
-extern bool IsHiRes;
 
 extern CloseDataPtr CPtr;
 extern uint16 RoomNum;
@@ -170,7 +169,7 @@ static uint16 AmigaMapPalette[] = {
 
 
 static uint16 mapScaleX(uint16 x) {
-	if (IsHiRes)
+	if (g_lab->_isHiRes)
 		return (x - 45);
 	else
 		return ((x - 45) >> 1);
@@ -179,7 +178,7 @@ static uint16 mapScaleX(uint16 x) {
 
 
 static uint16 mapScaleY(uint16 y) {
-	if (IsHiRes)
+	if (g_lab->_isHiRes)
 		return y;
 	else
 		return ((y - 35) >> 1) - (y >> 6);
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index ace6459..eeae317 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -35,8 +35,6 @@
 
 namespace Lab {
 
-extern bool IsHiRes;
-
 static bool LeftClick = false;
 static bool RightClick = false;
 
@@ -75,7 +73,7 @@ Gadget *EventManager::checkGadgetHit(Gadget *gadlist, Common::Point pos) {
 		    (pos.x <= (gadlist->x + gadlist->Im->Width)) &&
 		    (pos.y <= (gadlist->y + gadlist->Im->Height)) &&
 		     !(GADGETOFF & gadlist->GadgetFlags)) {
-			if (IsHiRes) {
+			if (_vm->_isHiRes) {
 				hitgad = gadlist;
 			} else {
 				mouseHide();
@@ -118,7 +116,7 @@ void EventManager::mouseHandler(int flag, Common::Point pos) {
 	if (flag & 0x02) { /* Left mouse button click */
 		Gadget *tmp = NULL;
 		if (ScreenGadgetList)
-			tmp = checkGadgetHit(ScreenGadgetList, IsHiRes ? pos : Common::Point(pos.x / 2, pos.y));
+			tmp = checkGadgetHit(ScreenGadgetList, _vm->_isHiRes ? pos : Common::Point(pos.x / 2, pos.y));
 
 		if (tmp)
 			LastGadgetHit = tmp;
@@ -200,7 +198,7 @@ void EventManager::mouseHide() {
 /* from virtual to screen co-ordinates automatically.                        */
 /*****************************************************************************/
 Common::Point EventManager::getMousePos() {
-	if (IsHiRes)
+	if (_vm->_isHiRes)
 		return _vm->_mousePos;
 	else
 		return Common::Point(_vm->_mousePos.x / 2, _vm->_mousePos.y);
@@ -211,7 +209,7 @@ Common::Point EventManager::getMousePos() {
 /* Moves the mouse to new co-ordinates.                                      */
 /*****************************************************************************/
 void EventManager::setMousePos(Common::Point pos) {
-	if (IsHiRes)
+	if (_vm->_isHiRes)
 		g_system->warpMouse(pos.x, pos.y);
 	else
 		g_system->warpMouse(pos.x * 2, pos.y);
@@ -229,14 +227,14 @@ void EventManager::setMousePos(Common::Point pos) {
 bool EventManager::mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
 	if (leftbutton) {
 		if (LeftClick) {
-			*x = (!IsHiRes) ? (uint16)_vm->_mousePos.x / 2 : (uint16)_vm->_mousePos.x;
+			*x = (!_vm->_isHiRes) ? (uint16)_vm->_mousePos.x / 2 : (uint16)_vm->_mousePos.x;
 			*y = (uint16)_vm->_mousePos.y;
 			LeftClick = false;
 			return true;
 		}
 	} else {
 		if (RightClick) {
-			*x = (!IsHiRes) ? (uint16)_vm->_mousePos.x / 2 : (uint16)_vm->_mousePos.x;
+			*x = (!_vm->_isHiRes) ? (uint16)_vm->_mousePos.x / 2 : (uint16)_vm->_mousePos.x;
 			*y = (uint16)_vm->_mousePos.y;
 			RightClick = false;
 			return true;
@@ -249,7 +247,7 @@ bool EventManager::mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
 Gadget *EventManager::mouseGadget() {
 	Gadget *Temp = LastGadgetHit;
 
-	LastGadgetHit = NULL;
+	LastGadgetHit = nullptr;
 	return Temp;
 }
 
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 9b0ed42..96f7bfd 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -85,7 +85,7 @@ uint16 CurTile[4][4] = {
 
 extern TextFont *MsgFont;
 extern uint16 *FadePalette;
-extern bool nopalchange, DoBlack, IsHiRes;
+extern bool nopalchange, DoBlack;
 extern BitMap *DispBitMap, *DrawBitMap;
 extern char diffcmap[3 * 256];
 extern CloseDataPtr CPtr;
@@ -187,7 +187,7 @@ static void changeCombination(uint16 number) {
 	display.Height    = g_lab->_screenHeight;
 
 	for (uint16 i = 1; i <= (Images[combnum]->Height / 2); i++) {
-		if (IsHiRes) {
+		if (g_lab->_isHiRes) {
 			if (i & 1)
 				g_lab->waitTOF();
 		} else


Commit: 771e558d905ee467280482d62697dc66d969ed2b
    https://github.com/scummvm/scummvm/commit/771e558d905ee467280482d62697dc66d969ed2b
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:44+01:00

Commit Message:
LAB: Move the global variable g_resource to the main engine class

Changed paths:
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/intro.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/labfun.h
    engines/lab/labsets.cpp
    engines/lab/map.cpp
    engines/lab/processroom.cpp
    engines/lab/resource.cpp
    engines/lab/resource.h
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index e246d6d..d7561d1 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -650,13 +650,13 @@ void LabEngine::mainGameLoop() {
 	RoomNum = 1;
 	Direction = NORTH;
 
-	g_resource->readRoomData("LAB:Doors");
-	g_resource->readInventory("LAB:Inventor");
+	_resource->readRoomData("LAB:Doors");
+	_resource->readInventory("LAB:Inventor");
 
-	if (!(_conditions = new LargeSet(HighestCondition + 1)))
+	if (!(_conditions = new LargeSet(HighestCondition + 1, this)))
 		return;
 
-	if (!(_roomsFound = new LargeSet(ManyRooms + 1)))
+	if (!(_roomsFound = new LargeSet(ManyRooms + 1, this)))
 		return;
 
 	_conditions->readInitialConditions("LAB:Conditio");
@@ -1328,7 +1328,7 @@ void LabEngine::go() {
 	if (!dointro)
 		g_music->initMusic();
 
-	MsgFont = g_resource->getFont("P:AvanteG.12");
+	MsgFont = _resource->getFont("P:AvanteG.12");
 
 	_event->mouseHide();
 
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 218f3c6..80d78ed 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -93,7 +93,7 @@ bool readPict(const char *filename, bool PlayOnce) {
 /* Reads in a music file.  Ignores any graphics.                             */
 /*****************************************************************************/
 bool readMusic(const char *filename, bool waitTillFinished) {
-	Common::File *file = g_resource->openDataFile(filename, MKTAG('D', 'I', 'F', 'F'));
+	Common::File *file = g_lab->_resource->openDataFile(filename, MKTAG('D', 'I', 'F', 'F'));
 	g_music->updateMusic();
 	if (!g_music->_doNotFilestopSoundEffect)
 		g_music->stopSoundEffect();
@@ -360,7 +360,7 @@ int32 LabEngine::longDrawMessage(const char *str) {
 }
 
 void LabEngine::drawStaticMessage(byte index) {
-	drawMessage(g_resource->getStaticText((StaticText)index).c_str());
+	drawMessage(_resource->getStaticText((StaticText)index).c_str());
 }
 
 /******************************************************************************/
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 269922b..7cbe48c 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -347,7 +347,7 @@ void Intro::introSequence() {
 	blackAllScreen();
 	g_music->updateMusic();
 
-	_msgfont = g_resource->getFont("P:Map.fon");
+	_msgfont = g_lab->_resource->getFont("P:Map.fon");
 
 	nopalchange = true;
 	nReadPict("Intro.1", true);
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index b2e779f..3792f2b 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -73,6 +73,10 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
     _nextKeyOut = 0;
 
 	_isHiRes = false;
+
+	_event = nullptr;
+	_resource = nullptr;
+
 	//const Common::FSNode gameDataDir(ConfMan.get("path"));
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game/pict");
@@ -83,6 +87,9 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 LabEngine::~LabEngine() {
 	// Remove all of our debug levels here
 	DebugMan.clearAllDebugChannels();
+
+	delete _event;
+	delete _resource;
 }
 
 Common::Error LabEngine::run() {
@@ -92,9 +99,9 @@ Common::Error LabEngine::run() {
 		initGraphics(640, 480, true);
 
 	_event = new EventManager(this);
+	_resource = new Resource(this);
 
 	g_music = new Music();
-	g_resource = new Resource();
 
 	if (getPlatform() == Common::kPlatformWindows) {
 		// Check if this is the Wyrmkeep trial
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 8ead009..7e7f645 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -38,6 +38,7 @@
 #include "lab/labfun.h"
 #include "lab/interface.h"
 #include "lab/mouse.h"
+#include "lab/resource.h"
 
 struct ADGameDescription;
 
@@ -99,6 +100,8 @@ private:
 
 public:
 	EventManager *_event;
+	Resource *_resource;
+
 	byte *_currentDsplayBuffer;
 	Common::Point _mousePos;
 
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index f602d60..dd4796a 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -47,6 +47,8 @@
 
 namespace Lab {
 
+class LabEngine;
+
 /* Direction defines */
 #define NORTH   0
 #define SOUTH   1
@@ -209,12 +211,16 @@ extern Music *g_music;
 
 class LargeSet {
 public:
-    LargeSet(uint16 last);
+    LargeSet(uint16 last, LabEngine *vm);
     ~LargeSet();
     bool in(uint16 element);
     void inclElement(uint16 element);
     void exclElement(uint16 element);
     bool readInitialConditions(const char *fileName);
+
+private:
+	LabEngine *_vm;
+
 public:
     uint16 _lastElement;
     uint16 *_array;
diff --git a/engines/lab/labsets.cpp b/engines/lab/labsets.cpp
index 4dcc0c8..edd7646 100644
--- a/engines/lab/labsets.cpp
+++ b/engines/lab/labsets.cpp
@@ -28,13 +28,14 @@
  *
  */
 
+#include "lab/lab.h"
 #include "lab/stddefines.h"
 #include "lab/labfun.h"
 #include "lab/resource.h"
 
 namespace Lab {
 
-LargeSet::LargeSet(uint16 last) {
+	LargeSet::LargeSet(uint16 last, LabEngine *vm) : _vm(vm) {
 	last = (((last + 15) >> 4) << 4);
 
 	_array = (uint16 *)calloc(last >> 3, 2);
@@ -60,7 +61,7 @@ void LargeSet::exclElement(uint16 element) {
 bool LargeSet::readInitialConditions(const char *fileName) {
 	Common::File *file;
 
-	if (file = g_resource->openDataFile(fileName, MKTAG('C', 'O', 'N', '0'))) {
+	if (file = _vm->_resource->openDataFile(fileName, MKTAG('C', 'O', 'N', '0'))) {
 		uint16 conditions = file->readUint16LE();
 		for (int i = 0; i < conditions; i++) {
 			inclElement(file->readUint16LE());
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index e4b8b32..e4a6f04 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -196,7 +196,7 @@ static bool loadMapData() {
 
 	BigMsgFont = &bmf;
 
-	if (!(BigMsgFont = g_resource->getFont("P:Map.fon")))
+	if (!(BigMsgFont = g_lab->_resource->getFont("P:Map.fon")))
 		BigMsgFont = MsgFont;
 
 	resetBuffer();  /* Make images load into start of buffer */
@@ -249,7 +249,7 @@ static bool loadMapData() {
 		counter++;
 	}
 
-	Common::File *mapFile = g_resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0'));
+	Common::File *mapFile = g_lab->_resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0'));
 	if (!mapFile)
 		error("Corrupt map file");
 	g_music->updateMusic();
@@ -611,31 +611,31 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 		if (onFloor(HEDGEMAZEFLOOR))
 			drawImage(HugeMaze, mapScaleX(524), mapScaleY(97));
 	} else if (Floor == SURMAZEFLOOR) {
-		sptr = (char *)g_resource->getStaticText(kTextSurmazeMessage).c_str();
+		sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str();
 		flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr);
 	}
 
 	switch (Floor) {
 	case LOWERFLOOR:
-		sptr = (char *)g_resource->getStaticText(kTextLowerFloor).c_str();
+		sptr = (char *)_resource->getStaticText(kTextLowerFloor).c_str();
 		break;
 	case MIDDLEFLOOR:
-		sptr = (char *)g_resource->getStaticText(kTextMiddleFloor).c_str();
+		sptr = (char *)_resource->getStaticText(kTextMiddleFloor).c_str();
 		break;
 	case UPPERFLOOR:
-		sptr = (char *)g_resource->getStaticText(kTextUpperFloor).c_str();
+		sptr = (char *)_resource->getStaticText(kTextUpperFloor).c_str();
 		break;
 	case MEDMAZEFLOOR:
-		sptr = (char *)g_resource->getStaticText(kTextMedMazeFloor).c_str();
+		sptr = (char *)_resource->getStaticText(kTextMedMazeFloor).c_str();
 		break;
 	case HEDGEMAZEFLOOR:
-		sptr = (char *)g_resource->getStaticText(kTextHedgeMazeFloor).c_str();
+		sptr = (char *)_resource->getStaticText(kTextHedgeMazeFloor).c_str();
 		break;
 	case SURMAZEFLOOR:
-		sptr = (char *)g_resource->getStaticText(kTextSurMazeFloor).c_str();
+		sptr = (char *)_resource->getStaticText(kTextSurMazeFloor).c_str();
 		break;
 	case CARNIVAL:
-		sptr = (char *)g_resource->getStaticText(kTextCarnivalFloor).c_str();
+		sptr = (char *)_resource->getStaticText(kTextCarnivalFloor).c_str();
 		break;
 	default:
 		sptr = NULL;
@@ -795,7 +795,7 @@ void LabEngine::processMap(uint16 CurRoom) {
 
 					if (OldMsg != CurMsg) {
 						if (_rooms[CurMsg]._roomMsg == nullptr)
-							g_resource->readViews(CurMsg);
+							_resource->readViews(CurMsg);
 
 						if ((sptr = _rooms[CurMsg]._roomMsg)) {
 							_event->mouseHide();
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 1932d48..ef1a801 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -96,7 +96,7 @@ ViewData *getViewData(uint16 roomNum, uint16 direction) {
 	ViewData *view = NULL;
 
 	if (!_rooms[roomNum]._roomMsg)
-		g_resource->readViews(roomNum);
+		g_lab->_resource->readViews(roomNum);
 
 	if (direction == NORTH)
 		view = _rooms[roomNum]._northView;
@@ -202,13 +202,13 @@ void LabEngine::drawDirection(CloseDataPtr LCPtr) {
 	}
 
 	if (Direction == NORTH)
-		message += g_resource->getStaticText(kTextFacingNorth);
+		message += _resource->getStaticText(kTextFacingNorth);
 	else if (Direction == EAST)
-		message += g_resource->getStaticText(kTextFacingEast);
+		message += _resource->getStaticText(kTextFacingEast);
 	else if (Direction == SOUTH)
-		message += g_resource->getStaticText(kTextFacingSouth);
+		message += _resource->getStaticText(kTextFacingSouth);
 	else if (Direction == WEST)
-		message += g_resource->getStaticText(kTextFacingWest);
+		message += _resource->getStaticText(kTextFacingWest);
 
 	drawMessage(message.c_str());
 }
@@ -614,7 +614,7 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr LCPtr, Clo
 		RuleList *rules = _rooms[RoomNum]._rules;
 
 		if ((rules == NULL) && (roomNum == 0)) {
-			g_resource->readViews(roomNum);
+			g_lab->_resource->readViews(roomNum);
 			rules = _rooms[roomNum]._rules;
 		}
 
@@ -671,7 +671,7 @@ static bool doOperateRuleSub(int16 ItemNum, int16 roomNum, CloseDataPtr LCPtr, C
 			RuleList *rules = _rooms[roomNum]._rules;
 
 			if ((rules == NULL) && (roomNum == 0)) {
-				g_resource->readViews(roomNum);
+				g_lab->_resource->readViews(roomNum);
 				rules = _rooms[roomNum]._rules;
 			}
 
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 2f11515..5e6fe29 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -39,9 +39,7 @@ extern RoomData *_rooms;
 extern InventoryData *Inventory;
 extern uint16 NumInv, ManyRooms, HighestCondition;
 
-Resource *g_resource;
-
-Resource::Resource() {
+Resource::Resource(LabEngine *vm) : _vm(vm) {
 	readStaticText();
 }
 
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index d41859e..841aa09 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -95,7 +95,7 @@ enum StaticText {
 
 class Resource {
 public:
-	Resource();
+	Resource(LabEngine *vm);
 	~Resource() {}
 
 	Common::File *openDataFile(const char * fileName, uint32 fileHeader);
@@ -106,6 +106,7 @@ public:
 	Common::String getStaticText(byte index) const { return _staticText[index]; }
 
 private:
+	LabEngine *_vm;
 	char *readString(Common::File *file);
 	int16 *readConditions(Common::File *file);
 	RuleList *readRule(Common::File *file);
@@ -117,8 +118,6 @@ private:
 	Common::String _staticText[48];
 };
 
-extern Resource *g_resource;
-
 } // End of namespace Lab
 
 #endif /* LAB_RESOURCE_H */
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 96f7bfd..eaa9ef2 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -461,7 +461,7 @@ void doNotes() {
 	/* Load in the data */
 	BigMsgFont = &bmfont;
 
-	if (!(BigMsgFont = g_resource->getFont("P:Note.fon"))) {
+	if (!(BigMsgFont = g_lab->_resource->getFont("P:Note.fon"))) {
 		BigMsgFont = NULL;
 		return;
 	}
@@ -487,7 +487,7 @@ void doWestPaper() {
 
 	BigMsgFont = &bmfont;
 
-	if (!(BigMsgFont = g_resource->getFont("P:News22.fon"))) {
+	if (!(BigMsgFont = g_lab->_resource->getFont("P:News22.fon"))) {
 		BigMsgFont = NULL;
 		return;
 	}
@@ -499,7 +499,7 @@ void doWestPaper() {
 
 	BigMsgFont = &bmfont;
 
-	if (!(BigMsgFont = g_resource->getFont("P:News32.fon"))) {
+	if (!(BigMsgFont = g_lab->_resource->getFont("P:News32.fon"))) {
 		BigMsgFont = NULL;
 		return;
 	}
@@ -518,7 +518,7 @@ void doWestPaper() {
 
 	BigMsgFont = &bmfont;
 
-	if (!(BigMsgFont = g_resource->getFont("P:Note.fon"))) {
+	if (!(BigMsgFont = g_lab->_resource->getFont("P:Note.fon"))) {
 		BigMsgFont = NULL;
 		return;
 	}
@@ -548,7 +548,7 @@ static bool loadJournalData() {
 
 	BigMsgFont = &bmfont;
 
-	if (!(BigMsgFont = g_resource->getFont("P:Journal.fon"))) {
+	if (!(BigMsgFont = g_lab->_resource->getFont("P:Journal.fon"))) {
 		BigMsgFont = NULL;
 		return false;
 	}
@@ -1047,7 +1047,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 
 	BigMsgFont = &bmfont;
 
-	if (!(BigMsgFont = g_resource->getFont("P:Map.fon"))) {
+	if (!(BigMsgFont = _resource->getFont("P:Map.fon"))) {
 		freeAllStolenMem();
 		BigMsgFont = NULL;
 		return;


Commit: 05f54b7fe0a0fbdfc731404b77b149f10ad5679b
    https://github.com/scummvm/scummvm/commit/05f54b7fe0a0fbdfc731404b77b149f10ad5679b
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:44+01:00

Commit Message:
LAB: Make _music a member of LabEngine instead of a global

Changed paths:
    engines/lab/graphics.cpp
    engines/lab/intro.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/labfun.h
    engines/lab/labmusic.cpp
    engines/lab/map.cpp
    engines/lab/processroom.cpp
    engines/lab/readdiff.cpp
    engines/lab/resource.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 80d78ed..4d19f61 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -68,7 +68,7 @@ bool readPict(const char *filename, bool PlayOnce) {
 
 	stopDiff();
 
-	file = g_music->newOpen(filename);
+	file = g_lab->g_music->newOpen(filename);
 
 	if (file == NULL) {
 		if ((filename[0] == 'p') || (filename[0] == 'P'))
@@ -94,9 +94,9 @@ bool readPict(const char *filename, bool PlayOnce) {
 /*****************************************************************************/
 bool readMusic(const char *filename, bool waitTillFinished) {
 	Common::File *file = g_lab->_resource->openDataFile(filename, MKTAG('D', 'I', 'F', 'F'));
-	g_music->updateMusic();
-	if (!g_music->_doNotFilestopSoundEffect)
-		g_music->stopSoundEffect();
+	g_lab->g_music->updateMusic();
+	if (!g_lab->g_music->_doNotFilestopSoundEffect)
+		g_lab->g_music->stopSoundEffect();
 	if (!file)
 		return false;
 
@@ -121,7 +121,7 @@ byte *readPictToMem(const char *filename, uint16 x, uint16 y) {
 	allocFile((void **)&Mem, (int32) x * (int32) y, "Bitmap");
 	CurMem = Mem;
 
-	file = g_music->newOpen(filename);
+	file = g_lab->g_music->newOpen(filename);
 
 	if (file == NULL)
 		return NULL;
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 7cbe48c..eaf1aa9 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -90,10 +90,10 @@ void Intro::doPictText(const char *filename, bool isscreen) {
 	strcat(path, filename);
 
 	if (isscreen) {
-		g_music->updateMusic();
+		g_lab->g_music->updateMusic();
 		timedelay = 35;
 	} else {
-		g_music->updateMusic();
+		g_lab->g_music->updateMusic();
 		timedelay = 7;
 	}
 
@@ -105,7 +105,7 @@ void Intro::doPictText(const char *filename, bool isscreen) {
 			if (begin) {
 				begin = false;
 
-				tfile = g_music->newOpen(path);
+				tfile = g_lab->g_music->newOpen(path);
 
 				if (!tfile)
 					return;
@@ -144,7 +144,7 @@ void Intro::doPictText(const char *filename, bool isscreen) {
 		msg = g_lab->getMsg();
 
 		if (msg == NULL) {
-			g_music->updateMusic();
+			g_lab->g_music->updateMusic();
 			g_lab->diffNextFrame();
 			g_lab->getTime(&secs, &micros);
 			g_lab->anyTimeDiff(lastsecs, lastmicros, secs, micros, &secs, &micros);
@@ -216,13 +216,13 @@ void Intro::doPictText(const char *filename, bool isscreen) {
 /* Does a one second delay, but checks the music while doing it.             */
 /*****************************************************************************/
 void Intro::musicDelay() {
-	g_music->updateMusic();
+	g_lab->g_music->updateMusic();
 
 	if (_quitIntro)
 		return;
 
 	for (uint16 i = 0; i < 20; i++) {
-		g_music->updateMusic();
+		g_lab->g_music->updateMusic();
 		g_lab->waitTOF();
 		g_lab->waitTOF();
 		g_lab->waitTOF();
@@ -234,7 +234,7 @@ void Intro::musicDelay() {
 void Intro::nReadPict(const char *filename, bool playOnce) {
 	Common::String finalFileName = Common::String("P:Intro/") + filename;
 
-	g_music->updateMusic();
+	g_lab->g_music->updateMusic();
 	introEatMessages();
 
 	if (_quitIntro)
@@ -277,7 +277,7 @@ void Intro::introSequence() {
 
 	blackAllScreen();
 
-	g_music->initMusic();
+	g_lab->g_music->initMusic();
 
 	nopalchange = true;
 	if (g_lab->getPlatform() != Common::kPlatformWindows)
@@ -297,14 +297,14 @@ void Intro::introSequence() {
 		                   (diffcmap[i * 3 + 2] >> 2);
 	}
 
-	g_music->updateMusic();
+	g_lab->g_music->updateMusic();
 	fade(true, 0);
 
 	for (int times = 0; times < 150; times++) {
 		if (_quitIntro)
 			break;
 
-		g_music->updateMusic();
+		g_lab->g_music->updateMusic();
 		uint16 temp = palette[2];
 
 		for (uint16 i = 2; i < 15; i++)
@@ -319,7 +319,7 @@ void Intro::introSequence() {
 	fade(false, 0);
 	blackAllScreen();
 
-	g_music->updateMusic();
+	g_lab->g_music->updateMusic();
 
 	nReadPict("Title.A", true);
 	nReadPict("AB", true);
@@ -341,11 +341,11 @@ void Intro::introSequence() {
 	nReadPict("DA", true);
 	musicDelay();
 
-	g_music->newOpen("p:Intro/Intro.1");  /* load the picture into the buffer */
+	g_lab->g_music->newOpen("p:Intro/Intro.1");  /* load the picture into the buffer */
 
-	g_music->updateMusic();
+	g_lab->g_music->updateMusic();
 	blackAllScreen();
-	g_music->updateMusic();
+	g_lab->g_music->updateMusic();
 
 	_msgfont = g_lab->_resource->getFont("P:Map.fon");
 
@@ -366,7 +366,7 @@ void Intro::introSequence() {
 	freeAllStolenMem();
 
 	blackAllScreen();
-	g_music->updateMusic();
+	g_lab->g_music->updateMusic();
 
 	_introDoBlack = true;
 	nReadPict("Station1", true);
@@ -398,7 +398,7 @@ void Intro::introSequence() {
 			for (uint16 idx = (8 * 3); idx < (255 * 3); idx++)
 				diffcmap[idx] = 255 - diffcmap[idx];
 
-			g_music->updateMusic();
+			g_lab->g_music->updateMusic();
 			g_lab->waitTOF();
 			g_lab->VGASetPal(diffcmap, 256);
 			g_lab->	waitTOF();
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 3792f2b..745bb74 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -76,6 +76,7 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 
 	_event = nullptr;
 	_resource = nullptr;
+	g_music = nullptr;
 
 	//const Common::FSNode gameDataDir(ConfMan.get("path"));
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
@@ -100,8 +101,7 @@ Common::Error LabEngine::run() {
 
 	_event = new EventManager(this);
 	_resource = new Resource(this);
-
-	g_music = new Music();
+	g_music = new Music(this);
 
 	if (getPlatform() == Common::kPlatformWindows) {
 		// Check if this is the Wyrmkeep trial
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 7e7f645..dd0c204 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -101,6 +101,7 @@ private:
 public:
 	EventManager *_event;
 	Resource *_resource;
+	Music *g_music;
 
 	byte *_currentDsplayBuffer;
 	Common::Point _mousePos;
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index dd4796a..57d5817 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -157,7 +157,7 @@ void closePartial(int32 File);
 
 class Music {
 public:
-	Music();
+	Music(LabEngine *vm);
 
 	byte **newOpen(const char *name);
 	byte **newOpen(const char *name, uint32 &size);
@@ -185,6 +185,7 @@ public:
 	bool _doReset;
 
 private:
+	LabEngine *_vm;
 	void fillbuffer(byte *musicBuffer);
 	void startMusic(bool startatbegin);
 
@@ -202,9 +203,6 @@ private:
 	Audio::QueuingAudioStream *_queuingAudioStream;
 };
 
-
-extern Music *g_music;
-
 /*---------------------------*/
 /*----- From LabSets.c ------*/
 /*---------------------------*/
diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index a7043dc..843a866 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -43,10 +43,9 @@ namespace Lab {
 #define CLOWNROOM           123
 #define DIMROOM              80
 
-Music *g_music;
 extern uint16 RoomNum;	// TODO: Move into a class
 
-Music::Music() {
+Music::Music(LabEngine *vm) : _vm(vm) {
 	_file = 0;
 	_tFile = 0;
 	_musicPaused = false;
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index e4a6f04..6c22016 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -84,9 +84,9 @@ char *getText(const char *filename) {
 	bool dodecrypt;
 	byte **tfile;
 
-	g_music->updateMusic();
+	g_lab->g_music->updateMusic();
 	dodecrypt = (isBuffered(filename) == NULL);
-	tfile = g_music->newOpen(filename);
+	tfile = g_lab->g_music->newOpen(filename);
 
 	if (!tfile)
 		return NULL;
@@ -200,7 +200,7 @@ static bool loadMapData() {
 		BigMsgFont = MsgFont;
 
 	resetBuffer();  /* Make images load into start of buffer */
-	buffer = g_music->newOpen("P:MapImage", Size);
+	buffer = g_lab->g_music->newOpen("P:MapImage", Size);
 
 	if (!buffer)
 		return false;
@@ -252,9 +252,9 @@ static bool loadMapData() {
 	Common::File *mapFile = g_lab->_resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0'));
 	if (!mapFile)
 		error("Corrupt map file");
-	g_music->updateMusic();
-	if (!g_music->_doNotFilestopSoundEffect)
-		g_music->stopSoundEffect();
+	g_lab->g_music->updateMusic();
+	if (!g_lab->g_music->_doNotFilestopSoundEffect)
+		g_lab->g_music->stopSoundEffect();
 
 	MaxRooms = mapFile->readUint16LE();
 	Maps = new MapData[MaxRooms];	// will be freed when the user exits the map
@@ -309,7 +309,7 @@ void fade(bool fadein, uint16 res) {
 
 		setAmigaPal(newpal, 16);
 		g_lab->waitTOF();
-		g_music->updateMusic();
+		g_lab->g_music->updateMusic();
 	}
 }
 
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index ef1a801..2939d8a 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -333,26 +333,26 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 	uint32 StartSecs, StartMicros, CurSecs, CurMicros;
 
 	while (APtr) {
-		g_music->updateMusic();
+		g_lab->g_music->updateMusic();
 
 		switch (APtr->ActionType) {
 		case PLAYSOUND:
-			g_music->_loopSoundEffect = false;
-			g_music->_waitTillFinished = true;
+			g_lab->g_music->_loopSoundEffect = false;
+			g_lab->g_music->_waitTillFinished = true;
 			readMusic((char *)APtr->Data, true);
-			g_music->_waitTillFinished = false;
+			g_lab->g_music->_waitTillFinished = false;
 			break;
 
 		case PLAYSOUNDB:
-			g_music->_loopSoundEffect = false;
-			g_music->_waitTillFinished = false;
+			g_lab->g_music->_loopSoundEffect = false;
+			g_lab->g_music->_waitTillFinished = false;
 			readMusic((char *)APtr->Data, false);
 			break;
 
 		case PLAYSOUNDCONT:
-			g_music->_doNotFilestopSoundEffect = true;
-			g_music->_loopSoundEffect = true;
-			readMusic((char *)APtr->Data, g_music->_waitTillFinished);
+			g_lab->g_music->_doNotFilestopSoundEffect = true;
+			g_lab->g_music->_loopSoundEffect = true;
+			readMusic((char *)APtr->Data, g_lab->g_music->_waitTillFinished);
 			break;
 
 		case SHOWDIFF:
@@ -370,7 +370,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 			}
 
 			if (APtr->Data)
-				g_music->newOpen((char *)APtr->Data);          /* Puts a file into memory */
+				g_lab->g_music->newOpen((char *)APtr->Data);          /* Puts a file into memory */
 
 			break;
 
@@ -485,7 +485,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 			g_lab->WSDL_UpdateScreen();
 
 			while (1) {
-				g_music->updateMusic();
+				g_lab->g_music->updateMusic();
 				g_lab->diffNextFrame();
 				g_lab->getTime(&CurSecs, &CurMicros);
 
@@ -497,30 +497,30 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 			break;
 
 		case STOPMUSIC:
-			g_music->setMusic(false);
+			g_lab->g_music->setMusic(false);
 			break;
 
 		case STARTMUSIC:
-			g_music->setMusic(true);
+			g_lab->g_music->setMusic(true);
 			break;
 
 		case CHANGEMUSIC:
-			g_music->changeMusic((const char *)APtr->Data);
-			g_music->setMusicReset(false);
+			g_lab->g_music->changeMusic((const char *)APtr->Data);
+			g_lab->g_music->setMusicReset(false);
 			break;
 
 		case RESETMUSIC:
-			g_music->resetMusic();
-			g_music->setMusicReset(true);
+			g_lab->g_music->resetMusic();
+			g_lab->g_music->setMusicReset(true);
 			break;
 
 		case FILLMUSIC:
-			g_music->updateMusic();
+			g_lab->g_music->updateMusic();
 			break;
 
 		case WAITSOUND:
-			while (g_music->isSoundEffectActive()) {
-				g_music->updateMusic();
+			while (g_lab->g_music->isSoundEffectActive()) {
+				g_lab->g_music->updateMusic();
 				g_lab->diffNextFrame();
 				g_lab->waitTOF();
 			}
@@ -528,18 +528,18 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 			break;
 
 		case CLEARSOUND:
-			if (g_music->_loopSoundEffect) {
-				g_music->_loopSoundEffect = false;
-				g_music->stopSoundEffect();
-			} else if (g_music->isSoundEffectActive())
-				g_music->stopSoundEffect();
+			if (g_lab->g_music->_loopSoundEffect) {
+				g_lab->g_music->_loopSoundEffect = false;
+				g_lab->g_music->stopSoundEffect();
+			} else if (g_lab->g_music->isSoundEffectActive())
+				g_lab->g_music->stopSoundEffect();
 
 			break;
 
 		case WINMUSIC:
-			g_music->_winmusic = true;
-			g_music->freeMusic();
-			g_music->initMusic();
+			g_lab->g_music->_winmusic = true;
+			g_lab->g_music->freeMusic();
+			g_lab->g_music->initMusic();
 			break;
 
 		case WINGAME:
@@ -590,18 +590,18 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 		APtr = APtr->NextAction;
 	}
 
-	if (g_music->_loopSoundEffect) {
-		g_music->_loopSoundEffect = false;
-		g_music->stopSoundEffect();
+	if (g_lab->g_music->_loopSoundEffect) {
+		g_lab->g_music->_loopSoundEffect = false;
+		g_lab->g_music->stopSoundEffect();
 	} else {
-		while (g_music->isSoundEffectActive()) {
-			g_music->updateMusic();
+		while (g_lab->g_music->isSoundEffectActive()) {
+			g_lab->g_music->updateMusic();
 			g_lab->diffNextFrame();
 			g_lab->waitTOF();
 		}
 	}
 
-	g_music->_doNotFilestopSoundEffect = false;
+	g_lab->g_music->_doNotFilestopSoundEffect = false;
 }
 
 /*****************************************************************************/
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index ca7d390..88b4c18 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -393,7 +393,7 @@ void stopDiff() {
 void stopDiffEnd() {
 	if (IsPlaying) {
 		while (IsPlaying) {
-			g_music->updateMusic();
+			g_lab->g_music->updateMusic();
 			g_lab->diffNextFrame();
 		}
 	}
@@ -431,14 +431,14 @@ void readSound(bool waitTillFinished, Common::File *file) {
 		return;
 
 	while (soundTag != 65535) {
-		g_music->updateMusic();
+		g_lab->g_music->updateMusic();
 		soundTag = file->readUint32LE();
 		soundSize = file->readUint32LE() - 8;
 
 		if ((soundTag == 30) || (soundTag == 31)) {
 			if (waitTillFinished) {
-				while (g_music->isSoundEffectActive()) {
-					g_music->updateMusic();
+				while (g_lab->g_music->isSoundEffectActive()) {
+					g_lab->g_music->updateMusic();
 					g_lab->waitTOF();
 				}
 			}
@@ -449,11 +449,11 @@ void readSound(bool waitTillFinished, Common::File *file) {
 			file->skip(2);
 			byte *soundData = (byte *)malloc(soundSize);
 			file->read(soundData, soundSize);
-			g_music->playSoundEffect(sampleRate, soundSize, soundData);
+			g_lab->g_music->playSoundEffect(sampleRate, soundSize, soundData);
 		} else if (soundTag == 65535L) {
 			if (waitTillFinished) {
-				while (g_music->isSoundEffectActive()) {
-					g_music->updateMusic();
+				while (g_lab->g_music->isSoundEffectActive()) {
+					g_lab->g_music->updateMusic();
 					g_lab->waitTOF();
 				}
 			}
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 5e6fe29..1e0ac6b 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -28,13 +28,13 @@
  *
  */
 
+#include "lab/lab.h"
 #include "lab/text.h"
 #include "lab/resource.h"
 
 namespace Lab {
 
 static uint16 allocroom;
-
 extern RoomData *_rooms;
 extern InventoryData *Inventory;
 extern uint16 NumInv, ManyRooms, HighestCondition;
@@ -65,7 +65,7 @@ TextFont *Resource::getFont(const char *fileName) {
 	if (fileSize <= headerSize)
 		return NULL;
 
-	g_music->updateMusic();
+	_vm->g_music->updateMusic();
 
 	TextFont *textfont = (TextFont *)malloc(sizeof(TextFont));
 	textfont->DataLength = fileSize - headerSize;
@@ -142,7 +142,7 @@ bool Resource::readViews(uint16 roomNum) {
 	_rooms[roomNum]._westView = readView(dataFile);
 	_rooms[roomNum]._rules = readRule(dataFile);
 
-	g_music->updateMusic();
+	_vm->g_music->updateMusic();
 
 	delete dataFile;
 	return true;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index eaa9ef2..417f854 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -153,7 +153,7 @@ void showCombination(const char *filename) {
 
 	blackScreen();
 
-	buffer = g_music->newOpen("P:Numbers");
+	buffer = g_lab->g_music->newOpen("P:Numbers");
 
 	for (uint16 CurBit = 0; CurBit < 10; CurBit++)
 		readImage(buffer, &(Images[CurBit]));
@@ -297,10 +297,10 @@ void showTile(const char *filename, bool showsolution) {
 
 	if (showsolution) {
 		start  = 0;
-		buffer = g_music->newOpen("P:TileSolution");
+		buffer = g_lab->g_music->newOpen("P:TileSolution");
 	} else {
 		start  = 1;
-		buffer = g_music->newOpen("P:Tile");
+		buffer = g_lab->g_music->newOpen("P:Tile");
 	}
 
 	if (!buffer)
@@ -553,7 +553,7 @@ static bool loadJournalData() {
 		return false;
 	}
 
-	g_music->updateMusic();
+	g_lab->g_music->updateMusic();
 
 	strcpy(filename, "Lab:Rooms/j0");
 	bridge = g_lab->_conditions->in(BRIDGE0) || g_lab->_conditions->in(BRIDGE1);
@@ -586,7 +586,7 @@ static bool loadJournalData() {
 	if ((journaltexttitle = getText("Lab:Rooms/jt")) == NULL)
 		return false;
 
-	buffer = g_music->newOpen("P:JImage");
+	buffer = g_lab->g_music->newOpen("P:JImage");
 
 	if (!buffer)
 		return false;
@@ -628,7 +628,7 @@ static void drawJournalText() {
 	char *CurText = journaltext;
 
 	while (DrawingToPage < JPage) {
-		g_music->updateMusic();
+		g_lab->g_music->updateMusic();
 		CurText = (char *)(journaltext + CharsDrawn);
 		CharsDrawn += flowText(BigMsgFont, -2, 2, 0, false, false, false, false, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText);
 
@@ -648,7 +648,7 @@ static void drawJournalText() {
 		CharsDrawn += flowTextToMem(&JBackImage, BigMsgFont, -2, 2, 0, false, false, false, true, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText);
 	}
 
-	g_music->updateMusic();
+	g_lab->g_music->updateMusic();
 	CurText = (char *)(journaltext + CharsDrawn);
 	lastpage = (*CurText == 0);
 	flowTextToMem(&JBackImage, BigMsgFont, -2, 2, 0, false, false, false, true, VGAScaleX(171), VGAScaleY(32), VGAScaleX(271), VGAScaleY(148), CurText);
@@ -663,14 +663,14 @@ static void drawJournalText() {
 static void turnPage(bool FromLeft) {
 	if (FromLeft) {
 		for (int i = 0; i < g_lab->_screenWidth; i += 8) {
-			g_music->updateMusic();
+			g_lab->g_music->updateMusic();
 			g_lab->waitTOF();
 			ScreenImage.ImageData = g_lab->getVGABaseAddr();
 			g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight);
 		}
 	} else {
 		for (int i = (g_lab->_screenWidth - 8); i > 0; i -= 8) {
-			g_music->updateMusic();
+			g_lab->g_music->updateMusic();
 			g_lab->waitTOF();
 			ScreenImage.ImageData = g_lab->getVGABaseAddr();
 			g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight);
@@ -837,7 +837,7 @@ bool saveRestoreGame() {
 		if (slot >= 0) {
 			isOK = loadGame(&RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), slot);
 			if (isOK)
-				g_music->resetMusic();
+				g_lab->g_music->resetMusic();
 		}
 	}
 
@@ -855,7 +855,7 @@ static void getMonImages() {
 
 	resetBuffer();
 
-	buffer = g_music->newOpen("P:MonImage", bufferSize);
+	buffer = g_lab->g_music->newOpen("P:MonImage", bufferSize);
 
 	if (!buffer)
 		return;


Commit: d0c6c730365764668567f19e07b6971974c649fb
    https://github.com/scummvm/scummvm/commit/d0c6c730365764668567f19e07b6971974c649fb
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:44+01:00

Commit Message:
LAB: Rename _music, delete it in engine destructor

Changed paths:
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/intro.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/processroom.cpp
    engines/lab/readdiff.cpp
    engines/lab/resource.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index d7561d1..5de7e8f 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -678,7 +678,7 @@ void LabEngine::mainGameLoop() {
 				break;
 			}
 
-			g_music->resumeBackMusic();
+			_music->resumeBackMusic();
 
 			/* Sees what kind of close up we're in and does the appropriate stuff, if any. */
 			if (doCloseUp(CPtr)) {
@@ -734,15 +734,15 @@ void LabEngine::mainGameLoop() {
 			}
 		}
 
-		g_music->updateMusic();  /* Make sure we check the music at least after every message */
+		_music->updateMusic();  /* Make sure we check the music at least after every message */
 		interfaceOn();
 		Msg = getMsg();
 
 		Common::Point curPos;
 		if (Msg == NULL) { /* Does music load and next animation frame when you've run out of messages */
 			GotMessage = false;
-			g_music->checkRoomMusic();
-			g_music->updateMusic();
+			_music->checkRoomMusic();
+			_music->updateMusic();
 			diffNextFrame();
 
 			if (FollowingCrumbs) {
@@ -836,11 +836,11 @@ from_crumbs:
 					interfaceOff();
 
 					while (1) {
-						g_music->updateMusic();  /* Make sure we check the music at least after every message */
+						_music->updateMusic();  /* Make sure we check the music at least after every message */
 						Msg = getMsg();
 
 						if (Msg == NULL) { /* Does music load and next animation frame when you've run out of messages */
-							g_music->updateMusic();
+							_music->updateMusic();
 							diffNextFrame();
 						} else {
 							if (Msg->msgClass == RAWKEY) {
@@ -1326,7 +1326,7 @@ void LabEngine::go() {
 	mem = mem && initRoomBuffer();
 
 	if (!dointro)
-		g_music->initMusic();
+		_music->initMusic();
 
 	MsgFont = _resource->getFont("P:AvanteG.12");
 
@@ -1349,7 +1349,7 @@ void LabEngine::go() {
 		readPict("P:End/L2In.1", true);
 
 		for (uint16 i = 0; i < 120; i++) {
-			g_music->updateMusic();
+			_music->updateMusic();
 			waitTOF();
 		}
 
@@ -1358,7 +1358,7 @@ void LabEngine::go() {
 
 		warning("STUB: waitForPress");
 		while (!1) { // 1 means ignore SDL_ProcessInput calls
-			g_music->updateMusic();
+			_music->updateMusic();
 			diffNextFrame();
 			waitTOF();
 		}
@@ -1369,7 +1369,7 @@ void LabEngine::go() {
 	freeRoomBuffer();
 	freeBuffer();
 
-	g_music->freeMusic();
+	_music->freeMusic();
 }
 
 /*****************************************************************************/
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 4d19f61..9f689bd 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -68,7 +68,7 @@ bool readPict(const char *filename, bool PlayOnce) {
 
 	stopDiff();
 
-	file = g_lab->g_music->newOpen(filename);
+	file = g_lab->_music->newOpen(filename);
 
 	if (file == NULL) {
 		if ((filename[0] == 'p') || (filename[0] == 'P'))
@@ -94,9 +94,9 @@ bool readPict(const char *filename, bool PlayOnce) {
 /*****************************************************************************/
 bool readMusic(const char *filename, bool waitTillFinished) {
 	Common::File *file = g_lab->_resource->openDataFile(filename, MKTAG('D', 'I', 'F', 'F'));
-	g_lab->g_music->updateMusic();
-	if (!g_lab->g_music->_doNotFilestopSoundEffect)
-		g_lab->g_music->stopSoundEffect();
+	g_lab->_music->updateMusic();
+	if (!g_lab->_music->_doNotFilestopSoundEffect)
+		g_lab->_music->stopSoundEffect();
 	if (!file)
 		return false;
 
@@ -121,7 +121,7 @@ byte *readPictToMem(const char *filename, uint16 x, uint16 y) {
 	allocFile((void **)&Mem, (int32) x * (int32) y, "Bitmap");
 	CurMem = Mem;
 
-	file = g_lab->g_music->newOpen(filename);
+	file = g_lab->_music->newOpen(filename);
 
 	if (file == NULL)
 		return NULL;
@@ -425,9 +425,9 @@ void LabEngine::doScrollBlack() {
 	Im.Width = width;
 	Im.Height = height;
 	Im.ImageData = mem;
-	g_music->updateMusic();
+	_music->updateMusic();
 	g_lab->readScreenImage(&Im, 0, 0);
-	g_music->updateMusic();
+	_music->updateMusic();
 
 	BaseAddr = (uint32 *)g_lab->getVGABaseAddr();
 
@@ -435,7 +435,7 @@ void LabEngine::doScrollBlack() {
 	nheight = height;
 
 	while (nheight) {
-		g_music->updateMusic();
+		_music->updateMusic();
 
 		if (!_isHiRes)
 			g_lab->waitTOF();
@@ -523,8 +523,8 @@ void LabEngine::doScrollWipe(char *filename) {
 	width = VGAScaleX(320);
 	height = VGAScaleY(149) + SVGACord(2);
 
-	while (g_music->isSoundEffectActive()) {
-		g_music->updateMusic();
+	while (_music->isSoundEffectActive()) {
+		_music->updateMusic();
 		g_lab->waitTOF();
 	}
 
@@ -534,12 +534,12 @@ void LabEngine::doScrollWipe(char *filename) {
 	IsBM = false;
 	mem = RawDiffBM.Planes[0];
 
-	g_music->updateMusic();
+	_music->updateMusic();
 	by      = VGAScaleX(3);
 	nheight = height;
 
 	while (onrow < headerdata.y) {
-		g_music->updateMusic();
+		_music->updateMusic();
 
 		if ((by > nheight) && nheight)
 			by = nheight;
@@ -593,11 +593,11 @@ void LabEngine::doScrollBounce() {
 	int height = VGAScaleY(149) + SVGACord(2);
 	byte *mem = RawDiffBM.Planes[0];
 
-	g_music->updateMusic();
+	_music->updateMusic();
 	int startline = headerdata.y - height - 1;
 
 	for (int i = 0; i < 5; i++) {
-		g_music->updateMusic();
+		_music->updateMusic();
 		startline -= newby[i];
 		copyPage(width, height, 0, startline, mem);
 
@@ -606,7 +606,7 @@ void LabEngine::doScrollBounce() {
 	}
 
 	for (int i = 8; i > 0; i--) {
-		g_music->updateMusic();
+		_music->updateMusic();
 		startline += newby1[i - 1];
 		copyPage(width, height, 0, startline, mem);
 
@@ -638,7 +638,7 @@ void LabEngine::doTransWipe(CloseDataPtr *CPtr, char *filename) {
 
 		while (CurY < LastY) {
 			if (linesdone >= lineslast) {
-				g_music->updateMusic();
+				_music->updateMusic();
 				g_lab->waitTOF();
 				linesdone = 0;
 			}
@@ -656,7 +656,7 @@ void LabEngine::doTransWipe(CloseDataPtr *CPtr, char *filename) {
 
 		while (CurY <= LastY) {
 			if (linesdone >= lineslast) {
-				g_music->updateMusic();
+				_music->updateMusic();
 				g_lab->waitTOF();
 				linesdone = 0;
 			}
@@ -691,7 +691,7 @@ void LabEngine::doTransWipe(CloseDataPtr *CPtr, char *filename) {
 
 			while (CurY < LastY) {
 				if (linesdone >= lineslast) {
-					g_music->updateMusic();
+					_music->updateMusic();
 					g_lab->waitTOF();
 					linesdone = 0;
 				}
@@ -710,7 +710,7 @@ void LabEngine::doTransWipe(CloseDataPtr *CPtr, char *filename) {
 
 			while (CurY <= LastY) {
 				if (linesdone >= lineslast) {
-					g_music->updateMusic();
+					_music->updateMusic();
 					g_lab->waitTOF();
 					linesdone = 0;
 				}
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index eaf1aa9..36137be 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -90,10 +90,10 @@ void Intro::doPictText(const char *filename, bool isscreen) {
 	strcat(path, filename);
 
 	if (isscreen) {
-		g_lab->g_music->updateMusic();
+		g_lab->_music->updateMusic();
 		timedelay = 35;
 	} else {
-		g_lab->g_music->updateMusic();
+		g_lab->_music->updateMusic();
 		timedelay = 7;
 	}
 
@@ -105,7 +105,7 @@ void Intro::doPictText(const char *filename, bool isscreen) {
 			if (begin) {
 				begin = false;
 
-				tfile = g_lab->g_music->newOpen(path);
+				tfile = g_lab->_music->newOpen(path);
 
 				if (!tfile)
 					return;
@@ -144,7 +144,7 @@ void Intro::doPictText(const char *filename, bool isscreen) {
 		msg = g_lab->getMsg();
 
 		if (msg == NULL) {
-			g_lab->g_music->updateMusic();
+			g_lab->_music->updateMusic();
 			g_lab->diffNextFrame();
 			g_lab->getTime(&secs, &micros);
 			g_lab->anyTimeDiff(lastsecs, lastmicros, secs, micros, &secs, &micros);
@@ -216,13 +216,13 @@ void Intro::doPictText(const char *filename, bool isscreen) {
 /* Does a one second delay, but checks the music while doing it.             */
 /*****************************************************************************/
 void Intro::musicDelay() {
-	g_lab->g_music->updateMusic();
+	g_lab->_music->updateMusic();
 
 	if (_quitIntro)
 		return;
 
 	for (uint16 i = 0; i < 20; i++) {
-		g_lab->g_music->updateMusic();
+		g_lab->_music->updateMusic();
 		g_lab->waitTOF();
 		g_lab->waitTOF();
 		g_lab->waitTOF();
@@ -234,7 +234,7 @@ void Intro::musicDelay() {
 void Intro::nReadPict(const char *filename, bool playOnce) {
 	Common::String finalFileName = Common::String("P:Intro/") + filename;
 
-	g_lab->g_music->updateMusic();
+	g_lab->_music->updateMusic();
 	introEatMessages();
 
 	if (_quitIntro)
@@ -277,7 +277,7 @@ void Intro::introSequence() {
 
 	blackAllScreen();
 
-	g_lab->g_music->initMusic();
+	g_lab->_music->initMusic();
 
 	nopalchange = true;
 	if (g_lab->getPlatform() != Common::kPlatformWindows)
@@ -297,14 +297,14 @@ void Intro::introSequence() {
 		                   (diffcmap[i * 3 + 2] >> 2);
 	}
 
-	g_lab->g_music->updateMusic();
+	g_lab->_music->updateMusic();
 	fade(true, 0);
 
 	for (int times = 0; times < 150; times++) {
 		if (_quitIntro)
 			break;
 
-		g_lab->g_music->updateMusic();
+		g_lab->_music->updateMusic();
 		uint16 temp = palette[2];
 
 		for (uint16 i = 2; i < 15; i++)
@@ -319,7 +319,7 @@ void Intro::introSequence() {
 	fade(false, 0);
 	blackAllScreen();
 
-	g_lab->g_music->updateMusic();
+	g_lab->_music->updateMusic();
 
 	nReadPict("Title.A", true);
 	nReadPict("AB", true);
@@ -341,11 +341,11 @@ void Intro::introSequence() {
 	nReadPict("DA", true);
 	musicDelay();
 
-	g_lab->g_music->newOpen("p:Intro/Intro.1");  /* load the picture into the buffer */
+	g_lab->_music->newOpen("p:Intro/Intro.1");  /* load the picture into the buffer */
 
-	g_lab->g_music->updateMusic();
+	g_lab->_music->updateMusic();
 	blackAllScreen();
-	g_lab->g_music->updateMusic();
+	g_lab->_music->updateMusic();
 
 	_msgfont = g_lab->_resource->getFont("P:Map.fon");
 
@@ -366,7 +366,7 @@ void Intro::introSequence() {
 	freeAllStolenMem();
 
 	blackAllScreen();
-	g_lab->g_music->updateMusic();
+	g_lab->_music->updateMusic();
 
 	_introDoBlack = true;
 	nReadPict("Station1", true);
@@ -398,7 +398,7 @@ void Intro::introSequence() {
 			for (uint16 idx = (8 * 3); idx < (255 * 3); idx++)
 				diffcmap[idx] = 255 - diffcmap[idx];
 
-			g_lab->g_music->updateMusic();
+			g_lab->_music->updateMusic();
 			g_lab->waitTOF();
 			g_lab->VGASetPal(diffcmap, 256);
 			g_lab->	waitTOF();
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 745bb74..9ad51fd 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -76,7 +76,7 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 
 	_event = nullptr;
 	_resource = nullptr;
-	g_music = nullptr;
+	_music = nullptr;
 
 	//const Common::FSNode gameDataDir(ConfMan.get("path"));
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
@@ -91,6 +91,7 @@ LabEngine::~LabEngine() {
 
 	delete _event;
 	delete _resource;
+	delete _music;
 }
 
 Common::Error LabEngine::run() {
@@ -101,7 +102,7 @@ Common::Error LabEngine::run() {
 
 	_event = new EventManager(this);
 	_resource = new Resource(this);
-	g_music = new Music(this);
+	_music = new Music(this);
 
 	if (getPlatform() == Common::kPlatformWindows) {
 		// Check if this is the Wyrmkeep trial
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index dd0c204..e7c2303 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -101,7 +101,7 @@ private:
 public:
 	EventManager *_event;
 	Resource *_resource;
-	Music *g_music;
+	Music *_music;
 
 	byte *_currentDsplayBuffer;
 	Common::Point _mousePos;
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 6c22016..ac612fb 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -84,9 +84,9 @@ char *getText(const char *filename) {
 	bool dodecrypt;
 	byte **tfile;
 
-	g_lab->g_music->updateMusic();
+	g_lab->_music->updateMusic();
 	dodecrypt = (isBuffered(filename) == NULL);
-	tfile = g_lab->g_music->newOpen(filename);
+	tfile = g_lab->_music->newOpen(filename);
 
 	if (!tfile)
 		return NULL;
@@ -200,7 +200,7 @@ static bool loadMapData() {
 		BigMsgFont = MsgFont;
 
 	resetBuffer();  /* Make images load into start of buffer */
-	buffer = g_lab->g_music->newOpen("P:MapImage", Size);
+	buffer = g_lab->_music->newOpen("P:MapImage", Size);
 
 	if (!buffer)
 		return false;
@@ -252,9 +252,9 @@ static bool loadMapData() {
 	Common::File *mapFile = g_lab->_resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0'));
 	if (!mapFile)
 		error("Corrupt map file");
-	g_lab->g_music->updateMusic();
-	if (!g_lab->g_music->_doNotFilestopSoundEffect)
-		g_lab->g_music->stopSoundEffect();
+	g_lab->_music->updateMusic();
+	if (!g_lab->_music->_doNotFilestopSoundEffect)
+		g_lab->_music->stopSoundEffect();
 
 	MaxRooms = mapFile->readUint16LE();
 	Maps = new MapData[MaxRooms];	// will be freed when the user exits the map
@@ -309,7 +309,7 @@ void fade(bool fadein, uint16 res) {
 
 		setAmigaPal(newpal, 16);
 		g_lab->waitTOF();
-		g_lab->g_music->updateMusic();
+		g_lab->_music->updateMusic();
 	}
 }
 
@@ -572,7 +572,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 	for (uint16 i = 1; i <= MaxRooms; i++) {
 		if ((Maps[i].PageNumber == Floor) && _roomsFound->in(i) && Maps[i].x) {
 			drawRoom(i, (bool)(i == CurRoom));
-			g_music->updateMusic();
+			_music->updateMusic();
 		}
 	}
 
@@ -669,11 +669,11 @@ void LabEngine::processMap(uint16 CurRoom) {
 	CurFloor = Maps[CurRoom].PageNumber;
 
 	while (1) {
-		g_music->updateMusic();  /* Make sure we check the music at least after every message */
+		_music->updateMusic();  /* Make sure we check the music at least after every message */
 		Msg = getMsg();
 
 		if (Msg == NULL) {
-			g_music->updateMusic();
+			_music->updateMusic();
 
 			if (place <= 14) {
 				newcolor[0] = 14 << 2;
@@ -833,7 +833,7 @@ void LabEngine::processMap(uint16 CurRoom) {
 void LabEngine::doMap(uint16 CurRoom) {
 	FadePalette = AmigaMapPalette;
 
-	g_music->updateMusic();
+	_music->updateMusic();
 	loadMapData();
 	blackAllScreen();
 
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 2939d8a..bc62aac 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -333,26 +333,26 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 	uint32 StartSecs, StartMicros, CurSecs, CurMicros;
 
 	while (APtr) {
-		g_lab->g_music->updateMusic();
+		g_lab->_music->updateMusic();
 
 		switch (APtr->ActionType) {
 		case PLAYSOUND:
-			g_lab->g_music->_loopSoundEffect = false;
-			g_lab->g_music->_waitTillFinished = true;
+			g_lab->_music->_loopSoundEffect = false;
+			g_lab->_music->_waitTillFinished = true;
 			readMusic((char *)APtr->Data, true);
-			g_lab->g_music->_waitTillFinished = false;
+			g_lab->_music->_waitTillFinished = false;
 			break;
 
 		case PLAYSOUNDB:
-			g_lab->g_music->_loopSoundEffect = false;
-			g_lab->g_music->_waitTillFinished = false;
+			g_lab->_music->_loopSoundEffect = false;
+			g_lab->_music->_waitTillFinished = false;
 			readMusic((char *)APtr->Data, false);
 			break;
 
 		case PLAYSOUNDCONT:
-			g_lab->g_music->_doNotFilestopSoundEffect = true;
-			g_lab->g_music->_loopSoundEffect = true;
-			readMusic((char *)APtr->Data, g_lab->g_music->_waitTillFinished);
+			g_lab->_music->_doNotFilestopSoundEffect = true;
+			g_lab->_music->_loopSoundEffect = true;
+			readMusic((char *)APtr->Data, g_lab->_music->_waitTillFinished);
 			break;
 
 		case SHOWDIFF:
@@ -370,7 +370,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 			}
 
 			if (APtr->Data)
-				g_lab->g_music->newOpen((char *)APtr->Data);          /* Puts a file into memory */
+				g_lab->_music->newOpen((char *)APtr->Data);          /* Puts a file into memory */
 
 			break;
 
@@ -485,7 +485,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 			g_lab->WSDL_UpdateScreen();
 
 			while (1) {
-				g_lab->g_music->updateMusic();
+				g_lab->_music->updateMusic();
 				g_lab->diffNextFrame();
 				g_lab->getTime(&CurSecs, &CurMicros);
 
@@ -497,30 +497,30 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 			break;
 
 		case STOPMUSIC:
-			g_lab->g_music->setMusic(false);
+			g_lab->_music->setMusic(false);
 			break;
 
 		case STARTMUSIC:
-			g_lab->g_music->setMusic(true);
+			g_lab->_music->setMusic(true);
 			break;
 
 		case CHANGEMUSIC:
-			g_lab->g_music->changeMusic((const char *)APtr->Data);
-			g_lab->g_music->setMusicReset(false);
+			g_lab->_music->changeMusic((const char *)APtr->Data);
+			g_lab->_music->setMusicReset(false);
 			break;
 
 		case RESETMUSIC:
-			g_lab->g_music->resetMusic();
-			g_lab->g_music->setMusicReset(true);
+			g_lab->_music->resetMusic();
+			g_lab->_music->setMusicReset(true);
 			break;
 
 		case FILLMUSIC:
-			g_lab->g_music->updateMusic();
+			g_lab->_music->updateMusic();
 			break;
 
 		case WAITSOUND:
-			while (g_lab->g_music->isSoundEffectActive()) {
-				g_lab->g_music->updateMusic();
+			while (g_lab->_music->isSoundEffectActive()) {
+				g_lab->_music->updateMusic();
 				g_lab->diffNextFrame();
 				g_lab->waitTOF();
 			}
@@ -528,18 +528,18 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 			break;
 
 		case CLEARSOUND:
-			if (g_lab->g_music->_loopSoundEffect) {
-				g_lab->g_music->_loopSoundEffect = false;
-				g_lab->g_music->stopSoundEffect();
-			} else if (g_lab->g_music->isSoundEffectActive())
-				g_lab->g_music->stopSoundEffect();
+			if (g_lab->_music->_loopSoundEffect) {
+				g_lab->_music->_loopSoundEffect = false;
+				g_lab->_music->stopSoundEffect();
+			} else if (g_lab->_music->isSoundEffectActive())
+				g_lab->_music->stopSoundEffect();
 
 			break;
 
 		case WINMUSIC:
-			g_lab->g_music->_winmusic = true;
-			g_lab->g_music->freeMusic();
-			g_lab->g_music->initMusic();
+			g_lab->_music->_winmusic = true;
+			g_lab->_music->freeMusic();
+			g_lab->_music->initMusic();
 			break;
 
 		case WINGAME:
@@ -590,18 +590,18 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 		APtr = APtr->NextAction;
 	}
 
-	if (g_lab->g_music->_loopSoundEffect) {
-		g_lab->g_music->_loopSoundEffect = false;
-		g_lab->g_music->stopSoundEffect();
+	if (g_lab->_music->_loopSoundEffect) {
+		g_lab->_music->_loopSoundEffect = false;
+		g_lab->_music->stopSoundEffect();
 	} else {
-		while (g_lab->g_music->isSoundEffectActive()) {
-			g_lab->g_music->updateMusic();
+		while (g_lab->_music->isSoundEffectActive()) {
+			g_lab->_music->updateMusic();
 			g_lab->diffNextFrame();
 			g_lab->waitTOF();
 		}
 	}
 
-	g_lab->g_music->_doNotFilestopSoundEffect = false;
+	g_lab->_music->_doNotFilestopSoundEffect = false;
 }
 
 /*****************************************************************************/
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index 88b4c18..926ef35 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -166,7 +166,7 @@ void LabEngine::diffNextFrame() {
 			return; /* done with the next frame. */
 		}
 
-		g_music->updateMusic();
+		_music->updateMusic();
 		readBlock(&header, 4L, difffile);
 		swapULong(&header);
 		readBlock(&size, 4L, difffile);
@@ -227,8 +227,8 @@ void LabEngine::diffNextFrame() {
 		case 30L:
 		case 31L: {
 			if (waitForEffect) {
-				while (g_music->isSoundEffectActive()) {
-					g_music->updateMusic();
+				while (_music->isSoundEffectActive()) {
+					_music->updateMusic();
 					waitTOF();
 				}
 			}
@@ -245,7 +245,7 @@ void LabEngine::diffNextFrame() {
 			uint32 musicsize = size;
 			(*difffile) += size;
 
-			g_music->playSoundEffect(samplespeed, musicsize, music);
+			_music->playSoundEffect(samplespeed, musicsize, music);
 			break;
 		}
 		case 65535L:
@@ -253,8 +253,8 @@ void LabEngine::diffNextFrame() {
 				int didTOF = 0;
 
 				if (waitForEffect) {
-					while (g_music->isSoundEffectActive()) {
-						g_music->updateMusic();
+					while (_music->isSoundEffectActive()) {
+						_music->updateMusic();
 						waitTOF();
 
 						if (DispBitMap->Flags & BITMAPF_VIDEO)
@@ -393,7 +393,7 @@ void stopDiff() {
 void stopDiffEnd() {
 	if (IsPlaying) {
 		while (IsPlaying) {
-			g_lab->g_music->updateMusic();
+			g_lab->_music->updateMusic();
 			g_lab->diffNextFrame();
 		}
 	}
@@ -431,14 +431,14 @@ void readSound(bool waitTillFinished, Common::File *file) {
 		return;
 
 	while (soundTag != 65535) {
-		g_lab->g_music->updateMusic();
+		g_lab->_music->updateMusic();
 		soundTag = file->readUint32LE();
 		soundSize = file->readUint32LE() - 8;
 
 		if ((soundTag == 30) || (soundTag == 31)) {
 			if (waitTillFinished) {
-				while (g_lab->g_music->isSoundEffectActive()) {
-					g_lab->g_music->updateMusic();
+				while (g_lab->_music->isSoundEffectActive()) {
+					g_lab->_music->updateMusic();
 					g_lab->waitTOF();
 				}
 			}
@@ -449,11 +449,11 @@ void readSound(bool waitTillFinished, Common::File *file) {
 			file->skip(2);
 			byte *soundData = (byte *)malloc(soundSize);
 			file->read(soundData, soundSize);
-			g_lab->g_music->playSoundEffect(sampleRate, soundSize, soundData);
+			g_lab->_music->playSoundEffect(sampleRate, soundSize, soundData);
 		} else if (soundTag == 65535L) {
 			if (waitTillFinished) {
-				while (g_lab->g_music->isSoundEffectActive()) {
-					g_lab->g_music->updateMusic();
+				while (g_lab->_music->isSoundEffectActive()) {
+					g_lab->_music->updateMusic();
 					g_lab->waitTOF();
 				}
 			}
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 1e0ac6b..290216c 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -65,7 +65,7 @@ TextFont *Resource::getFont(const char *fileName) {
 	if (fileSize <= headerSize)
 		return NULL;
 
-	_vm->g_music->updateMusic();
+	_vm->_music->updateMusic();
 
 	TextFont *textfont = (TextFont *)malloc(sizeof(TextFont));
 	textfont->DataLength = fileSize - headerSize;
@@ -142,7 +142,7 @@ bool Resource::readViews(uint16 roomNum) {
 	_rooms[roomNum]._westView = readView(dataFile);
 	_rooms[roomNum]._rules = readRule(dataFile);
 
-	_vm->g_music->updateMusic();
+	_vm->_music->updateMusic();
 
 	delete dataFile;
 	return true;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 417f854..7519ad1 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -153,7 +153,7 @@ void showCombination(const char *filename) {
 
 	blackScreen();
 
-	buffer = g_lab->g_music->newOpen("P:Numbers");
+	buffer = g_lab->_music->newOpen("P:Numbers");
 
 	for (uint16 CurBit = 0; CurBit < 10; CurBit++)
 		readImage(buffer, &(Images[CurBit]));
@@ -297,10 +297,10 @@ void showTile(const char *filename, bool showsolution) {
 
 	if (showsolution) {
 		start  = 0;
-		buffer = g_lab->g_music->newOpen("P:TileSolution");
+		buffer = g_lab->_music->newOpen("P:TileSolution");
 	} else {
 		start  = 1;
-		buffer = g_lab->g_music->newOpen("P:Tile");
+		buffer = g_lab->_music->newOpen("P:Tile");
 	}
 
 	if (!buffer)
@@ -553,7 +553,7 @@ static bool loadJournalData() {
 		return false;
 	}
 
-	g_lab->g_music->updateMusic();
+	g_lab->_music->updateMusic();
 
 	strcpy(filename, "Lab:Rooms/j0");
 	bridge = g_lab->_conditions->in(BRIDGE0) || g_lab->_conditions->in(BRIDGE1);
@@ -586,7 +586,7 @@ static bool loadJournalData() {
 	if ((journaltexttitle = getText("Lab:Rooms/jt")) == NULL)
 		return false;
 
-	buffer = g_lab->g_music->newOpen("P:JImage");
+	buffer = g_lab->_music->newOpen("P:JImage");
 
 	if (!buffer)
 		return false;
@@ -628,7 +628,7 @@ static void drawJournalText() {
 	char *CurText = journaltext;
 
 	while (DrawingToPage < JPage) {
-		g_lab->g_music->updateMusic();
+		g_lab->_music->updateMusic();
 		CurText = (char *)(journaltext + CharsDrawn);
 		CharsDrawn += flowText(BigMsgFont, -2, 2, 0, false, false, false, false, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText);
 
@@ -648,7 +648,7 @@ static void drawJournalText() {
 		CharsDrawn += flowTextToMem(&JBackImage, BigMsgFont, -2, 2, 0, false, false, false, true, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText);
 	}
 
-	g_lab->g_music->updateMusic();
+	g_lab->_music->updateMusic();
 	CurText = (char *)(journaltext + CharsDrawn);
 	lastpage = (*CurText == 0);
 	flowTextToMem(&JBackImage, BigMsgFont, -2, 2, 0, false, false, false, true, VGAScaleX(171), VGAScaleY(32), VGAScaleX(271), VGAScaleY(148), CurText);
@@ -663,14 +663,14 @@ static void drawJournalText() {
 static void turnPage(bool FromLeft) {
 	if (FromLeft) {
 		for (int i = 0; i < g_lab->_screenWidth; i += 8) {
-			g_lab->g_music->updateMusic();
+			g_lab->_music->updateMusic();
 			g_lab->waitTOF();
 			ScreenImage.ImageData = g_lab->getVGABaseAddr();
 			g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight);
 		}
 	} else {
 		for (int i = (g_lab->_screenWidth - 8); i > 0; i -= 8) {
-			g_lab->g_music->updateMusic();
+			g_lab->_music->updateMusic();
 			g_lab->waitTOF();
 			ScreenImage.ImageData = g_lab->getVGABaseAddr();
 			g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight);
@@ -685,7 +685,7 @@ static void turnPage(bool FromLeft) {
 void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 	_event->mouseHide();
 
-	g_music->updateMusic();
+	_music->updateMusic();
 
 	if (!GotBackImage)
 		JBackImage.ImageData = loadBackPict("P:Journal.pic", true);
@@ -732,11 +732,11 @@ void LabEngine::processJournal() {
 	uint16 Qualifier, GadID;
 
 	while (1) {
-		g_music->updateMusic();  /* Make sure we check the music at least after every message */
+		_music->updateMusic();  /* Make sure we check the music at least after every message */
 		Msg = getMsg();
 
 		if (Msg == NULL) {
-			g_music->updateMusic();
+			_music->updateMusic();
 		} else {
 			Class     = Msg->msgClass;
 			Qualifier = Msg->qualifier;
@@ -785,7 +785,7 @@ void LabEngine::doJournal() {
 	ScreenImage = JBackImage;
 	ScreenImage.ImageData = getVGABaseAddr();
 
-	g_music->updateMusic();
+	_music->updateMusic();
 	loadJournalData();
 
 	drawJournal(0, true);
@@ -837,7 +837,7 @@ bool saveRestoreGame() {
 		if (slot >= 0) {
 			isOK = loadGame(&RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), slot);
 			if (isOK)
-				g_lab->g_music->resetMusic();
+				g_lab->_music->resetMusic();
 		}
 	}
 
@@ -855,7 +855,7 @@ static void getMonImages() {
 
 	resetBuffer();
 
-	buffer = g_lab->g_music->newOpen("P:MonImage", bufferSize);
+	buffer = g_lab->_music->newOpen("P:MonImage", bufferSize);
 
 	if (!buffer)
 		return;
@@ -906,7 +906,7 @@ void LabEngine::drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16
 	}
 
 	while (DrawingToPage < monitorPage) {
-		g_music->updateMusic();
+		_music->updateMusic();
 		CurText = (char *)(text + CharsDrawn);
 		CharsDrawn += flowText(BigMsgFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, CurText);
 		lastpage = (*CurText == 0);
@@ -960,11 +960,11 @@ void LabEngine::processMonitor(char *ntext, bool isinteractive, uint16 x1, uint1
 			}
 		}
 
-		g_music->updateMusic();  /* Make sure we check the music at least after every message */
+		_music->updateMusic();  /* Make sure we check the music at least after every message */
 		Msg = getMsg();
 
 		if (Msg == NULL) {
-			g_music->updateMusic();
+			_music->updateMusic();
 		} else {
 			Class     = Msg->msgClass;
 			Qualifier = Msg->qualifier;


Commit: 6cee2eb2be4e6977d659a47809a91454532c0f11
    https://github.com/scummvm/scummvm/commit/6cee2eb2be4e6977d659a47809a91454532c0f11
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:44+01:00

Commit Message:
LAB: Move RoomNum to main engine class

Changed paths:
    engines/lab/engine.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/labfun.h
    engines/lab/labmusic.cpp
    engines/lab/map.cpp
    engines/lab/processroom.cpp
    engines/lab/savegame.cpp
    engines/lab/special.cpp
    engines/lab/text.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 5de7e8f..50b404a 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -53,7 +53,7 @@ extern bool DoBlack, waitForEffect, stopsound, DoNotDrawMessage, nopalchange;
 
 extern RoomData *_rooms;
 extern InventoryData *Inventory;
-extern uint16 NumInv, RoomNum, ManyRooms, HighestCondition, Direction;
+extern uint16 NumInv, ManyRooms, HighestCondition, Direction;
 CloseDataPtr CPtr;
 
 CrumbData BreadCrumbs[MAX_CRUMBS];
@@ -528,7 +528,7 @@ bool LabEngine::doUse(uint16 CurInv) {
 		stopDiff();
 		CurFileName = " ";
 		CPtr = NULL;
-		doMap(RoomNum);
+		doMap(_roomNum);
 		VGASetPal(initcolors, 8);
 		drawMessage(NULL);
 		drawPanel();
@@ -647,7 +647,7 @@ void LabEngine::mainGameLoop() {
 	VGASetPal(initcolors, 8);
 
 	CPtr    = NULL;
-	RoomNum = 1;
+	_roomNum = 1;
 	Direction = NORTH;
 
 	_resource->readRoomData("LAB:Doors");
@@ -693,7 +693,7 @@ void LabEngine::mainGameLoop() {
 				Test = getPictName(&CPtr);
 
 			if (noupdatediff) {
-				_roomsFound->inclElement(RoomNum); /* Potentially entered another room */
+				_roomsFound->inclElement(_roomNum); /* Potentially entered another room */
 				ForceDraw = (strcmp(Test, CurFileName) != 0) || ForceDraw;
 
 				noupdatediff = false;
@@ -702,7 +702,7 @@ void LabEngine::mainGameLoop() {
 
 			else if (strcmp(Test, CurFileName) != 0) {
 				interfaceOff();
-				_roomsFound->inclElement(RoomNum); /* Potentially entered another room */
+				_roomsFound->inclElement(_roomNum); /* Potentially entered another room */
 				CurFileName = Test;
 
 				if (CPtr) {
@@ -965,18 +965,18 @@ from_crumbs:
 						mayShowCrumbIndicator();
 						WSDL_UpdateScreen();
 					} else if (GadID == 7) {
-						OldRoomNum = RoomNum;
+						OldRoomNum = _roomNum;
 
 						if (doGoForward(&CPtr)) {
-							if (OldRoomNum == RoomNum)
+							if (OldRoomNum == _roomNum)
 								DoBlack = true;
 						} else {
 							DoBlack = true;
 							processArrow(&Direction, GadID - 6);
 
-							if (OldRoomNum != RoomNum) {
+							if (OldRoomNum != _roomNum) {
 								drawStaticMessage(kTextGoForward);
-								_roomsFound->inclElement(RoomNum); /* Potentially entered a new room */
+								_roomsFound->inclElement(_roomNum); /* Potentially entered a new room */
 								CurFileName = " ";
 								ForceDraw = true;
 							} else {
@@ -991,15 +991,15 @@ from_crumbs:
 									FollowingCrumbs = false;
 								}
 							} else {
-								if (RoomNum == OldRoomNum) { // didn't get there?
+								if (_roomNum == OldRoomNum) { // didn't get there?
 									FollowingCrumbs = false;
 								}
 							}
-						} else if (DroppingCrumbs && OldRoomNum != RoomNum) {
+						} else if (DroppingCrumbs && OldRoomNum != _roomNum) {
 							// If in surreal maze, turn off DroppingCrumbs.
 							// Note: These numbers were generated by parsing the
 							// "Maps" file, which is why they are hard-coded. Bleh!
-							if (RoomNum >= 245 && RoomNum <= 280) {
+							if (_roomNum >= 245 && _roomNum <= 280) {
 								FollowingCrumbs = false;
 								DroppingCrumbs = false;
 								NumCrumbs = 0;
@@ -1007,7 +1007,7 @@ from_crumbs:
 							} else {
 								bool intersect = false;
 								for (int idx = 0; idx < NumCrumbs; idx++) {
-									if (BreadCrumbs[idx].RoomNum == RoomNum) {
+									if (BreadCrumbs[idx].RoomNum == _roomNum) {
 										NumCrumbs = idx + 1;
 										BreadCrumbs[NumCrumbs].RoomNum = 0;
 										intersect = true;
@@ -1020,7 +1020,7 @@ from_crumbs:
 										memcpy(&BreadCrumbs[0], &BreadCrumbs[1], NumCrumbs * sizeof BreadCrumbs[0]);
 									}
 
-									BreadCrumbs[NumCrumbs].RoomNum = RoomNum;
+									BreadCrumbs[NumCrumbs].RoomNum = _roomNum;
 									BreadCrumbs[NumCrumbs++].Direction = Direction;
 								}
 							}
@@ -1175,11 +1175,11 @@ from_crumbs:
 					eatMessages();
 
 					if (ActionMode == 0) { /* Take something. */
-						if (doActionRule(Common::Point(curPos.x, curPos.y), ActionMode, RoomNum, &CPtr))
+						if (doActionRule(Common::Point(curPos.x, curPos.y), ActionMode, _roomNum, &CPtr))
 							CurFileName = NewFileName;
 						else if (takeItem(curPos.x, curPos.y, &CPtr))
 							drawStaticMessage(kTextTakeItem);
-						else if (doActionRule(curPos, TAKEDEF - 1, RoomNum, &CPtr))
+						else if (doActionRule(curPos, TAKEDEF - 1, _roomNum, &CPtr))
 							CurFileName = NewFileName;
 						else if (doActionRule(curPos, TAKE - 1, 0, &CPtr))
 							CurFileName = NewFileName;
@@ -1188,7 +1188,7 @@ from_crumbs:
 					} else if ((ActionMode == 1) /* Manipulate an object */  ||
 					         (ActionMode == 2) /* Open up a "door" */      ||
 					         (ActionMode == 3)) { /* Close a "door" */
-						if (doActionRule(curPos, ActionMode, RoomNum, &CPtr))
+						if (doActionRule(curPos, ActionMode, _roomNum, &CPtr))
 							CurFileName = NewFileName;
 						else if (!doActionRule(curPos, ActionMode, 0, &CPtr)) {
 							if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
@@ -1224,7 +1224,7 @@ from_crumbs:
 				mayShowCrumbIndicator();
 				WSDL_UpdateScreen();
 			} else if (Class == DELTAMOVE) {
-				VPtr = getViewData(RoomNum, Direction);
+				VPtr = getViewData(_roomNum, Direction);
 				OldCPtr = VPtr->closeUps;
 
 				if (HCPtr == NULL) {
@@ -1400,7 +1400,7 @@ int followCrumbs() {
 		BreadCrumbs[NumCrumbs--].RoomNum = 0;
 
 	// Is the current crumb this room? If not, logic error.
-	if (RoomNum != BreadCrumbs[NumCrumbs].RoomNum) {
+	if (g_lab->_roomNum != BreadCrumbs[NumCrumbs].RoomNum) {
 		NumCrumbs = 0;
 		BreadCrumbs[0].RoomNum = 0;
 		DroppingCrumbs = false;
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 9ad51fd..6d7ed00 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -73,11 +73,13 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
     _nextKeyOut = 0;
 
 	_isHiRes = false;
+	_roomNum = -1;
 
 	_event = nullptr;
 	_resource = nullptr;
 	_music = nullptr;
 
+
 	//const Common::FSNode gameDataDir(ConfMan.get("path"));
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game/pict");
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index e7c2303..3c62113 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -103,6 +103,7 @@ public:
 	Resource *_resource;
 	Music *_music;
 
+	int _roomNum;
 	byte *_currentDsplayBuffer;
 	Common::Point _mousePos;
 
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 57d5817..d20db11 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -256,8 +256,8 @@ bool saveRestoreGame();
 /*----- From saveGame.c ----*/
 /*--------------------------*/
 
-bool saveGame(uint16 RoomNum, uint16 Direction, uint16 Quarters, int slot, Common::String desc);
-bool loadGame(uint16 *RoomNum, uint16 *Direction, uint16 *Quarters, int slot);
+bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc);
+bool loadGame(uint16 *Direction, uint16 *Quarters, int slot);
 bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header);
 
 /*--------------------------*/
diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index 843a866..3f8017d 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -43,8 +43,6 @@ namespace Lab {
 #define CLOWNROOM           123
 #define DIMROOM              80
 
-extern uint16 RoomNum;	// TODO: Move into a class
-
 Music::Music(LabEngine *vm) : _vm(vm) {
 	_file = 0;
 	_tFile = 0;
@@ -70,9 +68,9 @@ Music::Music(LabEngine *vm) : _vm(vm) {
 /* it from the Audio device.                                                 */
 /*****************************************************************************/
 void Music::updateMusic() {
-	g_lab->WSDL_ProcessInput(0);
+	_vm->WSDL_ProcessInput(0);
 
-	g_lab->_event->updateMouse();
+	_vm->_event->updateMouse();
 
 	if (_musicOn && getPlayingBufferCount() < MAXBUFFERS) {
 		// NOTE: We need to use malloc(), cause this will be freed with free()
@@ -89,7 +87,7 @@ void Music::updateMusic() {
 		}
 
 		byte soundFlags = Audio::FLAG_LITTLE_ENDIAN;
-		if (g_lab->getPlatform() == Common::kPlatformWindows)
+		if (_vm->getPlatform() == Common::kPlatformWindows)
 			soundFlags |= Audio::FLAG_16BITS;
 		else
 			soundFlags |= Audio::FLAG_UNSIGNED;
@@ -97,7 +95,7 @@ void Music::updateMusic() {
 		_queuingAudioStream->queueBuffer(musicBuffer, MUSICBUFSIZE, DisposeAfterUse::YES, soundFlags);
 
 		if (startMusic)
-			g_lab->_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _queuingAudioStream);
+			_vm->_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _queuingAudioStream);
 	}
 }
 
@@ -113,7 +111,7 @@ void Music::playSoundEffect(uint16 SampleSpeed, uint32 Length, void *Data) {
 		SampleSpeed = 4000;
 
 	byte soundFlags = Audio::FLAG_LITTLE_ENDIAN;
-	if (g_lab->getPlatform() == Common::kPlatformWindows)
+	if (_vm->getPlatform() == Common::kPlatformWindows)
 		soundFlags |= Audio::FLAG_16BITS;
 	else
 		soundFlags |= Audio::FLAG_UNSIGNED;
@@ -121,16 +119,16 @@ void Music::playSoundEffect(uint16 SampleSpeed, uint32 Length, void *Data) {
 	Audio::SeekableAudioStream *audioStream = Audio::makeRawStream((const byte *)Data, Length, SampleSpeed, soundFlags, DisposeAfterUse::NO);
 	uint loops = (_loopSoundEffect) ? 0 : 1;
 	Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, loops);
-	g_lab->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, loopingAudioStream);
+	_vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, loopingAudioStream);
 }
 
 void Music::stopSoundEffect() {
 	if (isSoundEffectActive())
-		g_lab->_mixer->stopHandle(_sfxHandle);
+		_vm->_mixer->stopHandle(_sfxHandle);
 }
 
 bool Music::isSoundEffectActive() const {
-	return g_lab->_mixer->isSoundHandleActive(_sfxHandle);
+	return _vm->_mixer->isSoundHandleActive(_sfxHandle);
 }
 
 void Music::fillbuffer(byte *musicBuffer) {
@@ -196,10 +194,10 @@ bool Music::initMusic() {
 void Music::freeMusic() {
 	_musicOn = false;
 
-	g_lab->_mixer->stopHandle(_musicHandle);
+	_vm->_mixer->stopHandle(_musicHandle);
 	_queuingAudioStream = NULL;
 
-	g_lab->_mixer->stopHandle(_sfxHandle);
+	_vm->_mixer->stopHandle(_sfxHandle);
 
 	delete _file;
 	_file = NULL;
@@ -214,7 +212,7 @@ void Music::pauseBackMusic() {
 		_musicOn = false;
 		stopSoundEffect();
 
-		g_lab->_mixer->pauseHandle(_musicHandle, true);
+		_vm->_mixer->pauseHandle(_musicHandle, true);
 
 		_musicPaused = true;
 	}
@@ -228,7 +226,7 @@ void Music::resumeBackMusic() {
 		stopSoundEffect();
 		_musicOn = true;
 
-		g_lab->_mixer->pauseHandle(_musicHandle, false);
+		_vm->_mixer->pauseHandle(_musicHandle, false);
 
 		updateMusic();
 		_musicPaused = false;
@@ -255,17 +253,17 @@ void Music::setMusic(bool on) {
 /* Checks the music that should be playing in a particular room.              */
 /******************************************************************************/
 void Music::checkRoomMusic() {
-	if ((_lastMusicRoom == RoomNum) || !_musicOn)
+	if ((_lastMusicRoom == _vm->_roomNum) || !_musicOn)
 		return;
 
-	if (RoomNum == CLOWNROOM)
+	if (_vm->_roomNum == CLOWNROOM)
 		changeMusic("Music:Laugh");
-	else if (RoomNum == DIMROOM)
+	else if (_vm->_roomNum == DIMROOM)
 		changeMusic("Music:Rm81");
 	else if (_doReset)
 		resetMusic();
 
-	_lastMusicRoom = RoomNum;
+	_lastMusicRoom = _vm->_roomNum;
 }
 
 /*****************************************************************************/
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index ac612fb..859d1ff 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -49,7 +49,6 @@ static TextFont bmf;
 extern uint16 Direction;
 
 extern CloseDataPtr CPtr;
-extern uint16 RoomNum;
 
 /*****************************************************************************/
 /* Converts an Amiga palette (up to 16 colors) to a VGA palette, then sets   */
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index bc62aac..8453fe6 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -47,7 +47,7 @@ namespace Lab {
 
 RoomData *_rooms;
 InventoryData *Inventory;
-uint16 NumInv, RoomNum, ManyRooms, HighestCondition, Direction;
+uint16 NumInv, ManyRooms, HighestCondition, Direction;
 const char *NewFileName;
 
 extern bool DoNotDrawMessage, IsBM, noupdatediff, QuitLab, MusicOn, DoBlack, LongWinInFront;
@@ -124,7 +124,7 @@ static CloseData *getObject(uint16 x, uint16 y, CloseDataPtr LCPtr) {
 	ViewData *VPtr;
 
 	if (LCPtr == NULL) {
-		VPtr = getViewData(RoomNum, Direction);
+		VPtr = getViewData(g_lab->_roomNum, Direction);
 		LCPtr = VPtr->closeUps;
 	}
 
@@ -173,7 +173,7 @@ static CloseDataPtr findCPtrMatch(CloseDataPtr Main, CloseDataPtr List) {
 /* Returns the current picture name.                                         */
 /*****************************************************************************/
 char *getPictName(CloseDataPtr *LCPtr) {
-	ViewData *ViewPtr = getViewData(RoomNum, Direction);
+	ViewData *ViewPtr = getViewData(g_lab->_roomNum, Direction);
 
 	if (*LCPtr != NULL) {
 		*LCPtr = findCPtrMatch(*LCPtr, ViewPtr->closeUps);
@@ -196,8 +196,8 @@ void LabEngine::drawDirection(CloseDataPtr LCPtr) {
 
 	Common::String message;
 
-	if (_rooms[RoomNum]._roomMsg) {
-		message += _rooms[RoomNum]._roomMsg;
+	if (_rooms[_roomNum]._roomMsg) {
+		message += _rooms[_roomNum]._roomMsg;
 		message += ", ";
 	}
 
@@ -221,18 +221,18 @@ bool processArrow(uint16 *direction, uint16 Arrow) {
 
 	if (Arrow == 1) { /* Forward */
 		if (*direction == NORTH)
-			room = _rooms[RoomNum]._northDoor;
+			room = _rooms[g_lab->_roomNum]._northDoor;
 		else if (*direction == SOUTH)
-			room = _rooms[RoomNum]._southDoor;
+			room = _rooms[g_lab->_roomNum]._southDoor;
 		else if (*direction == EAST)
-			room = _rooms[RoomNum]._eastDoor;
+			room = _rooms[g_lab->_roomNum]._eastDoor;
 		else if (*direction == WEST)
-			room = _rooms[RoomNum]._westDoor;
+			room = _rooms[g_lab->_roomNum]._westDoor;
 
 		if (room == 0)
 			return false;
 		else
-			RoomNum = room;
+			g_lab->_roomNum = room;
 	} else if (Arrow == 0) { /* Left */
 		if (*direction == NORTH)
 			*direction = WEST;
@@ -265,7 +265,7 @@ void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords)
 	uint16 x1, y1, x2, y2;
 
 	if (*cptr == NULL) {
-		VPtr = getViewData(RoomNum, Direction);
+		VPtr = getViewData(g_lab->_roomNum, Direction);
 		LCPtr = VPtr->closeUps;
 	} else
 		LCPtr = (*cptr)->SubCloseUps;
@@ -300,7 +300,7 @@ bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
 	CloseDataPtr LCPtr;
 
 	if (*cptr == NULL) {
-		VPtr = getViewData(RoomNum, Direction);
+		VPtr = getViewData(g_lab->_roomNum, Direction);
 		LCPtr = VPtr->closeUps;
 	} else if ((*cptr)->CloseUpType < 0) {
 		g_lab->_conditions->inclElement(abs((*cptr)->CloseUpType));
@@ -443,7 +443,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 				continue;
 			}
 
-			RoomNum   = APtr->Param1;
+			g_lab->_roomNum   = APtr->Param1;
 			Direction = APtr->Param2 - 1;
 			*LCPtr      = NULL;
 			DoBlack    = true;
@@ -611,7 +611,7 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr LCPtr, Clo
 	action++;
 
 	if (LCPtr) {
-		RuleList *rules = _rooms[RoomNum]._rules;
+		RuleList *rules = _rooms[g_lab->_roomNum]._rules;
 
 		if ((rules == NULL) && (roomNum == 0)) {
 			g_lab->_resource->readViews(roomNum);
@@ -700,13 +700,13 @@ bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *LCPtr) {
 
 	TLCPtr = getObject(x, y, *LCPtr);
 
-	if (doOperateRuleSub(ItemNum, RoomNum, TLCPtr, LCPtr, false))
+	if (doOperateRuleSub(ItemNum, g_lab->_roomNum, TLCPtr, LCPtr, false))
 		return true;
-	else if (doOperateRuleSub(ItemNum, RoomNum, *LCPtr, LCPtr, false))
+	else if (doOperateRuleSub(ItemNum, g_lab->_roomNum, *LCPtr, LCPtr, false))
 		return true;
-	else if (doOperateRuleSub(ItemNum, RoomNum, TLCPtr, LCPtr, true))
+	else if (doOperateRuleSub(ItemNum, g_lab->_roomNum, TLCPtr, LCPtr, true))
 		return true;
-	else if (doOperateRuleSub(ItemNum, RoomNum, *LCPtr, LCPtr, true))
+	else if (doOperateRuleSub(ItemNum, g_lab->_roomNum, *LCPtr, LCPtr, true))
 		return true;
 	else {
 		NewFileName = CurFileName;
@@ -728,7 +728,7 @@ bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *LCPtr) {
 /* Goes thru the rules if the user tries to go forward.                      */
 /*****************************************************************************/
 bool doGoForward(CloseDataPtr *LCPtr) {
-	RuleList *rules = _rooms[RoomNum]._rules;
+	RuleList *rules = _rooms[g_lab->_roomNum]._rules;
 
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 		if (((*rule)->RuleType == GOFORWARD) && ((*rule)->Param1 == (Direction + 1))) {
@@ -749,7 +749,7 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *LCPtr) {
 	from++;
 	to++;
 
-	RuleList *rules = _rooms[RoomNum]._rules;
+	RuleList *rules = _rooms[g_lab->_roomNum]._rules;
 
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 		if (((*rule)->RuleType == TURN) ||
@@ -769,7 +769,7 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *LCPtr) {
 /* Goes thru the rules if the user tries to go to the main view              */
 /*****************************************************************************/
 bool doMainView(CloseDataPtr *LCPtr) {
-	RuleList *rules = _rooms[RoomNum]._rules;
+	RuleList *rules = _rooms[g_lab->_roomNum]._rules;
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 		if ((*rule)->RuleType == GOMAINVIEW) {
 			if (checkConditions((*rule)->Condition)) {
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index a32971b..b8a59a5 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -132,7 +132,7 @@ bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
 /*****************************************************************************/
 /* Writes the game out to disk.                                              */
 /*****************************************************************************/
-bool saveGame(uint16 RoomNum, uint16 Direction, uint16 Quarters, int slot, Common::String desc) {
+bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc) {
 	uint16 i, j;
 	Common::String fileName = g_lab->generateSaveFileName(slot);
 	Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
@@ -146,7 +146,7 @@ bool saveGame(uint16 RoomNum, uint16 Direction, uint16 Quarters, int slot, Commo
 	readPict(getPictName(&CPtr), true);
 
 	writeSaveGameHeader(file, desc);
-	file->writeUint16LE(RoomNum);
+	file->writeUint16LE(g_lab->_roomNum);
 	file->writeUint16LE(Direction);
 	file->writeUint16LE(Quarters);
 
@@ -185,7 +185,7 @@ bool saveGame(uint16 RoomNum, uint16 Direction, uint16 Quarters, int slot, Commo
 /*****************************************************************************/
 /* Reads the game from disk.                                                 */
 /*****************************************************************************/
-bool loadGame(uint16 *RoomNum, uint16 *Direction, uint16 *Quarters, int slot) {
+bool loadGame(uint16 *Direction, uint16 *Quarters, int slot) {
 	uint16 i, j;
 	Common::String fileName = g_lab->generateSaveFileName(slot);
 	Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
@@ -196,7 +196,7 @@ bool loadGame(uint16 *RoomNum, uint16 *Direction, uint16 *Quarters, int slot) {
 
 	SaveGameHeader header;
 	readSaveGameHeader(file, header);
-	*RoomNum = file->readUint16LE();
+	g_lab->_roomNum = file->readUint16LE();
 	*Direction = file->readUint16LE();
 	*Quarters = file->readUint16LE();
 
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 7519ad1..e3d1541 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -90,7 +90,7 @@ extern BitMap *DispBitMap, *DrawBitMap;
 extern char diffcmap[3 * 256];
 extern CloseDataPtr CPtr;
 extern InventoryData *Inventory;
-extern uint16 RoomNum, Direction;
+extern uint16 Direction;
 
 #define COMBINATIONUNLOCKED  130
 #define BRICKOPEN            115
@@ -828,14 +828,14 @@ bool saveRestoreGame() {
 				desc = dialog->createDefaultSaveDescription(slot);
 			}
 
-			isOK = saveGame(RoomNum, Direction, Inventory[QUARTERNUM].Many, slot, desc);
+			isOK = saveGame(Direction, Inventory[QUARTERNUM].Many, slot, desc);
 		}
 	} else {
 		// Restore
 		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
 		int slot = dialog->runModalWithCurrentTarget();
 		if (slot >= 0) {
-			isOK = loadGame(&RoomNum, &Direction, &(Inventory[QUARTERNUM].Many), slot);
+			isOK = loadGame(&Direction, &(Inventory[QUARTERNUM].Many), slot);
 			if (isOK)
 				g_lab->_music->resetMusic();
 		}
diff --git a/engines/lab/text.cpp b/engines/lab/text.cpp
index 10e4ac8..3fc1b1a 100644
--- a/engines/lab/text.cpp
+++ b/engines/lab/text.cpp
@@ -73,7 +73,7 @@ uint16 textHeight(struct TextFont *tf) {
 /*****************************************************************************/
 /* Draws the text to the screen.                                             */
 /*****************************************************************************/
-void text(struct TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numchars) {
+void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numchars) {
 	byte *VGATop, *VGACur, *VGATemp, *VGATempLine, *cdata;
 	uint32 RealOffset, SegmentOffset;
 	int32 templeft, LeftInSegment;


Commit: 11df8b5cf76bf9e3bbdbb5b264ec318d0e7e2911
    https://github.com/scummvm/scummvm/commit/11df8b5cf76bf9e3bbdbb5b264ec318d0e7e2911
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:44+01:00

Commit Message:
LAB: Make consistent the type of pen number

Changed paths:
    engines/lab/graphics.cpp
    engines/lab/intro.cpp
    engines/lab/lab.h
    engines/lab/labfun.h
    engines/lab/vga.cpp



diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 9f689bd..54bf880 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -225,8 +225,8 @@ static void getLine(TextFont *tf, char *LineBuffer, const char **MainBuffer, uin
 /******************************************************************************/
 uint32 flowText(void *font,      /* the TextAttr pointer */
                 int16 spacing,          /* How much vertical spacing between the lines */
-                uint16 pencolor,         /* pen number to use for text */
-                uint16 backpen,          /* the background color */
+                byte pencolor,         /* pen number to use for text */
+                byte backpen,          /* the background color */
                 bool fillback,                /* Whether to fill the background */
                 bool centerh,                 /* Whether to center the text horizontally */
                 bool centerv,                 /* Whether to center the text vertically */
@@ -292,8 +292,8 @@ uint32 flowText(void *font,      /* the TextAttr pointer */
 /******************************************************************************/
 uint32 flowTextToMem(Image *DestIm, void *font,     /* the TextAttr pointer */
                      int16 spacing,          /* How much vertical spacing between the lines */
-                     uint16 pencolor,         /* pen number to use for text */
-                     uint16 backpen,          /* the background color */
+                     byte pencolor,         /* pen number to use for text */
+                     byte backpen,          /* the background color */
                      bool fillback,                /* Whether to fill the background */
                      bool centerh,                 /* Whether to center the text horizontally */
                      bool centerv,                 /* Whether to center the text vertically */
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 36137be..7660b29 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -115,7 +115,7 @@ void Intro::doPictText(const char *filename, bool isscreen) {
 				fade(false, 0);
 
 			if (isscreen) {
-				g_lab->setAPen(7L);
+				g_lab->setAPen(7);
 				g_lab->rectFill(VGAScaleX(10), VGAScaleY(10), VGAScaleX(310), VGAScaleY(190));
 
 				Drawn = flowText(_msgfont, (!g_lab->_isHiRes) * -1, 5, 7, false, false, true, true, VGAScaleX(14), VGAScaleY(11), VGAScaleX(306), VGAScaleY(189), (char *)curplace);
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 3c62113..2e23ee3 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -125,7 +125,7 @@ private:
 
 public:
 	void waitTOF();
-	void setAPen(uint16 pennum);
+	void setAPen(byte pennum);
 	void writeColorRegs(byte *buf, uint16 first, uint16 numreg);
 	byte *getVGABaseAddr();
 	void readScreenImage(Image *Im, uint16 x, uint16 y);
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index d20db11..77a259a 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -80,8 +80,8 @@ byte *readPictToMem(const char *filename, uint16 x, uint16 y);
 
 uint32 flowText(void *font,  /* the TextAttr pointer */
                 int16 spacing,          /* How much vertical spacing between the lines */
-                uint16 pencolor,         /* pen number to use for text */
-                uint16 backpen,          /* the background color */
+                byte pencolor,         /* pen number to use for text */
+                byte backpen,          /* the background color */
                 bool fillback,                /* Whether to fill the background */
                 bool centerh,                 /* Whether to center the text horizontally */
                 bool centerv,                 /* Whether to center the text vertically */
@@ -91,8 +91,8 @@ uint32 flowText(void *font,  /* the TextAttr pointer */
 
 uint32 flowTextToMem(Image *DestIm, void *font,     /* the TextAttr pointer */
                      int16 spacing,          /* How much vertical spacing between the lines */
-                     uint16 pencolor,         /* pen number to use for text */
-                     uint16 backpen,          /* the background color */
+                     byte pencolor,         /* pen number to use for text */
+                     byte backpen,          /* the background color */
                      bool fillback,                /* Whether to fill the background */
                      bool centerh,                 /* Whether to center the text horizontally */
                      bool centerv,                 /* Whether to center the text vertically */
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index c7252d4..d307164 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -524,8 +524,8 @@ void LabEngine::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16
 /*****************************************************************************/
 /* Sets the pen number to use on all the drawing operations.                 */
 /*****************************************************************************/
-void LabEngine::setAPen(uint16 pennum) {
-	_curapen = (unsigned char)pennum;
+void LabEngine::setAPen(byte pennum) {
+	_curapen = pennum;
 }
 
 /*****************************************************************************/


Commit: 17678103db3fcfc6b49dfad44a46cb63bc1e4945
    https://github.com/scummvm/scummvm/commit/17678103db3fcfc6b49dfad44a46cb63bc1e4945
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:44+01:00

Commit Message:
LAB: Move Music declaration to a separate header file

Changed paths:
  A engines/lab/music.h
    engines/lab/lab.h
    engines/lab/labfun.h
    engines/lab/labmusic.cpp



diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 2e23ee3..6749a74 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -38,6 +38,7 @@
 #include "lab/labfun.h"
 #include "lab/interface.h"
 #include "lab/mouse.h"
+#include "lab/music.h"
 #include "lab/resource.h"
 
 struct ADGameDescription;
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 77a259a..7fffb1b 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -150,60 +150,6 @@ Common::File *openPartial(const char *name);
 void closePartial(int32 File);
 
 /*---------------------------*/
-/*----- From LabMusic.c -----*/
-/*---------------------------*/
-
-#define MAXBUFFERS         5L
-
-class Music {
-public:
-	Music(LabEngine *vm);
-
-	byte **newOpen(const char *name);
-	byte **newOpen(const char *name, uint32 &size);
-	bool initMusic();
-	void freeMusic();
-	void updateMusic();
-	uint16 getPlayingBufferCount();
-	void closeMusic();
-	void setMusic(bool on);
-	void resumeBackMusic();
-	void pauseBackMusic();
-	void changeMusic(const char *newmusic);
-	void checkRoomMusic();
-	void resetMusic();
-	void setMusicReset(bool reset) { _doReset = reset; }
-	void playSoundEffect(uint16 SampleSpeed, uint32 Length, void *Data);
-	void stopSoundEffect();
-	bool isSoundEffectActive() const;
-
-	bool _winmusic, _doNotFilestopSoundEffect;
-	bool _musicOn;
-	bool _loopSoundEffect;
-	bool _waitTillFinished;
-	uint16 _lastMusicRoom ;
-	bool _doReset;
-
-private:
-	LabEngine *_vm;
-	void fillbuffer(byte *musicBuffer);
-	void startMusic(bool startatbegin);
-
-	Common::File *_file;
-	Common::File *_tFile;
-	bool _musicPaused;
-
-	bool _tMusicOn;
-	uint32 _tLeftInFile;
-	uint32 _leftinfile;
-
-	Audio::SoundHandle _musicHandle;
-	Audio::SoundHandle _sfxHandle;
-
-	Audio::QueuingAudioStream *_queuingAudioStream;
-};
-
-/*---------------------------*/
 /*----- From LabSets.c ------*/
 /*---------------------------*/
 
diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
index 3f8017d..1f99a68 100644
--- a/engines/lab/labmusic.cpp
+++ b/engines/lab/labmusic.cpp
@@ -33,6 +33,7 @@
 #include "lab/stddefines.h"
 #include "lab/labfun.h"
 #include "lab/mouse.h"
+#include "lab/music.h"
 #include "lab/lab.h"
 
 namespace Lab {
diff --git a/engines/lab/music.h b/engines/lab/music.h
new file mode 100644
index 0000000..1e2bdc3
--- /dev/null
+++ b/engines/lab/music.h
@@ -0,0 +1,101 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#ifndef LAB_MUSIC_H
+#define LAB_MUSIC_H
+
+#include "common/events.h"
+
+// For the Music class - TODO: Move to another header file
+#include "audio/mixer.h"
+#include "audio/audiostream.h"
+#include "audio/decoders/raw.h"
+
+namespace Lab {
+
+class LabEngine;
+
+/*---------------------------*/
+/*----- From LabMusic.c -----*/
+/*---------------------------*/
+
+#define MAXBUFFERS         5L
+
+class Music {
+public:
+	Music(LabEngine *vm);
+
+	byte **newOpen(const char *name);
+	byte **newOpen(const char *name, uint32 &size);
+	bool initMusic();
+	void freeMusic();
+	void updateMusic();
+	uint16 getPlayingBufferCount();
+	void closeMusic();
+	void setMusic(bool on);
+	void resumeBackMusic();
+	void pauseBackMusic();
+	void changeMusic(const char *newmusic);
+	void checkRoomMusic();
+	void resetMusic();
+	void setMusicReset(bool reset) { _doReset = reset; }
+	void playSoundEffect(uint16 SampleSpeed, uint32 Length, void *Data);
+	void stopSoundEffect();
+	bool isSoundEffectActive() const;
+
+	bool _winmusic, _doNotFilestopSoundEffect;
+	bool _musicOn;
+	bool _loopSoundEffect;
+	bool _waitTillFinished;
+	uint16 _lastMusicRoom ;
+	bool _doReset;
+
+private:
+	LabEngine *_vm;
+	void fillbuffer(byte *musicBuffer);
+	void startMusic(bool startatbegin);
+
+	Common::File *_file;
+	Common::File *_tFile;
+	bool _musicPaused;
+
+	bool _tMusicOn;
+	uint32 _tLeftInFile;
+	uint32 _leftinfile;
+
+	Audio::SoundHandle _musicHandle;
+	Audio::SoundHandle _sfxHandle;
+
+	Audio::QueuingAudioStream *_queuingAudioStream;
+};
+
+} // End of namespace Lab
+
+#endif /* LAB_MUSIC_H */


Commit: 6395095b831c1d1a29e315f948ad1d6667255c7b
    https://github.com/scummvm/scummvm/commit/6395095b831c1d1a29e315f948ad1d6667255c7b
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:44+01:00

Commit Message:
LAB: Move crumb variables to main class

Changed paths:
    engines/lab/engine.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/parsetypes.h
    engines/lab/savegame.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 50b404a..37a8977 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -56,19 +56,6 @@ extern InventoryData *Inventory;
 extern uint16 NumInv, ManyRooms, HighestCondition, Direction;
 CloseDataPtr CPtr;
 
-CrumbData BreadCrumbs[MAX_CRUMBS];
-uint16 NumCrumbs;
-bool DroppingCrumbs;
-bool FollowingCrumbs;
-bool FollowCrumbsFast;
-bool IsCrumbTurning;
-uint32 CrumbSecs, CrumbMicros;
-bool IsCrumbWaiting;
-
-int     followCrumbs();
-void    mayShowCrumbIndicator();
-void    mayShowCrumbIndicatorOff();
-
 bool Alternate = false, ispal = false, noupdatediff = false, MainDisplay = true, QuitLab = false;
 
 extern const char *NewFileName;  /* When ProcessRoom.c decides to change the filename
@@ -142,9 +129,9 @@ void LabEngine::drawPanel() {
 	setAPen(5);                 /* Second Line */
 	drawHLine(0, VGAScaleY(149) + 1 + SVGACord(2), VGAScaleX(319));
 
-	/* Gadget Seperators */
+	/* Gadget Separators */
 	setAPen(0);
-	drawHLine(0, VGAScaleY(170), VGAScaleX(319));     /* First black line to seperate buttons */
+	drawHLine(0, VGAScaleY(170), VGAScaleX(319));     /* First black line to separate buttons */
 
 	if (!Alternate) {
 		setAPen(4);
@@ -631,7 +618,6 @@ void LabEngine::decIncInv(uint16 *CurInv, bool dec) {
 /* The main game loop                                                         */
 /******************************************************************************/
 void LabEngine::mainGameLoop() {
-	IntuiMessage *Msg;
 	uint32 Class;
 
 	uint16 Qualifier, ActionMode = 4;
@@ -723,7 +709,7 @@ void LabEngine::mainGameLoop() {
 				mayShowCrumbIndicator();
 				WSDL_UpdateScreen();
 
-				if (!FollowingCrumbs)
+				if (!_followingCrumbs)
 					eatMessages();
 			}
 
@@ -736,16 +722,16 @@ void LabEngine::mainGameLoop() {
 
 		_music->updateMusic();  /* Make sure we check the music at least after every message */
 		interfaceOn();
-		Msg = getMsg();
+		IntuiMessage *curMsg = getMsg();
 
 		Common::Point curPos;
-		if (Msg == NULL) { /* Does music load and next animation frame when you've run out of messages */
+		if (curMsg == NULL) { /* Does music load and next animation frame when you've run out of messages */
 			GotMessage = false;
 			_music->checkRoomMusic();
 			_music->updateMusic();
 			diffNextFrame();
 
-			if (FollowingCrumbs) {
+			if (_followingCrumbs) {
 				int result = followCrumbs();
 
 				if (result != 0) {
@@ -772,14 +758,14 @@ void LabEngine::mainGameLoop() {
 		} else {
 			GotMessage = true;
 
-			Class     = Msg->msgClass;
-			code      = Msg->code;
-			Qualifier = Msg->qualifier;
-			curPos.x  = Msg->mouseX;
-			curPos.y  = Msg->mouseY;
-			GadID     = Msg->gadgetID;
+			Class     = curMsg->msgClass;
+			code      = curMsg->code;
+			Qualifier = curMsg->qualifier;
+			curPos.x  = curMsg->mouseX;
+			curPos.y  = curMsg->mouseY;
+			GadID     = curMsg->gadgetID;
 
-			FollowingCrumbs = false;
+			_followingCrumbs = false;
 
 from_crumbs:
 			DoBlack = false;
@@ -791,20 +777,20 @@ from_crumbs:
 					curPos = _event->getMousePos();
 				} else if (getPlatform() == Common::kPlatformWindows &&
 						(code == 'b' || code == 'B')) {  /* Start bread crumbs */
-					BreadCrumbs[0].RoomNum = 0;
-					NumCrumbs = 0;
-					DroppingCrumbs = true;
+					_breadCrumbs[0]._roomNum = 0;
+					_numCrumbs = 0;
+					_droppingCrumbs = true;
 					mayShowCrumbIndicator();
 					WSDL_UpdateScreen();
 				} else if (code == 'f' || code == 'F' ||
 				         code == 'r' || code == 'R') {  /* Follow bread crumbs */
-					if (DroppingCrumbs) {
-						if (NumCrumbs > 0) {
-							FollowingCrumbs = true;
-							FollowCrumbsFast = (code == 'r' || code == 'R');
-							IsCrumbTurning = false;
-							IsCrumbWaiting = false;
-							getTime(&CrumbSecs, &CrumbMicros);
+					if (_droppingCrumbs) {
+						if (_numCrumbs > 0) {
+							_followingCrumbs = true;
+							_followCrumbsFast = (code == 'r' || code == 'R');
+							_isCrumbTurning = false;
+							_isCrumbWaiting = false;
+							getTime(&_crumbSecs, &_crumbMicros);
 
 							if (Alternate) {
 								eatMessages();
@@ -819,8 +805,8 @@ from_crumbs:
 								WSDL_UpdateScreen();
 							}
 						} else {
-							BreadCrumbs[0].RoomNum = 0;
-							DroppingCrumbs = false;
+							_breadCrumbs[0]._roomNum = 0;
+							_droppingCrumbs = false;
 
 							// Need to hide indicator!!!!
 							mayShowCrumbIndicatorOff();
@@ -837,20 +823,20 @@ from_crumbs:
 
 					while (1) {
 						_music->updateMusic();  /* Make sure we check the music at least after every message */
-						Msg = getMsg();
+						curMsg = getMsg();
 
-						if (Msg == NULL) { /* Does music load and next animation frame when you've run out of messages */
+						if (curMsg == NULL) { /* Does music load and next animation frame when you've run out of messages */
 							_music->updateMusic();
 							diffNextFrame();
 						} else {
-							if (Msg->msgClass == RAWKEY) {
-								if ((Msg->code == 'Y') || (Msg->code == 'y') || (Msg->code == 'Q') || (Msg->code == 'q')) {
+							if (curMsg->msgClass == RAWKEY) {
+								if ((curMsg->code == 'Y') || (curMsg->code == 'y') || (curMsg->code == 'Q') || (curMsg->code == 'q')) {
 									doit = true;
 									break;
-								} else if (Msg->code < 128) {
+								} else if (curMsg->code < 128) {
 									break;
 								}
-							} else if (Msg->msgClass == MOUSEBUTTONS) {
+							} else if (curMsg->msgClass == MOUSEBUTTONS) {
 								break;
 							}
 						}
@@ -985,43 +971,43 @@ from_crumbs:
 							}
 						}
 
-						if (FollowingCrumbs) {
-							if (IsCrumbTurning) {
+						if (_followingCrumbs) {
+							if (_isCrumbTurning) {
 								if (Direction == OldDirection) {
-									FollowingCrumbs = false;
+									_followingCrumbs = false;
 								}
 							} else {
 								if (_roomNum == OldRoomNum) { // didn't get there?
-									FollowingCrumbs = false;
+									_followingCrumbs = false;
 								}
 							}
-						} else if (DroppingCrumbs && OldRoomNum != _roomNum) {
+						} else if (_droppingCrumbs && OldRoomNum != _roomNum) {
 							// If in surreal maze, turn off DroppingCrumbs.
 							// Note: These numbers were generated by parsing the
 							// "Maps" file, which is why they are hard-coded. Bleh!
 							if (_roomNum >= 245 && _roomNum <= 280) {
-								FollowingCrumbs = false;
-								DroppingCrumbs = false;
-								NumCrumbs = 0;
-								BreadCrumbs[0].RoomNum = 0;
+								_followingCrumbs = false;
+								_droppingCrumbs = false;
+								_numCrumbs = 0;
+								_breadCrumbs[0]._roomNum = 0;
 							} else {
 								bool intersect = false;
-								for (int idx = 0; idx < NumCrumbs; idx++) {
-									if (BreadCrumbs[idx].RoomNum == _roomNum) {
-										NumCrumbs = idx + 1;
-										BreadCrumbs[NumCrumbs].RoomNum = 0;
+								for (int idx = 0; idx < _numCrumbs; idx++) {
+									if (_breadCrumbs[idx]._roomNum == _roomNum) {
+										_numCrumbs = idx + 1;
+										_breadCrumbs[_numCrumbs]._roomNum = 0;
 										intersect = true;
 									}
 								}
 
 								if (!intersect) {
-									if (NumCrumbs == MAX_CRUMBS) {
-										NumCrumbs = MAX_CRUMBS - 1;
-										memcpy(&BreadCrumbs[0], &BreadCrumbs[1], NumCrumbs * sizeof BreadCrumbs[0]);
+									if (_numCrumbs == MAX_CRUMBS) {
+										_numCrumbs = MAX_CRUMBS - 1;
+										memcpy(&_breadCrumbs[0], &_breadCrumbs[1], _numCrumbs * sizeof _breadCrumbs[0]);
 									}
 
-									BreadCrumbs[NumCrumbs].RoomNum = _roomNum;
-									BreadCrumbs[NumCrumbs++].Direction = Direction;
+									_breadCrumbs[_numCrumbs]._roomNum = _roomNum;
+									_breadCrumbs[_numCrumbs++]._direction = Direction;
 								}
 							}
 						}
@@ -1119,19 +1105,19 @@ from_crumbs:
 
 					WSDL_UpdateScreen();
 				} else if (GadID == 5) { /* bread crumbs */
-					BreadCrumbs[0].RoomNum = 0;
-					NumCrumbs = 0;
-					DroppingCrumbs = true;
+					_breadCrumbs[0]._roomNum = 0;
+					_numCrumbs = 0;
+					_droppingCrumbs = true;
 					mayShowCrumbIndicator();
 					WSDL_UpdateScreen();
 				} else if (GadID == 6) { /* follow crumbs */
-					if (DroppingCrumbs) {
-						if (NumCrumbs > 0) {
-							FollowingCrumbs = true;
-							FollowCrumbsFast = false;
-							IsCrumbTurning = false;
-							IsCrumbWaiting = false;
-							getTime(&CrumbSecs, &CrumbMicros);
+					if (_droppingCrumbs) {
+						if (_numCrumbs > 0) {
+							_followingCrumbs = true;
+							_followCrumbsFast = false;
+							_isCrumbTurning = false;
+							_isCrumbWaiting = false;
+							getTime(&_crumbSecs, &_crumbMicros);
 
 							eatMessages();
 							Alternate = false;
@@ -1144,8 +1130,8 @@ from_crumbs:
 							drawRoomMessage(CurInv, CPtr);
 							WSDL_UpdateScreen();
 						} else {
-							BreadCrumbs[0].RoomNum = 0;
-							DroppingCrumbs = false;
+							_breadCrumbs[0]._roomNum = 0;
+							_droppingCrumbs = false;
 
 							// Need to hide indicator!!!!
 							mayShowCrumbIndicatorOff();
@@ -1297,7 +1283,7 @@ from_crumbs:
 }
 
 void LabEngine::go() {
-	bool dointro = true;
+	bool doIntro = true;
 
 	_isHiRes = ((getFeatures() & GF_LOWRES) == 0);
 
@@ -1325,14 +1311,14 @@ void LabEngine::go() {
 
 	mem = mem && initRoomBuffer();
 
-	if (!dointro)
+	if (!doIntro)
 		_music->initMusic();
 
 	MsgFont = _resource->getFont("P:AvanteG.12");
 
 	_event->mouseHide();
 
-	if (dointro && mem) {
+	if (doIntro && mem) {
 		Intro intro;
 		intro.introSequence();
 	} else
@@ -1375,7 +1361,7 @@ void LabEngine::go() {
 /*****************************************************************************/
 /* New code to allow quick(er) return navigation in game.                    */
 /*****************************************************************************/
-int followCrumbs() {
+int LabEngine::followCrumbs() {
 	// NORTH, SOUTH, EAST, WEST
 	static int movement[4][4] = {
 		{ VKEY_UPARROW, VKEY_RTARROW, VKEY_RTARROW, VKEY_LTARROW },
@@ -1384,74 +1370,71 @@ int followCrumbs() {
 		{ VKEY_RTARROW, VKEY_LTARROW, VKEY_RTARROW, VKEY_UPARROW }
 	};
 
-	if (IsCrumbWaiting) {
+	if (_isCrumbWaiting) {
 		uint32 Secs;
 		uint32 Micros;
 
-		g_lab->timeDiff(CrumbSecs, CrumbMicros, &Secs, &Micros);
+		g_lab->timeDiff(_crumbSecs, _crumbMicros, &Secs, &Micros);
 
 		if (Secs != 0 || Micros != 0)
 			return 0;
 
-		IsCrumbWaiting = false;
+		_isCrumbWaiting = false;
 	}
 
-	if (!IsCrumbTurning)
-		BreadCrumbs[NumCrumbs--].RoomNum = 0;
+	if (!_isCrumbTurning)
+		_breadCrumbs[_numCrumbs--]._roomNum = 0;
 
 	// Is the current crumb this room? If not, logic error.
-	if (g_lab->_roomNum != BreadCrumbs[NumCrumbs].RoomNum) {
-		NumCrumbs = 0;
-		BreadCrumbs[0].RoomNum = 0;
-		DroppingCrumbs = false;
-		FollowingCrumbs = false;
+	if (g_lab->_roomNum != _breadCrumbs[_numCrumbs]._roomNum) {
+		_numCrumbs = 0;
+		_breadCrumbs[0]._roomNum = 0;
+		_droppingCrumbs = false;
+		_followingCrumbs = false;
 		return 0;
 	}
 
-	int ExitDir;
+	int exitDir;
 
 	// which direction is last crumb
-	if (BreadCrumbs[NumCrumbs].Direction == EAST)
-		ExitDir = WEST;
-	else if (BreadCrumbs[NumCrumbs].Direction == WEST)
-		ExitDir = EAST;
-	else if (BreadCrumbs[NumCrumbs].Direction == NORTH)
-		ExitDir = SOUTH;
+	if (_breadCrumbs[_numCrumbs]._direction == EAST)
+		exitDir = WEST;
+	else if (_breadCrumbs[_numCrumbs]._direction == WEST)
+		exitDir = EAST;
+	else if (_breadCrumbs[_numCrumbs]._direction == NORTH)
+		exitDir = SOUTH;
 	else
-		ExitDir = NORTH;
+		exitDir = NORTH;
 
-	int MoveDir = movement[Direction][ExitDir];
+	int moveDir = movement[Direction][exitDir];
 
-	if (NumCrumbs == 0) {
-		IsCrumbTurning = false;
-		BreadCrumbs[0].RoomNum = 0;
-		DroppingCrumbs = false;
-		FollowingCrumbs = false;
+	if (_numCrumbs == 0) {
+		_isCrumbTurning = false;
+		_breadCrumbs[0]._roomNum = 0;
+		_droppingCrumbs = false;
+		_followingCrumbs = false;
 	} else {
-		int theDelay = (FollowCrumbsFast ? ONESECOND / 4 : ONESECOND);
+		int theDelay = (_followCrumbsFast ? ONESECOND / 4 : ONESECOND);
 
-		IsCrumbTurning = (MoveDir != VKEY_UPARROW);
-		IsCrumbWaiting = true;
+		_isCrumbTurning = (moveDir != VKEY_UPARROW);
+		_isCrumbWaiting = true;
 
-		g_lab->addCurTime(theDelay / ONESECOND, theDelay % ONESECOND, &CrumbSecs, &CrumbMicros);
+		g_lab->addCurTime(theDelay / ONESECOND, theDelay % ONESECOND, &_crumbSecs, &_crumbMicros);
 	}
 
-	return MoveDir;
+	return moveDir;
 }
 
-byte dropCrumbs[] = { 0x00 };
-byte dropCrumbsOff[] = { 0x00 };
-
-Image DropCrumbsImage = { 24, 24, dropCrumbs };
-Image DropCrumbsOffImage = { 24, 24, dropCrumbsOff };
-
 void LabEngine::mayShowCrumbIndicator() {
 	if (getPlatform() != Common::kPlatformWindows)
 		return;
 
-	if (DroppingCrumbs && MainDisplay) {
+	if (_droppingCrumbs && MainDisplay) {
+		static byte dropCrumbs[] = { 0x00 };
+		static Image dropCrumbsImage = { 24, 24, dropCrumbs };
+
 		_event->mouseHide();
-		drawMaskImage(&DropCrumbsImage, 612, 4);
+		drawMaskImage(&dropCrumbsImage, 612, 4);
 		_event->mouseShow();
 	}
 }
@@ -1461,8 +1444,11 @@ void LabEngine::mayShowCrumbIndicatorOff() {
 		return;
 
 	if (MainDisplay) {
+		static byte dropCrumbsOff[] = { 0x00 };
+		static Image dropCrumbsOffImage = { 24, 24, dropCrumbsOff };
+
 		_event->mouseHide();
-		drawMaskImage(&DropCrumbsOffImage, 612, 4);
+		drawMaskImage(&dropCrumbsOffImage, 612, 4);
 		_event->mouseShow();
 	}
 }
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 6d7ed00..b42e486 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -74,12 +74,24 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 
 	_isHiRes = false;
 	_roomNum = -1;
+	for (int i = 0; i < MAX_CRUMBS; i++) {
+		_breadCrumbs[i]._roomNum = 0;
+		_breadCrumbs[i]._direction = NORTH;
+	}
+
+	_numCrumbs = 0;
+	_droppingCrumbs = false;
+	_followingCrumbs = false;
+	_followCrumbsFast = false;
+	_isCrumbTurning = false;
+	_isCrumbWaiting = false;
+	_crumbSecs = 0;
+	_crumbMicros = 0;
 
 	_event = nullptr;
 	_resource = nullptr;
 	_music = nullptr;
 
-
 	//const Common::FSNode gameDataDir(ConfMan.get("path"));
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game/pict");
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 6749a74..b2ec4b1 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -108,6 +108,17 @@ public:
 	byte *_currentDsplayBuffer;
 	Common::Point _mousePos;
 
+	CrumbData _breadCrumbs[MAX_CRUMBS];
+	uint16 _numCrumbs;
+	bool _droppingCrumbs;
+	bool _followingCrumbs;
+	bool _followCrumbsFast;
+	bool _isCrumbTurning;
+	uint32 _crumbSecs, _crumbMicros;
+	bool _isCrumbWaiting;
+	byte *_tempScrollData;
+	bool _isHiRes;
+
 private:
 	byte *_displayBuffer;
 
@@ -117,9 +128,6 @@ private:
 	uint16 _keyBuf[64];
 	uint16 _nextKeyOut;
 	bool _mouseAtEdge;
-public:
-	byte *_tempScrollData;
-	bool _isHiRes;
 
 private:
 	bool createScreen(bool HiRes);
@@ -173,6 +181,7 @@ public:
 	void eatMessages();
 	void drawStaticMessage(byte index);
 	void drawDirection(CloseDataPtr LCPtr);
+	int followCrumbs();
 
 private:
 	void quickWaitTOF();
diff --git a/engines/lab/parsetypes.h b/engines/lab/parsetypes.h
index e482775..2585ae5 100644
--- a/engines/lab/parsetypes.h
+++ b/engines/lab/parsetypes.h
@@ -195,8 +195,8 @@ struct MapData {
 #endif
 
 struct CrumbData {
-	uint16 RoomNum;
-	uint16 Direction;
+	uint16 _roomNum;
+	uint16 _direction;
 };
 
 #define MAX_CRUMBS          128
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index b8a59a5..b01ac27 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -54,10 +54,6 @@ namespace Lab {
 /* Lab: Labyrinth specific */
 extern byte combination[6];
 extern uint16 CurTile[4] [4];
-extern CrumbData BreadCrumbs[MAX_CRUMBS];
-extern uint16 NumCrumbs;
-extern bool DroppingCrumbs;
-extern bool FollowingCrumbs;
 extern char *getPictName(CloseDataPtr *LCPtr);
 
 void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName) {
@@ -168,9 +164,9 @@ bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc)
 			file->writeUint16LE(CurTile[i][j]);
 
 	// Breadcrumbs
-	for (i = 0; i < sizeof(BreadCrumbs); i++) {
-		file->writeUint16LE(BreadCrumbs[i].RoomNum);
-		file->writeUint16LE(BreadCrumbs[i].Direction);
+	for (i = 0; i < sizeof(g_lab->_breadCrumbs); i++) {
+		file->writeUint16LE(g_lab->_breadCrumbs[i]._roomNum);
+		file->writeUint16LE(g_lab->_breadCrumbs[i]._direction);
 	}
 
 	file->flush();
@@ -219,17 +215,17 @@ bool loadGame(uint16 *Direction, uint16 *Quarters, int slot) {
 
 	// Breadcrumbs
 	for (i = 0; i < 128; i++) {
-		BreadCrumbs[i].RoomNum = file->readUint16LE();
-		BreadCrumbs[i].Direction = file->readUint16LE();
+		g_lab->_breadCrumbs[i]._roomNum = file->readUint16LE();
+		g_lab->_breadCrumbs[i]._direction = file->readUint16LE();
 	}
 
-	DroppingCrumbs = (BreadCrumbs[0].RoomNum != 0);
-	FollowingCrumbs = false;
+	g_lab->_droppingCrumbs = (g_lab->_breadCrumbs[0]._roomNum != 0);
+	g_lab->_followingCrumbs = false;
 
 	for (i = 0; i < 128; i++) {
-		if (BreadCrumbs[i].RoomNum == 0)
+		if (g_lab->_breadCrumbs[i]._roomNum == 0)
 			break;
-		NumCrumbs = i;
+		g_lab->_numCrumbs = i;
 	}
 
 	delete file;


Commit: d45d46c2cb682937ae64373aeee9517ba2ca346d
    https://github.com/scummvm/scummvm/commit/d45d46c2cb682937ae64373aeee9517ba2ca346d
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:44+01:00

Commit Message:
LAB: Rename music source file

Changed paths:
  A engines/lab/music.cpp
  R engines/lab/labmusic.cpp
    engines/lab/module.mk



diff --git a/engines/lab/labmusic.cpp b/engines/lab/labmusic.cpp
deleted file mode 100644
index 1f99a68..0000000
--- a/engines/lab/labmusic.cpp
+++ /dev/null
@@ -1,358 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "audio/mixer.h"
-
-#include "lab/stddefines.h"
-#include "lab/labfun.h"
-#include "lab/mouse.h"
-#include "lab/music.h"
-#include "lab/lab.h"
-
-namespace Lab {
-
-#define MUSICBUFSIZE   (2 * 65536L)
-#define SAMPLESPEED    15000L
-
-#define CLOWNROOM           123
-#define DIMROOM              80
-
-Music::Music(LabEngine *vm) : _vm(vm) {
-	_file = 0;
-	_tFile = 0;
-	_musicPaused = false;
-
-	_tMusicOn = false;
-	_tLeftInFile = 0;
-
-	_leftinfile = 0;
-
-	_musicOn = false;
-	_winmusic = false;
-	_loopSoundEffect = false;
-	_queuingAudioStream = NULL;
-	_doNotFilestopSoundEffect = false;
-	_lastMusicRoom = 1;
-	_doReset = true;
-	_waitTillFinished = false;
-}
-
-/*****************************************************************************/
-/* Figures out which buffer is currently playing based on messages sent to   */
-/* it from the Audio device.                                                 */
-/*****************************************************************************/
-void Music::updateMusic() {
-	_vm->WSDL_ProcessInput(0);
-
-	_vm->_event->updateMouse();
-
-	if (_musicOn && getPlayingBufferCount() < MAXBUFFERS) {
-		// NOTE: We need to use malloc(), cause this will be freed with free()
-		// by the music code
-		byte *musicBuffer = (byte *)malloc(MUSICBUFSIZE);
-		fillbuffer(musicBuffer);
-
-		// Queue a music block, and start the music, if needed
-		bool startMusic = false;
-
-		if (!_queuingAudioStream) {
-			_queuingAudioStream = Audio::makeQueuingAudioStream(SAMPLESPEED, false);
-			startMusic = true;
-		}
-
-		byte soundFlags = Audio::FLAG_LITTLE_ENDIAN;
-		if (_vm->getPlatform() == Common::kPlatformWindows)
-			soundFlags |= Audio::FLAG_16BITS;
-		else
-			soundFlags |= Audio::FLAG_UNSIGNED;
-
-		_queuingAudioStream->queueBuffer(musicBuffer, MUSICBUFSIZE, DisposeAfterUse::YES, soundFlags);
-
-		if (startMusic)
-			_vm->_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _queuingAudioStream);
-	}
-}
-
-uint16 Music::getPlayingBufferCount() {
-	return (_queuingAudioStream) ? _queuingAudioStream->numQueuedStreams() : 0;
-}
-
-void Music::playSoundEffect(uint16 SampleSpeed, uint32 Length, void *Data) {
-	pauseBackMusic();
-	stopSoundEffect();
-
-	if (SampleSpeed < 4000)
-		SampleSpeed = 4000;
-
-	byte soundFlags = Audio::FLAG_LITTLE_ENDIAN;
-	if (_vm->getPlatform() == Common::kPlatformWindows)
-		soundFlags |= Audio::FLAG_16BITS;
-	else
-		soundFlags |= Audio::FLAG_UNSIGNED;
-
-	Audio::SeekableAudioStream *audioStream = Audio::makeRawStream((const byte *)Data, Length, SampleSpeed, soundFlags, DisposeAfterUse::NO);
-	uint loops = (_loopSoundEffect) ? 0 : 1;
-	Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, loops);
-	_vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, loopingAudioStream);
-}
-
-void Music::stopSoundEffect() {
-	if (isSoundEffectActive())
-		_vm->_mixer->stopHandle(_sfxHandle);
-}
-
-bool Music::isSoundEffectActive() const {
-	return _vm->_mixer->isSoundHandleActive(_sfxHandle);
-}
-
-void Music::fillbuffer(byte *musicBuffer) {
-	if (MUSICBUFSIZE < _leftinfile) {
-		_file->read(musicBuffer, MUSICBUFSIZE);
-		_leftinfile -= MUSICBUFSIZE;
-	} else {
-		_file->read(musicBuffer, _leftinfile);
-
-		memset((char *)musicBuffer + _leftinfile, 0, MUSICBUFSIZE - _leftinfile);
-
-		_file->seek(0);
-		_leftinfile = _file->size();
-	}
-}
-
-/*****************************************************************************/
-/* Starts up the music initially.                                            */
-/*****************************************************************************/
-void Music::startMusic(bool startatbegin) {
-	if (!_musicOn)
-		return;
-
-	stopSoundEffect();
-
-	if (startatbegin) {
-		_file->seek(0);
-		_leftinfile  = _file->size();
-	}
-
-	_musicOn = true;
-	updateMusic();
-}
-
-/*****************************************************************************/
-/* Initializes the music buffers.                                            */
-/*****************************************************************************/
-bool Music::initMusic() {
-	_musicOn = true;
-	_musicPaused = false;
-
-	const char *filename;
-
-	if (_winmusic)
-		filename = "Music:WinGame";
-	else
-		filename = "Music:BackGrou";
-
-	_file = openPartial(filename);
-
-	if (_file) {
-		startMusic(true);
-		return true;
-	}
-
-	_musicOn = false;
-	return false;
-}
-
-/*****************************************************************************/
-/* Frees up the music buffers and closes the file.                           */
-/*****************************************************************************/
-void Music::freeMusic() {
-	_musicOn = false;
-
-	_vm->_mixer->stopHandle(_musicHandle);
-	_queuingAudioStream = NULL;
-
-	_vm->_mixer->stopHandle(_sfxHandle);
-
-	delete _file;
-	_file = NULL;
-}
-
-/*****************************************************************************/
-/* Pauses the background music.                                              */
-/*****************************************************************************/
-void Music::pauseBackMusic() {
-	if (!_musicPaused && _musicOn) {
-		updateMusic();
-		_musicOn = false;
-		stopSoundEffect();
-
-		_vm->_mixer->pauseHandle(_musicHandle, true);
-
-		_musicPaused = true;
-	}
-}
-
-/*****************************************************************************/
-/* Resumes the paused background music.                                      */
-/*****************************************************************************/
-void Music::resumeBackMusic() {
-	if (_musicPaused) {
-		stopSoundEffect();
-		_musicOn = true;
-
-		_vm->_mixer->pauseHandle(_musicHandle, false);
-
-		updateMusic();
-		_musicPaused = false;
-	}
-}
-
-/*****************************************************************************/
-/* Turns the music on and off.                                               */
-/*****************************************************************************/
-void Music::setMusic(bool on) {
-	stopSoundEffect();
-
-	if (on && !_musicOn) {
-		_musicOn = true;
-		startMusic(true);
-	} else if (!on && _musicOn) {
-		_musicOn = false;
-		updateMusic();
-	} else
-		_musicOn = on;
-}
-
-/******************************************************************************/
-/* Checks the music that should be playing in a particular room.              */
-/******************************************************************************/
-void Music::checkRoomMusic() {
-	if ((_lastMusicRoom == _vm->_roomNum) || !_musicOn)
-		return;
-
-	if (_vm->_roomNum == CLOWNROOM)
-		changeMusic("Music:Laugh");
-	else if (_vm->_roomNum == DIMROOM)
-		changeMusic("Music:Rm81");
-	else if (_doReset)
-		resetMusic();
-
-	_lastMusicRoom = _vm->_roomNum;
-}
-
-/*****************************************************************************/
-/* Changes the background music to something else.                           */
-/*****************************************************************************/
-void Music::changeMusic(const char *newmusic) {
-	if (!_tFile) {
-		_tFile = _file;
-		_tMusicOn = _musicOn;
-		_tLeftInFile = _leftinfile + 65536L;
-
-		if (_tLeftInFile > (uint32)_tFile->size())
-			_tLeftInFile = _leftinfile;
-	}
-
-	_file = openPartial(newmusic);
-
-	if (_file) {
-		_musicOn = true;   /* turn it off */
-		setMusic(false);
-		_musicOn = false;  /* turn it back on */
-		setMusic(true);
-	} else {
-		_file  = _tFile;
-		_tFile = 0;
-	}
-}
-
-/*****************************************************************************/
-/* Changes the background music to the original piece playing.               */
-/*****************************************************************************/
-void Music::resetMusic() {
-	if (!_tFile)
-		return;
-
-	if (_file->isOpen())
-		_file->close();
-
-	_file      = _tFile;
-	_leftinfile = _tLeftInFile;
-
-	_file->seek(_file->size() - _leftinfile);
-
-	_musicOn = true;
-	setMusic(false);
-	updateMusic();
-
-	if (!_tMusicOn) {
-		_tFile = 0;
-		return;
-	}
-
-	_musicOn = _tMusicOn;
-	startMusic(false);
-
-	_tFile = 0;
-}
-
-byte **Music::newOpen(const char *name) {
-	uint32 unused;
-	return newOpen(name, unused);
-}
-
-/*****************************************************************************/
-/* Checks whether or note enough memory in music buffer before loading any   */
-/* files.  Fills it if not.  Does not take into account the current buffer   */
-/* playing; a built in fudge factor.  We've also got another FUDGEFACTOR     */
-/* defined above in case things go wrong.                                    */
-/*                                                                           */
-/* Here, the seconds are multipled by 10.                                    */
-/*****************************************************************************/
-byte **Music::newOpen(const char *name, uint32 &size) {
-	byte **file;
-
-	if (!name || !strcmp(name, "") || !strcmp(name, " "))
-		return NULL;
-
-	if ((file = isBuffered(name)))
-		return file;
-
-	updateMusic();
-
-	if (!_doNotFilestopSoundEffect)
-		stopSoundEffect();
-
-	file = openFile(name, size);
-	updateMusic();
-	return file;
-}
-
-} // End of namespace Lab
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index f36871c..c9682f2 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -9,11 +9,11 @@ MODULE_OBJS := \
 	intro.o \
 	lab.o \
 	labfile.o \
-	labmusic.o \
 	labsets.o \
 	machine.o \
 	map.o \
 	mouse.o \
+	music.o \
 	processroom.o \
 	readdiff.o \
 	resource.o \
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
new file mode 100644
index 0000000..1f99a68
--- /dev/null
+++ b/engines/lab/music.cpp
@@ -0,0 +1,358 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "audio/mixer.h"
+
+#include "lab/stddefines.h"
+#include "lab/labfun.h"
+#include "lab/mouse.h"
+#include "lab/music.h"
+#include "lab/lab.h"
+
+namespace Lab {
+
+#define MUSICBUFSIZE   (2 * 65536L)
+#define SAMPLESPEED    15000L
+
+#define CLOWNROOM           123
+#define DIMROOM              80
+
+Music::Music(LabEngine *vm) : _vm(vm) {
+	_file = 0;
+	_tFile = 0;
+	_musicPaused = false;
+
+	_tMusicOn = false;
+	_tLeftInFile = 0;
+
+	_leftinfile = 0;
+
+	_musicOn = false;
+	_winmusic = false;
+	_loopSoundEffect = false;
+	_queuingAudioStream = NULL;
+	_doNotFilestopSoundEffect = false;
+	_lastMusicRoom = 1;
+	_doReset = true;
+	_waitTillFinished = false;
+}
+
+/*****************************************************************************/
+/* Figures out which buffer is currently playing based on messages sent to   */
+/* it from the Audio device.                                                 */
+/*****************************************************************************/
+void Music::updateMusic() {
+	_vm->WSDL_ProcessInput(0);
+
+	_vm->_event->updateMouse();
+
+	if (_musicOn && getPlayingBufferCount() < MAXBUFFERS) {
+		// NOTE: We need to use malloc(), cause this will be freed with free()
+		// by the music code
+		byte *musicBuffer = (byte *)malloc(MUSICBUFSIZE);
+		fillbuffer(musicBuffer);
+
+		// Queue a music block, and start the music, if needed
+		bool startMusic = false;
+
+		if (!_queuingAudioStream) {
+			_queuingAudioStream = Audio::makeQueuingAudioStream(SAMPLESPEED, false);
+			startMusic = true;
+		}
+
+		byte soundFlags = Audio::FLAG_LITTLE_ENDIAN;
+		if (_vm->getPlatform() == Common::kPlatformWindows)
+			soundFlags |= Audio::FLAG_16BITS;
+		else
+			soundFlags |= Audio::FLAG_UNSIGNED;
+
+		_queuingAudioStream->queueBuffer(musicBuffer, MUSICBUFSIZE, DisposeAfterUse::YES, soundFlags);
+
+		if (startMusic)
+			_vm->_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _queuingAudioStream);
+	}
+}
+
+uint16 Music::getPlayingBufferCount() {
+	return (_queuingAudioStream) ? _queuingAudioStream->numQueuedStreams() : 0;
+}
+
+void Music::playSoundEffect(uint16 SampleSpeed, uint32 Length, void *Data) {
+	pauseBackMusic();
+	stopSoundEffect();
+
+	if (SampleSpeed < 4000)
+		SampleSpeed = 4000;
+
+	byte soundFlags = Audio::FLAG_LITTLE_ENDIAN;
+	if (_vm->getPlatform() == Common::kPlatformWindows)
+		soundFlags |= Audio::FLAG_16BITS;
+	else
+		soundFlags |= Audio::FLAG_UNSIGNED;
+
+	Audio::SeekableAudioStream *audioStream = Audio::makeRawStream((const byte *)Data, Length, SampleSpeed, soundFlags, DisposeAfterUse::NO);
+	uint loops = (_loopSoundEffect) ? 0 : 1;
+	Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, loops);
+	_vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, loopingAudioStream);
+}
+
+void Music::stopSoundEffect() {
+	if (isSoundEffectActive())
+		_vm->_mixer->stopHandle(_sfxHandle);
+}
+
+bool Music::isSoundEffectActive() const {
+	return _vm->_mixer->isSoundHandleActive(_sfxHandle);
+}
+
+void Music::fillbuffer(byte *musicBuffer) {
+	if (MUSICBUFSIZE < _leftinfile) {
+		_file->read(musicBuffer, MUSICBUFSIZE);
+		_leftinfile -= MUSICBUFSIZE;
+	} else {
+		_file->read(musicBuffer, _leftinfile);
+
+		memset((char *)musicBuffer + _leftinfile, 0, MUSICBUFSIZE - _leftinfile);
+
+		_file->seek(0);
+		_leftinfile = _file->size();
+	}
+}
+
+/*****************************************************************************/
+/* Starts up the music initially.                                            */
+/*****************************************************************************/
+void Music::startMusic(bool startatbegin) {
+	if (!_musicOn)
+		return;
+
+	stopSoundEffect();
+
+	if (startatbegin) {
+		_file->seek(0);
+		_leftinfile  = _file->size();
+	}
+
+	_musicOn = true;
+	updateMusic();
+}
+
+/*****************************************************************************/
+/* Initializes the music buffers.                                            */
+/*****************************************************************************/
+bool Music::initMusic() {
+	_musicOn = true;
+	_musicPaused = false;
+
+	const char *filename;
+
+	if (_winmusic)
+		filename = "Music:WinGame";
+	else
+		filename = "Music:BackGrou";
+
+	_file = openPartial(filename);
+
+	if (_file) {
+		startMusic(true);
+		return true;
+	}
+
+	_musicOn = false;
+	return false;
+}
+
+/*****************************************************************************/
+/* Frees up the music buffers and closes the file.                           */
+/*****************************************************************************/
+void Music::freeMusic() {
+	_musicOn = false;
+
+	_vm->_mixer->stopHandle(_musicHandle);
+	_queuingAudioStream = NULL;
+
+	_vm->_mixer->stopHandle(_sfxHandle);
+
+	delete _file;
+	_file = NULL;
+}
+
+/*****************************************************************************/
+/* Pauses the background music.                                              */
+/*****************************************************************************/
+void Music::pauseBackMusic() {
+	if (!_musicPaused && _musicOn) {
+		updateMusic();
+		_musicOn = false;
+		stopSoundEffect();
+
+		_vm->_mixer->pauseHandle(_musicHandle, true);
+
+		_musicPaused = true;
+	}
+}
+
+/*****************************************************************************/
+/* Resumes the paused background music.                                      */
+/*****************************************************************************/
+void Music::resumeBackMusic() {
+	if (_musicPaused) {
+		stopSoundEffect();
+		_musicOn = true;
+
+		_vm->_mixer->pauseHandle(_musicHandle, false);
+
+		updateMusic();
+		_musicPaused = false;
+	}
+}
+
+/*****************************************************************************/
+/* Turns the music on and off.                                               */
+/*****************************************************************************/
+void Music::setMusic(bool on) {
+	stopSoundEffect();
+
+	if (on && !_musicOn) {
+		_musicOn = true;
+		startMusic(true);
+	} else if (!on && _musicOn) {
+		_musicOn = false;
+		updateMusic();
+	} else
+		_musicOn = on;
+}
+
+/******************************************************************************/
+/* Checks the music that should be playing in a particular room.              */
+/******************************************************************************/
+void Music::checkRoomMusic() {
+	if ((_lastMusicRoom == _vm->_roomNum) || !_musicOn)
+		return;
+
+	if (_vm->_roomNum == CLOWNROOM)
+		changeMusic("Music:Laugh");
+	else if (_vm->_roomNum == DIMROOM)
+		changeMusic("Music:Rm81");
+	else if (_doReset)
+		resetMusic();
+
+	_lastMusicRoom = _vm->_roomNum;
+}
+
+/*****************************************************************************/
+/* Changes the background music to something else.                           */
+/*****************************************************************************/
+void Music::changeMusic(const char *newmusic) {
+	if (!_tFile) {
+		_tFile = _file;
+		_tMusicOn = _musicOn;
+		_tLeftInFile = _leftinfile + 65536L;
+
+		if (_tLeftInFile > (uint32)_tFile->size())
+			_tLeftInFile = _leftinfile;
+	}
+
+	_file = openPartial(newmusic);
+
+	if (_file) {
+		_musicOn = true;   /* turn it off */
+		setMusic(false);
+		_musicOn = false;  /* turn it back on */
+		setMusic(true);
+	} else {
+		_file  = _tFile;
+		_tFile = 0;
+	}
+}
+
+/*****************************************************************************/
+/* Changes the background music to the original piece playing.               */
+/*****************************************************************************/
+void Music::resetMusic() {
+	if (!_tFile)
+		return;
+
+	if (_file->isOpen())
+		_file->close();
+
+	_file      = _tFile;
+	_leftinfile = _tLeftInFile;
+
+	_file->seek(_file->size() - _leftinfile);
+
+	_musicOn = true;
+	setMusic(false);
+	updateMusic();
+
+	if (!_tMusicOn) {
+		_tFile = 0;
+		return;
+	}
+
+	_musicOn = _tMusicOn;
+	startMusic(false);
+
+	_tFile = 0;
+}
+
+byte **Music::newOpen(const char *name) {
+	uint32 unused;
+	return newOpen(name, unused);
+}
+
+/*****************************************************************************/
+/* Checks whether or note enough memory in music buffer before loading any   */
+/* files.  Fills it if not.  Does not take into account the current buffer   */
+/* playing; a built in fudge factor.  We've also got another FUDGEFACTOR     */
+/* defined above in case things go wrong.                                    */
+/*                                                                           */
+/* Here, the seconds are multipled by 10.                                    */
+/*****************************************************************************/
+byte **Music::newOpen(const char *name, uint32 &size) {
+	byte **file;
+
+	if (!name || !strcmp(name, "") || !strcmp(name, " "))
+		return NULL;
+
+	if ((file = isBuffered(name)))
+		return file;
+
+	updateMusic();
+
+	if (!_doNotFilestopSoundEffect)
+		stopSoundEffect();
+
+	file = openFile(name, size);
+	updateMusic();
+	return file;
+}
+
+} // End of namespace Lab


Commit: 4a90aba77af7de91f03dc51a7180637eb843ca95
    https://github.com/scummvm/scummvm/commit/4a90aba77af7de91f03dc51a7180637eb843ca95
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:44+01:00

Commit Message:
LAB: Get rid of a goto

Changed paths:
    engines/lab/engine.cpp
    engines/lab/lab.h



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 37a8977..7d67241 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -618,17 +618,10 @@ void LabEngine::decIncInv(uint16 *CurInv, bool dec) {
 /* The main game loop                                                         */
 /******************************************************************************/
 void LabEngine::mainGameLoop() {
-	uint32 Class;
+	uint16 actionMode = 4;
+	uint16 curInv = MAPNUM;
 
-	uint16 Qualifier, ActionMode = 4;
-	uint16 CurInv = MAPNUM, LastInv = MAPNUM, Old;
-
-	bool ForceDraw = false, doit, GotMessage = true;
-
-	uint16 OldRoomNum, OldDirection = 0, GadID = 0, NewDir;
-
-	CloseDataPtr OldCPtr, TempCPtr, HCPtr = NULL;
-	ViewData *VPtr;
+	bool forceDraw = false, GotMessage = true;
 
 	VGASetPal(initcolors, 8);
 
@@ -650,11 +643,10 @@ void LabEngine::mainGameLoop() {
 	LongWinInFront = false;
 	drawPanel();
 
-	perFlipGadget(ActionMode);
+	perFlipGadget(actionMode);
 
 	/* Set up initial picture. */
 
-	uint16 code = 0;
 	while (1) {
 		WSDL_ProcessInput(1);
 
@@ -680,7 +672,7 @@ void LabEngine::mainGameLoop() {
 
 			if (noupdatediff) {
 				_roomsFound->inclElement(_roomNum); /* Potentially entered another room */
-				ForceDraw = (strcmp(Test, CurFileName) != 0) || ForceDraw;
+				forceDraw = (strcmp(Test, CurFileName) != 0) || forceDraw;
 
 				noupdatediff = false;
 				CurFileName = Test;
@@ -703,8 +695,8 @@ void LabEngine::mainGameLoop() {
 				} else
 					readPict(CurFileName, false);
 
-				drawRoomMessage(CurInv, CPtr);
-				ForceDraw = false;
+				drawRoomMessage(curInv, CPtr);
+				forceDraw = false;
 
 				mayShowCrumbIndicator();
 				WSDL_UpdateScreen();
@@ -713,9 +705,9 @@ void LabEngine::mainGameLoop() {
 					eatMessages();
 			}
 
-			if (ForceDraw) {
-				drawRoomMessage(CurInv, CPtr);
-				ForceDraw = false;
+			if (forceDraw) {
+				drawRoomMessage(curInv, CPtr);
+				forceDraw = false;
 				WSDL_UpdateScreen();
 			}
 		}
@@ -724,7 +716,6 @@ void LabEngine::mainGameLoop() {
 		interfaceOn();
 		IntuiMessage *curMsg = getMsg();
 
-		Common::Point curPos;
 		if (curMsg == NULL) { /* Does music load and next animation frame when you've run out of messages */
 			GotMessage = false;
 			_music->checkRoomMusic();
@@ -735,21 +726,19 @@ void LabEngine::mainGameLoop() {
 				int result = followCrumbs();
 
 				if (result != 0) {
-					curPos = WSDL_GetMousePos();
-					Class     = GADGETUP;
-					Qualifier = 0;
-
+					uint16 code = 0;
 					if (result == VKEY_UPARROW)
-						code = GadID = 7;
+						code = 7;
 					else if (result == VKEY_LTARROW)
-						code = GadID = 6;
+						code = 6;
 					else if (result == VKEY_RTARROW)
-						code = GadID = 8;
+						code = 8;
 
 					GotMessage = true;
 					mayShowCrumbIndicator();
 					WSDL_UpdateScreen();
-					goto from_crumbs;
+					if (!from_crumbs(GADGETUP, code, 0, WSDL_GetMousePos(), curInv, curMsg, forceDraw, code, actionMode))
+						break;
 				}
 			}
 
@@ -758,528 +747,540 @@ void LabEngine::mainGameLoop() {
 		} else {
 			GotMessage = true;
 
-			Class     = curMsg->msgClass;
-			code      = curMsg->code;
-			Qualifier = curMsg->qualifier;
+			Common::Point curPos;
 			curPos.x  = curMsg->mouseX;
 			curPos.y  = curMsg->mouseY;
-			GadID     = curMsg->gadgetID;
 
 			_followingCrumbs = false;
+			if (!from_crumbs(curMsg->msgClass, curMsg->code, curMsg->qualifier, curPos, curInv, curMsg, forceDraw, curMsg->gadgetID, actionMode))
+				break;
+		}
+	}
 
-from_crumbs:
-			DoBlack = false;
+	delete _conditions;
+	delete _roomsFound;
 
-			if ((Class == RAWKEY) && (!LongWinInFront)) {
-				if (code == 13) { /* The return key */
-					Class     = MOUSEBUTTONS;
-					Qualifier = IEQUALIFIER_LEFTBUTTON;
-					curPos = _event->getMousePos();
-				} else if (getPlatform() == Common::kPlatformWindows &&
-						(code == 'b' || code == 'B')) {  /* Start bread crumbs */
-					_breadCrumbs[0]._roomNum = 0;
-					_numCrumbs = 0;
-					_droppingCrumbs = true;
-					mayShowCrumbIndicator();
-					WSDL_UpdateScreen();
-				} else if (code == 'f' || code == 'F' ||
-				         code == 'r' || code == 'R') {  /* Follow bread crumbs */
-					if (_droppingCrumbs) {
-						if (_numCrumbs > 0) {
-							_followingCrumbs = true;
-							_followCrumbsFast = (code == 'r' || code == 'R');
-							_isCrumbTurning = false;
-							_isCrumbWaiting = false;
-							getTime(&_crumbSecs, &_crumbMicros);
-
-							if (Alternate) {
-								eatMessages();
-								Alternate = false;
-								DoBlack = true;
-								DoNotDrawMessage = false;
-
-								MainDisplay = true;
-								interfaceOn(); /* Sets the correct gadget list */
-								drawPanel();
-								drawRoomMessage(CurInv, CPtr);
-								WSDL_UpdateScreen();
-							}
-						} else {
-							_breadCrumbs[0]._roomNum = 0;
-							_droppingCrumbs = false;
+	if (_rooms) {
+		free(_rooms);
+		_rooms = nullptr;
+	}
 
-							// Need to hide indicator!!!!
-							mayShowCrumbIndicatorOff();
-							WSDL_UpdateScreen();
-						}
-					}
-				} else if ((code == 315) || (code == 'x') || (code == 'X')
-				         || (code == 'q') || (code == 'Q')) {  /* Quit? */
-					DoNotDrawMessage = false;
-					drawMessage("Do you want to quit? (Y/N)");
-					doit = false;
-					eatMessages();
-					interfaceOff();
-
-					while (1) {
-						_music->updateMusic();  /* Make sure we check the music at least after every message */
-						curMsg = getMsg();
-
-						if (curMsg == NULL) { /* Does music load and next animation frame when you've run out of messages */
-							_music->updateMusic();
-							diffNextFrame();
-						} else {
-							if (curMsg->msgClass == RAWKEY) {
-								if ((curMsg->code == 'Y') || (curMsg->code == 'y') || (curMsg->code == 'Q') || (curMsg->code == 'q')) {
-									doit = true;
-									break;
-								} else if (curMsg->code < 128) {
-									break;
-								}
-							} else if (curMsg->msgClass == MOUSEBUTTONS) {
-								break;
-							}
-						}
+	if (Inventory) {
+		for (int i = 1; i <= NumInv; i++) {
+			if (Inventory[i].name)
+				free(Inventory[i].name);
+
+			if (Inventory[i].BInvName)
+				free(Inventory[i].BInvName);
+		}
+
+		free(Inventory);
+	}
+}
+
+bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Common::Point tmpPos, uint16 &curInv, IntuiMessage *curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode) {
+	uint32 msgClass = tmpClass;
+	Common::Point curPos = tmpPos;
+
+	uint16 OldRoomNum, OldDirection = 0;
+	uint16 LastInv = MAPNUM, Old;
+	CloseDataPtr OldCPtr, TempCPtr, HCPtr = NULL;
+	ViewData *VPtr;
+	bool doit;
+	uint16 NewDir;
+
+
+	DoBlack = false;
+
+	if ((msgClass == RAWKEY) && (!LongWinInFront)) {
+		if (code == 13) { /* The return key */
+			msgClass     = MOUSEBUTTONS;
+			Qualifier = IEQUALIFIER_LEFTBUTTON;
+			curPos = _event->getMousePos();
+		} else if (getPlatform() == Common::kPlatformWindows &&
+				(code == 'b' || code == 'B')) {  /* Start bread crumbs */
+			_breadCrumbs[0]._roomNum = 0;
+			_numCrumbs = 0;
+			_droppingCrumbs = true;
+			mayShowCrumbIndicator();
+			WSDL_UpdateScreen();
+		} else if (code == 'f' || code == 'F' ||
+		         code == 'r' || code == 'R') {  /* Follow bread crumbs */
+			if (_droppingCrumbs) {
+				if (_numCrumbs > 0) {
+					_followingCrumbs = true;
+					_followCrumbsFast = (code == 'r' || code == 'R');
+					_isCrumbTurning = false;
+					_isCrumbWaiting = false;
+					getTime(&_crumbSecs, &_crumbMicros);
+
+					if (Alternate) {
+						eatMessages();
+						Alternate = false;
+						DoBlack = true;
+						DoNotDrawMessage = false;
+
+						MainDisplay = true;
+						interfaceOn(); /* Sets the correct gadget list */
+						drawPanel();
+						drawRoomMessage(curInv, CPtr);
+						WSDL_UpdateScreen();
 					}
+				} else {
+					_breadCrumbs[0]._roomNum = 0;
+					_droppingCrumbs = false;
 
-					if (doit) {
-						stopDiff();
+					// Need to hide indicator!!!!
+					mayShowCrumbIndicatorOff();
+					WSDL_UpdateScreen();
+				}
+			}
+		} else if ((code == 315) || (code == 'x') || (code == 'X')
+		         || (code == 'q') || (code == 'Q')) {  /* Quit? */
+			DoNotDrawMessage = false;
+			drawMessage("Do you want to quit? (Y/N)");
+			doit = false;
+			eatMessages();
+			interfaceOff();
+
+			while (1) {
+				_music->updateMusic();  /* Make sure we check the music at least after every message */
+				curMsg = getMsg();
+
+				if (curMsg == NULL) { /* Does music load and next animation frame when you've run out of messages */
+					_music->updateMusic();
+					diffNextFrame();
+				} else {
+					if (curMsg->msgClass == RAWKEY) {
+						if ((curMsg->code == 'Y') || (curMsg->code == 'y') || (curMsg->code == 'Q') || (curMsg->code == 'q')) {
+							doit = true;
+							break;
+						} else if (curMsg->code < 128) {
+							break;
+						}
+					} else if (curMsg->msgClass == MOUSEBUTTONS) {
 						break;
-					} else {
-						ForceDraw = true;
-						interfaceOn();
 					}
-				} else if (code == 9) { /* TAB key */
-					Class = DELTAMOVE;
-				} else if (code == 27) { /* ESC key */
-					CPtr = NULL;
 				}
+			}
 
-				eatMessages();
+			if (doit) {
+				stopDiff();
+				return false;
+			} else {
+				forceDraw = true;
+				interfaceOn();
 			}
+		} else if (code == 9) { /* TAB key */
+			msgClass = DELTAMOVE;
+		} else if (code == 27) { /* ESC key */
+			CPtr = NULL;
+		}
 
-			if (LongWinInFront) {
-				if ((Class == RAWKEY) ||
-				        ((Class == MOUSEBUTTONS) &&
-				         ((IEQUALIFIER_LEFTBUTTON & Qualifier) ||
-				          (IEQUALIFIER_RBUTTON & Qualifier)))) {
-					LongWinInFront = false;
-					DoNotDrawMessage = false;
-					drawPanel();
-					drawRoomMessage(CurInv, CPtr);
-					WSDL_UpdateScreen();
-				}
-			} else if ((Class == GADGETUP) && !Alternate) {
-				if (GadID <= 5) {
-					if ((ActionMode == 4) && (GadID == 4) && (CPtr != NULL)) {
-						doMainView(&CPtr);
+		eatMessages();
+	}
 
-						DoBlack = true;
-						HCPtr = NULL;
-						CPtr = NULL;
-						mayShowCrumbIndicator();
-						WSDL_UpdateScreen();
-					} else if (GadID == 5) {
-						eatMessages();
+	if (LongWinInFront) {
+		if ((msgClass == RAWKEY) ||
+		        ((msgClass == MOUSEBUTTONS) &&
+		         ((IEQUALIFIER_LEFTBUTTON & Qualifier) ||
+		          (IEQUALIFIER_RBUTTON & Qualifier)))) {
+			LongWinInFront = false;
+			DoNotDrawMessage = false;
+			drawPanel();
+			drawRoomMessage(curInv, CPtr);
+			WSDL_UpdateScreen();
+		}
+	} else if ((msgClass == GADGETUP) && !Alternate) {
+		if (gadgetId <= 5) {
+			if ((actionMode == 4) && (gadgetId == 4) && (CPtr != NULL)) {
+				doMainView(&CPtr);
 
-						Alternate = true;
-						DoBlack = true;
-						DoNotDrawMessage = false;
-						interfaceOn(); /* Sets the correct gadget list */
+				DoBlack = true;
+				HCPtr = NULL;
+				CPtr = NULL;
+				mayShowCrumbIndicator();
+				WSDL_UpdateScreen();
+			} else if (gadgetId == 5) {
+				eatMessages();
+
+				Alternate = true;
+				DoBlack = true;
+				DoNotDrawMessage = false;
+				interfaceOn(); /* Sets the correct gadget list */
 
-						MainDisplay = false;
+				MainDisplay = false;
 
-						if (LastInv && _conditions->in(LastInv)) {
-							CurInv = LastInv;
-							Test = getInvName(CurInv);
-						} else
-							decIncInv(&CurInv, false);
+				if (LastInv && _conditions->in(LastInv)) {
+					curInv = LastInv;
+					Test = getInvName(curInv);
+				} else
+					decIncInv(&curInv, false);
 
-						drawPanel();
-						drawRoomMessage(CurInv, CPtr);
+				drawPanel();
+				drawRoomMessage(curInv, CPtr);
 
-						mayShowCrumbIndicator();
-						WSDL_UpdateScreen();
-					} else {
-						Old        = ActionMode;
-						ActionMode = GadID;
+				mayShowCrumbIndicator();
+				WSDL_UpdateScreen();
+			} else {
+				Old        = actionMode;
+				actionMode = gadgetId;
+
+				if (Old < 5)
+					perFlipGadget(Old);
+
+				perFlipGadget(actionMode);
+
+				if (gadgetId == 0)
+					drawStaticMessage(kTextTakeWhat);
+				else if (gadgetId == 1)
+					drawStaticMessage(kTextMoveWhat);
+				else if (gadgetId == 2)
+					drawStaticMessage(kTextOpenWhat);
+				else if (gadgetId == 3)
+					drawStaticMessage(kTextCloseWhat);
+				else if (gadgetId == 4)
+					drawStaticMessage(kTextLookWhat);
 
-						if (Old < 5)
-							perFlipGadget(Old);
+				WSDL_UpdateScreen();
+			}
+		} else if (gadgetId == 9) {
+			doUse(MAPNUM);
 
-						perFlipGadget(ActionMode);
+			mayShowCrumbIndicator();
+			WSDL_UpdateScreen();
+		} else if (gadgetId >= 6) { /* Arrow Gadgets */
+			CPtr = NULL;
+			HCPtr = NULL;
 
-						if (GadID == 0)
-							drawStaticMessage(kTextTakeWhat);
-						else if (GadID == 1)
-							drawStaticMessage(kTextMoveWhat);
-						else if (GadID == 2)
-							drawStaticMessage(kTextOpenWhat);
-						else if (GadID == 3)
-							drawStaticMessage(kTextCloseWhat);
-						else if (GadID == 4)
-							drawStaticMessage(kTextLookWhat);
+			if ((gadgetId == 6) || (gadgetId == 8)) {
+				if (gadgetId == 6)
+					drawStaticMessage(kTextTurnLeft);
+				else
+					drawStaticMessage(kTextTurnRight);
 
-						WSDL_UpdateScreen();
-					}
-				} else if (GadID == 9) {
-					doUse(MAPNUM);
+				CurFileName = " ";
 
-					mayShowCrumbIndicator();
-					WSDL_UpdateScreen();
-				} else if (GadID >= 6) { /* Arrow Gadgets */
-					CPtr = NULL;
-					HCPtr = NULL;
+				OldDirection = Direction;
 
-					if ((GadID == 6) || (GadID == 8)) {
-						if (GadID == 6)
-							drawStaticMessage(kTextTurnLeft);
-						else
-							drawStaticMessage(kTextTurnRight);
+				NewDir = Direction;
+				processArrow(&NewDir, gadgetId - 6);
+				doTurn(Direction, NewDir, &CPtr);
+				DoBlack = true;
+				Direction = NewDir;
+				forceDraw = true;
 
-						CurFileName = " ";
+				mayShowCrumbIndicator();
+				WSDL_UpdateScreen();
+			} else if (gadgetId == 7) {
+				OldRoomNum = _roomNum;
 
-						OldDirection = Direction;
+				if (doGoForward(&CPtr)) {
+					if (OldRoomNum == _roomNum)
+						DoBlack = true;
+				} else {
+					DoBlack = true;
+					processArrow(&Direction, gadgetId - 6);
 
-						NewDir = Direction;
-						processArrow(&NewDir, GadID - 6);
-						doTurn(Direction, NewDir, &CPtr);
+					if (OldRoomNum != _roomNum) {
+						drawStaticMessage(kTextGoForward);
+						_roomsFound->inclElement(_roomNum); /* Potentially entered a new room */
+						CurFileName = " ";
+						forceDraw = true;
+					} else {
 						DoBlack = true;
-						Direction = NewDir;
-						ForceDraw = true;
+						drawStaticMessage(kTextNoPath);
+					}
+				}
 
-						mayShowCrumbIndicator();
-						WSDL_UpdateScreen();
-					} else if (GadID == 7) {
-						OldRoomNum = _roomNum;
-
-						if (doGoForward(&CPtr)) {
-							if (OldRoomNum == _roomNum)
-								DoBlack = true;
-						} else {
-							DoBlack = true;
-							processArrow(&Direction, GadID - 6);
-
-							if (OldRoomNum != _roomNum) {
-								drawStaticMessage(kTextGoForward);
-								_roomsFound->inclElement(_roomNum); /* Potentially entered a new room */
-								CurFileName = " ";
-								ForceDraw = true;
-							} else {
-								DoBlack = true;
-								drawStaticMessage(kTextNoPath);
+				if (_followingCrumbs) {
+					if (_isCrumbTurning) {
+						if (Direction == OldDirection) {
+							_followingCrumbs = false;
+						}
+					} else {
+						if (_roomNum == OldRoomNum) { // didn't get there?
+							_followingCrumbs = false;
+						}
+					}
+				} else if (_droppingCrumbs && OldRoomNum != _roomNum) {
+					// If in surreal maze, turn off DroppingCrumbs.
+					// Note: These numbers were generated by parsing the
+					// "Maps" file, which is why they are hard-coded. Bleh!
+					if (_roomNum >= 245 && _roomNum <= 280) {
+						_followingCrumbs = false;
+						_droppingCrumbs = false;
+						_numCrumbs = 0;
+						_breadCrumbs[0]._roomNum = 0;
+					} else {
+						bool intersect = false;
+						for (int idx = 0; idx < _numCrumbs; idx++) {
+							if (_breadCrumbs[idx]._roomNum == _roomNum) {
+								_numCrumbs = idx + 1;
+								_breadCrumbs[_numCrumbs]._roomNum = 0;
+								intersect = true;
 							}
 						}
 
-						if (_followingCrumbs) {
-							if (_isCrumbTurning) {
-								if (Direction == OldDirection) {
-									_followingCrumbs = false;
-								}
-							} else {
-								if (_roomNum == OldRoomNum) { // didn't get there?
-									_followingCrumbs = false;
-								}
+						if (!intersect) {
+							if (_numCrumbs == MAX_CRUMBS) {
+								_numCrumbs = MAX_CRUMBS - 1;
+								memcpy(&_breadCrumbs[0], &_breadCrumbs[1], _numCrumbs * sizeof _breadCrumbs[0]);
 							}
-						} else if (_droppingCrumbs && OldRoomNum != _roomNum) {
-							// If in surreal maze, turn off DroppingCrumbs.
-							// Note: These numbers were generated by parsing the
-							// "Maps" file, which is why they are hard-coded. Bleh!
-							if (_roomNum >= 245 && _roomNum <= 280) {
-								_followingCrumbs = false;
-								_droppingCrumbs = false;
-								_numCrumbs = 0;
-								_breadCrumbs[0]._roomNum = 0;
-							} else {
-								bool intersect = false;
-								for (int idx = 0; idx < _numCrumbs; idx++) {
-									if (_breadCrumbs[idx]._roomNum == _roomNum) {
-										_numCrumbs = idx + 1;
-										_breadCrumbs[_numCrumbs]._roomNum = 0;
-										intersect = true;
-									}
-								}
-
-								if (!intersect) {
-									if (_numCrumbs == MAX_CRUMBS) {
-										_numCrumbs = MAX_CRUMBS - 1;
-										memcpy(&_breadCrumbs[0], &_breadCrumbs[1], _numCrumbs * sizeof _breadCrumbs[0]);
-									}
-
-									_breadCrumbs[_numCrumbs]._roomNum = _roomNum;
-									_breadCrumbs[_numCrumbs++]._direction = Direction;
-								}
-							}
-						}
 
-						mayShowCrumbIndicator();
-						WSDL_UpdateScreen();
+							_breadCrumbs[_numCrumbs]._roomNum = _roomNum;
+							_breadCrumbs[_numCrumbs++]._direction = Direction;
+						}
 					}
 				}
-			} else if ((Class == GADGETUP) && Alternate) {
-				DoBlack = true;
-
-				if (GadID == 0) {
-					eatMessages();
-					Alternate = false;
-					DoBlack = true;
-					DoNotDrawMessage = false;
 
-					MainDisplay = true;
-					interfaceOn(); /* Sets the correct gadget list */
-					drawPanel();
-					drawRoomMessage(CurInv, CPtr);
-
-					WSDL_UpdateScreen();
-				}
+				mayShowCrumbIndicator();
+				WSDL_UpdateScreen();
+			}
+		}
+	} else if ((msgClass == GADGETUP) && Alternate) {
+		DoBlack = true;
 
-				GadID--;
+		if (gadgetId == 0) {
+			eatMessages();
+			Alternate = false;
+			DoBlack = true;
+			DoNotDrawMessage = false;
 
-				if (GadID == 0) {
-					interfaceOff();
-					stopDiff();
-					CurFileName = " ";
+			MainDisplay = true;
+			interfaceOn(); /* Sets the correct gadget list */
+			drawPanel();
+			drawRoomMessage(curInv, CPtr);
 
-					doit = !saveRestoreGame();
-					CPtr = NULL;
+			WSDL_UpdateScreen();
+		}
 
-					MainDisplay = true;
+		gadgetId--;
 
-					CurInv = MAPNUM;
-					LastInv = MAPNUM;
+		if (gadgetId == 0) {
+			interfaceOff();
+			stopDiff();
+			CurFileName = " ";
 
-					Test = getInvName(CurInv);
+			doit = !saveRestoreGame();
+			CPtr = NULL;
 
-					drawPanel();
+			MainDisplay = true;
 
-					if (doit) {
-						drawMessage("Disk operation failed.");
-						VGASetPal(initcolors, 8);
+			curInv = MAPNUM;
+			LastInv = MAPNUM;
 
-						WSDL_UpdateScreen();
+			Test = getInvName(curInv);
 
-						g_system->delayMillis(1000);
-					} else {
-						WSDL_UpdateScreen();
-					}
-				} else if (GadID == 1) {
-					if (!doUse(CurInv)) {
-						Old        = ActionMode;
-						ActionMode = 5;  /* Use button */
+			drawPanel();
 
-						if (Old < 5)
-							perFlipGadget(Old);
+			if (doit) {
+				drawMessage("Disk operation failed.");
+				VGASetPal(initcolors, 8);
 
-						drawStaticMessage(kTextUseOnWhat);
-						MainDisplay = true;
+				WSDL_UpdateScreen();
 
-						WSDL_UpdateScreen();
-					}
-				} else if (GadID == 2) {
-					MainDisplay = !MainDisplay;
+				g_system->delayMillis(1000);
+			} else {
+				WSDL_UpdateScreen();
+			}
+		} else if (gadgetId == 1) {
+			if (!doUse(curInv)) {
+				Old        = actionMode;
+				actionMode = 5;  /* Use button */
 
-					if ((CurInv == 0) || (CurInv > NumInv)) {
-						CurInv = 1;
+				if (Old < 5)
+					perFlipGadget(Old);
 
-						while ((CurInv <= NumInv) && (!_conditions->in(CurInv)))
-							CurInv++;
-					}
+				drawStaticMessage(kTextUseOnWhat);
+				MainDisplay = true;
 
-					if ((CurInv <= NumInv) && _conditions->in(CurInv) &&
-					        Inventory[CurInv].BInvName)
-						Test = getInvName(CurInv);
+				WSDL_UpdateScreen();
+			}
+		} else if (gadgetId == 2) {
+			MainDisplay = !MainDisplay;
 
-					WSDL_UpdateScreen();
-				} else if (GadID == 3) { /* Left gadget */
-					decIncInv(&CurInv, true);
-					LastInv = CurInv;
-					DoNotDrawMessage = false;
-					drawRoomMessage(CurInv, CPtr);
+			if ((curInv == 0) || (curInv > NumInv)) {
+				curInv = 1;
 
-					WSDL_UpdateScreen();
-				} else if (GadID == 4) { /* Right gadget */
-					decIncInv(&CurInv, false);
-					LastInv = CurInv;
-					DoNotDrawMessage = false;
-					drawRoomMessage(CurInv, CPtr);
+				while ((curInv <= NumInv) && (!_conditions->in(curInv)))
+					curInv++;
+			}
 
-					WSDL_UpdateScreen();
-				} else if (GadID == 5) { /* bread crumbs */
-					_breadCrumbs[0]._roomNum = 0;
-					_numCrumbs = 0;
-					_droppingCrumbs = true;
-					mayShowCrumbIndicator();
-					WSDL_UpdateScreen();
-				} else if (GadID == 6) { /* follow crumbs */
-					if (_droppingCrumbs) {
-						if (_numCrumbs > 0) {
-							_followingCrumbs = true;
-							_followCrumbsFast = false;
-							_isCrumbTurning = false;
-							_isCrumbWaiting = false;
-							getTime(&_crumbSecs, &_crumbMicros);
-
-							eatMessages();
-							Alternate = false;
-							DoBlack = true;
-							DoNotDrawMessage = false;
-
-							MainDisplay = true;
-							interfaceOn(); /* Sets the correct gadget list */
-							drawPanel();
-							drawRoomMessage(CurInv, CPtr);
-							WSDL_UpdateScreen();
-						} else {
-							_breadCrumbs[0]._roomNum = 0;
-							_droppingCrumbs = false;
-
-							// Need to hide indicator!!!!
-							mayShowCrumbIndicatorOff();
-							WSDL_UpdateScreen();
-						}
-					}
-				}
-			} else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier) && MainDisplay) {
-				interfaceOff();
-				MainDisplay = true;
+			if ((curInv <= NumInv) && _conditions->in(curInv) &&
+			        Inventory[curInv].BInvName)
+				Test = getInvName(curInv);
 
-				doit = false;
+			WSDL_UpdateScreen();
+		} else if (gadgetId == 3) { /* Left gadget */
+			decIncInv(&curInv, true);
+			LastInv = curInv;
+			DoNotDrawMessage = false;
+			drawRoomMessage(curInv, CPtr);
 
-				if (CPtr) {
-					if ((CPtr->CloseUpType == SPECIALLOCK) && MainDisplay) /* LAB: Labyrinth specific code */
-						mouseCombination(curPos);
-					else if ((CPtr->CloseUpType == SPECIALBRICK) && MainDisplay)
-						mouseTile(curPos);
-					else
-						doit = true;
-				} else
-					doit = true;
+			WSDL_UpdateScreen();
+		} else if (gadgetId == 4) { /* Right gadget */
+			decIncInv(&curInv, false);
+			LastInv = curInv;
+			DoNotDrawMessage = false;
+			drawRoomMessage(curInv, CPtr);
 
+			WSDL_UpdateScreen();
+		} else if (gadgetId == 5) { /* bread crumbs */
+			_breadCrumbs[0]._roomNum = 0;
+			_numCrumbs = 0;
+			_droppingCrumbs = true;
+			mayShowCrumbIndicator();
+			WSDL_UpdateScreen();
+		} else if (gadgetId == 6) { /* follow crumbs */
+			if (_droppingCrumbs) {
+				if (_numCrumbs > 0) {
+					_followingCrumbs = true;
+					_followCrumbsFast = false;
+					_isCrumbTurning = false;
+					_isCrumbWaiting = false;
+					getTime(&_crumbSecs, &_crumbMicros);
 
-				if (doit) {
-					HCPtr = NULL;
 					eatMessages();
+					Alternate = false;
+					DoBlack = true;
+					DoNotDrawMessage = false;
 
-					if (ActionMode == 0) { /* Take something. */
-						if (doActionRule(Common::Point(curPos.x, curPos.y), ActionMode, _roomNum, &CPtr))
-							CurFileName = NewFileName;
-						else if (takeItem(curPos.x, curPos.y, &CPtr))
-							drawStaticMessage(kTextTakeItem);
-						else if (doActionRule(curPos, TAKEDEF - 1, _roomNum, &CPtr))
-							CurFileName = NewFileName;
-						else if (doActionRule(curPos, TAKE - 1, 0, &CPtr))
-							CurFileName = NewFileName;
-						else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
-							drawStaticMessage(kTextNothing);
-					} else if ((ActionMode == 1) /* Manipulate an object */  ||
-					         (ActionMode == 2) /* Open up a "door" */      ||
-					         (ActionMode == 3)) { /* Close a "door" */
-						if (doActionRule(curPos, ActionMode, _roomNum, &CPtr))
-							CurFileName = NewFileName;
-						else if (!doActionRule(curPos, ActionMode, 0, &CPtr)) {
-							if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
-								drawStaticMessage(kTextNothing);
-						}
-					} else if (ActionMode == 4) { /* Look at closeups */
-						TempCPtr = CPtr;
-						setCurClose(curPos, &TempCPtr);
-
-						if (CPtr == TempCPtr) {
-							if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
-								drawStaticMessage(kTextNothing);
-						} else if (TempCPtr->GraphicName) {
-							if (*(TempCPtr->GraphicName)) {
-								DoBlack = true;
-								CPtr = TempCPtr;
-							} else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
-								drawStaticMessage(kTextNothing);
-						} else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
-							drawStaticMessage(kTextNothing);
-					} else if ((ActionMode == 5)  &&
-					         _conditions->in(CurInv)) { /* Use an item on something else */
-						if (doOperateRule(curPos.x, curPos.y, CurInv, &CPtr)) {
-							CurFileName = NewFileName;
-
-							if (!_conditions->in(CurInv))
-								decIncInv(&CurInv, false);
-						} else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
-							drawStaticMessage(kTextNothing);
-					}
-				}
-
-				mayShowCrumbIndicator();
-				WSDL_UpdateScreen();
-			} else if (Class == DELTAMOVE) {
-				VPtr = getViewData(_roomNum, Direction);
-				OldCPtr = VPtr->closeUps;
-
-				if (HCPtr == NULL) {
-					TempCPtr = CPtr;
-					setCurClose(curPos, &TempCPtr);
-
-					if ((TempCPtr == NULL) || (TempCPtr == CPtr)) {
-						if (CPtr == NULL)
-							HCPtr = OldCPtr;
-						else
-							HCPtr = CPtr->SubCloseUps;
-					} else
-						HCPtr = TempCPtr->NextCloseUp;
-				} else
-					HCPtr = HCPtr->NextCloseUp;
-
+					MainDisplay = true;
+					interfaceOn(); /* Sets the correct gadget list */
+					drawPanel();
+					drawRoomMessage(curInv, CPtr);
+					WSDL_UpdateScreen();
+				} else {
+					_breadCrumbs[0]._roomNum = 0;
+					_droppingCrumbs = false;
 
-				if (HCPtr == NULL) {
-					if (CPtr == NULL)
-						HCPtr = OldCPtr;
-					else
-						HCPtr = CPtr->SubCloseUps;
+					// Need to hide indicator!!!!
+					mayShowCrumbIndicatorOff();
+					WSDL_UpdateScreen();
 				}
+			}
+		}
+	} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier) && MainDisplay) {
+		interfaceOff();
+		MainDisplay = true;
 
-				if (HCPtr)
-					_event->setMousePos(Common::Point(scaleX((HCPtr->x1 + HCPtr->x2) / 2), scaleY((HCPtr->y1 + HCPtr->y2) / 2)));
-			} else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) {
-				eatMessages();
-				Alternate = !Alternate;
-				DoBlack = true;
-				DoNotDrawMessage = false;
-				MainDisplay = true;
-				interfaceOn(); /* Sets the correct gadget list */
+		doit = false;
 
-				if (Alternate) {
-					if (LastInv && _conditions->in(LastInv))
-						CurInv = LastInv;
-					else
-						decIncInv(&CurInv, false);
+		if (CPtr) {
+			if ((CPtr->CloseUpType == SPECIALLOCK) && MainDisplay) /* LAB: Labyrinth specific code */
+				mouseCombination(curPos);
+			else if ((CPtr->CloseUpType == SPECIALBRICK) && MainDisplay)
+				mouseTile(curPos);
+			else
+				doit = true;
+		} else
+			doit = true;
+
+
+		if (doit) {
+			HCPtr = NULL;
+			eatMessages();
+
+			if (actionMode == 0) { /* Take something. */
+				if (doActionRule(Common::Point(curPos.x, curPos.y), actionMode, _roomNum, &CPtr))
+					CurFileName = NewFileName;
+				else if (takeItem(curPos.x, curPos.y, &CPtr))
+					drawStaticMessage(kTextTakeItem);
+				else if (doActionRule(curPos, TAKEDEF - 1, _roomNum, &CPtr))
+					CurFileName = NewFileName;
+				else if (doActionRule(curPos, TAKE - 1, 0, &CPtr))
+					CurFileName = NewFileName;
+				else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
+					drawStaticMessage(kTextNothing);
+			} else if ((actionMode == 1) /* Manipulate an object */  ||
+			         (actionMode == 2) /* Open up a "door" */      ||
+			         (actionMode == 3)) { /* Close a "door" */
+				if (doActionRule(curPos, actionMode, _roomNum, &CPtr))
+					CurFileName = NewFileName;
+				else if (!doActionRule(curPos, actionMode, 0, &CPtr)) {
+					if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
+						drawStaticMessage(kTextNothing);
 				}
-
-				drawPanel();
-				drawRoomMessage(CurInv, CPtr);
-
-				mayShowCrumbIndicator();
-				WSDL_UpdateScreen();
+			} else if (actionMode == 4) { /* Look at closeups */
+				TempCPtr = CPtr;
+				setCurClose(curPos, &TempCPtr);
+
+				if (CPtr == TempCPtr) {
+					if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
+						drawStaticMessage(kTextNothing);
+				} else if (TempCPtr->GraphicName) {
+					if (*(TempCPtr->GraphicName)) {
+						DoBlack = true;
+						CPtr = TempCPtr;
+					} else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
+						drawStaticMessage(kTextNothing);
+				} else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
+					drawStaticMessage(kTextNothing);
+			} else if ((actionMode == 5)  &&
+			         _conditions->in(curInv)) { /* Use an item on something else */
+				if (doOperateRule(curPos.x, curPos.y, curInv, &CPtr)) {
+					CurFileName = NewFileName;
+
+					if (!_conditions->in(curInv))
+						decIncInv(&curInv, false);
+				} else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
+					drawStaticMessage(kTextNothing);
 			}
 		}
-	}
 
-	delete _conditions;
-	delete _roomsFound;
+		mayShowCrumbIndicator();
+		WSDL_UpdateScreen();
+	} else if (msgClass == DELTAMOVE) {
+		VPtr = getViewData(_roomNum, Direction);
+		OldCPtr = VPtr->closeUps;
+
+		if (HCPtr == NULL) {
+			TempCPtr = CPtr;
+			setCurClose(curPos, &TempCPtr);
+
+			if ((TempCPtr == NULL) || (TempCPtr == CPtr)) {
+				if (CPtr == NULL)
+					HCPtr = OldCPtr;
+				else
+					HCPtr = CPtr->SubCloseUps;
+			} else
+				HCPtr = TempCPtr->NextCloseUp;
+		} else
+			HCPtr = HCPtr->NextCloseUp;
 
-	if (_rooms) {
-		free(_rooms);
-		_rooms = nullptr;
-	}
 
-	if (Inventory) {
-		for (code = 1; code <= NumInv; code++) {
-			if (Inventory[code].name)
-				free(Inventory[code].name);
+		if (HCPtr == NULL) {
+			if (CPtr == NULL)
+				HCPtr = OldCPtr;
+			else
+				HCPtr = CPtr->SubCloseUps;
+		}
 
-			if (Inventory[code].BInvName)
-				free(Inventory[code].BInvName);
+		if (HCPtr)
+			_event->setMousePos(Common::Point(scaleX((HCPtr->x1 + HCPtr->x2) / 2), scaleY((HCPtr->y1 + HCPtr->y2) / 2)));
+	} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) {
+		eatMessages();
+		Alternate = !Alternate;
+		DoBlack = true;
+		DoNotDrawMessage = false;
+		MainDisplay = true;
+		interfaceOn(); /* Sets the correct gadget list */
+
+		if (Alternate) {
+			if (LastInv && _conditions->in(LastInv))
+				curInv = LastInv;
+			else
+				decIncInv(&curInv, false);
 		}
 
-		free(Inventory);
+		drawPanel();
+		drawRoomMessage(curInv, CPtr);
+
+		mayShowCrumbIndicator();
+		WSDL_UpdateScreen();
 	}
+	return true;
 }
 
 void LabEngine::go() {
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index b2ec4b1..f403e45 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -131,6 +131,7 @@ private:
 
 private:
 	bool createScreen(bool HiRes);
+	bool from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Common::Point tmpPos, uint16 &curInv, IntuiMessage * curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode);
 
 public:
 	void waitTOF();


Commit: 8dbdc70de4b7819186620079bbb6a175d058f5e8
    https://github.com/scummvm/scummvm/commit/8dbdc70de4b7819186620079bbb6a175d058f5e8
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:44+01:00

Commit Message:
LAB: Fix stopDiffEnd. This fixes the intro (between others)

Changed paths:
    engines/lab/readdiff.cpp



diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index 926ef35..bfe574a 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -36,6 +36,8 @@
 namespace Lab {
 
 static bool PlayOnce = false;
+static bool StopPlayingEnd = false;
+
 static uint32 header, size, WaitSec = 0L, WaitMicros = 0L, DelayMicros = 0L;
 static uint16 CurBit = 0, framenumber = 0, samplespeed, numchunks = 1;
 static byte *Buffer, temp[5];
@@ -249,7 +251,7 @@ void LabEngine::diffNextFrame() {
 			break;
 		}
 		case 65535L:
-			if ((framenumber == 1) || PlayOnce) {
+			if ((framenumber == 1) || PlayOnce || StopPlayingEnd) {
 				int didTOF = 0;
 
 				if (waitForEffect) {
@@ -294,6 +296,7 @@ void playDiff() {
 	framenumber = 0;
 	numchunks   = 1;
 	donepal     = false;
+	StopPlayingEnd = false;
 	difffile    = &storagefordifffile;
 
 	IsPlaying   = true;
@@ -385,13 +388,12 @@ void stopDiff() {
 	}
 }
 
-
-
 /*****************************************************************************/
 /* Stops an animation from running.                                          */
 /*****************************************************************************/
 void stopDiffEnd() {
 	if (IsPlaying) {
+		StopPlayingEnd = true;
 		while (IsPlaying) {
 			g_lab->_music->updateMusic();
 			g_lab->diffNextFrame();


Commit: 6d4b71e2ce21aa9843aa90522e972a95f3966bd6
    https://github.com/scummvm/scummvm/commit/6d4b71e2ce21aa9843aa90522e972a95f3966bd6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:45+01:00

Commit Message:
LAB: Renames in vga.cpp

Changed paths:
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/interface.cpp
    engines/lab/intro.cpp
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/mouse.cpp
    engines/lab/music.cpp
    engines/lab/processroom.cpp
    engines/lab/readdiff.cpp
    engines/lab/special.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 7d67241..b7970ae 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -516,7 +516,7 @@ bool LabEngine::doUse(uint16 CurInv) {
 		CurFileName = " ";
 		CPtr = NULL;
 		doMap(_roomNum);
-		VGASetPal(initcolors, 8);
+		setPalette(initcolors, 8);
 		drawMessage(NULL);
 		drawPanel();
 	} else if (CurInv == JOURNALNUM) {         /* LAB: Labyrinth specific */
@@ -623,7 +623,7 @@ void LabEngine::mainGameLoop() {
 
 	bool forceDraw = false, GotMessage = true;
 
-	VGASetPal(initcolors, 8);
+	setPalette(initcolors, 8);
 
 	CPtr    = NULL;
 	_roomNum = 1;
@@ -648,7 +648,7 @@ void LabEngine::mainGameLoop() {
 	/* Set up initial picture. */
 
 	while (1) {
-		WSDL_ProcessInput(1);
+		processInput(true);
 
 		if (GotMessage) {
 			if (QuitLab || g_engine->shouldQuit()) {
@@ -663,7 +663,7 @@ void LabEngine::mainGameLoop() {
 				CPtr = NULL;
 
 				mayShowCrumbIndicator();
-				WSDL_UpdateScreen();
+				screenUpdate();
 			}
 
 			/* Sets the current picture properly on the screen */
@@ -699,7 +699,7 @@ void LabEngine::mainGameLoop() {
 				forceDraw = false;
 
 				mayShowCrumbIndicator();
-				WSDL_UpdateScreen();
+				screenUpdate();
 
 				if (!_followingCrumbs)
 					eatMessages();
@@ -708,7 +708,7 @@ void LabEngine::mainGameLoop() {
 			if (forceDraw) {
 				drawRoomMessage(curInv, CPtr);
 				forceDraw = false;
-				WSDL_UpdateScreen();
+				screenUpdate();
 			}
 		}
 
@@ -736,14 +736,14 @@ void LabEngine::mainGameLoop() {
 
 					GotMessage = true;
 					mayShowCrumbIndicator();
-					WSDL_UpdateScreen();
+					screenUpdate();
 					if (!from_crumbs(GADGETUP, code, 0, WSDL_GetMousePos(), curInv, curMsg, forceDraw, code, actionMode))
 						break;
 				}
 			}
 
 			mayShowCrumbIndicator();
-			WSDL_UpdateScreen();
+			screenUpdate();
 		} else {
 			GotMessage = true;
 
@@ -803,7 +803,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			_numCrumbs = 0;
 			_droppingCrumbs = true;
 			mayShowCrumbIndicator();
-			WSDL_UpdateScreen();
+			screenUpdate();
 		} else if (code == 'f' || code == 'F' ||
 		         code == 'r' || code == 'R') {  /* Follow bread crumbs */
 			if (_droppingCrumbs) {
@@ -824,7 +824,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 						interfaceOn(); /* Sets the correct gadget list */
 						drawPanel();
 						drawRoomMessage(curInv, CPtr);
-						WSDL_UpdateScreen();
+						screenUpdate();
 					}
 				} else {
 					_breadCrumbs[0]._roomNum = 0;
@@ -832,7 +832,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 					// Need to hide indicator!!!!
 					mayShowCrumbIndicatorOff();
-					WSDL_UpdateScreen();
+					screenUpdate();
 				}
 			}
 		} else if ((code == 315) || (code == 'x') || (code == 'X')
@@ -889,7 +889,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			DoNotDrawMessage = false;
 			drawPanel();
 			drawRoomMessage(curInv, CPtr);
-			WSDL_UpdateScreen();
+			screenUpdate();
 		}
 	} else if ((msgClass == GADGETUP) && !Alternate) {
 		if (gadgetId <= 5) {
@@ -900,7 +900,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				HCPtr = NULL;
 				CPtr = NULL;
 				mayShowCrumbIndicator();
-				WSDL_UpdateScreen();
+				screenUpdate();
 			} else if (gadgetId == 5) {
 				eatMessages();
 
@@ -921,7 +921,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				drawRoomMessage(curInv, CPtr);
 
 				mayShowCrumbIndicator();
-				WSDL_UpdateScreen();
+				screenUpdate();
 			} else {
 				Old        = actionMode;
 				actionMode = gadgetId;
@@ -942,13 +942,13 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				else if (gadgetId == 4)
 					drawStaticMessage(kTextLookWhat);
 
-				WSDL_UpdateScreen();
+				screenUpdate();
 			}
 		} else if (gadgetId == 9) {
 			doUse(MAPNUM);
 
 			mayShowCrumbIndicator();
-			WSDL_UpdateScreen();
+			screenUpdate();
 		} else if (gadgetId >= 6) { /* Arrow Gadgets */
 			CPtr = NULL;
 			HCPtr = NULL;
@@ -971,7 +971,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				forceDraw = true;
 
 				mayShowCrumbIndicator();
-				WSDL_UpdateScreen();
+				screenUpdate();
 			} else if (gadgetId == 7) {
 				OldRoomNum = _roomNum;
 
@@ -1035,7 +1035,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				}
 
 				mayShowCrumbIndicator();
-				WSDL_UpdateScreen();
+				screenUpdate();
 			}
 		}
 	} else if ((msgClass == GADGETUP) && Alternate) {
@@ -1052,7 +1052,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			drawPanel();
 			drawRoomMessage(curInv, CPtr);
 
-			WSDL_UpdateScreen();
+			screenUpdate();
 		}
 
 		gadgetId--;
@@ -1076,13 +1076,13 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 			if (doit) {
 				drawMessage("Disk operation failed.");
-				VGASetPal(initcolors, 8);
+				setPalette(initcolors, 8);
 
-				WSDL_UpdateScreen();
+				screenUpdate();
 
 				g_system->delayMillis(1000);
 			} else {
-				WSDL_UpdateScreen();
+				screenUpdate();
 			}
 		} else if (gadgetId == 1) {
 			if (!doUse(curInv)) {
@@ -1095,7 +1095,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				drawStaticMessage(kTextUseOnWhat);
 				MainDisplay = true;
 
-				WSDL_UpdateScreen();
+				screenUpdate();
 			}
 		} else if (gadgetId == 2) {
 			MainDisplay = !MainDisplay;
@@ -1111,27 +1111,27 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			        Inventory[curInv].BInvName)
 				Test = getInvName(curInv);
 
-			WSDL_UpdateScreen();
+			screenUpdate();
 		} else if (gadgetId == 3) { /* Left gadget */
 			decIncInv(&curInv, true);
 			LastInv = curInv;
 			DoNotDrawMessage = false;
 			drawRoomMessage(curInv, CPtr);
 
-			WSDL_UpdateScreen();
+			screenUpdate();
 		} else if (gadgetId == 4) { /* Right gadget */
 			decIncInv(&curInv, false);
 			LastInv = curInv;
 			DoNotDrawMessage = false;
 			drawRoomMessage(curInv, CPtr);
 
-			WSDL_UpdateScreen();
+			screenUpdate();
 		} else if (gadgetId == 5) { /* bread crumbs */
 			_breadCrumbs[0]._roomNum = 0;
 			_numCrumbs = 0;
 			_droppingCrumbs = true;
 			mayShowCrumbIndicator();
-			WSDL_UpdateScreen();
+			screenUpdate();
 		} else if (gadgetId == 6) { /* follow crumbs */
 			if (_droppingCrumbs) {
 				if (_numCrumbs > 0) {
@@ -1150,14 +1150,14 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 					interfaceOn(); /* Sets the correct gadget list */
 					drawPanel();
 					drawRoomMessage(curInv, CPtr);
-					WSDL_UpdateScreen();
+					screenUpdate();
 				} else {
 					_breadCrumbs[0]._roomNum = 0;
 					_droppingCrumbs = false;
 
 					// Need to hide indicator!!!!
 					mayShowCrumbIndicatorOff();
-					WSDL_UpdateScreen();
+					screenUpdate();
 				}
 			}
 		}
@@ -1230,7 +1230,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 		}
 
 		mayShowCrumbIndicator();
-		WSDL_UpdateScreen();
+		screenUpdate();
 	} else if (msgClass == DELTAMOVE) {
 		VPtr = getViewData(_roomNum, Direction);
 		OldCPtr = VPtr->closeUps;
@@ -1278,7 +1278,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 		drawRoomMessage(curInv, CPtr);
 
 		mayShowCrumbIndicator();
-		WSDL_UpdateScreen();
+		screenUpdate();
 	}
 	return true;
 }
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 54bf880..460d4d5 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -465,7 +465,7 @@ void LabEngine::doScrollBlack() {
 		g_lab->setAPen(0);
 		g_lab->rectFill(0, nheight, width - 1, nheight + by - 1);
 
-		g_lab->WSDL_UpdateScreen();
+		g_lab->screenUpdate();
 
 		if (!_isHiRes) {
 			if (nheight <= (height / 8))
@@ -530,7 +530,7 @@ void LabEngine::doScrollWipe(char *filename) {
 
 	IsBM = true;
 	readPict(filename, true);
-	g_lab->VGASetPal(diffcmap, 256);
+	g_lab->setPalette(diffcmap, 256);
 	IsBM = false;
 	mem = RawDiffBM.Planes[0];
 
@@ -552,7 +552,7 @@ void LabEngine::doScrollWipe(char *filename) {
 
 		copyPage(width, height, nheight, startline, mem);
 
-		g_lab->WSDL_UpdateScreen();
+		g_lab->screenUpdate();
 
 		if (!nheight)
 			startline += by;
@@ -601,7 +601,7 @@ void LabEngine::doScrollBounce() {
 		startline -= newby[i];
 		copyPage(width, height, 0, startline, mem);
 
-		g_lab->WSDL_UpdateScreen();
+		g_lab->screenUpdate();
 		g_lab->waitTOF();
 	}
 
@@ -610,7 +610,7 @@ void LabEngine::doScrollBounce() {
 		startline += newby1[i - 1];
 		copyPage(width, height, 0, startline, mem);
 
-		g_lab->WSDL_UpdateScreen();
+		g_lab->screenUpdate();
 		g_lab->waitTOF();
 
 	}
@@ -675,7 +675,7 @@ void LabEngine::doTransWipe(CloseDataPtr *CPtr, char *filename) {
 		CurFileName = getPictName(CPtr);
 
 	byte *BitMapMem = readPictToMem(CurFileName, g_lab->_screenWidth, LastY + 5);
-	g_lab->VGASetPal(diffcmap, 256);
+	g_lab->setPalette(diffcmap, 256);
 
 	if (BitMapMem) {
 		ImSource.Width = g_lab->_screenWidth;
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index d9ea459..a31e289 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -155,8 +155,8 @@ Gadget *LabEngine::checkNumGadgetHit(Gadget *gadlist, uint16 key) {
 /* Checks whether or not a key has been pressed.                             */
 /*****************************************************************************/
 static bool keyPress(uint16 *KeyCode) {
-	if (g_lab->WSDL_HasNextChar()) {
-        *KeyCode = g_lab->WSDL_GetNextChar();
+	if (g_lab->haveNextChar()) {
+        *KeyCode = g_lab->getNextChar();
 		return true;
 	}
 
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 7660b29..b556501 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -400,7 +400,7 @@ void Intro::introSequence() {
 
 			g_lab->_music->updateMusic();
 			g_lab->waitTOF();
-			g_lab->VGASetPal(diffcmap, 256);
+			g_lab->setPalette(diffcmap, 256);
 			g_lab->	waitTOF();
 			g_lab->waitTOF();
 		}
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index f403e45..7cca825 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -139,19 +139,19 @@ public:
 	void writeColorRegs(byte *buf, uint16 first, uint16 numreg);
 	byte *getVGABaseAddr();
 	void readScreenImage(Image *Im, uint16 x, uint16 y);
-	void WSDL_UpdateScreen();
+	void screenUpdate();
 	void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest, uint16 xd, uint16 yd, uint16 width, uint16 height);
-	void VGASetPal(void *cmap, uint16 numcolors);
+	void setPalette(void *cmap, uint16 numcolors);
 	void drawHLine(uint16 x, uint16 y1, uint16 y2);
 	void drawVLine(uint16 x1, uint16 y, uint16 x2);
 	void drawImage(Image *Im, uint16 x, uint16 y);
-	bool WSDL_HasNextChar();
-	uint16 WSDL_GetNextChar();
-	void WSDL_ProcessInput(bool can_delay);
+	bool haveNextChar();
+	uint16 getNextChar();
+	void processInput(bool can_delay = false);
 	void writeColorReg(byte *buf, uint16 regnum);
 	void writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg);
 
@@ -192,7 +192,7 @@ private:
 	void drawMaskImage(Image *Im, uint16 x, uint16 y);
 	Common::Point WSDL_GetMousePos();
 	void changeVolume(int delta);
-	void WSDL_SetColors(byte *buf, uint16 first, uint16 numreg, uint16 slow);
+	void applyPalette(byte *buf, uint16 first, uint16 numreg, uint16 slow);
 
 	// engine.cpp
 	bool setUpScreens();
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 859d1ff..2db3610 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -820,7 +820,7 @@ void LabEngine::processMap(uint16 CurRoom) {
 				}
 			}
 
-			WSDL_UpdateScreen();
+			screenUpdate();
 		}
 	}
 }
@@ -848,7 +848,7 @@ void LabEngine::doMap(uint16 CurRoom) {
 	drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true);
 	_event->mouseShow();
 	_event->attachGadgetList(MapGadgetList);
-	WSDL_UpdateScreen();
+	screenUpdate();
 	processMap(CurRoom);
 	_event->attachGadgetList(NULL);
 	fade(false, 0);
@@ -859,7 +859,7 @@ void LabEngine::doMap(uint16 CurRoom) {
 	freeMapData();
 	blackAllScreen();
 	_event->mouseShow();
-	WSDL_UpdateScreen();
+	screenUpdate();
 }
 
 } // End of namespace Lab
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index eeae317..a7e6296 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -150,7 +150,7 @@ void EventManager::updateMouse() {
 	}
 
 	if (doUpdateDisplay)
-		_vm->WSDL_UpdateScreen();
+		_vm->screenUpdate();
 }
 
 
@@ -173,7 +173,7 @@ void EventManager::mouseShow() {
 		NumHidden--;
 
 	if ((NumHidden == 0) && MouseHidden) {
-		_vm->WSDL_ProcessInput(0);
+		_vm->processInput();
 		MouseHidden = false;
 	}
 
@@ -215,7 +215,7 @@ void EventManager::setMousePos(Common::Point pos) {
 		g_system->warpMouse(pos.x * 2, pos.y);
 
 	if (!MouseHidden)
-		_vm->WSDL_ProcessInput(0);
+		_vm->processInput();
 }
 
 
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 1f99a68..b6587eb 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -69,7 +69,7 @@ Music::Music(LabEngine *vm) : _vm(vm) {
 /* it from the Audio device.                                                 */
 /*****************************************************************************/
 void Music::updateMusic() {
-	_vm->WSDL_ProcessInput(0);
+	_vm->processInput();
 
 	_vm->_event->updateMouse();
 
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 8453fe6..87a56b0 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -482,7 +482,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 		case WAITSECS:
 			g_lab->addCurTime(APtr->Param1, 0, &StartSecs, &StartMicros);
 
-			g_lab->WSDL_UpdateScreen();
+			g_lab->screenUpdate();
 
 			while (1) {
 				g_lab->_music->updateMusic();
@@ -566,7 +566,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 					diffcmap[idx] = 255 - diffcmap[idx];
 
 				g_lab->waitTOF();
-				g_lab->VGASetPal(diffcmap, 256);
+				g_lab->setPalette(diffcmap, 256);
 				g_lab->waitTOF();
 				g_lab->waitTOF();
 			} else if (APtr->Param1 == 4) { /* white the palette */
@@ -575,7 +575,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 				g_lab->waitTOF();
 			} else if (APtr->Param1 == 6) { /* Restore the palette */
 				g_lab->waitTOF();
-				g_lab->VGASetPal(diffcmap, 256);
+				g_lab->setPalette(diffcmap, 256);
 				g_lab->waitTOF();
 				g_lab->waitTOF();
 			} else if (APtr->Param1 == 7) { /* Quick pause */
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index bfe574a..9e87ad9 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -140,7 +140,7 @@ void LabEngine::diffNextFrame() {
 				}
 
 				if (IsPal && !nopalchange) {
-					VGASetPal(diffcmap, 256);
+					setPalette(diffcmap, 256);
 					IsPal = false;
 				}
 
@@ -148,7 +148,7 @@ void LabEngine::diffNextFrame() {
 			}
 
 			if (IsPal && !nopalchange && !IsBM && !donepal) {
-				VGASetPal(diffcmap, 256);
+				setPalette(diffcmap, 256);
 				IsPal = false;
 			}
 
@@ -163,7 +163,7 @@ void LabEngine::diffNextFrame() {
 			CurBit = 0;
 
 			if (DispBitMap->Flags & BITMAPF_VIDEO)
-				WSDL_UpdateScreen();
+				screenUpdate();
 
 			return; /* done with the next frame. */
 		}
@@ -268,7 +268,7 @@ void LabEngine::diffNextFrame() {
 				_event->mouseShow();
 
 				if (!didTOF)
-					WSDL_UpdateScreen();
+					screenUpdate();
 
 				return;
 			}
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index e3d1541..f350a5c 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -162,7 +162,7 @@ void showCombination(const char *filename) {
 
 	doCombination();
 
-	g_lab->VGASetPal(diffcmap, 256);
+	g_lab->setPalette(diffcmap, 256);
 }
 
 
@@ -313,7 +313,7 @@ void showTile(const char *filename, bool showsolution) {
 
 	doTile(showsolution);
 
-	g_lab->VGASetPal(diffcmap, 256);
+	g_lab->setPalette(diffcmap, 256);
 }
 
 static void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
@@ -471,7 +471,7 @@ void doNotes() {
 
 	flowText(BigMsgFont, -2 + SVGACord(1), 0, 0, false, false, true, true, VGAScaleX(25) + SVGACord(15), VGAScaleY(50), VGAScaleX(295) - SVGACord(15), VGAScaleY(148), ntext);
 
-	g_lab->VGASetPal(diffcmap, 256);
+	g_lab->setPalette(diffcmap, 256);
 	freeAllStolenMem();
 }
 
@@ -533,7 +533,7 @@ void doWestPaper() {
 
 	CharsPrinted = flowText(BigMsgFont, -4, 0, 0, false, false, false, true, VGAScaleX(162), VGAScaleY(y), VGAScaleX(275), VGAScaleY(148), ntext);
 
-	g_lab->VGASetPal(diffcmap, 256);
+	g_lab->setPalette(diffcmap, 256);
 	freeAllStolenMem();
 }
 
@@ -841,7 +841,7 @@ bool saveRestoreGame() {
 		}
 	}
 
-	g_lab->WSDL_UpdateScreen();
+	g_lab->screenUpdate();
 
 	return isOK;
 }
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index d307164..bb313e1 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -63,10 +63,10 @@ void LabEngine::changeVolume(int delta) {
 	warning("STUB: changeVolume()");
 }
 
-uint16 LabEngine::WSDL_GetNextChar() {
+uint16 LabEngine::getNextChar() {
 	uint16 c = 0;
 
-	WSDL_ProcessInput(0);
+	processInput();
 	if (_nextKeyIn != _nextKeyOut) {
 		c = _keyBuf[_nextKeyOut];
 		_nextKeyOut = ((((unsigned int)((_nextKeyOut + 1) >> 31) >> 26) + (byte)_nextKeyOut + 1) & 0x3F)
@@ -76,12 +76,12 @@ uint16 LabEngine::WSDL_GetNextChar() {
 	return c;
 }
 
-bool LabEngine::WSDL_HasNextChar() {
-	WSDL_ProcessInput(0);
+bool LabEngine::haveNextChar() {
+	processInput();
 	return _nextKeyIn != _nextKeyOut;
 }
 
-void LabEngine::WSDL_ProcessInput(bool can_delay) {
+void LabEngine::processInput(bool can_delay) {
 	Common::Event event;
 
 	if (1 /*!g_IgnoreProcessInput*/) {
@@ -167,7 +167,7 @@ void LabEngine::WSDL_ProcessInput(bool can_delay) {
 }
 
 Common::Point LabEngine::WSDL_GetMousePos() {
-	WSDL_ProcessInput(0);
+	processInput();
 
 	return _mousePos;
 }
@@ -176,7 +176,7 @@ void LabEngine::waitTOF() {
 	g_system->copyRectToScreen(_displayBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight);
 	g_system->updateScreen();
 
-  	WSDL_ProcessInput(0);
+  	processInput();
 
   	uint32 now;
 
@@ -186,7 +186,7 @@ void LabEngine::waitTOF() {
 	_lastWaitTOFTicks = now;
 }
 
-void LabEngine::WSDL_SetColors(byte *buf, uint16 first, uint16 numreg, uint16 slow) {
+void LabEngine::applyPalette(byte *buf, uint16 first, uint16 numreg, uint16 slow) {
 	byte tmp[256 * 3];
 
 	for (int i = 0; i < 256 * 3; i++) {
@@ -211,12 +211,12 @@ void LabEngine::WSDL_SetColors(byte *buf, uint16 first, uint16 numreg, uint16 sl
 /*           selected.                                                       */
 /*****************************************************************************/
 void LabEngine::writeColorRegs(byte *buf, uint16 first, uint16 numreg) {
-	WSDL_SetColors(buf, first, numreg, 0);
+	applyPalette(buf, first, numreg, 0);
 	memcpy(&(_curvgapal[first * 3]), buf, numreg * 3);
 }
 
 void LabEngine::writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg) {
-	WSDL_SetColors(buf, first, numreg, 1);
+	applyPalette(buf, first, numreg, 1);
 	memcpy(&(_curvgapal[first * 3]), buf, numreg * 3);
 }
 
@@ -229,16 +229,16 @@ void LabEngine::writeColorReg(byte *buf, uint16 regnum) {
 	writeColorRegs(buf, regnum, 1);
 }
 
-void LabEngine::VGASetPal(void *cmap, uint16 numcolors) {
+void LabEngine::setPalette(void *cmap, uint16 numcolors) {
 	if (memcmp(cmap, _curvgapal, numcolors * 3) != 0)
 		writeColorRegs((byte *)cmap, 0, numcolors);
 }
 
-void LabEngine::WSDL_UpdateScreen() {
+void LabEngine::screenUpdate() {
 	g_system->copyRectToScreen(_displayBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight);
 	g_system->updateScreen();
 
-	WSDL_ProcessInput(0);
+	processInput();
 }
 
 /*****************************************************************************/


Commit: fa8d319e3106f1b8ee5c8ebfcb2e8a8df8ca5bf0
    https://github.com/scummvm/scummvm/commit/fa8d319e3106f1b8ee5c8ebfcb2e8a8df8ca5bf0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:45+01:00

Commit Message:
LAB: More renames

Changed paths:
    engines/lab/engine.cpp
    engines/lab/lab.h
    engines/lab/vga.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index b7970ae..05a2196 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -737,7 +737,7 @@ void LabEngine::mainGameLoop() {
 					GotMessage = true;
 					mayShowCrumbIndicator();
 					screenUpdate();
-					if (!from_crumbs(GADGETUP, code, 0, WSDL_GetMousePos(), curInv, curMsg, forceDraw, code, actionMode))
+					if (!from_crumbs(GADGETUP, code, 0, getMousePos(), curInv, curMsg, forceDraw, code, actionMode))
 						break;
 				}
 			}
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 7cca825..0b2e777 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -190,7 +190,7 @@ private:
 	/*---------- Drawing Routines ----------*/
 
 	void drawMaskImage(Image *Im, uint16 x, uint16 y);
-	Common::Point WSDL_GetMousePos();
+	Common::Point getMousePos();
 	void changeVolume(int delta);
 	void applyPalette(byte *buf, uint16 first, uint16 numreg, uint16 slow);
 
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index bb313e1..79261df 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -166,7 +166,7 @@ void LabEngine::processInput(bool can_delay) {
 		g_system->delayMillis(10);
 }
 
-Common::Point LabEngine::WSDL_GetMousePos() {
+Common::Point LabEngine::getMousePos() {
 	processInput();
 
 	return _mousePos;


Commit: 29fc7a56c1163d2931980e1bec1ab440183ab639
    https://github.com/scummvm/scummvm/commit/29fc7a56c1163d2931980e1bec1ab440183ab639
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:45+01:00

Commit Message:
LAB: Fix warning

Changed paths:
    engines/lab/labsets.cpp



diff --git a/engines/lab/labsets.cpp b/engines/lab/labsets.cpp
index edd7646..ad721fa 100644
--- a/engines/lab/labsets.cpp
+++ b/engines/lab/labsets.cpp
@@ -61,7 +61,7 @@ void LargeSet::exclElement(uint16 element) {
 bool LargeSet::readInitialConditions(const char *fileName) {
 	Common::File *file;
 
-	if (file = _vm->_resource->openDataFile(fileName, MKTAG('C', 'O', 'N', '0'))) {
+	if ((file = _vm->_resource->openDataFile(fileName, MKTAG('C', 'O', 'N', '0')))) {
 		uint16 conditions = file->readUint16LE();
 		for (int i = 0; i < conditions; i++) {
 			inclElement(file->readUint16LE());


Commit: 06b8eb856e5150419e4fd2f54fa951829dc278cb
    https://github.com/scummvm/scummvm/commit/06b8eb856e5150419e4fd2f54fa951829dc278cb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:45+01:00

Commit Message:
LAB: C++'ify vga.cpp

Changed paths:
    engines/lab/vga.cpp



diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 79261df..48c82b4 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -41,8 +41,8 @@ namespace Lab {
 /*****************************************************************************/
 /* Sets up either a low-res or a high-res 256 color screen.                  */
 /*****************************************************************************/
-bool LabEngine::createScreen(bool HiRes) {
-	if (HiRes) {
+bool LabEngine::createScreen(bool hiRes) {
+	if (hiRes) {
 		_screenWidth  = 640;
 		_screenHeight = 480;
 	} else {
@@ -254,15 +254,11 @@ byte *LabEngine::getVGABaseAddr() {
 /*****************************************************************************/
 /* Draws an image to the screen.                                             */
 /*****************************************************************************/
-void LabEngine::drawImage(Image *Im, uint16 x, uint16 y) {
-	int sx, sy, dx, dy, w, h;
-
-	sx = 0;
-	sy = 0;
-	dx = x;
-	dy = y;
-	w = Im->Width;
-	h = Im->Height;
+void LabEngine::drawImage(Image *im, uint16 x, uint16 y) {
+	int sx = 0, sy = 0;
+	int dx = x, dy = y;
+	int w = im->Width;
+	int h = im->Height;
 
 	if (dx < 0) {
 		sx -= dx;
@@ -283,12 +279,12 @@ void LabEngine::drawImage(Image *Im, uint16 x, uint16 y) {
 		h = _screenHeight - dy;
 
 	if ((w > 0) && (h > 0)) {
-		byte *s = Im->ImageData + sy * Im->Width + sx;
+		byte *s = im->ImageData + sy * im->Width + sx;
 		byte *d = getVGABaseAddr() + dy * _screenWidth + dx;
 
 		while (h-- > 0) {
 			memcpy(d, s, w);
-			s += Im->Width;
+			s += im->Width;
 			d += _screenWidth;
 		}
 	}
@@ -297,15 +293,11 @@ void LabEngine::drawImage(Image *Im, uint16 x, uint16 y) {
 /*****************************************************************************/
 /* Draws an image to the screen.                                             */
 /*****************************************************************************/
-void LabEngine::drawMaskImage(Image *Im, uint16 x, uint16 y) {
-	int sx, sy, dx, dy, w, h;
-
-	sx = 0;
-	sy = 0;
-	dx = x;
-	dy = y;
-	w = Im->Width;
-	h = Im->Height;
+void LabEngine::drawMaskImage(Image *im, uint16 x, uint16 y) {
+	int sx = 0, sy = 0;
+	int dx = x, dy = y;
+	int w = im->Width;
+	int h = im->Height;
 
 	if (dx < 0) {
 		sx -= dx;
@@ -326,7 +318,7 @@ void LabEngine::drawMaskImage(Image *Im, uint16 x, uint16 y) {
 		h = _screenHeight - dy;
 
 	if ((w > 0) && (h > 0)) {
-		byte *s = Im->ImageData + sy * Im->Width + sx;
+		byte *s = im->ImageData + sy * im->Width + sx;
 		byte *d = getVGABaseAddr() + dy * _screenWidth + dx;
 
 		while (h-- > 0) {
@@ -341,7 +333,7 @@ void LabEngine::drawMaskImage(Image *Im, uint16 x, uint16 y) {
 				else dd++;
 			}
 
-			s += Im->Width;
+			s += im->Width;
 			d += _screenWidth;
 		}
 	}
@@ -350,15 +342,11 @@ void LabEngine::drawMaskImage(Image *Im, uint16 x, uint16 y) {
 /*****************************************************************************/
 /* Reads an image from the screen.                                           */
 /*****************************************************************************/
-void LabEngine::readScreenImage(Image *Im, uint16 x, uint16 y) {
-	int sx, sy, dx, dy, w, h;
-
-	sx = 0;
-	sy = 0;
-	dx = x;
-	dy = y;
-	w = Im->Width;
-	h = Im->Height;
+void LabEngine::readScreenImage(Image *im, uint16 x, uint16 y) {
+	int sx = 0, sy = 0;
+	int	dx = x, dy = y;
+	int w = im->Width;
+	int h = im->Height;
 
 	if (dx < 0) {
 		sx -= dx;
@@ -379,12 +367,12 @@ void LabEngine::readScreenImage(Image *Im, uint16 x, uint16 y) {
 		h = _screenHeight - dy;
 
 	if ((w > 0) && (h > 0)) {
-		byte *s = Im->ImageData + sy * Im->Width + sx;
+		byte *s = im->ImageData + sy * im->Width + sx;
 		byte *d = getVGABaseAddr() + dy * _screenWidth + dx;
 
 		while (h-- > 0) {
 			memcpy(s, d, w);
-			s += Im->Width;
+			s += im->Width;
 			d += _screenWidth;
 		}
 	}
@@ -394,18 +382,16 @@ void LabEngine::readScreenImage(Image *Im, uint16 x, uint16 y) {
 /* Blits a piece of one image to another.                                    */
 /* NOTE: for our purposes, assumes that ImDest is to be in VGA memory.       */
 /*****************************************************************************/
-void LabEngine::bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest,
+void LabEngine::bltBitMap(Image *imSource, uint16 xs, uint16 ys, Image *imDest,
 					uint16 xd, uint16 yd, uint16 width, uint16 height) {
 	// I think the old code assumed that the source image data was valid for the given box.
 	// I will proceed on that assumption.
-	int sx, sy, dx, dy, w, h;
-
-	sx = xs;
-	sy = ys;
-	dx = xd;
-	dy = yd;
-	w = width;
-	h = height;
+	int sx = xs;
+	int sy = ys;
+	int dx = xd;
+	int dy = yd;
+	int w = width;
+	int h = height;
 
 	if (dx < 0) {
 		sx -= dx;
@@ -419,18 +405,20 @@ void LabEngine::bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest,
 		dy = 0;
 	}
 
-	if (dx + w > ImDest->Width) w = ImDest->Width - dx;
+	if (dx + w > imDest->Width)
+		w = imDest->Width - dx;
 
-	if (dy + h > ImDest->Height) h = ImDest->Height - dy;
+	if (dy + h > imDest->Height)
+		h = imDest->Height - dy;
 
 	if (w > 0 && h > 0) {
-		byte *s = ImSource->ImageData + sy * ImSource->Width + sx;
-		byte *d = ImDest->ImageData + dy * ImDest->Width + dx;
+		byte *s = imSource->ImageData + sy * imSource->Width + sx;
+		byte *d = imDest->ImageData + dy * imDest->Width + dx;
 
 		while (h-- > 0) {
 			memcpy(d, s, w);
-			s += ImSource->Width;
-			d += ImDest->Width;
+			s += imSource->Width;
+			d += imDest->Width;
 		}
 	}
 }
@@ -441,10 +429,10 @@ void LabEngine::bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest,
 /* function will fail.                                                       */
 /*****************************************************************************/
 void LabEngine::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	Image Im;
+	Image im;
 	uint16 temp;
 
-	Im.ImageData = _tempScrollData;
+	im.ImageData = _tempScrollData;
 
 	if (x1 > x2) {
 		temp = x2;
@@ -459,20 +447,20 @@ void LabEngine::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16
 	}
 
 	if (dx > 0) {
-		Im.Width = x2 - x1 + 1 - dx;
-		Im.Height = y2 - y1 + 1;
+		im.Width = x2 - x1 + 1 - dx;
+		im.Height = y2 - y1 + 1;
 
-		readScreenImage(&Im, x1, y1);
-		drawImage(&Im, x1 + dx, y1);
+		readScreenImage(&im, x1, y1);
+		drawImage(&im, x1 + dx, y1);
 
 		setAPen(0);
 		rectFill(x1, y1, x1 + dx - 1, y2);
 	} else if (dx < 0) {
-		Im.Width = x2 - x1 + 1 + dx;
-		Im.Height = y2 - y1 + 1;
+		im.Width = x2 - x1 + 1 + dx;
+		im.Height = y2 - y1 + 1;
 
-		readScreenImage(&Im, x1 - dx, y1);
-		drawImage(&Im, x1, y1);
+		readScreenImage(&im, x1 - dx, y1);
+		drawImage(&im, x1, y1);
 
 		setAPen(0);
 		rectFill(x2 + dx + 1, y1, x2, y2);
@@ -483,10 +471,10 @@ void LabEngine::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16
 /* Scrolls the display in the y direction by blitting.                       */
 /*****************************************************************************/
 void LabEngine::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	Image Im;
+	Image im;
 	uint16 temp;
 
-	Im.ImageData = _tempScrollData;
+	im.ImageData = _tempScrollData;
 
 	if (x1 > x2) {
 		temp = x2;
@@ -501,20 +489,20 @@ void LabEngine::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16
 	}
 
 	if (dy > 0) {
-		Im.Width = x2 - x1 + 1;
-		Im.Height = y2 - y1 + 1 - dy;
+		im.Width = x2 - x1 + 1;
+		im.Height = y2 - y1 + 1 - dy;
 
-		readScreenImage(&Im, x1, y1);
-		drawImage(&Im, x1, y1 + dy);
+		readScreenImage(&im, x1, y1);
+		drawImage(&im, x1, y1 + dy);
 
 		setAPen(0);
 		rectFill(x1, y1, x2, y1 + dy - 1);
 	} else if (dy < 0) {
-		Im.Width = x2 - x1 + 1;
-		Im.Height = y2 - y1 + 1 + dy;
+		im.Width = x2 - x1 + 1;
+		im.Height = y2 - y1 + 1 + dy;
 
-		readScreenImage(&Im, x1, y1 - dy);
-		drawImage(&Im, x1, y1);
+		readScreenImage(&im, x1, y1 - dy);
+		drawImage(&im, x1, y1);
 
 		setAPen(0);
 		rectFill(x1, y2 + dy + 1, x2, y2);
@@ -532,12 +520,10 @@ void LabEngine::setAPen(byte pennum) {
 /* Fills in a rectangle.                                                     */
 /*****************************************************************************/
 void LabEngine::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	int dx, dy, w, h;
-
-	dx = x1;
-	dy = y1;
-	w = x2 - x1 + 1;
-	h = y2 - y1 + 1;
+	int dx = x1;
+	int dy = y1;
+	int w = x2 - x1 + 1;
+	int h = y2 - y1 + 1;
 
 	if (dx < 0) {
 		w += dx;
@@ -589,12 +575,10 @@ void LabEngine::drawHLine(uint16 x1, uint16 y, uint16 x2) {
 /* Ghoasts a region on the screen using the desired pen color.               */
 /*****************************************************************************/
 void LabEngine::ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	int dx, dy, w, h;
-
-	dx = x1;
-	dy = y1;
-	w = x2 - x1 + 1;
-	h = y2 - y1 + 1;
+	int dx = x1;
+	int dy = y1;
+	int w = x2 - x1 + 1;
+	int h = y2 - y1 + 1;
 
 	if (dx < 0) {
 		w += dx;


Commit: 51d04a81875ba86ce3e882fc0e005e1142e05a8e
    https://github.com/scummvm/scummvm/commit/51d04a81875ba86ce3e882fc0e005e1142e05a8e
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:45+01:00

Commit Message:
LAB: Remove leftover debug code

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 05a2196..d96111f 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -1288,13 +1288,6 @@ void LabEngine::go() {
 
 	_isHiRes = ((getFeatures() & GF_LOWRES) == 0);
 
-#if 0
-	if (_isHiRes)
-		warning("Running in HiRes mode");
-	else
-		warning("Running in LowRes mode");
-#endif
-
 	bool mem = false;
 	if (initBuffer(BUFFERSIZE, true)) {
 		mem = true;


Commit: 24684fe321f337caf96af917a3b7e647e8fd113b
    https://github.com/scummvm/scummvm/commit/24684fe321f337caf96af917a3b7e647e8fd113b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:45+01:00

Commit Message:
LAB: Move getText to the Resource class

Also, make getFont() error out when it can't find a font, and get rid
of BigMsgFont

Changed paths:
    engines/lab/lab.h
    engines/lab/labfun.h
    engines/lab/map.cpp
    engines/lab/resource.cpp
    engines/lab/resource.h
    engines/lab/special.cpp



diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 0b2e777..36a3c6c 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -176,8 +176,8 @@ public:
 	void drawJournal(uint16 wipenum, bool needFade);
 	void processJournal();
 	void doJournal();
-	void drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive);
-	void processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive);
+	void processMonitor(char *ntext, TextFont *monitorFont, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void eatMessages();
 	void drawStaticMessage(byte index);
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 7fffb1b..ea2c985 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -189,7 +189,6 @@ char *translateFileName(const char *filename);
 
 void fade(bool fadein, uint16 res);
 void setAmigaPal(uint16 *pal, uint16 numcolors);
-char *getText(const char *filename);
 void readImage(byte **buffer, Image **im);
 void doMap(uint16 CurRoom);
 void doJournal();
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 2db3610..02cdbfb 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -42,10 +42,6 @@
 
 namespace Lab {
 
-static TextFont *BigMsgFont;
-static TextFont bmf;
-
-
 extern uint16 Direction;
 
 extern CloseDataPtr CPtr;
@@ -70,33 +66,6 @@ void setAmigaPal(uint16 *pal, uint16 numcolors) {
 	g_lab->writeColorRegsSmooth(vgapal, 0, 16);
 }
 
-void decrypt(byte *text) {
-	while (text && *text != '\0') {
-		*text++ -= (byte)95;
-	}
-}
-
-/*****************************************************************************/
-/* Gets a chunk of text and puts it into the graphics memory.                */
-/*****************************************************************************/
-char *getText(const char *filename) {
-	bool dodecrypt;
-	byte **tfile;
-
-	g_lab->_music->updateMusic();
-	dodecrypt = (isBuffered(filename) == NULL);
-	tfile = g_lab->_music->newOpen(filename);
-
-	if (!tfile)
-		return NULL;
-
-	if (dodecrypt)
-		decrypt(*tfile);
-
-	return (char *)*tfile;
-}
-
-
 
 /*****************************************************************************/
 /* Reads in an image from disk.                                              */
@@ -193,11 +162,6 @@ static bool loadMapData() {
 	Gadget *gptr;
 	uint16 counter;
 
-	BigMsgFont = &bmf;
-
-	if (!(BigMsgFont = g_lab->_resource->getFont("P:Map.fon")))
-		BigMsgFont = MsgFont;
-
 	resetBuffer();  /* Make images load into start of buffer */
 	buffer = g_lab->_music->newOpen("P:MapImage", Size);
 
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 290216c..0c60924 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -58,7 +58,7 @@ void Resource::readStaticText() {
 TextFont *Resource::getFont(const char *fileName) {
 	Common::File *dataFile;
 	if (!(dataFile = openDataFile(fileName, MKTAG('V', 'G', 'A', 'F'))))
-		return NULL;
+		error("getFont: couldn't open %s (%s)", translateFileName(fileName), fileName);
 
 	uint32 headerSize = 4L + 2L + 256 * 3 + 4L;
 	uint32 fileSize = dataFile->size();
@@ -80,6 +80,25 @@ TextFont *Resource::getFont(const char *fileName) {
 	return textfont;
 }
 
+char *Resource::getText(const char *fileName) {
+	Common::File *dataFile = new Common::File();
+	dataFile->open(translateFileName(fileName));
+	if (!dataFile->isOpen())
+		error("getText: couldn't open %s (%s)", translateFileName(fileName), fileName);
+
+	g_lab->_music->updateMusic();
+
+	byte count = dataFile->size();
+	byte *buffer = new byte[count];
+	byte *text = buffer;
+	dataFile->read(buffer, count);
+
+	while (text && *text != '\0')
+		*text++ -= (byte)95;
+
+	return (char *)buffer;
+}
+
 bool Resource::readRoomData(const char *fileName) {
 	Common::File *dataFile;
 	if (!(dataFile = openDataFile(fileName, MKTAG('D', 'O', 'R', '1'))))
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index 841aa09..b9bdbbb 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -102,7 +102,8 @@ public:
 	bool readRoomData(const char *fileName);
 	bool readInventory(const char *fileName);
 	bool readViews(uint16 roomNum);
-	TextFont *getFont(const char *filename);
+	TextFont *getFont(const char *fileName);
+	char *getText(const char *fileName);
 	Common::String getStaticText(byte index) const { return _staticText[index]; }
 
 private:
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index f350a5c..6be525d 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -54,8 +54,7 @@ static Image *Images[10];
 byte combination[6] = { 0, 0, 0, 0, 0, 0 }, solution[] = { 0, 4, 0, 8, 7, 2 };
 static uint16 combx[] = { 45, 83, 129, 166, 211, 248 };
 
-static TextFont *BigMsgFont;
-static TextFont bmfont;
+static TextFont *journalFont;
 static char *journaltext, *journaltexttitle;
 static uint16 JPage = 0;
 static bool lastpage = false;
@@ -456,23 +455,15 @@ void mouseTile(Common::Point pos) {
 /* Does the things to properly set up the detective notes.                   */
 /*****************************************************************************/
 void doNotes() {
-	char *ntext;
-
-	/* Load in the data */
-	BigMsgFont = &bmfont;
-
-	if (!(BigMsgFont = g_lab->_resource->getFont("P:Note.fon"))) {
-		BigMsgFont = NULL;
-		return;
-	}
-
-	if ((ntext = getText("Lab:Rooms/Notes")) == NULL)
-		return;
-
-	flowText(BigMsgFont, -2 + SVGACord(1), 0, 0, false, false, true, true, VGAScaleX(25) + SVGACord(15), VGAScaleY(50), VGAScaleX(295) - SVGACord(15), VGAScaleY(148), ntext);
+	TextFont *noteFont = g_lab->_resource->getFont("P:Note.fon");
+	char *ntext = g_lab->_resource->getText("Lab:Rooms/Notes");
 
+	flowText(noteFont, -2 + SVGACord(1), 0, 0, false, false, true, true, VGAScaleX(25) + SVGACord(15), VGAScaleY(50), VGAScaleX(295) - SVGACord(15), VGAScaleY(148), ntext);
 	g_lab->setPalette(diffcmap, 256);
-	freeAllStolenMem();
+
+	delete[] noteFont->data;
+	free(noteFont);
+	delete[] ntext;
 }
 
 
@@ -482,56 +473,39 @@ void doNotes() {
 /*****************************************************************************/
 void doWestPaper() {
 	char *ntext;
+	TextFont *paperFont;
 	int32 FileLen, CharsPrinted;
 	uint16 y = 268;
 
-	BigMsgFont = &bmfont;
-
-	if (!(BigMsgFont = g_lab->_resource->getFont("P:News22.fon"))) {
-		BigMsgFont = NULL;
-		return;
-	}
-
-	if ((ntext = getText("Lab:Rooms/Date")) == NULL)
-		return;
-
-	flowText(BigMsgFont, 0, 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(77) + SVGACord(2), VGAScaleX(262), VGAScaleY(91), ntext);
-
-	BigMsgFont = &bmfont;
-
-	if (!(BigMsgFont = g_lab->_resource->getFont("P:News32.fon"))) {
-		BigMsgFont = NULL;
-		return;
-	}
-
-	if ((ntext = getText("Lab:Rooms/Headline")) == NULL)
-		return;
+	paperFont = g_lab->_resource->getFont("P:News22.fon");
+	ntext = g_lab->_resource->getText("Lab:Rooms/Date");
+	flowText(paperFont, 0, 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(77) + SVGACord(2), VGAScaleX(262), VGAScaleY(91), ntext);
+	delete[] paperFont->data;
+	free(paperFont);
+	delete[] ntext;
 
+	paperFont = g_lab->_resource->getFont("P:News32.fon");
+	ntext = g_lab->_resource->getText("Lab:Rooms/Headline");
 	FileLen = strlen(ntext) - 1;
-	CharsPrinted = flowText(BigMsgFont, -8, 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(86) - SVGACord(2), VGAScaleX(262), VGAScaleY(118), ntext);
-
+	CharsPrinted = flowText(paperFont, -8, 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(86) - SVGACord(2), VGAScaleX(262), VGAScaleY(118), ntext);
 	if (CharsPrinted < FileLen) {
 		y = 130 - SVGACord(5);
-		flowText(BigMsgFont, -8 - SVGACord(1), 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(86) - SVGACord(2), VGAScaleX(262), VGAScaleY(132), ntext);
+		flowText(paperFont, -8 - SVGACord(1), 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(86) - SVGACord(2), VGAScaleX(262), VGAScaleY(132), ntext);
 	} else
 		y = 115 - SVGACord(5);
-
-	BigMsgFont = &bmfont;
-
-	if (!(BigMsgFont = g_lab->_resource->getFont("P:Note.fon"))) {
-		BigMsgFont = NULL;
-		return;
-	}
-
-	if ((ntext = getText("Lab:Rooms/Col1")) == NULL)
-		return;
-
-	CharsPrinted = flowText(BigMsgFont, -4, 0, 0, false, false, false, true, VGAScaleX(45), VGAScaleY(y), VGAScaleX(158), VGAScaleY(148), ntext);
-
-	if ((ntext = getText("Lab:Rooms/Col2")) == NULL)
-		return;
-
-	CharsPrinted = flowText(BigMsgFont, -4, 0, 0, false, false, false, true, VGAScaleX(162), VGAScaleY(y), VGAScaleX(275), VGAScaleY(148), ntext);
+	delete[] paperFont->data;
+	free(paperFont);
+	delete[] ntext;
+
+	paperFont = g_lab->_resource->getFont("P:Note.fon");
+	ntext = g_lab->_resource->getText("Lab:Rooms/Col1");
+	CharsPrinted = flowText(paperFont, -4, 0, 0, false, false, false, true, VGAScaleX(45), VGAScaleY(y), VGAScaleX(158), VGAScaleY(148), ntext);
+	delete[] ntext;
+	ntext = g_lab->_resource->getText("Lab:Rooms/Col2");
+	CharsPrinted = flowText(paperFont, -4, 0, 0, false, false, false, true, VGAScaleX(162), VGAScaleY(y), VGAScaleX(275), VGAScaleY(148), ntext);
+	delete[] ntext;
+	delete[] paperFont->data;
+	free(paperFont);
 
 	g_lab->setPalette(diffcmap, 256);
 	freeAllStolenMem();
@@ -546,12 +520,7 @@ static bool loadJournalData() {
 	Gadget *TopGadget = &BackG;
 	bool bridge, dirty, news, clean;
 
-	BigMsgFont = &bmfont;
-
-	if (!(BigMsgFont = g_lab->_resource->getFont("P:Journal.fon"))) {
-		BigMsgFont = NULL;
-		return false;
-	}
+	journalFont = g_lab->_resource->getFont("P:Journal.fon");
 
 	g_lab->_music->updateMusic();
 
@@ -580,11 +549,8 @@ static bool loadJournalData() {
 	else if (bridge)
 		filename[11] = '1';
 
-	if ((journaltext = getText(filename)) == NULL)
-		return false;
-
-	if ((journaltexttitle = getText("Lab:Rooms/jt")) == NULL)
-		return false;
+	journaltext = g_lab->_resource->getText(filename);
+	journaltexttitle = g_lab->_resource->getText("Lab:Rooms/jt");
 
 	buffer = g_lab->_music->newOpen("P:JImage");
 
@@ -630,7 +596,7 @@ static void drawJournalText() {
 	while (DrawingToPage < JPage) {
 		g_lab->_music->updateMusic();
 		CurText = (char *)(journaltext + CharsDrawn);
-		CharsDrawn += flowText(BigMsgFont, -2, 2, 0, false, false, false, false, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText);
+		CharsDrawn += flowText(journalFont, -2, 2, 0, false, false, false, false, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText);
 
 		lastpage = (*CurText == 0);
 
@@ -642,16 +608,16 @@ static void drawJournalText() {
 
 	if (JPage <= 1) {
 		CurText = journaltexttitle;
-		flowTextToMem(&JBackImage, BigMsgFont, -2, 2, 0, false, true, true, true, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText);
+		flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, true, true, true, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText);
 	} else {
 		CurText = (char *)(journaltext + CharsDrawn);
-		CharsDrawn += flowTextToMem(&JBackImage, BigMsgFont, -2, 2, 0, false, false, false, true, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText);
+		CharsDrawn += flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText);
 	}
 
 	g_lab->_music->updateMusic();
 	CurText = (char *)(journaltext + CharsDrawn);
 	lastpage = (*CurText == 0);
-	flowTextToMem(&JBackImage, BigMsgFont, -2, 2, 0, false, false, false, true, VGAScaleX(171), VGAScaleY(32), VGAScaleX(271), VGAScaleY(148), CurText);
+	flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, VGAScaleX(171), VGAScaleY(32), VGAScaleX(271), VGAScaleY(148), CurText);
 
 	CurText = (char *)(journaltext + CharsDrawn);
 	lastpage = lastpage || (*CurText == 0);
@@ -869,7 +835,7 @@ static void getMonImages() {
 /*****************************************************************************/
 /* Draws the text for the monitor.                                           */
 /*****************************************************************************/
-void LabEngine::drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) {
+void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) {
 	uint16 DrawingToPage = 0, yspacing = 0, numlines, fheight;
 	int32 CharsDrawn    = 0L;
 	char *CurText = text;
@@ -883,7 +849,7 @@ void LabEngine::drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16
 		numlines += (*text - '0');
 		text += 2;
 
-		fheight = textHeight(BigMsgFont);
+		fheight = textHeight(monitorFont);
 		x1 = MonButton->Width + VGAScaleX(3);
 		MonGadHeight = MonButton->Height + VGAScaleY(3);
 
@@ -908,7 +874,7 @@ void LabEngine::drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16
 	while (DrawingToPage < monitorPage) {
 		_music->updateMusic();
 		CurText = (char *)(text + CharsDrawn);
-		CharsDrawn += flowText(BigMsgFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, CurText);
+		CharsDrawn += flowText(monitorFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, CurText);
 		lastpage = (*CurText == 0);
 
 		if (lastpage)
@@ -919,7 +885,7 @@ void LabEngine::drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16
 
 	CurText = (char *)(text + CharsDrawn);
 	lastpage = (*CurText == 0);
-	CharsDrawn = flowText(BigMsgFont, yspacing, 2, 0, false, false, false, true, x1, y1, x2, y2, CurText);
+	CharsDrawn = flowText(monitorFont, yspacing, 2, 0, false, false, false, true, x1, y1, x2, y2, CurText);
 	CurText += CharsDrawn;
 	lastpage = lastpage || (*CurText == 0);
 
@@ -929,7 +895,7 @@ void LabEngine::drawMonText(char *text, uint16 x1, uint16 y1, uint16 x2, uint16
 /*****************************************************************************/
 /* Processes user input.                                                     */
 /*****************************************************************************/
-void LabEngine::processMonitor(char *ntext, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	IntuiMessage *Msg;
 	uint32 Class;
 	uint16 Qualifier, Code, MouseX, MouseY;
@@ -953,10 +919,11 @@ void LabEngine::processMonitor(char *ntext, bool isinteractive, uint16 x1, uint1
 				monitorPage      = 0;
 				TextFileName = Test;
 
-				ntext = getText(TextFileName);
+				ntext = g_lab->_resource->getText(TextFileName);
 				fade(false, 0);
-				drawMonText(ntext, x1, y1, x2, y2, isinteractive);
+				drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
 				fade(true, 0);
+				delete[] ntext;
 			}
 		}
 
@@ -981,14 +948,14 @@ void LabEngine::processMonitor(char *ntext, bool isinteractive, uint16 x1, uint1
 					if ((MouseX >= VGAScaleX(259)) && (MouseX <= VGAScaleX(289))) {
 						if (!lastpage) {
 							monitorPage += 1;
-							drawMonText(ntext, x1, y1, x2, y2, isinteractive);
+							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
 						}
 					} else if ((MouseX >= VGAScaleX(0)) && (MouseX <= VGAScaleX(31))) {
 						return;
 					} else if ((MouseX >= VGAScaleX(290)) && (MouseX <= VGAScaleX(320))) {
 						if (monitorPage >= 1) {
 							monitorPage -= 1;
-							drawMonText(ntext, x1, y1, x2, y2, isinteractive);
+							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
 						}
 					} else if ((MouseX >= VGAScaleX(31)) && (MouseX <= VGAScaleX(59))) {
 						if (isinteractive) {
@@ -1000,7 +967,7 @@ void LabEngine::processMonitor(char *ntext, bool isinteractive, uint16 x1, uint1
 							}
 						} else if (monitorPage > 0) {
 							monitorPage = 0;
-							drawMonText(ntext, x1, y1, x2, y2, isinteractive);
+							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
 						}
 					}
 				} else if (isinteractive) {
@@ -1045,31 +1012,20 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 	lastpage = false;
 	FadePalette = hipal;
 
-	BigMsgFont = &bmfont;
-
-	if (!(BigMsgFont = _resource->getFont("P:Map.fon"))) {
-		freeAllStolenMem();
-		BigMsgFont = NULL;
-		return;
-	}
-
+	TextFont *monitorFont = _resource->getFont("P:Map.fon");
 	getMonImages();
 
-	if ((ntext = getText(textfile)) == NULL) {
-		freeAllStolenMem();
-		return;
-	}
-
+	ntext = _resource->getText(textfile);
 	loadBackPict(background, false);
-
-	drawMonText(ntext, x1, y1, x2, y2, isinteractive);
-
+	drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
 	_event->mouseShow();
 	fade(true, 0);
-	processMonitor(ntext, isinteractive, x1, y1, x2, y2);
+	processMonitor(ntext, monitorFont, isinteractive, x1, y1, x2, y2);
 	fade(false, 0);
 	_event->mouseHide();
-
+	delete[] ntext;
+	delete[] monitorFont->data;
+	free(monitorFont);
 	freeAllStolenMem();
 
 	setAPen(0);


Commit: 0fbf62f7f0115a0ad04b594f834e41cb7f719072
    https://github.com/scummvm/scummvm/commit/0fbf62f7f0115a0ad04b594f834e41cb7f719072
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:45+01:00

Commit Message:
LAB: Plug several font-related memory leaks. Some cleanup

Changed paths:
    engines/lab/intro.cpp
    engines/lab/intro.h
    engines/lab/resource.cpp
    engines/lab/special.cpp
    engines/lab/text.cpp



diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index b556501..e7f0187 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -42,7 +42,6 @@ extern char diffcmap[256 * 3];
 extern uint16 *FadePalette;
 
 Intro::Intro() {
-	_msgfont = &_filler;
 	_quitIntro = false;
 }
 
@@ -76,7 +75,7 @@ void Intro::introEatMessages() {
 /*****************************************************************************/
 /* Reads in a picture.                                                       */
 /*****************************************************************************/
-void Intro::doPictText(const char *filename, bool isscreen) {
+void Intro::doPictText(const char *filename, TextFont *msgFont, bool isscreen) {
 	uint32 lastsecs = 0L, lastmicros = 0L, secs = 0L, micros = 0L;
 	IntuiMessage *msg;
 	char path[50] = "Lab:rooms/Intro/";
@@ -118,7 +117,7 @@ void Intro::doPictText(const char *filename, bool isscreen) {
 				g_lab->setAPen(7);
 				g_lab->rectFill(VGAScaleX(10), VGAScaleY(10), VGAScaleX(310), VGAScaleY(190));
 
-				Drawn = flowText(_msgfont, (!g_lab->_isHiRes) * -1, 5, 7, false, false, true, true, VGAScaleX(14), VGAScaleY(11), VGAScaleX(306), VGAScaleY(189), (char *)curplace);
+				Drawn = flowText(msgFont, (!g_lab->_isHiRes) * -1, 5, 7, false, false, true, true, VGAScaleX(14), VGAScaleY(11), VGAScaleX(306), VGAScaleY(189), (char *)curplace);
 				fade(true, 0);
 			} else {
 				Drawn = g_lab->longDrawMessage((char *)curplace);
@@ -347,7 +346,7 @@ void Intro::introSequence() {
 	blackAllScreen();
 	g_lab->_music->updateMusic();
 
-	_msgfont = g_lab->_resource->getFont("P:Map.fon");
+	TextFont *msgFont = g_lab->_resource->getFont("P:Map.fon");
 
 	nopalchange = true;
 	nReadPict("Intro.1", true);
@@ -359,9 +358,9 @@ void Intro::introSequence() {
 		             (diffcmap[i * 3 + 2] >> 2);
 	}
 
-	doPictText("i.1", true);
-	doPictText("i.2A", true);
-	doPictText("i.2B", true);
+	doPictText("i.1", msgFont, true);
+	doPictText("i.2A", msgFont, true);
+	doPictText("i.2B", msgFont, true);
 
 	freeAllStolenMem();
 
@@ -370,28 +369,28 @@ void Intro::introSequence() {
 
 	_introDoBlack = true;
 	nReadPict("Station1", true);
-	doPictText("i.3", false);
+	doPictText("i.3", msgFont, false);
 
 	nReadPict("Station2", true);
-	doPictText("i.4", false);
+	doPictText("i.4", msgFont, false);
 
 	nReadPict("Stiles4", true);
-	doPictText("i.5", false);
+	doPictText("i.5", msgFont, false);
 
 	nReadPict("Stiles3", true);
-	doPictText("i.6", false);
+	doPictText("i.6", msgFont, false);
 
 	nReadPict("Platform2", true);
-	doPictText("i.7", false);
+	doPictText("i.7", msgFont, false);
 
 	nReadPict("Subway.1", true);
-	doPictText("i.8", false);
+	doPictText("i.8", msgFont, false);
 
 	nReadPict("Subway.2", true);
 
-	doPictText("i.9", false);
-	doPictText("i.10", false);
-	doPictText("i.11", false);
+	doPictText("i.9", msgFont, false);
+	doPictText("i.10", msgFont, false);
+	doPictText("i.11", msgFont, false);
 
 	if (!_quitIntro)
 		for (uint16 i = 0; i < 50; i++) {
@@ -401,60 +400,60 @@ void Intro::introSequence() {
 			g_lab->_music->updateMusic();
 			g_lab->waitTOF();
 			g_lab->setPalette(diffcmap, 256);
-			g_lab->	waitTOF();
+			g_lab->waitTOF();
 			g_lab->waitTOF();
 		}
 
-	doPictText("i.12", false);
-	doPictText("i.13", false);
+	doPictText("i.12", msgFont, false);
+	doPictText("i.13", msgFont, false);
 
 	_introDoBlack = false;
 	nReadPict("Daed0", true);
-	doPictText("i.14", false);
+	doPictText("i.14", msgFont, false);
 
 	nReadPict("Daed1", true);
-	doPictText("i.15", false);
+	doPictText("i.15", msgFont, false);
 
 	nReadPict("Daed2", true);
-	doPictText("i.16", false);
-	doPictText("i.17", false);
-	doPictText("i.18", false);
+	doPictText("i.16", msgFont, false);
+	doPictText("i.17", msgFont, false);
+	doPictText("i.18", msgFont, false);
 
 	nReadPict("Daed3", true);
-	doPictText("i.19", false);
-	doPictText("i.20", false);
+	doPictText("i.19", msgFont, false);
+	doPictText("i.20", msgFont, false);
 
 	nReadPict("Daed4", true);
-	doPictText("i.21", false);
+	doPictText("i.21", msgFont, false);
 
 	nReadPict("Daed5", true);
-	doPictText("i.22", false);
-	doPictText("i.23", false);
-	doPictText("i.24", false);
+	doPictText("i.22", msgFont, false);
+	doPictText("i.23", msgFont, false);
+	doPictText("i.24", msgFont, false);
 
 	nReadPict("Daed6", true);
-	doPictText("i.25", false);
-	doPictText("i.26", false);
+	doPictText("i.25", msgFont, false);
+	doPictText("i.26", msgFont, false);
 
 	nReadPict("Daed7", false);
-	doPictText("i.27", false);
-	doPictText("i.28", false);
+	doPictText("i.27", msgFont, false);
+	doPictText("i.28", msgFont, false);
 	stopDiffEnd();
 
 	nReadPict("Daed8", true);
-	doPictText("i.29", false);
-	doPictText("i.30", false);
+	doPictText("i.29", msgFont, false);
+	doPictText("i.30", msgFont, false);
 
 	nReadPict("Daed9", true);
-	doPictText("i.31", false);
-	doPictText("i.32", false);
-	doPictText("i.33", false);
+	doPictText("i.31", msgFont, false);
+	doPictText("i.32", msgFont, false);
+	doPictText("i.33", msgFont, false);
 
 	nReadPict("Daed9a", true);
 	nReadPict("Daed10", true);
-	doPictText("i.34", false);
-	doPictText("i.35", false);
-	doPictText("i.36", false);
+	doPictText("i.34", msgFont, false);
+	doPictText("i.35", msgFont, false);
+	doPictText("i.36", msgFont, false);
 
 	nReadPict("SubX", true);
 
@@ -463,6 +462,8 @@ void Intro::introSequence() {
 		g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
 		DoBlack = true;
 	}
+
+	closeFont(msgFont);
 }
 
 } // End of namespace Lab
diff --git a/engines/lab/intro.h b/engines/lab/intro.h
index 724feda..2979bcd 100644
--- a/engines/lab/intro.h
+++ b/engines/lab/intro.h
@@ -43,11 +43,10 @@ public:
 
 private:
 	void introEatMessages();
-	void doPictText(const char *Filename, bool isscreen);
+	void doPictText(const char *Filename, TextFont *msgFont, bool isscreen);
 	void musicDelay();
 	void nReadPict(const char *Filename, bool PlayOnce);
 
-	TextFont _filler, *_msgfont;
 	bool _quitIntro, _introDoBlack;
 };
 
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 0c60924..b1ad528 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -67,14 +67,13 @@ TextFont *Resource::getFont(const char *fileName) {
 
 	_vm->_music->updateMusic();
 
-	TextFont *textfont = (TextFont *)malloc(sizeof(TextFont));
+	TextFont *textfont = new TextFont();
 	textfont->DataLength = fileSize - headerSize;
 	textfont->Height = dataFile->readUint16LE();
 	dataFile->read(textfont->Widths, 256);
 	for (int i = 0; i < 256; i++)
 		textfont->Offsets[i] = dataFile->readUint16LE();
 	dataFile->skip(4);
-	// TODO: Fix memory leak!!
 	textfont->data = new byte[textfont->DataLength + 4];
 	dataFile->read(textfont->data, textfont->DataLength);
 	return textfont;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 6be525d..70ec15a 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -461,8 +461,7 @@ void doNotes() {
 	flowText(noteFont, -2 + SVGACord(1), 0, 0, false, false, true, true, VGAScaleX(25) + SVGACord(15), VGAScaleY(50), VGAScaleX(295) - SVGACord(15), VGAScaleY(148), ntext);
 	g_lab->setPalette(diffcmap, 256);
 
-	delete[] noteFont->data;
-	free(noteFont);
+	closeFont(noteFont);
 	delete[] ntext;
 }
 
@@ -480,8 +479,7 @@ void doWestPaper() {
 	paperFont = g_lab->_resource->getFont("P:News22.fon");
 	ntext = g_lab->_resource->getText("Lab:Rooms/Date");
 	flowText(paperFont, 0, 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(77) + SVGACord(2), VGAScaleX(262), VGAScaleY(91), ntext);
-	delete[] paperFont->data;
-	free(paperFont);
+	closeFont(paperFont);
 	delete[] ntext;
 
 	paperFont = g_lab->_resource->getFont("P:News32.fon");
@@ -493,8 +491,7 @@ void doWestPaper() {
 		flowText(paperFont, -8 - SVGACord(1), 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(86) - SVGACord(2), VGAScaleX(262), VGAScaleY(132), ntext);
 	} else
 		y = 115 - SVGACord(5);
-	delete[] paperFont->data;
-	free(paperFont);
+	closeFont(paperFont);
 	delete[] ntext;
 
 	paperFont = g_lab->_resource->getFont("P:Note.fon");
@@ -504,8 +501,7 @@ void doWestPaper() {
 	ntext = g_lab->_resource->getText("Lab:Rooms/Col2");
 	CharsPrinted = flowText(paperFont, -4, 0, 0, false, false, false, true, VGAScaleX(162), VGAScaleY(y), VGAScaleX(275), VGAScaleY(148), ntext);
 	delete[] ntext;
-	delete[] paperFont->data;
-	free(paperFont);
+	closeFont(paperFont);
 
 	g_lab->setPalette(diffcmap, 256);
 	freeAllStolenMem();
@@ -520,7 +516,7 @@ static bool loadJournalData() {
 	Gadget *TopGadget = &BackG;
 	bool bridge, dirty, news, clean;
 
-	journalFont = g_lab->_resource->getFont("P:Journal.fon");
+	journalFont = g_lab->_resource->getFont("P:Journal.fon");	// FIXME: memory leak
 
 	g_lab->_music->updateMusic();
 
@@ -1024,8 +1020,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 	fade(false, 0);
 	_event->mouseHide();
 	delete[] ntext;
-	delete[] monitorFont->data;
-	free(monitorFont);
+	closeFont(monitorFont);
 	freeAllStolenMem();
 
 	setAPen(0);
diff --git a/engines/lab/text.cpp b/engines/lab/text.cpp
index 3fc1b1a..a7b41f1 100644
--- a/engines/lab/text.cpp
+++ b/engines/lab/text.cpp
@@ -38,19 +38,19 @@ namespace Lab {
 /*****************************************************************************/
 /* Closes a font and frees all memory associated with it.                    */
 /*****************************************************************************/
-void closeFont(struct TextFont *tf) {
+void closeFont(TextFont *tf) {
 	if (tf) {
 		if (tf->data && tf->DataLength)
 			delete[] tf->data;
 
-		free(tf);
+		delete tf;
 	}
 }
 
 /*****************************************************************************/
 /* Returns the length of a text in the specified font.                       */
 /*****************************************************************************/
-uint16 textLength(struct TextFont *tf, const char *text, uint16 numchars) {
+uint16 textLength(TextFont *tf, const char *text, uint16 numchars) {
 	uint16 length = 0;
 
 	if (tf) {
@@ -66,7 +66,7 @@ uint16 textLength(struct TextFont *tf, const char *text, uint16 numchars) {
 /*****************************************************************************/
 /* Returns the height of a specified font.                                   */
 /*****************************************************************************/
-uint16 textHeight(struct TextFont *tf) {
+uint16 textHeight(TextFont *tf) {
 	return (tf) ? tf->Height : 0;
 }
 


Commit: f817c1de2e96da59362ea4e5cbdffe40fffa4dbb
    https://github.com/scummvm/scummvm/commit/f817c1de2e96da59362ea4e5cbdffe40fffa4dbb
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:45+01:00

Commit Message:
LAB: Get rid of stddefines

Changed paths:
  R engines/lab/stddefines.h
    engines/lab/allocroom.cpp
    engines/lab/diff.h
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/interface.cpp
    engines/lab/labfun.h
    engines/lab/labsets.cpp
    engines/lab/machine.cpp
    engines/lab/map.cpp
    engines/lab/mouse.cpp
    engines/lab/mouse.h
    engines/lab/music.cpp
    engines/lab/parsefun.h
    engines/lab/parsetypes.h
    engines/lab/processroom.cpp
    engines/lab/readdiff.cpp
    engines/lab/savegame.cpp
    engines/lab/special.cpp
    engines/lab/text.cpp
    engines/lab/text.h
    engines/lab/undiff.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/allocroom.cpp b/engines/lab/allocroom.cpp
index b98bd24..e960dda 100644
--- a/engines/lab/allocroom.cpp
+++ b/engines/lab/allocroom.cpp
@@ -28,7 +28,6 @@
  *
  */
 
-#include "lab/stddefines.h"
 #include "lab/parsetypes.h"
 
 namespace Lab {
diff --git a/engines/lab/diff.h b/engines/lab/diff.h
index b4436b8..5ed6278 100644
--- a/engines/lab/diff.h
+++ b/engines/lab/diff.h
@@ -31,17 +31,18 @@
 #ifndef LAB_DIFF_H
 #define LAB_DIFF_H
 
-#include "lab/stddefines.h"
 #include "common/file.h"
 
 namespace Lab {
 
 
 struct DIFFHeader {
-	uint16 Version, x, y;
-	char depth, fps;
-	uint32 BufferSize;
-	uint16 Machine;
+	uint16 Version;    // unused
+	uint16 x, y;
+	char depth;        // unused
+	char fps;
+	uint32 BufferSize; // unused
+	uint16 Machine;    // unused
 	uint32 Flags;
 };
 
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index d96111f..f845dfa 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -29,7 +29,6 @@
  */
 
 #include "lab/lab.h"
-#include "lab/stddefines.h"
 #include "lab/labfun.h"
 #include "lab/diff.h"
 #include "lab/text.h"
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 460d4d5..413796d 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -29,7 +29,6 @@
  */
 
 #include "lab/lab.h"
-#include "lab/stddefines.h"
 #include "lab/diff.h"
 #include "lab/parsetypes.h"
 #include "lab/labfun.h"
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index a31e289..f786bb8 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -30,7 +30,6 @@
 
 #include "lab/lab.h"
 #include "lab/labfun.h"
-#include "lab/stddefines.h"
 #include "lab/interface.h"
 #include "lab/mouse.h"
 #include "common/util.h"
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index ea2c985..4f7573e 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -32,7 +32,6 @@
 #define LAB_LABFUN_H
 
 #include "common/events.h"
-#include "lab/stddefines.h"
 #include "lab/parsetypes.h"
 
 // For the Music class - TODO: Move to another header file
diff --git a/engines/lab/labsets.cpp b/engines/lab/labsets.cpp
index ad721fa..2ab9abf 100644
--- a/engines/lab/labsets.cpp
+++ b/engines/lab/labsets.cpp
@@ -29,7 +29,6 @@
  */
 
 #include "lab/lab.h"
-#include "lab/stddefines.h"
 #include "lab/labfun.h"
 #include "lab/resource.h"
 
diff --git a/engines/lab/machine.cpp b/engines/lab/machine.cpp
index 2bef80d..0667772 100644
--- a/engines/lab/machine.cpp
+++ b/engines/lab/machine.cpp
@@ -29,9 +29,7 @@
  */
 
 #include "common/str.h"
-
 #include "lab/lab.h"
-#include "lab/stddefines.h"
 
 namespace Lab {
 
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 02cdbfb..36b01d1 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -29,7 +29,6 @@
  */
 
 #include "lab/lab.h"
-#include "lab/stddefines.h"
 #include "lab/labfun.h"
 #include "lab/diff.h"
 #include "lab/text.h"
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index a7e6296..9ff5117 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -30,7 +30,6 @@
 
 #include "lab/lab.h"
 #include "lab/mouse.h"
-#include "lab/stddefines.h"
 #include "lab/interface.h"
 
 namespace Lab {
diff --git a/engines/lab/mouse.h b/engines/lab/mouse.h
index 6468ba9..4bccb17 100644
--- a/engines/lab/mouse.h
+++ b/engines/lab/mouse.h
@@ -29,7 +29,6 @@
  */
 
 #include "common/events.h"
-#include "lab/stddefines.h"
 
 #ifndef LAB_MOUSE_H
 #define LAB_MOUSE_H
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index b6587eb..8d51320 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -30,7 +30,6 @@
 
 #include "audio/mixer.h"
 
-#include "lab/stddefines.h"
 #include "lab/labfun.h"
 #include "lab/mouse.h"
 #include "lab/music.h"
diff --git a/engines/lab/parsefun.h b/engines/lab/parsefun.h
index f376a23..5fbc62c 100644
--- a/engines/lab/parsefun.h
+++ b/engines/lab/parsefun.h
@@ -31,7 +31,6 @@
 #ifndef LAB_PARSEFUN_H
 #define LAB_PARSEFUN_H
 
-#include "lab/stddefines.h"
 #include "lab/labfun.h"
 #include "lab/parsetypes.h"
 
diff --git a/engines/lab/parsetypes.h b/engines/lab/parsetypes.h
index 2585ae5..3ca441a 100644
--- a/engines/lab/parsetypes.h
+++ b/engines/lab/parsetypes.h
@@ -31,6 +31,8 @@
 #ifndef LAB_PARSETYPES_H
 #define LAB_PARSETYPES_H
 
+#include "common/system.h"
+
 namespace Lab {
 
 #define MAXFILELEN 31
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 87a56b0..04fe70d 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -31,7 +31,6 @@
 #include "gui/message.h"
 
 #include "lab/lab.h"
-#include "lab/stddefines.h"
 #include "lab/labfun.h"
 #include "lab/parsetypes.h"
 #include "lab/parsefun.h"
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index 9e87ad9..f7fb995 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -169,10 +169,11 @@ void LabEngine::diffNextFrame() {
 		}
 
 		_music->updateMusic();
-		readBlock(&header, 4L, difffile);
-		swapULong(&header);
-		readBlock(&size, 4L, difffile);
-		swapULong(&size);
+ 		header = READ_LE_UINT32(*difffile);
+		*difffile += 4;
+
+		size = READ_LE_UINT32(*difffile);
+		*difffile += 4;
 
 		switch (header) {
 		case 8L:
@@ -239,9 +240,8 @@ void LabEngine::diffNextFrame() {
 
 
 			(*difffile) += 4;
-			readBlock(&samplespeed, 2L, difffile);
-			swapUShortPtr(&samplespeed, 1);
-			(*difffile) += 2;
+			samplespeed = READ_LE_UINT16(*difffile);
+			(*difffile) += 4;
 
 			byte *music = *difffile;
 			uint32 musicsize = size;
@@ -315,41 +315,44 @@ void playDiff() {
 	}
 
 	continuous = false;
-	readBlock(temp, 4L, difffile);
-	temp[4] = '\0';
+	uint32 signature = READ_BE_UINT32(*difffile);
+	(*difffile) += 4;
 
-	readBlock(&header, 4L, difffile);
-	swapULong(&header);
+	header = READ_LE_UINT32(*difffile);
+	(*difffile) += 4;
 
-	if (!((strcmp((char *)temp, "DIFF") == 0) && (header == 1219009121L))) {
+	if ((signature != MKTAG('D', 'I', 'F', 'F')) || (header != 1219009121L)) {
 		IsPlaying = false;
 		return;
 	}
 
-	readBlock(&header, 4L, difffile);
-	swapULong(&header);
+	header = READ_LE_UINT32(*difffile);
+	(*difffile) += 4;
 
-	readBlock(&size, 4L, difffile);
-	swapULong(&size);
+	size = READ_LE_UINT32(*difffile);
+	(*difffile) += 4;
 
 	if (header == 0) {
 		// sizeof(headerdata) != 18, but the padding might be at the end
-		readBlock(&headerdata.Version, 2, difffile);
-		readBlock(&headerdata.x, 2, difffile);
-		readBlock(&headerdata.y, 2, difffile);
-		readBlock(&headerdata.depth, 1, difffile);
-		readBlock(&headerdata.fps, 1, difffile);
-		readBlock(&headerdata.BufferSize, 4, difffile);
-		readBlock(&headerdata.Machine, 2, difffile);
-		readBlock(&headerdata.Flags, 4, difffile);
+		headerdata.Version = READ_LE_UINT16(*difffile);
+		(*difffile) += 2;
+		headerdata.x = READ_LE_UINT16(*difffile);
+		(*difffile) += 2;
+		headerdata.y = READ_LE_UINT16(*difffile);
+		(*difffile) += 2;
+		headerdata.depth = *difffile[0];
+		(*difffile)++;
+		headerdata.fps = *difffile[0];
+		(*difffile)++;
+		headerdata.BufferSize = READ_LE_UINT32(*difffile);
+		(*difffile) += 4;
+		headerdata.Machine = READ_LE_UINT16(*difffile);
+		(*difffile) += 2;
+		headerdata.Flags = READ_LE_UINT32(*difffile);
+		(*difffile) += 4;
 
 		(*difffile) += size - 18;
 
-		swapUShortPtr(&headerdata.Version, 3);
-		swapULong(&headerdata.BufferSize);
-		swapUShortPtr(&headerdata.Machine, 1);
-		swapULong(&headerdata.Flags);
-
 		continuous = CONTINUOUS & headerdata.Flags;
 		diffwidth = headerdata.x;
 		diffheight = headerdata.y;
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index b01ac27..d54e6cb 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -34,7 +34,6 @@
 #include "graphics/thumbnail.h"
 
 #include "lab/lab.h"
-#include "lab/stddefines.h"
 #include "lab/labfun.h"
 
 namespace Lab {
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 70ec15a..59cf2d1 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -40,7 +40,6 @@
 #include "lab/diff.h"
 #include "lab/text.h"
 #include "lab/mouse.h"
-#include "lab/stddefines.h"
 #include "lab/parsetypes.h"
 #include "lab/resource.h"
 
diff --git a/engines/lab/stddefines.h b/engines/lab/stddefines.h
deleted file mode 100644
index 8c74d10..0000000
--- a/engines/lab/stddefines.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "common/system.h"
-#include "common/debug.h"
-#include "common/textconsole.h"
-
-#ifndef LAB_STDDEFINES_H
-#define LAB_STDDEFINES_H
-
-namespace Lab {
-
-#define swapUShort(value) (value)
-#define swapUShortPtr(ptr,count) (ptr)
-#define swapShort(value) (value)
-#define swapShortPtr(ptr,count) (ptr)
-#define swapUInt(value) (value)
-#define swapInt(value) (value)
-#define swapULong(value) (value)
-#define swapLong(value) (value)
-
-} // End of namespace Lab
-
-#endif /* LAB_STDDEFINES_H */
diff --git a/engines/lab/text.cpp b/engines/lab/text.cpp
index a7b41f1..6c5ac8c 100644
--- a/engines/lab/text.cpp
+++ b/engines/lab/text.cpp
@@ -29,7 +29,6 @@
  */
 
 #include "lab/lab.h"
-#include "lab/stddefines.h"
 #include "lab/labfun.h"
 #include "lab/text.h"
 
diff --git a/engines/lab/text.h b/engines/lab/text.h
index 8d171b2..7401f02 100644
--- a/engines/lab/text.h
+++ b/engines/lab/text.h
@@ -31,9 +31,6 @@
 #ifndef LAB_TEXT_H
 #define LAB_TEXT_H
 
-
-#include "lab/stddefines.h"
-
 namespace Lab {
 
 #if defined(WIN32)
diff --git a/engines/lab/undiff.cpp b/engines/lab/undiff.cpp
index 2b22496..f7d8989 100644
--- a/engines/lab/undiff.cpp
+++ b/engines/lab/undiff.cpp
@@ -28,8 +28,8 @@
  *
  */
 
-#include "lab/stddefines.h"
 #include "common/endian.h"
+#include "lab/lab.h"
 
 namespace Lab {
 
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 48c82b4..6af1fda 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -28,14 +28,12 @@
  *
  */
 
-#include "lab/lab.h"
-#include "lab/stddefines.h"
-#include "lab/mouse.h"
-
 #include "graphics/palette.h"
-
 #include "common/events.h"
 
+#include "lab/lab.h"
+#include "lab/mouse.h"
+
 namespace Lab {
 
 /*****************************************************************************/


Commit: 377bed8db04075ce67c573b0646c3f714d205287
    https://github.com/scummvm/scummvm/commit/377bed8db04075ce67c573b0646c3f714d205287
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:45+01:00

Commit Message:
LAB: Some renaming in Room Markers

Changed paths:
    engines/lab/allocroom.cpp



diff --git a/engines/lab/allocroom.cpp b/engines/lab/allocroom.cpp
index e960dda..e0051fa 100644
--- a/engines/lab/allocroom.cpp
+++ b/engines/lab/allocroom.cpp
@@ -41,11 +41,11 @@ namespace Lab {
 extern RoomData *_rooms;
 
 typedef struct {
-	uint16 RoomNum;
-	void *Start0, *End0, *Start1, *End1;
+	uint16 _roomNum;
+	void *_start0, *_end0, *_start1, *_end1;
 } RoomMarker;
 
-static RoomMarker RoomMarkers[MAXMARKERS];
+static RoomMarker _roomMarkers[MAXMARKERS];
 static void *RoomBuffer = NULL;
 static uint16 CurMarker  = 0;
 static void *MemPlace = NULL, *NextMemPlace = NULL;
@@ -62,7 +62,7 @@ bool initRoomBuffer() {
 		MemLeftInBuffer = ROOMBUFFERSIZE;
 
 		for (uint16 i = 0; i < MAXMARKERS; i++)
-			RoomMarkers[i].RoomNum = EMPTYROOM;
+			_roomMarkers[i]._roomNum = EMPTYROOM;
 
 		return true;
 	} else
@@ -80,32 +80,29 @@ void freeRoomBuffer() {
 /*****************************************************************************/
 /* Frees a room's resources.                                                 */
 /*****************************************************************************/
-static void freeRoom(uint16 RMarker) {
-	uint16 RoomNum;
+static void freeRoom(uint16 roomMarkerId) {
+	uint16 roomNum = _roomMarkers[roomMarkerId]._roomNum;
 
-	RoomNum = RoomMarkers[RMarker].RoomNum;
+	if (roomNum != EMPTYROOM) {
+		_rooms[roomNum]._northView = nullptr;
+		_rooms[roomNum]._southView = nullptr;
+		_rooms[roomNum]._eastView = nullptr;
+		_rooms[roomNum]._westView = nullptr;
 
-	if (RoomNum != EMPTYROOM) {
-		_rooms[RoomNum]._northView = nullptr;
-		_rooms[RoomNum]._southView = nullptr;
-		_rooms[RoomNum]._eastView = nullptr;
-		_rooms[RoomNum]._westView = nullptr;
-
-		RuleList *rules = _rooms[RoomNum]._rules;
+		RuleList *rules = _rooms[roomNum]._rules;
 		for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule)
 			delete *rule;
-		_rooms[RoomNum]._rules->clear();
-		delete _rooms[RoomNum]._rules;
-		_rooms[RoomNum]._rules = nullptr;
-
-		_rooms[RoomNum]._roomMsg = nullptr;
+		_rooms[roomNum]._rules->clear();
+		delete _rooms[roomNum]._rules;
+		_rooms[roomNum]._rules = nullptr;
+		_rooms[roomNum]._roomMsg = nullptr;
 	}
 
-	RoomMarkers[RMarker].RoomNum = EMPTYROOM;
-	RoomMarkers[RMarker].Start0  = NULL;
-	RoomMarkers[RMarker].End0    = NULL;
-	RoomMarkers[RMarker].Start1  = NULL;
-	RoomMarkers[RMarker].End1    = NULL;
+	_roomMarkers[roomMarkerId]._roomNum = EMPTYROOM;
+	_roomMarkers[roomMarkerId]._start0  = nullptr;
+	_roomMarkers[roomMarkerId]._end0    = nullptr;
+	_roomMarkers[roomMarkerId]._start1  = nullptr;
+	_roomMarkers[roomMarkerId]._end1    = nullptr;
 }
 
 /*****************************************************************************/
@@ -126,11 +123,11 @@ static void *getCurMem(uint16 Size) {
 		NextMemPlace = NULL;
 
 		for (uint16 i = 0; i < MAXMARKERS; i++) {
-			if (RoomMarkers[i].RoomNum != EMPTYROOM) {
-				void *Start0 = RoomMarkers[i].Start0;
-				void *Start1 = RoomMarkers[i].Start1;
-				void *End0   = RoomMarkers[i].End0;
-				void *End1   = RoomMarkers[i].End1;
+			if (_roomMarkers[i]._roomNum != EMPTYROOM) {
+				void *Start0 = _roomMarkers[i]._start0;
+				void *Start1 = _roomMarkers[i]._start1;
+				void *End0   = _roomMarkers[i]._end0;
+				void *End1   = _roomMarkers[i]._end1;
 
 				if (((Start0 >= Ptr) && (Start0 < MemPlace))  ||
 				        ((End0 >= Ptr) && (End0 < MemPlace))    ||
@@ -166,43 +163,41 @@ static void *getCurMem(uint16 Size) {
 /* particular room.                                                          */
 /*****************************************************************************/
 void allocRoom(void **Ptr, uint16 size, uint16 roomNum) {
-	uint16 rMarker;
-
 	if (1 & size)  /* Memory is required to be even aligned */
 		size++;
 
-	rMarker = 0;
+	uint16 roomMarkerId = 0;
 
-	while ((rMarker < MAXMARKERS)) {
-		if (RoomMarkers[rMarker].RoomNum == roomNum)
+	while ((roomMarkerId < MAXMARKERS)) {
+		if (_roomMarkers[roomMarkerId]._roomNum == roomNum)
 			break;
 		else
-			rMarker++;
+			roomMarkerId++;
 	}
 
-	if (rMarker >= MAXMARKERS) {
-		rMarker = CurMarker;
+	if (roomMarkerId >= MAXMARKERS) {
+		roomMarkerId = CurMarker;
 		CurMarker++;
 
 		if (CurMarker >= MAXMARKERS)
 			CurMarker = 0;
 
-		freeRoom(rMarker);
-		RoomMarkers[rMarker].RoomNum = roomNum;
+		freeRoom(roomMarkerId);
+		_roomMarkers[roomMarkerId]._roomNum = roomNum;
 	}
 
 	*Ptr = getCurMem(size);
 
-	if (RoomMarkers[rMarker].Start0 == NULL) {
-		RoomMarkers[rMarker].Start0 = *Ptr;
-		RoomMarkers[rMarker].End0   = (void *)(((char *)(*Ptr)) + size - 1);
-	} else if (*Ptr < RoomMarkers[rMarker].Start0) {
-		if (RoomMarkers[rMarker].Start1 == NULL)
-			RoomMarkers[rMarker].Start1 = *Ptr;
+	if (!_roomMarkers[roomMarkerId]._start0) {
+		_roomMarkers[roomMarkerId]._start0 = *Ptr;
+		_roomMarkers[roomMarkerId]._end0   = (void *)(((char *)(*Ptr)) + size - 1);
+	} else if (*Ptr < _roomMarkers[roomMarkerId]._start0) {
+		if (_roomMarkers[roomMarkerId]._start1 == nullptr)
+			_roomMarkers[roomMarkerId]._start1 = *Ptr;
 
-		RoomMarkers[rMarker].End1 = (void *)(((char *)(*Ptr)) + size - 1);
+		_roomMarkers[roomMarkerId]._end1 = (void *)(((char *)(*Ptr)) + size - 1);
 	} else
-		RoomMarkers[rMarker].End0 = (void *)(((char *)(*Ptr)) + size - 1);
+		_roomMarkers[roomMarkerId]._end0 = (void *)(((char *)(*Ptr)) + size - 1);
 }
 
 } // End of namespace Lab


Commit: 609fd323d39035ea0ca02377ad8e0fdadd30e1a1
    https://github.com/scummvm/scummvm/commit/609fd323d39035ea0ca02377ad8e0fdadd30e1a1
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:45+01:00

Commit Message:
LAB: Remove some dead code

Changed paths:
    engines/lab/allocroom.cpp
    engines/lab/parsefun.h



diff --git a/engines/lab/allocroom.cpp b/engines/lab/allocroom.cpp
index e0051fa..a95aa8e 100644
--- a/engines/lab/allocroom.cpp
+++ b/engines/lab/allocroom.cpp
@@ -77,127 +77,4 @@ void freeRoomBuffer() {
 		free(RoomBuffer);
 }
 
-/*****************************************************************************/
-/* Frees a room's resources.                                                 */
-/*****************************************************************************/
-static void freeRoom(uint16 roomMarkerId) {
-	uint16 roomNum = _roomMarkers[roomMarkerId]._roomNum;
-
-	if (roomNum != EMPTYROOM) {
-		_rooms[roomNum]._northView = nullptr;
-		_rooms[roomNum]._southView = nullptr;
-		_rooms[roomNum]._eastView = nullptr;
-		_rooms[roomNum]._westView = nullptr;
-
-		RuleList *rules = _rooms[roomNum]._rules;
-		for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule)
-			delete *rule;
-		_rooms[roomNum]._rules->clear();
-		delete _rooms[roomNum]._rules;
-		_rooms[roomNum]._rules = nullptr;
-		_rooms[roomNum]._roomMsg = nullptr;
-	}
-
-	_roomMarkers[roomMarkerId]._roomNum = EMPTYROOM;
-	_roomMarkers[roomMarkerId]._start0  = nullptr;
-	_roomMarkers[roomMarkerId]._end0    = nullptr;
-	_roomMarkers[roomMarkerId]._start1  = nullptr;
-	_roomMarkers[roomMarkerId]._end1    = nullptr;
-}
-
-/*****************************************************************************/
-/* Gets a chunk of memory from the buffer.                                   */
-/*****************************************************************************/
-static void *getCurMem(uint16 Size) {
-	if (((int32) Size) > MemLeftInBuffer) {
-		MemPlace = RoomBuffer;
-		MemLeftInBuffer = ROOMBUFFERSIZE;
-		NextMemPlace = NULL;
-	}
-
-	void *Ptr = MemPlace;
-	MemPlace = (char *)MemPlace + Size;
-	MemLeftInBuffer -= Size;
-
-	if (MemPlace > NextMemPlace) {
-		NextMemPlace = NULL;
-
-		for (uint16 i = 0; i < MAXMARKERS; i++) {
-			if (_roomMarkers[i]._roomNum != EMPTYROOM) {
-				void *Start0 = _roomMarkers[i]._start0;
-				void *Start1 = _roomMarkers[i]._start1;
-				void *End0   = _roomMarkers[i]._end0;
-				void *End1   = _roomMarkers[i]._end1;
-
-				if (((Start0 >= Ptr) && (Start0 < MemPlace))  ||
-				        ((End0 >= Ptr) && (End0 < MemPlace))    ||
-				        ((Ptr >= Start0) && (Ptr <= End0))        ||
-
-				        ((Start1 >= Ptr) && (Start1 < MemPlace))  ||
-				        ((End1 >= Ptr) && (End1 < MemPlace))    ||
-				        ((Ptr >= Start1) && (Ptr <= End1))) {
-					freeRoom(i);
-				} else {
-					if (Start0 >= MemPlace)
-						if ((NextMemPlace == NULL) || (Start0 < NextMemPlace))
-							NextMemPlace = Start0;
-
-					if (Start1 >= MemPlace)
-						if ((NextMemPlace == NULL) || (Start1 < NextMemPlace))
-							NextMemPlace = Start1;
-				}
-			}
-		}
-
-		if (NextMemPlace == NULL) {
-			NextMemPlace = RoomBuffer;
-			NextMemPlace = (char *)NextMemPlace + ROOMBUFFERSIZE;
-		}
-	}
-
-	return Ptr;
-}
-
-/*****************************************************************************/
-/* Grabs a chunk of memory from the room buffer, and manages it for a        */
-/* particular room.                                                          */
-/*****************************************************************************/
-void allocRoom(void **Ptr, uint16 size, uint16 roomNum) {
-	if (1 & size)  /* Memory is required to be even aligned */
-		size++;
-
-	uint16 roomMarkerId = 0;
-
-	while ((roomMarkerId < MAXMARKERS)) {
-		if (_roomMarkers[roomMarkerId]._roomNum == roomNum)
-			break;
-		else
-			roomMarkerId++;
-	}
-
-	if (roomMarkerId >= MAXMARKERS) {
-		roomMarkerId = CurMarker;
-		CurMarker++;
-
-		if (CurMarker >= MAXMARKERS)
-			CurMarker = 0;
-
-		freeRoom(roomMarkerId);
-		_roomMarkers[roomMarkerId]._roomNum = roomNum;
-	}
-
-	*Ptr = getCurMem(size);
-
-	if (!_roomMarkers[roomMarkerId]._start0) {
-		_roomMarkers[roomMarkerId]._start0 = *Ptr;
-		_roomMarkers[roomMarkerId]._end0   = (void *)(((char *)(*Ptr)) + size - 1);
-	} else if (*Ptr < _roomMarkers[roomMarkerId]._start0) {
-		if (_roomMarkers[roomMarkerId]._start1 == nullptr)
-			_roomMarkers[roomMarkerId]._start1 = *Ptr;
-
-		_roomMarkers[roomMarkerId]._end1 = (void *)(((char *)(*Ptr)) + size - 1);
-	} else
-		_roomMarkers[roomMarkerId]._end0 = (void *)(((char *)(*Ptr)) + size - 1);
-}
-
 } // End of namespace Lab
diff --git a/engines/lab/parsefun.h b/engines/lab/parsefun.h
index 5fbc62c..46c26b6 100644
--- a/engines/lab/parsefun.h
+++ b/engines/lab/parsefun.h
@@ -45,8 +45,6 @@ bool parse(const char *InputFile);
 
 bool initRoomBuffer();
 void freeRoomBuffer();
-void allocRoom(void **Ptr, uint16 Size, uint16 RoomNum);
-
 
 /* From ProcessRoom.c */
 


Commit: 611df0c0dc7e98281fea354e20f74114fd94bee8
    https://github.com/scummvm/scummvm/commit/611df0c0dc7e98281fea354e20f74114fd94bee8
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:46+01:00

Commit Message:
LAB: Some renaming in allocroom, remove useless code and variables

Changed paths:
    engines/lab/allocroom.cpp
    engines/lab/labfile.cpp



diff --git a/engines/lab/allocroom.cpp b/engines/lab/allocroom.cpp
index a95aa8e..22617cb 100644
--- a/engines/lab/allocroom.cpp
+++ b/engines/lab/allocroom.cpp
@@ -35,34 +35,21 @@ namespace Lab {
 /* Have to make sure that ROOMBUFFERSIZE is bigger than the biggest piece of memory
    that we need */
 #define ROOMBUFFERSIZE (2 * 20480L)
-#define EMPTYROOM      ((uint16) -1)
-#define MAXMARKERS     10
 
 extern RoomData *_rooms;
 
-typedef struct {
-	uint16 _roomNum;
-	void *_start0, *_end0, *_start1, *_end1;
-} RoomMarker;
-
-static RoomMarker _roomMarkers[MAXMARKERS];
-static void *RoomBuffer = NULL;
-static uint16 CurMarker  = 0;
-static void *MemPlace = NULL, *NextMemPlace = NULL;
-static int32 MemLeftInBuffer = 0L;
+static void *_roomBuffer = nullptr;
+static uint16 _curMarker  = 0;
+static void *_memPlace = nullptr;
 
 /*****************************************************************************/
 /* Allocates the memory for the room buffers.                                */
 /*****************************************************************************/
 bool initRoomBuffer() {
-	CurMarker = 0;
-
-	if ((RoomBuffer = calloc(ROOMBUFFERSIZE, 1))) {
-		MemPlace = RoomBuffer;
-		MemLeftInBuffer = ROOMBUFFERSIZE;
+	_curMarker = 0;
 
-		for (uint16 i = 0; i < MAXMARKERS; i++)
-			_roomMarkers[i]._roomNum = EMPTYROOM;
+	if ((_roomBuffer = calloc(ROOMBUFFERSIZE, 1))) {
+		_memPlace = _roomBuffer;
 
 		return true;
 	} else
@@ -73,8 +60,10 @@ bool initRoomBuffer() {
 /* Frees the memory for the room buffers.                                    */
 /*****************************************************************************/
 void freeRoomBuffer() {
-	if (RoomBuffer)
-		free(RoomBuffer);
+	if (_roomBuffer) {
+		free(_roomBuffer);
+		_roomBuffer = nullptr;
+	}
 }
 
 } // End of namespace Lab
diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
index 31d1090..83f3b0f 100644
--- a/engines/lab/labfile.cpp
+++ b/engines/lab/labfile.cpp
@@ -53,8 +53,8 @@ struct FileMarker {
 
 
 static FileMarker FileMarkers[MAXMARKERS];
-static uint16 CurMarker  = 0;
-static void *MemPlace   = NULL;
+static uint16 _curMarker  = 0;
+static void *_memPlace   = NULL;
 
 
 
@@ -79,17 +79,17 @@ static void freeFile(uint16 RMarker) {
 static void *getCurMemLabFile(uint32 size) {
 	void *ptr = 0;
 
-	if ((((char *) MemPlace) + size - 1) >=
+	if ((((char *) _memPlace) + size - 1) >=
 	        (((char *) buffer) + buffersize))
-		MemPlace = buffer;
+		_memPlace = buffer;
 
-	ptr = MemPlace;
-	MemPlace = (char *)MemPlace + size;
+	ptr = _memPlace;
+	_memPlace = (char *)_memPlace + size;
 
 	for (int i = 0; i < MAXMARKERS; i++) {
 		if (FileMarkers[i].name[0]) {
-			if ( ((FileMarkers[i].Start >= ptr) && (FileMarkers[i].Start < MemPlace))
-			  || ((FileMarkers[i].End >= ptr) && (FileMarkers[i].End < MemPlace))
+			if ( ((FileMarkers[i].Start >= ptr) && (FileMarkers[i].Start < _memPlace))
+			  || ((FileMarkers[i].End >= ptr) && (FileMarkers[i].End < _memPlace))
 			  || ((ptr >= FileMarkers[i].Start) && (ptr <= FileMarkers[i].End)))
 				freeFile(i);
 		}
@@ -139,11 +139,11 @@ bool allocFile(void **Ptr, uint32 Size, const char *fileName) {
 		return true;
 	}
 
-	RMarker = CurMarker;
-	CurMarker++;
+	RMarker = _curMarker;
+	_curMarker++;
 
-	if (CurMarker >= MAXMARKERS)
-		CurMarker = 0;
+	if (_curMarker >= MAXMARKERS)
+		_curMarker = 0;
 
 	freeFile(RMarker);
 	strcpy(FileMarkers[RMarker].name, fileName);
@@ -204,9 +204,9 @@ void readBlock(void *Buffer, uint32 Size, byte **File) {
 void resetBuffer() {
 	uint16 RMarker;
 
-	CurMarker = 0;
+	_curMarker = 0;
 	RMarker   = 0;
-	MemPlace  = buffer;
+	_memPlace  = buffer;
 
 	while (RMarker < MAXMARKERS) {
 		freeFile(RMarker);
@@ -276,7 +276,7 @@ void *stealBufMem(int32 Size) {
 
 	buffer += Size;
 	buffersize -= Size;
-	MemPlace = buffer;
+	_memPlace = buffer;
 
 	return Mem;
 }
@@ -306,7 +306,7 @@ void freeAllStolenMem() {
 
 	buffer = realbufferstart;
 	buffersize = realbuffersize;
-	MemPlace = buffer;
+	_memPlace = buffer;
 }
 
 } // End of namespace Lab


Commit: 3f33ad277dc42526fb56845f522adad0064ee033
    https://github.com/scummvm/scummvm/commit/3f33ad277dc42526fb56845f522adad0064ee033
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:46+01:00

Commit Message:
LAB: More renames

Changed paths:
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/readdiff.cpp
    engines/lab/special.cpp
    engines/lab/text.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index f845dfa..4f44070 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -167,20 +167,12 @@ void LabEngine::drawPanel() {
 	_event->mouseShow();
 }
 
-
-extern bool LastMessageLong;
-
-static bool LastTooLong = false;
-
-
-
-
 /******************************************************************************/
 /* Draws the message for the room.                                            */
 /******************************************************************************/
 void LabEngine::drawRoomMessage(uint16 CurInv, CloseDataPtr cptr) {
-	if (LastTooLong) {
-		LastTooLong = false;
+	if (_lastTooLong) {
+		_lastTooLong = false;
 		return;
 	}
 
@@ -197,7 +189,7 @@ void LabEngine::drawRoomMessage(uint16 CurInv, CloseDataPtr cptr) {
 	} else
 		drawDirection(cptr);
 
-	LastTooLong = LastMessageLong;
+	_lastTooLong = _lastMessageLong;
 }
 
 
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 413796d..ea53292 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -50,10 +50,6 @@ extern bool DoBlack, stopsound;
 extern TextFont *MsgFont;
 extern const char *CurFileName;
 
-
-
-
-
 /*---------------------------------------------------------------------------*/
 /*------ From readPict.c.  Reads in pictures and animations from disk. ------*/
 /*---------------------------------------------------------------------------*/
@@ -62,7 +58,7 @@ extern const char *CurFileName;
 /*****************************************************************************/
 /* Reads in a picture into the dest bitmap.                                  */
 /*****************************************************************************/
-bool readPict(const char *filename, bool PlayOnce) {
+bool readPict(const char *filename, bool playOnce) {
 	byte **file = NULL;
 
 	stopDiff();
@@ -80,14 +76,11 @@ bool readPict(const char *filename, bool PlayOnce) {
 	DispBitMap->Rows        = g_lab->_screenHeight;
 	DispBitMap->Flags       = BITMAPF_VIDEO;
 
-	readDiff(PlayOnce);
+	readDiff(playOnce);
 
 	return true;
 }
 
-
-
-
 /*****************************************************************************/
 /* Reads in a music file.  Ignores any graphics.                             */
 /*****************************************************************************/
@@ -105,9 +98,6 @@ bool readMusic(const char *filename, bool waitTillFinished) {
 	return true;
 }
 
-
-
-
 /*****************************************************************************/
 /* Reads in a picture into buffer memory.                                    */
 /*****************************************************************************/
@@ -139,81 +129,65 @@ byte *readPictToMem(const char *filename, uint16 x, uint16 y) {
 	return Mem;
 }
 
-
-
-
 /*---------------------------------------------------------------------------*/
 /*------------ Does all the text rendering to the message boxes. ------------*/
 /*---------------------------------------------------------------------------*/
-
-
 bool DoNotDrawMessage = false;
 
 extern bool LongWinInFront, Alternate;
 
-
 /*----- The flowText routines -----*/
 
-
-
-
 /******************************************************************************/
 /* Extracts the first word from a string.                                     */
 /******************************************************************************/
-static void getWord(char *WordBuffer, const char *MainBuffer, uint16 *WordWidth) {
+static void getWord(char *wordBuffer, const char *mainBuffer, uint16 *wordWidth) {
 	uint16 width = 0;
 
-	while ((MainBuffer[width] != ' ') && MainBuffer[width] &&
-	        (MainBuffer[width] != '\n')) {
-		WordBuffer[width] = MainBuffer[width];
+	while ((mainBuffer[width] != ' ') && mainBuffer[width] &&
+	        (mainBuffer[width] != '\n')) {
+		wordBuffer[width] = mainBuffer[width];
 		width++;
 	}
 
-	WordBuffer[width] = 0;
+	wordBuffer[width] = 0;
 
-	*WordWidth = width;
+	*wordWidth = width;
 }
 
-
-
-
-
 /******************************************************************************/
 /* Gets a line of text for flowText; makes sure that its length is less than  */
 /* or equal to the maximum width.                                             */
 /******************************************************************************/
-static void getLine(TextFont *tf, char *LineBuffer, const char **MainBuffer, uint16 LineWidth) {
-	uint16 CurWidth = 0, WordWidth;
-	char WordBuffer[100];
+static void getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer, uint16 lineWidth) {
+	uint16 curWidth = 0, wordWidth;
+	char wordBuffer[100];
 	bool doit = true;
 
-	LineWidth += textLength(tf, " ", 1);
+	lineWidth += textLength(tf, " ", 1);
 
-	LineBuffer[0] = 0;
+	lineBuffer[0] = 0;
 
-	while ((*MainBuffer)[0] && doit) {
-		getWord(WordBuffer, *MainBuffer, &WordWidth);
-		strcat(WordBuffer, " ");
+	while ((*mainBuffer)[0] && doit) {
+		getWord(wordBuffer, *mainBuffer, &wordWidth);
+		strcat(wordBuffer, " ");
 
-		if ((CurWidth + textLength(tf, WordBuffer, WordWidth + 1)) <= LineWidth) {
-			strcat(LineBuffer, WordBuffer);
-			(*MainBuffer) += WordWidth;
+		if ((curWidth + textLength(tf, wordBuffer, wordWidth + 1)) <= lineWidth) {
+			strcat(lineBuffer, wordBuffer);
+			(*mainBuffer) += wordWidth;
 
-			if ((*MainBuffer)[0] == '\n')
+			if ((*mainBuffer)[0] == '\n')
 				doit = false;
 
-			if ((*MainBuffer)[0])
-				(*MainBuffer)++;
+			if ((*mainBuffer)[0])
+				(*mainBuffer)++;
 
-			CurWidth = textLength(tf, LineBuffer, strlen(LineBuffer));
+			curWidth = textLength(tf, lineBuffer, strlen(lineBuffer));
 		} else
 			doit = false;
 	}
 }
 
-
-
-
 /******************************************************************************/
 /* Dumps a chunk of text to an arbitrary box; flows it within that box and    */
 /* optionally centers it. Returns the number of characters that were          */
@@ -289,7 +263,7 @@ uint32 flowText(void *font,      /* the TextAttr pointer */
 /******************************************************************************/
 /* Calls flowText, but flows it to memory.  Same restrictions as flowText.    */
 /******************************************************************************/
-uint32 flowTextToMem(Image *DestIm, void *font,     /* the TextAttr pointer */
+uint32 flowTextToMem(Image *destIm, void *font,     /* the TextAttr pointer */
                      int16 spacing,          /* How much vertical spacing between the lines */
                      byte pencolor,         /* pen number to use for text */
                      byte backpen,          /* the background color */
@@ -300,26 +274,21 @@ uint32 flowTextToMem(Image *DestIm, void *font,     /* the TextAttr pointer */
                      uint16 x1,               /* Cords */
                      uint16 y1, uint16 x2, uint16 y2, const char *str) { /* The text itself */
 	uint32 res, vgabyte = g_lab->_screenBytesPerPage;
-	byte *tmp = g_lab->_currentDsplayBuffer;
+	byte *tmp = g_lab->_currentDisplayBuffer;
 
-	g_lab->_currentDsplayBuffer = DestIm->ImageData;
-	g_lab->_screenBytesPerPage = (uint32) DestIm->Width * (int32) DestIm->Height;
+	g_lab->_currentDisplayBuffer = destIm->ImageData;
+	g_lab->_screenBytesPerPage = (uint32)destIm->Width * (int32)destIm->Height;
 
 	res = flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str);
 
 	g_lab->_screenBytesPerPage = vgabyte;
-	g_lab->_currentDsplayBuffer = tmp;
+	g_lab->_currentDisplayBuffer = tmp;
 
 	return res;
 }
 
-
-
-
 /*----- The control panel stuff -----*/
 
-
-
 void createBox(uint16 y2) {
 	g_lab->setAPen(7);                 /* Message box area */
 	g_lab->rectFill(VGAScaleX(4), VGAScaleY(154), VGAScaleX(315), VGAScaleY(y2 - 2));
@@ -331,20 +300,15 @@ void createBox(uint16 y2) {
 	g_lab->drawVLine(VGAScaleX(2), VGAScaleY(152), VGAScaleY(y2));
 }
 
-
-
-
-bool LastMessageLong = false;
-
 int32 LabEngine::longDrawMessage(const char *str) {
-	char NewText[512];
+	char newText[512];
 
 	if (str == NULL)
 		return 0;
 
 	_event->attachGadgetList(NULL);
 	_event->mouseHide();
-	strcpy(NewText, str);
+	strcpy(newText, str);
 
 	if (!LongWinInFront) {
 		LongWinInFront = true;
@@ -374,7 +338,7 @@ void LabEngine::drawMessage(const char *str) {
 	if (str) {
 		if ((textLength(MsgFont, str, strlen(str)) > VGAScaleX(306))) {
 			longDrawMessage(str);
-			LastMessageLong = true;
+			_lastMessageLong = true;
 		} else {
 			if (LongWinInFront) {
 				LongWinInFront = false;
@@ -385,18 +349,15 @@ void LabEngine::drawMessage(const char *str) {
 			createBox(168);
 			text(MsgFont, VGAScaleX(7), VGAScaleY(155) + SVGACord(2), 1, str, strlen(str));
 			_event->mouseShow();
-			LastMessageLong = false;
+			_lastMessageLong = false;
 		}
 	}
 }
 
-
 /*---------------------------------------------------------------------------*/
 /*--------------------------- All the wipe stuff. ---------------------------*/
 /*---------------------------------------------------------------------------*/
 
-
-
 #define TRANSWIPE      1
 #define SCROLLWIPE     2
 #define SCROLLBLACK    3
@@ -410,25 +371,25 @@ void LabEngine::drawMessage(const char *str) {
 /*****************************************************************************/
 void LabEngine::doScrollBlack() {
 	byte *mem, *tempmem;
-	Image Im;
+	Image im;
 	uint16 width, height, by, nheight;
 	uint32 size, copysize;
-	uint32 *BaseAddr;
+	uint32 *baseAddr;
 
 	_event->mouseHide();
 	width = VGAScaleX(320);
 	height = VGAScaleY(149) + SVGACord(2);
 
-	allocFile((void **) &mem, (int32) width * (int32) height, "Temp Mem");
+	allocFile((void **)&mem, (int32)width * (int32)height, "Temp Mem");
 
-	Im.Width = width;
-	Im.Height = height;
-	Im.ImageData = mem;
+	im.Width = width;
+	im.Height = height;
+	im.ImageData = mem;
 	_music->updateMusic();
-	g_lab->readScreenImage(&Im, 0, 0);
+	g_lab->readScreenImage(&im, 0, 0);
 	_music->updateMusic();
 
-	BaseAddr = (uint32 *)g_lab->getVGABaseAddr();
+	baseAddr = (uint32 *)g_lab->getCurrentDrawingBuffer();
 
 	by      = VGAScaleX(4);
 	nheight = height;
@@ -439,14 +400,14 @@ void LabEngine::doScrollBlack() {
 		if (!_isHiRes)
 			g_lab->waitTOF();
 
-		BaseAddr = (uint32 *)g_lab->getVGABaseAddr();
+		baseAddr = (uint32 *)g_lab->getCurrentDrawingBuffer();
 
 		if (by > nheight)
 			by = nheight;
 
 		mem += by * width;
 		nheight -= by;
-		size = (int32) nheight * (int32) width;
+		size = (int32)nheight * (int32)width;
 		tempmem = mem;
 
 		while (size) {
@@ -457,7 +418,7 @@ void LabEngine::doScrollBlack() {
 
 			size -= copysize;
 
-			memcpy(BaseAddr, tempmem, copysize);
+			memcpy(baseAddr, tempmem, copysize);
 			tempmem += copysize;
 		}
 
@@ -484,33 +445,32 @@ extern BitMap RawDiffBM;
 extern DIFFHeader headerdata;
 
 static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem) {
-	uint32 size, OffSet, copysize;
-	uint16 CurPage;
-	uint32 *BaseAddr;
+	uint32 size, offSet, copysize;
+	uint16 curPage;
+	uint32 *baseAddr;
 
-	BaseAddr = (uint32 *)g_lab->getVGABaseAddr();
+	baseAddr = (uint32 *)g_lab->getCurrentDrawingBuffer();
 
-	size = (int32)(height - nheight) * (int32) width;
+	size = (int32)(height - nheight) * (int32)width;
 	mem += startline * width;
-	CurPage = ((int32) nheight * (int32) width) / g_lab->_screenBytesPerPage;
-	OffSet = ((int32) nheight * (int32) width) - (CurPage * g_lab->_screenBytesPerPage);
+	curPage = ((int32)nheight * (int32)width) / g_lab->_screenBytesPerPage;
+	offSet = ((int32)nheight * (int32)width) - (curPage * g_lab->_screenBytesPerPage);
 
 	while (size) {
-		if (size > (g_lab->_screenBytesPerPage - OffSet))
-			copysize = g_lab->_screenBytesPerPage - OffSet;
+		if (size > (g_lab->_screenBytesPerPage - offSet))
+			copysize = g_lab->_screenBytesPerPage - offSet;
 		else
 			copysize = size;
 
 		size -= copysize;
 
-		memcpy(BaseAddr + (OffSet >> 2), mem, copysize);
+		memcpy(baseAddr + (offSet >> 2), mem, copysize);
 		mem += copysize;
-		CurPage++;
-		OffSet = 0;
+		curPage++;
+		offSet = 0;
 	}
 }
 
-
 /*****************************************************************************/
 /* Scrolls the display to a new picture from a black screen.                 */
 /*****************************************************************************/
@@ -586,7 +546,6 @@ void LabEngine::doScrollBounce() {
 		newby1 = newby1w;
 	}
 
-
 	_event->mouseHide();
 	int width = VGAScaleX(320);
 	int height = VGAScaleY(149) + SVGACord(2);
@@ -620,30 +579,30 @@ void LabEngine::doScrollBounce() {
 /*****************************************************************************/
 /* Does the transporter wipe.                                                */
 /*****************************************************************************/
-void LabEngine::doTransWipe(CloseDataPtr *CPtr, char *filename) {
-	uint16 LastY, CurY, linesdone = 0, lineslast;
-	Image ImSource, ImDest;
+void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) {
+	uint16 lastY, curY, linesdone = 0, lineslast;
+	Image imSource, imDest;
 
 	if (_isHiRes) {
 		lineslast = 3;
-		LastY = 358;
+		lastY = 358;
 	} else {
 		lineslast = 1;
-		LastY = 148;
+		lastY = 148;
 	}
 
 	for (uint16 i = 0; i < 2; i++) {
-		CurY = i * 2;
+		curY = i * 2;
 
-		while (CurY < LastY) {
+		while (curY < lastY) {
 			if (linesdone >= lineslast) {
 				_music->updateMusic();
 				g_lab->waitTOF();
 				linesdone = 0;
 			}
 
-			g_lab->ghoastRect(0, 0, CurY, g_lab->_screenWidth - 1, CurY + 1);
-			CurY += 4;
+			g_lab->ghoastRect(0, 0, curY, g_lab->_screenWidth - 1, curY + 1);
+			curY += 4;
 			linesdone++;
 		}
 	}
@@ -651,77 +610,77 @@ void LabEngine::doTransWipe(CloseDataPtr *CPtr, char *filename) {
 	g_lab->setAPen(0);
 
 	for (uint16 i = 0; i < 2; i++) {
-		CurY = i * 2;
+		curY = i * 2;
 
-		while (CurY <= LastY) {
+		while (curY <= lastY) {
 			if (linesdone >= lineslast) {
 				_music->updateMusic();
 				g_lab->waitTOF();
 				linesdone = 0;
 			}
 
-			g_lab->rectFill(0, CurY, g_lab->_screenWidth - 1, CurY + 1);
-			CurY += 4;
+			g_lab->rectFill(0, curY, g_lab->_screenWidth - 1, curY + 1);
+			curY += 4;
 			linesdone++;
 		}
 	}
 
 	if (filename == NULL)
-		CurFileName = getPictName(CPtr);
+		CurFileName = getPictName(cPtr);
 	else if (filename[0] > ' ')
 		CurFileName = filename;
 	else
-		CurFileName = getPictName(CPtr);
+		CurFileName = getPictName(cPtr);
 
-	byte *BitMapMem = readPictToMem(CurFileName, g_lab->_screenWidth, LastY + 5);
+	byte *BitMapMem = readPictToMem(CurFileName, g_lab->_screenWidth, lastY + 5);
 	g_lab->setPalette(diffcmap, 256);
 
 	if (BitMapMem) {
-		ImSource.Width = g_lab->_screenWidth;
-		ImSource.Height = LastY;
-		ImSource.ImageData = BitMapMem;
+		imSource.Width = g_lab->_screenWidth;
+		imSource.Height = lastY;
+		imSource.ImageData = BitMapMem;
 
-		ImDest.Width = g_lab->_screenWidth;
-		ImDest.Height = g_lab->_screenHeight;
-		ImDest.ImageData = g_lab->getVGABaseAddr();
+		imDest.Width = g_lab->_screenWidth;
+		imDest.Height = g_lab->_screenHeight;
+		imDest.ImageData = g_lab->getCurrentDrawingBuffer();
 
 		for (uint16 i = 0; i < 2; i++) {
-			CurY = i * 2;
+			curY = i * 2;
 
-			while (CurY < LastY) {
+			while (curY < lastY) {
 				if (linesdone >= lineslast) {
 					_music->updateMusic();
 					g_lab->waitTOF();
 					linesdone = 0;
 				}
 
-				ImDest.ImageData = g_lab->getVGABaseAddr();
+				imDest.ImageData = g_lab->getCurrentDrawingBuffer();
 
-				g_lab->bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, g_lab->_screenWidth, 2);
-				g_lab->ghoastRect(0, 0, CurY, g_lab->_screenWidth - 1, CurY + 1);
-				CurY += 4;
+				g_lab->bltBitMap(&imSource, 0, curY, &imDest, 0, curY, g_lab->_screenWidth, 2);
+				g_lab->ghoastRect(0, 0, curY, g_lab->_screenWidth - 1, curY + 1);
+				curY += 4;
 				linesdone++;
 			}
 		}
 
 		for (uint16 i = 0; i < 2; i++) {
-			CurY = i * 2;
+			curY = i * 2;
 
-			while (CurY <= LastY) {
+			while (curY <= lastY) {
 				if (linesdone >= lineslast) {
 					_music->updateMusic();
 					g_lab->waitTOF();
 					linesdone = 0;
 				}
 
-				ImDest.ImageData = g_lab->getVGABaseAddr();
+				imDest.ImageData = g_lab->getCurrentDrawingBuffer();
 
-				if (CurY == LastY)
-					g_lab->bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, g_lab->_screenWidth, 1);
+				if (curY == lastY)
+					g_lab->bltBitMap(&imSource, 0, curY, &imDest, 0, curY, g_lab->_screenWidth, 1);
 				else
-					g_lab->bltBitMap(&ImSource, 0, CurY, &ImDest, 0, CurY, g_lab->_screenWidth, 2);
+					g_lab->bltBitMap(&imSource, 0, curY, &imDest, 0, curY, g_lab->_screenWidth, 2);
 
-				CurY += 4;
+				curY += 4;
 				linesdone++;
 			}
 		}
@@ -731,18 +690,18 @@ void LabEngine::doTransWipe(CloseDataPtr *CPtr, char *filename) {
 /*****************************************************************************/
 /* Does a certain number of pre-programmed wipes.                            */
 /*****************************************************************************/
-void LabEngine::doWipe(uint16 WipeType, CloseDataPtr *CPtr, char *filename) {
-	if ((WipeType == TRANSWIPE) || (WipeType == TRANSPORTER))
-		doTransWipe(CPtr, filename);
-	else if (WipeType == SCROLLWIPE)
+void LabEngine::doWipe(uint16 wipeType, CloseDataPtr *cPtr, char *filename) {
+	if ((wipeType == TRANSWIPE) || (wipeType == TRANSPORTER))
+		doTransWipe(cPtr, filename);
+	else if (wipeType == SCROLLWIPE)
 		doScrollWipe(filename);
-	else if (WipeType == SCROLLBLACK)
+	else if (wipeType == SCROLLBLACK)
 		doScrollBlack();
-	else if (WipeType == SCROLLBOUNCE)
+	else if (wipeType == SCROLLBOUNCE)
 		doScrollBounce();
-	else if (WipeType == READFIRSTFRAME)
+	else if (wipeType == READFIRSTFRAME)
 		readPict(filename, false);
-	else if (WipeType == READNEXTFRAME)
+	else if (wipeType == READNEXTFRAME)
 		diffNextFrame();
 }
 
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index b42e486..7ebfa8c 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -61,7 +61,7 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 
     _curapen = 0;
 
-    _currentDsplayBuffer = 0;
+    _currentDisplayBuffer = 0;
     _displayBuffer = 0;
 
     _lastWaitTOFTicks = 0;
@@ -92,6 +92,9 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_resource = nullptr;
 	_music = nullptr;
 
+    _lastMessageLong = false;
+    _lastTooLong = false;
+
 	//const Common::FSNode gameDataDir(ConfMan.get("path"));
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game/pict");
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 36a3c6c..c427b08 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -105,7 +105,7 @@ public:
 	Music *_music;
 
 	int _roomNum;
-	byte *_currentDsplayBuffer;
+	byte *_currentDisplayBuffer;
 	Common::Point _mousePos;
 
 	CrumbData _breadCrumbs[MAX_CRUMBS];
@@ -129,6 +129,9 @@ private:
 	uint16 _nextKeyOut;
 	bool _mouseAtEdge;
 
+	bool _lastMessageLong;
+	bool _lastTooLong;
+
 private:
 	bool createScreen(bool HiRes);
 	bool from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Common::Point tmpPos, uint16 &curInv, IntuiMessage * curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode);
@@ -137,7 +140,7 @@ public:
 	void waitTOF();
 	void setAPen(byte pennum);
 	void writeColorRegs(byte *buf, uint16 first, uint16 numreg);
-	byte *getVGABaseAddr();
+	byte *getCurrentDrawingBuffer();
 	void readScreenImage(Image *Im, uint16 x, uint16 y);
 	void screenUpdate();
 	void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index f7fb995..042889c 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -120,7 +120,7 @@ void LabEngine::diffNextFrame() {
 		return;
 
 	if (DispBitMap->Flags & BITMAPF_VIDEO) {
-		DispBitMap->Planes[0] = getVGABaseAddr();
+		DispBitMap->Planes[0] = getCurrentDrawingBuffer();
 		DispBitMap->Planes[1] = DispBitMap->Planes[0] + 0x10000;
 		DispBitMap->Planes[2] = DispBitMap->Planes[1] + 0x10000;
 		DispBitMap->Planes[3] = DispBitMap->Planes[2] + 0x10000;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 59cf2d1..e23ea70 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -180,7 +180,7 @@ static void changeCombination(uint16 number) {
 
 	combnum = combination[number];
 
-	display.ImageData = g_lab->getVGABaseAddr();
+	display.ImageData = g_lab->getCurrentDrawingBuffer();
 	display.Width     = g_lab->_screenWidth;
 	display.Height    = g_lab->_screenHeight;
 
@@ -191,7 +191,7 @@ static void changeCombination(uint16 number) {
 		} else
 			g_lab->waitTOF();
 
-		display.ImageData = g_lab->getVGABaseAddr();
+		display.ImageData = g_lab->getCurrentDrawingBuffer();
 
 		g_lab->scrollDisplayY(2, VGAScaleX(combx[number]), VGAScaleY(65), VGAScaleX(combx[number]) + (Images[combnum])->Width - 1, VGAScaleY(65) + (Images[combnum])->Height);
 
@@ -626,14 +626,14 @@ static void turnPage(bool FromLeft) {
 		for (int i = 0; i < g_lab->_screenWidth; i += 8) {
 			g_lab->_music->updateMusic();
 			g_lab->waitTOF();
-			ScreenImage.ImageData = g_lab->getVGABaseAddr();
+			ScreenImage.ImageData = g_lab->getCurrentDrawingBuffer();
 			g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight);
 		}
 	} else {
 		for (int i = (g_lab->_screenWidth - 8); i > 0; i -= 8) {
 			g_lab->_music->updateMusic();
 			g_lab->waitTOF();
-			ScreenImage.ImageData = g_lab->getVGABaseAddr();
+			ScreenImage.ImageData = g_lab->getCurrentDrawingBuffer();
 			g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight);
 		}
 	}
@@ -653,7 +653,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 
 	drawJournalText();
 
-	ScreenImage.ImageData = getVGABaseAddr();
+	ScreenImage.ImageData = getCurrentDrawingBuffer();
 
 	if (wipenum == 0)
 		bltBitMap(&JBackImage, 0, 0, &ScreenImage, 0, 0, _screenWidth, _screenHeight);
@@ -744,7 +744,7 @@ void LabEngine::doJournal() {
 	CancelG.NextGadget = &ForwardG;
 
 	ScreenImage = JBackImage;
-	ScreenImage.ImageData = getVGABaseAddr();
+	ScreenImage.ImageData = getCurrentDrawingBuffer();
 
 	_music->updateMusic();
 	loadJournalData();
@@ -758,7 +758,7 @@ void LabEngine::doJournal() {
 	fade(false, 0);
 	_event->mouseHide();
 
-	ScreenImage.ImageData = getVGABaseAddr();
+	ScreenImage.ImageData = getCurrentDrawingBuffer();
 
 	setAPen(0);
 	rectFill(0, 0, _screenWidth - 1, _screenHeight - 1);
diff --git a/engines/lab/text.cpp b/engines/lab/text.cpp
index 6c5ac8c..63ec12b 100644
--- a/engines/lab/text.cpp
+++ b/engines/lab/text.cpp
@@ -78,7 +78,7 @@ void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint
 	int32 templeft, LeftInSegment;
 	uint16 bwidth, mask, curpage, data;
 
-	VGATop = g_lab->getVGABaseAddr();
+	VGATop = g_lab->getCurrentDrawingBuffer();
 
 	for (uint16 i = 0; i < numchars; i++) {
 		RealOffset = (g_lab->_screenWidth * y) + x;
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 6af1fda..326b1f4 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -242,9 +242,9 @@ void LabEngine::screenUpdate() {
 /*****************************************************************************/
 /* Returns the base address of the current VGA display.                      */
 /*****************************************************************************/
-byte *LabEngine::getVGABaseAddr() {
-	if (_currentDsplayBuffer)
-		return _currentDsplayBuffer;
+byte *LabEngine::getCurrentDrawingBuffer() {
+	if (_currentDisplayBuffer)
+		return _currentDisplayBuffer;
 
 	return _displayBuffer;
 }
@@ -278,7 +278,7 @@ void LabEngine::drawImage(Image *im, uint16 x, uint16 y) {
 
 	if ((w > 0) && (h > 0)) {
 		byte *s = im->ImageData + sy * im->Width + sx;
-		byte *d = getVGABaseAddr() + dy * _screenWidth + dx;
+		byte *d = getCurrentDrawingBuffer() + dy * _screenWidth + dx;
 
 		while (h-- > 0) {
 			memcpy(d, s, w);
@@ -317,7 +317,7 @@ void LabEngine::drawMaskImage(Image *im, uint16 x, uint16 y) {
 
 	if ((w > 0) && (h > 0)) {
 		byte *s = im->ImageData + sy * im->Width + sx;
-		byte *d = getVGABaseAddr() + dy * _screenWidth + dx;
+		byte *d = getCurrentDrawingBuffer() + dy * _screenWidth + dx;
 
 		while (h-- > 0) {
 			byte *ss = s;
@@ -366,7 +366,7 @@ void LabEngine::readScreenImage(Image *im, uint16 x, uint16 y) {
 
 	if ((w > 0) && (h > 0)) {
 		byte *s = im->ImageData + sy * im->Width + sx;
-		byte *d = getVGABaseAddr() + dy * _screenWidth + dx;
+		byte *d = getCurrentDrawingBuffer() + dy * _screenWidth + dx;
 
 		while (h-- > 0) {
 			memcpy(s, d, w);
@@ -540,7 +540,7 @@ void LabEngine::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 		h = _screenHeight - dy;
 
 	if ((w > 0) && (h > 0)) {
-		char *d = (char *)getVGABaseAddr() + dy * _screenWidth + dx;
+		char *d = (char *)getCurrentDrawingBuffer() + dy * _screenWidth + dx;
 
 		while (h-- > 0) {
 			char *dd = d;
@@ -595,7 +595,7 @@ void LabEngine::ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uin
 		h = _screenHeight - dy;
 
 	if ((w > 0) && (h > 0)) {
-		char *d = (char *)getVGABaseAddr() + dy * _screenWidth + dx;
+		char *d = (char *)getCurrentDrawingBuffer() + dy * _screenWidth + dx;
 
 		while (h-- > 0) {
 			char *dd = d;


Commit: 27c204976e15fa4759b540b972a81fa0762a8cc9
    https://github.com/scummvm/scummvm/commit/27c204976e15fa4759b540b972a81fa0762a8cc9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:46+01:00

Commit Message:
LAB: Cleanup

Changed paths:
    engines/lab/graphics.cpp



diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index ea53292..fa750a6 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -59,11 +59,9 @@ extern const char *CurFileName;
 /* Reads in a picture into the dest bitmap.                                  */
 /*****************************************************************************/
 bool readPict(const char *filename, bool playOnce) {
-	byte **file = NULL;
-
 	stopDiff();
 
-	file = g_lab->_music->newOpen(filename);
+	byte **file = g_lab->_music->newOpen(filename);
 
 	if (file == NULL) {
 		if ((filename[0] == 'p') || (filename[0] == 'P'))
@@ -102,15 +100,14 @@ bool readMusic(const char *filename, bool waitTillFinished) {
 /* Reads in a picture into buffer memory.                                    */
 /*****************************************************************************/
 byte *readPictToMem(const char *filename, uint16 x, uint16 y) {
-	byte **file = NULL;
-	byte *Mem, *CurMem;
+	byte *mem;
 
 	stopDiff();
 
-	allocFile((void **)&Mem, (int32) x * (int32) y, "Bitmap");
-	CurMem = Mem;
+	allocFile((void **)&mem, (int32)x * (int32)y, "Bitmap");
+	byte *curMem = mem;
 
-	file = g_lab->_music->newOpen(filename);
+	byte **file = g_lab->_music->newOpen(filename);
 
 	if (file == NULL)
 		return NULL;
@@ -118,7 +115,7 @@ byte *readPictToMem(const char *filename, uint16 x, uint16 y) {
 	DispBitMap->BytesPerRow = x;
 	DispBitMap->Rows        = y;
 	DispBitMap->Flags       = 0;
-	DispBitMap->Planes[0] = CurMem;
+	DispBitMap->Planes[0] = curMem;
 	DispBitMap->Planes[1] = DispBitMap->Planes[0] + 0x10000;
 	DispBitMap->Planes[2] = DispBitMap->Planes[1] + 0x10000;
 	DispBitMap->Planes[3] = DispBitMap->Planes[2] + 0x10000;
@@ -126,7 +123,7 @@ byte *readPictToMem(const char *filename, uint16 x, uint16 y) {
 
 	readDiff(true);
 
-	return Mem;
+	return mem;
 }
 
 /*---------------------------------------------------------------------------*/
@@ -312,8 +309,8 @@ int32 LabEngine::longDrawMessage(const char *str) {
 
 	if (!LongWinInFront) {
 		LongWinInFront = true;
-		g_lab->setAPen(3);                 /* Clear Area */
-		g_lab->rectFill(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319), VGAScaleY(199));
+		setAPen(3);                 /* Clear Area */
+		rectFill(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319), VGAScaleY(199));
 	}
 
 	createBox(198);
@@ -342,7 +339,7 @@ void LabEngine::drawMessage(const char *str) {
 		} else {
 			if (LongWinInFront) {
 				LongWinInFront = false;
-				g_lab->drawPanel();
+				drawPanel();
 			}
 
 			_event->mouseHide();
@@ -372,13 +369,12 @@ void LabEngine::drawMessage(const char *str) {
 void LabEngine::doScrollBlack() {
 	byte *mem, *tempmem;
 	Image im;
-	uint16 width, height, by, nheight;
 	uint32 size, copysize;
 	uint32 *baseAddr;
 
 	_event->mouseHide();
-	width = VGAScaleX(320);
-	height = VGAScaleY(149) + SVGACord(2);
+	uint16 width = VGAScaleX(320);
+	uint16 height = VGAScaleY(149) + SVGACord(2);
 
 	allocFile((void **)&mem, (int32)width * (int32)height, "Temp Mem");
 
@@ -386,21 +382,21 @@ void LabEngine::doScrollBlack() {
 	im.Height = height;
 	im.ImageData = mem;
 	_music->updateMusic();
-	g_lab->readScreenImage(&im, 0, 0);
+	readScreenImage(&im, 0, 0);
 	_music->updateMusic();
 
-	baseAddr = (uint32 *)g_lab->getCurrentDrawingBuffer();
+	baseAddr = (uint32 *)getCurrentDrawingBuffer();
 
-	by      = VGAScaleX(4);
-	nheight = height;
+	uint16 by      = VGAScaleX(4);
+	uint16 nheight = height;
 
 	while (nheight) {
 		_music->updateMusic();
 
 		if (!_isHiRes)
-			g_lab->waitTOF();
+			waitTOF();
 
-		baseAddr = (uint32 *)g_lab->getCurrentDrawingBuffer();
+		baseAddr = (uint32 *)getCurrentDrawingBuffer();
 
 		if (by > nheight)
 			by = nheight;
@@ -411,8 +407,8 @@ void LabEngine::doScrollBlack() {
 		tempmem = mem;
 
 		while (size) {
-			if (size > g_lab->_screenBytesPerPage)
-				copysize = g_lab->_screenBytesPerPage;
+			if (size > _screenBytesPerPage)
+				copysize = _screenBytesPerPage;
 			else
 				copysize = size;
 
@@ -422,10 +418,10 @@ void LabEngine::doScrollBlack() {
 			tempmem += copysize;
 		}
 
-		g_lab->setAPen(0);
-		g_lab->rectFill(0, nheight, width - 1, nheight + by - 1);
+		setAPen(0);
+		rectFill(0, nheight, width - 1, nheight + by - 1);
 
-		g_lab->screenUpdate();
+		screenUpdate();
 
 		if (!_isHiRes) {
 			if (nheight <= (height / 8))
@@ -475,27 +471,26 @@ static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startli
 /* Scrolls the display to a new picture from a black screen.                 */
 /*****************************************************************************/
 void LabEngine::doScrollWipe(char *filename) {
-	byte *mem;
-	uint16 width, height, by, nheight, startline = 0, onrow = 0;
+	uint16 startline = 0, onrow = 0;
 
 	_event->mouseHide();
-	width = VGAScaleX(320);
-	height = VGAScaleY(149) + SVGACord(2);
+	uint16 width = VGAScaleX(320);
+	uint16 height = VGAScaleY(149) + SVGACord(2);
 
 	while (_music->isSoundEffectActive()) {
 		_music->updateMusic();
-		g_lab->waitTOF();
+		waitTOF();
 	}
 
 	IsBM = true;
 	readPict(filename, true);
-	g_lab->setPalette(diffcmap, 256);
+	setPalette(diffcmap, 256);
 	IsBM = false;
-	mem = RawDiffBM.Planes[0];
+	byte *mem = RawDiffBM.Planes[0];
 
 	_music->updateMusic();
-	by      = VGAScaleX(3);
-	nheight = height;
+	uint16 by = VGAScaleX(3);
+	uint16 nheight = height;
 
 	while (onrow < headerdata.y) {
 		_music->updateMusic();
@@ -511,7 +506,7 @@ void LabEngine::doScrollWipe(char *filename) {
 
 		copyPage(width, height, nheight, startline, mem);
 
-		g_lab->screenUpdate();
+		screenUpdate();
 
 		if (!nheight)
 			startline += by;
@@ -538,7 +533,7 @@ void LabEngine::doScrollBounce() {
 	const uint16 newbyd[5] = {5, 4, 3, 2, 1}, newby1d[8] = {3, 3, 2, 2, 2, 1, 1, 1};
 	const uint16 newbyw[5] = {10, 8, 6, 4, 2}, newby1w[8] = {6, 6, 4, 4, 4, 2, 2, 2};
 
-	if (g_lab->getPlatform() != Common::kPlatformWindows) {
+	if (getPlatform() != Common::kPlatformWindows) {
 		newby = newbyd;
 		newby1 = newby1d;
 	} else {
@@ -559,8 +554,8 @@ void LabEngine::doScrollBounce() {
 		startline -= newby[i];
 		copyPage(width, height, 0, startline, mem);
 
-		g_lab->screenUpdate();
-		g_lab->waitTOF();
+		screenUpdate();
+		waitTOF();
 	}
 
 	for (int i = 8; i > 0; i--) {
@@ -568,8 +563,8 @@ void LabEngine::doScrollBounce() {
 		startline += newby1[i - 1];
 		copyPage(width, height, 0, startline, mem);
 
-		g_lab->screenUpdate();
-		g_lab->waitTOF();
+		screenUpdate();
+		waitTOF();
 
 	}
 
@@ -597,17 +592,17 @@ void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 		while (curY < lastY) {
 			if (linesdone >= lineslast) {
 				_music->updateMusic();
-				g_lab->waitTOF();
+				waitTOF();
 				linesdone = 0;
 			}
 
-			g_lab->ghoastRect(0, 0, curY, g_lab->_screenWidth - 1, curY + 1);
+			ghoastRect(0, 0, curY, _screenWidth - 1, curY + 1);
 			curY += 4;
 			linesdone++;
 		}
 	}
 
-	g_lab->setAPen(0);
+	setAPen(0);
 
 	for (uint16 i = 0; i < 2; i++) {
 		curY = i * 2;
@@ -615,11 +610,11 @@ void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 		while (curY <= lastY) {
 			if (linesdone >= lineslast) {
 				_music->updateMusic();
-				g_lab->waitTOF();
+				waitTOF();
 				linesdone = 0;
 			}
 
-			g_lab->rectFill(0, curY, g_lab->_screenWidth - 1, curY + 1);
+			rectFill(0, curY, _screenWidth - 1, curY + 1);
 			curY += 4;
 			linesdone++;
 		}
@@ -632,17 +627,17 @@ void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 	else
 		CurFileName = getPictName(cPtr);
 
-	byte *BitMapMem = readPictToMem(CurFileName, g_lab->_screenWidth, lastY + 5);
-	g_lab->setPalette(diffcmap, 256);
+	byte *BitMapMem = readPictToMem(CurFileName, _screenWidth, lastY + 5);
+	setPalette(diffcmap, 256);
 
 	if (BitMapMem) {
-		imSource.Width = g_lab->_screenWidth;
+		imSource.Width = _screenWidth;
 		imSource.Height = lastY;
 		imSource.ImageData = BitMapMem;
 
-		imDest.Width = g_lab->_screenWidth;
-		imDest.Height = g_lab->_screenHeight;
-		imDest.ImageData = g_lab->getCurrentDrawingBuffer();
+		imDest.Width = _screenWidth;
+		imDest.Height = _screenHeight;
+		imDest.ImageData = getCurrentDrawingBuffer();
 
 		for (uint16 i = 0; i < 2; i++) {
 			curY = i * 2;
@@ -650,14 +645,14 @@ void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 			while (curY < lastY) {
 				if (linesdone >= lineslast) {
 					_music->updateMusic();
-					g_lab->waitTOF();
+					waitTOF();
 					linesdone = 0;
 				}
 
-				imDest.ImageData = g_lab->getCurrentDrawingBuffer();
+				imDest.ImageData = getCurrentDrawingBuffer();
 
-				g_lab->bltBitMap(&imSource, 0, curY, &imDest, 0, curY, g_lab->_screenWidth, 2);
-				g_lab->ghoastRect(0, 0, curY, g_lab->_screenWidth - 1, curY + 1);
+				bltBitMap(&imSource, 0, curY, &imDest, 0, curY, _screenWidth, 2);
+				ghoastRect(0, 0, curY, _screenWidth - 1, curY + 1);
 				curY += 4;
 				linesdone++;
 			}
@@ -669,16 +664,16 @@ void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 			while (curY <= lastY) {
 				if (linesdone >= lineslast) {
 					_music->updateMusic();
-					g_lab->waitTOF();
+					waitTOF();
 					linesdone = 0;
 				}
 
-				imDest.ImageData = g_lab->getCurrentDrawingBuffer();
+				imDest.ImageData = getCurrentDrawingBuffer();
 
 				if (curY == lastY)
-					g_lab->bltBitMap(&imSource, 0, curY, &imDest, 0, curY, g_lab->_screenWidth, 1);
+					bltBitMap(&imSource, 0, curY, &imDest, 0, curY, _screenWidth, 1);
 				else
-					g_lab->bltBitMap(&imSource, 0, curY, &imDest, 0, curY, g_lab->_screenWidth, 2);
+					bltBitMap(&imSource, 0, curY, &imDest, 0, curY, _screenWidth, 2);
 
 				curY += 4;
 				linesdone++;


Commit: 83d88cab8065613c71f91ce2b941b00192694ae1
    https://github.com/scummvm/scummvm/commit/83d88cab8065613c71f91ce2b941b00192694ae1
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:46+01:00

Commit Message:
LAB: Some renaming, get rid of copytwo()

Changed paths:
    engines/lab/diff.h
    engines/lab/graphics.cpp
    engines/lab/readdiff.cpp
    engines/lab/undiff.cpp



diff --git a/engines/lab/diff.h b/engines/lab/diff.h
index 5ed6278..4ff2059 100644
--- a/engines/lab/diff.h
+++ b/engines/lab/diff.h
@@ -37,33 +37,34 @@ namespace Lab {
 
 
 struct DIFFHeader {
-	uint16 Version;    // unused
-	uint16 x, y;
-	char depth;        // unused
-	char fps;
-	uint32 BufferSize; // unused
-	uint16 Machine;    // unused
-	uint32 Flags;
+	uint16 _version;    // unused
+	uint16 _width;
+	uint16 _height;
+	char _depth;        // unused
+	char _fps;
+	uint32 _bufferSize; // unused
+	uint16 _machine;    // unused
+	uint32 _flags;
 };
 
 struct BitMap {
-	uint16 BytesPerRow, Rows;
-	byte Flags;
-	byte *Planes[16];
+	uint16 _bytesPerRow;
+	uint16 _rows;       // unused
+	byte _flags;
+	byte *_planes[16];
 };
 
+#define BITMAPF_NONE  0
 #define BITMAPF_VIDEO (1<<7)
 
 /* unDiff.c */
 
-void initOffsets(uint16 bytesperrow);
+void initOffsets(uint16 bytesPerRow);
 
-bool unDIFFMemory(byte *Dest,       /* Where to Un-DIFF               */
-                  byte *diff,          /* The DIFFed code.               */
-                  uint16 HeaderSize,    /* Size of header (1, 2 or 4 bytes)
-                                                   (only supports 1 currently     */
-                  uint16 CopySize);     /* Size of minimum copy or skip.
-                                                   (1, 2 or 4 bytes)              */
+bool unDIFFMemory(byte *dest,           /* Where to Un-DIFF */
+                  byte *diff,           /* The DIFFed code. */
+                  uint16 headerSize,    /* Size of header (1, 2 or 4 bytes) (only supports 1 currently */
+                  uint16 copySize);     /* Size of minimum copy or skip. (1, 2 or 4 bytes) */
 
 bool VUnDIFFMemory(byte *Dest, byte *diff, uint16 HeaderSize, uint16 CopySize, uint16 bytesperrow);
 void runLengthDecode(byte *Dest, byte *Source);
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index fa750a6..1adcb2d 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -70,9 +70,9 @@ bool readPict(const char *filename, bool playOnce) {
 		return false;
 	}
 
-	DispBitMap->BytesPerRow = g_lab->_screenWidth;
-	DispBitMap->Rows        = g_lab->_screenHeight;
-	DispBitMap->Flags       = BITMAPF_VIDEO;
+	DispBitMap->_bytesPerRow = g_lab->_screenWidth;
+	DispBitMap->_rows        = g_lab->_screenHeight;
+	DispBitMap->_flags       = BITMAPF_VIDEO;
 
 	readDiff(playOnce);
 
@@ -112,14 +112,14 @@ byte *readPictToMem(const char *filename, uint16 x, uint16 y) {
 	if (file == NULL)
 		return NULL;
 
-	DispBitMap->BytesPerRow = x;
-	DispBitMap->Rows        = y;
-	DispBitMap->Flags       = 0;
-	DispBitMap->Planes[0] = curMem;
-	DispBitMap->Planes[1] = DispBitMap->Planes[0] + 0x10000;
-	DispBitMap->Planes[2] = DispBitMap->Planes[1] + 0x10000;
-	DispBitMap->Planes[3] = DispBitMap->Planes[2] + 0x10000;
-	DispBitMap->Planes[4] = DispBitMap->Planes[3] + 0x10000;
+	DispBitMap->_bytesPerRow = x;
+	DispBitMap->_rows        = y;
+	DispBitMap->_flags       = BITMAPF_NONE;
+	DispBitMap->_planes[0] = curMem;
+	DispBitMap->_planes[1] = DispBitMap->_planes[0] + 0x10000;
+	DispBitMap->_planes[2] = DispBitMap->_planes[1] + 0x10000;
+	DispBitMap->_planes[3] = DispBitMap->_planes[2] + 0x10000;
+	DispBitMap->_planes[4] = DispBitMap->_planes[3] + 0x10000;
 
 	readDiff(true);
 
@@ -486,19 +486,19 @@ void LabEngine::doScrollWipe(char *filename) {
 	readPict(filename, true);
 	setPalette(diffcmap, 256);
 	IsBM = false;
-	byte *mem = RawDiffBM.Planes[0];
+	byte *mem = RawDiffBM._planes[0];
 
 	_music->updateMusic();
 	uint16 by = VGAScaleX(3);
 	uint16 nheight = height;
 
-	while (onrow < headerdata.y) {
+	while (onrow < headerdata._height) {
 		_music->updateMusic();
 
 		if ((by > nheight) && nheight)
 			by = nheight;
 
-		if ((startline + by) > (headerdata.y - height - 1))
+		if ((startline + by) > (headerdata._height - height - 1))
 			break;
 
 		if (nheight)
@@ -544,10 +544,10 @@ void LabEngine::doScrollBounce() {
 	_event->mouseHide();
 	int width = VGAScaleX(320);
 	int height = VGAScaleY(149) + SVGACord(2);
-	byte *mem = RawDiffBM.Planes[0];
+	byte *mem = RawDiffBM._planes[0];
 
 	_music->updateMusic();
-	int startline = headerdata.y - height - 1;
+	int startline = headerdata._height - height - 1;
 
 	for (int i = 0; i < 5; i++) {
 		_music->updateMusic();
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index 042889c..abaa4f5 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -59,7 +59,7 @@ static bool continuous,
 	IsAnim         = false,
 	IsPal          = false;
 
-uint16 DataBytesPerRow;
+uint16 _dataBytesPerRow;
 DIFFHeader headerdata;
 char diffcmap[256 * 3];
 BitMap RawDiffBM;
@@ -119,12 +119,12 @@ void LabEngine::diffNextFrame() {
 	if (header == 65535)  /* Already done. */
 		return;
 
-	if (DispBitMap->Flags & BITMAPF_VIDEO) {
-		DispBitMap->Planes[0] = getCurrentDrawingBuffer();
-		DispBitMap->Planes[1] = DispBitMap->Planes[0] + 0x10000;
-		DispBitMap->Planes[2] = DispBitMap->Planes[1] + 0x10000;
-		DispBitMap->Planes[3] = DispBitMap->Planes[2] + 0x10000;
-		DispBitMap->Planes[4] = DispBitMap->Planes[3] + 0x10000;
+	if (DispBitMap->_flags & BITMAPF_VIDEO) {
+		DispBitMap->_planes[0] = getCurrentDrawingBuffer();
+		DispBitMap->_planes[1] = DispBitMap->_planes[0] + 0x10000;
+		DispBitMap->_planes[2] = DispBitMap->_planes[1] + 0x10000;
+		DispBitMap->_planes[3] = DispBitMap->_planes[2] + 0x10000;
+		DispBitMap->_planes[4] = DispBitMap->_planes[3] + 0x10000;
 	}
 
 	_event->mouseHide();
@@ -134,7 +134,7 @@ void LabEngine::diffNextFrame() {
 			_event->mouseShow();
 
 			if (!IsBM) {
-				if (headerdata.fps) {
+				if (headerdata._fps) {
 					waitForTime(WaitSec, WaitMicros);
 					addCurTime(0L, DelayMicros, &WaitSec, &WaitMicros);
 				}
@@ -162,7 +162,7 @@ void LabEngine::diffNextFrame() {
 			IsAnim = (framenumber >= 3) && (!PlayOnce);
 			CurBit = 0;
 
-			if (DispBitMap->Flags & BITMAPF_VIDEO)
+			if (DispBitMap->_flags & BITMAPF_VIDEO)
 				screenUpdate();
 
 			return; /* done with the next frame. */
@@ -182,12 +182,12 @@ void LabEngine::diffNextFrame() {
 			break;
 
 		case 10L:
-			RawDiffBM.Planes[CurBit] = *difffile;
+			RawDiffBM._planes[CurBit] = *difffile;
 
 			if (IsBM)
 				(*difffile) += size;
 			else {
-				readBlock(DrawBitMap->Planes[CurBit], size, difffile);
+				readBlock(DrawBitMap->_planes[CurBit], size, difffile);
 			}
 
 			CurBit++;
@@ -195,26 +195,26 @@ void LabEngine::diffNextFrame() {
 
 		case 11L:
 			(*difffile) += 4;
-			runLengthDecode(DrawBitMap->Planes[CurBit], *difffile);
+			runLengthDecode(DrawBitMap->_planes[CurBit], *difffile);
 			CurBit++;
 			(*difffile) += size - 4;
 			break;
 
 		case 12L:
 			(*difffile) += 4;
-			VRunLengthDecode(DrawBitMap->Planes[CurBit], *difffile, DrawBitMap->BytesPerRow);
+			VRunLengthDecode(DrawBitMap->_planes[CurBit], *difffile, DrawBitMap->_bytesPerRow);
 			CurBit++;
 			(*difffile) += size - 4;
 			break;
 
 		case 20L:
-			unDiff(DrawBitMap->Planes[CurBit], DispBitMap->Planes[CurBit], *difffile, DrawBitMap->BytesPerRow, false);
+			unDiff(DrawBitMap->_planes[CurBit], DispBitMap->_planes[CurBit], *difffile, DrawBitMap->_bytesPerRow, false);
 			CurBit++;
 			(*difffile) += size;
 			break;
 
 		case 21L:
-			unDiff(DrawBitMap->Planes[CurBit], DispBitMap->Planes[CurBit], *difffile, DrawBitMap->BytesPerRow, true);
+			unDiff(DrawBitMap->_planes[CurBit], DispBitMap->_planes[CurBit], *difffile, DrawBitMap->_bytesPerRow, true);
 			CurBit++;
 			(*difffile) += size;
 			break;
@@ -259,7 +259,7 @@ void LabEngine::diffNextFrame() {
 						_music->updateMusic();
 						waitTOF();
 
-						if (DispBitMap->Flags & BITMAPF_VIDEO)
+						if (DispBitMap->_flags & BITMAPF_VIDEO)
 							didTOF = 1;
 					}
 				}
@@ -334,29 +334,29 @@ void playDiff() {
 
 	if (header == 0) {
 		// sizeof(headerdata) != 18, but the padding might be at the end
-		headerdata.Version = READ_LE_UINT16(*difffile);
+		headerdata._version = READ_LE_UINT16(*difffile);
 		(*difffile) += 2;
-		headerdata.x = READ_LE_UINT16(*difffile);
+		headerdata._width = READ_LE_UINT16(*difffile);
 		(*difffile) += 2;
-		headerdata.y = READ_LE_UINT16(*difffile);
+		headerdata._height = READ_LE_UINT16(*difffile);
 		(*difffile) += 2;
-		headerdata.depth = *difffile[0];
+		headerdata._depth = *difffile[0];
 		(*difffile)++;
-		headerdata.fps = *difffile[0];
+		headerdata._fps = *difffile[0];
 		(*difffile)++;
-		headerdata.BufferSize = READ_LE_UINT32(*difffile);
+		headerdata._bufferSize = READ_LE_UINT32(*difffile);
 		(*difffile) += 4;
-		headerdata.Machine = READ_LE_UINT16(*difffile);
+		headerdata._machine = READ_LE_UINT16(*difffile);
 		(*difffile) += 2;
-		headerdata.Flags = READ_LE_UINT32(*difffile);
+		headerdata._flags = READ_LE_UINT32(*difffile);
 		(*difffile) += 4;
 
 		(*difffile) += size - 18;
 
-		continuous = CONTINUOUS & headerdata.Flags;
-		diffwidth = headerdata.x;
-		diffheight = headerdata.y;
-		DataBytesPerRow = diffwidth;
+		continuous = CONTINUOUS & headerdata._flags;
+		diffwidth = headerdata._width;
+		diffheight = headerdata._height;
+		_dataBytesPerRow = diffwidth;
 
 		numchunks = (((int32) diffwidth) * diffheight) / 0x10000;
 
@@ -367,10 +367,10 @@ void playDiff() {
 	}
 
 	for (header = 0; header < 8; header++)
-		RawDiffBM.Planes[header] = NULL;
+		RawDiffBM._planes[header] = NULL;
 
-	if (headerdata.fps)
-		DelayMicros = ONESECOND / headerdata.fps;
+	if (headerdata._fps)
+		DelayMicros = ONESECOND / headerdata._fps;
 
 	if (PlayOnce) {
 		while (header != 65535)
diff --git a/engines/lab/undiff.cpp b/engines/lab/undiff.cpp
index f7d8989..e5f193c 100644
--- a/engines/lab/undiff.cpp
+++ b/engines/lab/undiff.cpp
@@ -33,39 +33,15 @@
 
 namespace Lab {
 
-extern uint16 DataBytesPerRow;
-
-
-
-/*****************************************************************************/
-/* Copies memory.                                                            */
-/*****************************************************************************/
-
-static void copytwo(byte *Dest, byte *Source) {
-#if defined(USE_SWAP)
-	Dest[1] = Source[0];
-	Dest[0] = Source[1];
-#else
-	*Dest = *Source;
-	Dest++;
-	Source++;
-	*Dest = *Source;
-#endif
-}
-
-
-
+extern uint16 _dataBytesPerRow;
 
 /*------------------------ unDiff Horizontal Memory -------------------------*/
 
-
-
-
 /*****************************************************************************/
 /* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
 /* is also a byte.                                                           */
 /*****************************************************************************/
-static void unDIFFByteByte(byte *Dest, byte *diff) {
+static void unDIFFByteByte(byte *dest, byte *diff) {
 	uint16 skip, copy;
 
 	while (1) {
@@ -76,17 +52,17 @@ static void unDIFFByteByte(byte *Dest, byte *diff) {
 
 		if (skip == 255) {
 			if (copy == 0) {
-				copytwo((byte *) &skip, diff);
+				skip = READ_LE_UINT16(diff);
 				diff += 2;
-				copytwo((byte *) &copy, diff);
+				copy = READ_LE_UINT16(diff);
 				diff += 2;
 			} else if (copy == 255)
 				return;
 		}
 
-		Dest += skip;
-		memcpy(Dest, diff, copy);
-		Dest += copy;
+		dest += skip;
+		memcpy(dest, diff, copy);
+		dest += copy;
 		diff += copy;
 	}
 }
@@ -97,7 +73,7 @@ static void unDIFFByteByte(byte *Dest, byte *diff) {
 /* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
 /* is a word.                                                                */
 /*****************************************************************************/
-static void unDIFFByteWord(uint16 *Dest, uint16 *diff) {
+static void unDIFFByteWord(uint16 *dest, uint16 *diff) {
 	uint16 skip, copy;
 
 	while (1) {
@@ -116,31 +92,31 @@ static void unDIFFByteWord(uint16 *Dest, uint16 *diff) {
 				return;
 		}
 
-		Dest += skip;
+		dest += skip;
 
 		while (copy > 3) {
-			*Dest = READ_LE_UINT16(diff);
-			Dest++;
+			*dest = READ_LE_UINT16(diff);
+			dest++;
 			diff++;
 
-			*Dest = READ_LE_UINT16(diff);
-			Dest++;
+			*dest = READ_LE_UINT16(diff);
+			dest++;
 			diff++;
 
-			*Dest = READ_LE_UINT16(diff);
-			Dest++;
+			*dest = READ_LE_UINT16(diff);
+			dest++;
 			diff++;
 
-			*Dest = READ_LE_UINT16(diff);
-			Dest++;
+			*dest = READ_LE_UINT16(diff);
+			dest++;
 			diff++;
 
 			copy -= 4;
 		}
 
 		while (copy) {
-			*Dest = READ_LE_UINT16(diff);
-			Dest++;
+			*dest = READ_LE_UINT16(diff);
+			dest++;
 			diff++;
 			copy--;
 		}
@@ -152,30 +128,24 @@ static void unDIFFByteWord(uint16 *Dest, uint16 *diff) {
 /*****************************************************************************/
 /* UnDiffs a coded DIFF string onto an already initialized piece of memory.  */
 /*****************************************************************************/
-bool unDIFFMemory(byte *Dest, byte *diff, uint16 HeaderSize, uint16 CopySize) {
-	if (HeaderSize == 1) {
-		if (CopySize == 1)
-			unDIFFByteByte(Dest, diff);
+bool unDIFFMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySize) {
+	if (headerSize == 1) {
+		if (copySize == 1)
+			unDIFFByteByte(dest, diff);
 
-		else if (CopySize == 2)
-			unDIFFByteWord((uint16 *)Dest, (uint16 *)diff);
+		else if (copySize == 2)
+			unDIFFByteWord((uint16 *)dest, (uint16 *)diff);
 
 		else
 			return false;
 	} else
-		error("unDIFFMemory: HeaderSize is %d", HeaderSize);
+		error("unDIFFMemory: HeaderSize is %d", headerSize);
 
 	return true;
 }
 
-
-
-
 /*------------------------- unDiff Vertical Memory --------------------------*/
 
-
-
-
 /*****************************************************************************/
 /* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
 /* is a byte.                                                                */
@@ -186,7 +156,7 @@ static void VUnDIFFByteByte(byte *Dest, byte *diff, uint16 bytesperrow) {
 	uint16 counter = 0;
 
 
-	while (counter < DataBytesPerRow) {
+	while (counter < _dataBytesPerRow) {
 		CurPtr = Dest + counter;
 
 		for (;;) {
@@ -229,7 +199,7 @@ static void VUnDIFFByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow) {
 
 	wordsperrow = bytesperrow / 2;
 
-	while (counter < (DataBytesPerRow >> 1)) {
+	while (counter < (_dataBytesPerRow >> 1)) {
 		CurPtr = Dest + counter;
 
 		for (;;) {
@@ -274,7 +244,7 @@ static void VUnDIFFByteLong(uint32 *Dest, uint32 *diff, uint16 bytesperrow) {
 
 	longsperrow = bytesperrow / 4;
 
-	while (counter < (DataBytesPerRow >> 2)) {
+	while (counter < (_dataBytesPerRow >> 2)) {
 		CurPtr = Dest + counter;
 
 		for (;;) {
@@ -373,7 +343,7 @@ void VRunLengthDecode(byte *Dest, byte *Source, uint16 bytesperrow) {
 	int16 count;
 	byte *Top = Dest;
 
-	for (uint16 i = 0; i < DataBytesPerRow; i++) {
+	for (uint16 i = 0; i < _dataBytesPerRow; i++) {
 		Dest = Top;
 		Dest += i;
 


Commit: d656aa4859352e3d08e15346a482c943c1868502
    https://github.com/scummvm/scummvm/commit/d656aa4859352e3d08e15346a482c943c1868502
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:46+01:00

Commit Message:
LAB: Introduce the Anim class (WIP)

Changed paths:
  A engines/lab/anim.cpp
  A engines/lab/anim.h
  R engines/lab/diff.h
  R engines/lab/undiff.cpp
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/intro.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/labfun.h
    engines/lab/map.cpp
    engines/lab/module.mk
    engines/lab/processroom.cpp
    engines/lab/readdiff.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
new file mode 100644
index 0000000..44d9eea
--- /dev/null
+++ b/engines/lab/anim.cpp
@@ -0,0 +1,728 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "common/endian.h"
+#include "lab/lab.h"
+
+namespace Lab {
+
+extern uint16 _dataBytesPerRow;
+extern BitMap *DrawBitMap;
+extern byte **startoffile;
+extern BitMap *DispBitMap;
+
+Anim::Anim(LabEngine *vm) : _vm(vm) {
+	header = 0;
+	CurBit = 0;
+	numchunks = 1;
+	IsBM = false;
+	headerdata._width = 0;
+	headerdata._height = 0;
+	headerdata._fps = 0;
+	headerdata._flags = 0;
+	WaitSec = 0;
+	WaitMicros = 0;
+	DelayMicros = 0;
+	continuous = false;
+	IsPlaying = false;
+	IsAnim = false;
+	IsPal = false;
+	nopalchange = false;
+	donepal = false;
+	framenumber = 0;
+	PlayOnce = false;
+	Buffer = nullptr;
+	storagefordifffile = nullptr;
+	difffile = &storagefordifffile;
+	size = 0;
+	RawDiffBM._bytesPerRow = 0;
+	RawDiffBM._flags = 0;
+	for (int i = 0; i < 16; i++)
+		RawDiffBM._planes[i] = nullptr;
+	RawDiffBM._rows = 0;
+	waitForEffect = false;
+	StopPlayingEnd = false;
+	samplespeed = 0;
+	DoBlack = false;
+	start = nullptr;
+	diffwidth = 0;
+	diffheight = 0;
+	stopsound = false;
+
+
+	for (int i = 0; i < 3 * 256; i++)
+		diffcmap[i] = 0;
+
+}
+
+/*------------------------ unDiff Horizontal Memory -------------------------*/
+
+/*****************************************************************************/
+/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
+/* is also a byte.                                                           */
+/*****************************************************************************/
+static void unDIFFByteByte(byte *dest, byte *diff) {
+	uint16 skip, copy;
+
+	while (1) {
+		skip = *diff;
+		diff++;
+		copy = *diff;
+		diff++;
+
+		if (skip == 255) {
+			if (copy == 0) {
+				skip = READ_LE_UINT16(diff);
+				diff += 2;
+				copy = READ_LE_UINT16(diff);
+				diff += 2;
+			} else if (copy == 255)
+				return;
+		}
+
+		dest += skip;
+		memcpy(dest, diff, copy);
+		dest += copy;
+		diff += copy;
+	}
+}
+
+/*****************************************************************************/
+/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
+/* is a word.                                                                */
+/*****************************************************************************/
+static void unDIFFByteWord(uint16 *dest, uint16 *diff) {
+	uint16 skip, copy;
+
+	while (1) {
+		skip = ((byte *)diff)[0];
+		copy = ((byte *)diff)[1];
+
+		diff++;
+
+		if (skip == 255) {
+			if (copy == 0) {
+				skip = READ_LE_UINT16(diff);
+				diff++;
+				copy = READ_LE_UINT16(diff);
+				diff++;
+			} else if (copy == 255)
+				return;
+		}
+
+		dest += skip;
+
+		while (copy > 3) {
+			*dest = READ_LE_UINT16(diff);
+			dest++;
+			diff++;
+
+			*dest = READ_LE_UINT16(diff);
+			dest++;
+			diff++;
+
+			*dest = READ_LE_UINT16(diff);
+			dest++;
+			diff++;
+
+			*dest = READ_LE_UINT16(diff);
+			dest++;
+			diff++;
+
+			copy -= 4;
+		}
+
+		while (copy) {
+			*dest = READ_LE_UINT16(diff);
+			dest++;
+			diff++;
+			copy--;
+		}
+	}
+}
+
+/*****************************************************************************/
+/* UnDiffs a coded DIFF string onto an already initialized piece of memory.  */
+/*****************************************************************************/
+bool Anim::unDIFFMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySize) {
+	if (headerSize == 1) {
+		if (copySize == 1)
+			unDIFFByteByte(dest, diff);
+
+		else if (copySize == 2)
+			unDIFFByteWord((uint16 *)dest, (uint16 *)diff);
+
+		else
+			return false;
+	} else
+		error("unDIFFMemory: HeaderSize is %d", headerSize);
+
+	return true;
+}
+
+/*------------------------- unDiff Vertical Memory --------------------------*/
+
+/*****************************************************************************/
+/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
+/* is a byte.                                                                */
+/*****************************************************************************/
+static void VUnDIFFByteByte(byte *Dest, byte *diff, uint16 bytesperrow) {
+	byte *CurPtr;
+	uint16 skip, copy;
+	uint16 counter = 0;
+
+
+	while (counter < _dataBytesPerRow) {
+		CurPtr = Dest + counter;
+
+		for (;;) {
+			skip = *diff;
+			diff++;
+			copy = *diff;
+			diff++;
+
+			if (skip == 255) {
+				counter += copy;
+				break;
+			}
+
+			else {
+				CurPtr += (skip * bytesperrow);
+
+				while (copy) {
+					copy--;
+					*CurPtr = *diff;
+					CurPtr += bytesperrow;
+					diff++;
+				}
+			}
+		}
+	}
+}
+
+/*****************************************************************************/
+/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
+/* is a word.                                                                */
+/*****************************************************************************/
+static void VUnDIFFByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow) {
+	uint16 *CurPtr;
+	uint16 skip, copy;
+	uint16 counter = 0, wordsperrow;
+
+
+	wordsperrow = bytesperrow / 2;
+
+	while (counter < (_dataBytesPerRow >> 1)) {
+		CurPtr = Dest + counter;
+
+		for (;;) {
+			skip = ((byte *)diff)[0];
+			copy = ((byte *)diff)[1];
+
+			diff++;
+
+
+			if (skip == 255) {
+				counter += copy;
+				break;
+			}
+
+			else {
+				CurPtr += (skip * wordsperrow);
+
+				while (copy) {
+					*CurPtr = *diff; //swapUShort(*diff);
+					CurPtr += wordsperrow;
+					diff++;
+					copy--;
+				}
+			}
+		}
+	}
+}
+
+/*****************************************************************************/
+/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
+/* is a long.                                                                */
+/*****************************************************************************/
+static void VUnDIFFByteLong(uint32 *Dest, uint32 *diff, uint16 bytesperrow) {
+	uint32 *CurPtr;
+	uint16 skip, copy;
+	uint16 counter = 0, longsperrow;
+	byte *diff1 = (byte *)diff;
+
+
+	longsperrow = bytesperrow / 4;
+
+	while (counter < (_dataBytesPerRow >> 2)) {
+		CurPtr = Dest + counter;
+
+		for (;;) {
+			skip = *diff1;
+			diff1++;
+
+			copy = *diff1;
+			diff1++;
+
+
+			if (skip == 255) {
+				counter += copy;
+				break;
+			}
+
+			else {
+				CurPtr += (skip * longsperrow);
+
+				while (copy) {
+					*CurPtr = *(uint32 *)diff1; //swapULong(*diff);
+					CurPtr += longsperrow;
+					diff1 += 4;
+					copy--;
+				}
+			}
+		}
+	}
+}
+
+/*****************************************************************************/
+/* UnDiffs a coded DIFF string onto an already initialized piece of memory.  */
+/*****************************************************************************/
+bool Anim::VUnDIFFMemory(byte *Dest, byte *diff, uint16 HeaderSize, uint16 CopySize, uint16 bytesperrow) {
+	if (HeaderSize == 1) {
+		if (CopySize == 1)
+			VUnDIFFByteByte(Dest, diff, bytesperrow);
+
+		else if (CopySize == 2)
+			VUnDIFFByteWord((uint16 *)Dest, (uint16 *)diff, bytesperrow);
+
+		else if (CopySize == 4)
+			VUnDIFFByteLong((uint32 *)Dest, (uint32 *)diff, bytesperrow);
+
+		else
+			return false;
+	} else
+		return (false);
+
+	return true;
+}
+
+/*****************************************************************************/
+/* Runlength decodes a chunk of memory.                                      */
+/*****************************************************************************/
+void Anim::runLengthDecode(byte *Dest, byte *Source) {
+	int8 num;
+	int16 count;
+
+
+	while (1) {
+		num = (int8)*Source;
+		Source++;
+
+		if (num == 127) {
+			return;
+		} else if (num > '\0') {
+			memcpy(Dest, Source, num);
+			Source += num;
+			Dest   += num;
+		} else {
+			count = (int16)(-num);
+			num   = *Source;
+			Source++;
+
+			while (count) {
+				*Dest = num;
+				Dest++;
+				count--;
+			}
+		}
+	}
+}
+
+/*****************************************************************************/
+/* Does a vertical run length decode.                                        */
+/*****************************************************************************/
+void Anim::VRunLengthDecode(byte *Dest, byte *Source, uint16 bytesperrow) {
+	int8 num;
+	int16 count;
+	byte *Top = Dest;
+
+	for (uint16 i = 0; i < _dataBytesPerRow; i++) {
+		Dest = Top;
+		Dest += i;
+
+		num = (int8)*Source;
+		Source++;
+
+		while (num != 127) {
+			if (num > '\0') {
+				while (num) {
+					*Dest = *Source;
+					Source++;
+					Dest += bytesperrow;
+					num--;
+				}
+			} else {
+				count = (int16)(-num);
+				num   = (int8)*Source;
+				Source++;
+
+				while (count) {
+					*Dest = num;
+					Dest += bytesperrow;
+					count--;
+				}
+			}
+
+			num = *Source;
+			Source++;
+		}
+	}
+}
+
+/*****************************************************************************/
+/* Does the undiffing between the bitmaps.                                   */
+/*****************************************************************************/
+void Anim::unDiff(byte *NewBuf, byte *OldBuf, byte *DiffData, uint16 bytesperrow, bool IsV) {
+	byte buftype;
+
+	DiffData++;
+	buftype  = *DiffData;
+	DiffData++;
+
+	if (IsV)
+		VUnDIFFMemory(NewBuf, DiffData, 1, buftype + 1, bytesperrow);
+	else
+		unDIFFMemory(NewBuf, DiffData, 1, buftype + 1);
+}
+
+void Anim::diffNextFrame() {
+	if (header == 65535)  /* Already done. */
+		return;
+
+	if (DispBitMap->_flags & BITMAPF_VIDEO) {
+		DispBitMap->_planes[0] = g_lab->getCurrentDrawingBuffer();
+		DispBitMap->_planes[1] = DispBitMap->_planes[0] + 0x10000;
+		DispBitMap->_planes[2] = DispBitMap->_planes[1] + 0x10000;
+		DispBitMap->_planes[3] = DispBitMap->_planes[2] + 0x10000;
+		DispBitMap->_planes[4] = DispBitMap->_planes[3] + 0x10000;
+	}
+
+	_vm->_event->mouseHide();
+
+	while (1) {
+		if (CurBit >= numchunks) {
+			_vm->_event->mouseShow();
+
+			if (!IsBM) {
+				if (headerdata._fps) {
+					_vm->waitForTime(WaitSec, WaitMicros);
+					_vm->addCurTime(0L, DelayMicros, &WaitSec, &WaitMicros);
+				}
+
+				if (IsPal && !nopalchange) {
+					_vm->setPalette(diffcmap, 256);
+					IsPal = false;
+				}
+
+				donepal = true;
+			}
+
+			if (IsPal && !nopalchange && !IsBM && !donepal) {
+				_vm->setPalette(diffcmap, 256);
+				IsPal = false;
+			}
+
+			donepal = false;
+
+			framenumber++;
+
+			if ((framenumber == 1) && (continuous || (!PlayOnce)))
+				Buffer = *difffile;
+
+			IsAnim = (framenumber >= 3) && (!PlayOnce);
+			CurBit = 0;
+
+			if (DispBitMap->_flags & BITMAPF_VIDEO)
+				_vm->screenUpdate();
+
+			return; /* done with the next frame. */
+		}
+
+		_vm->_music->updateMusic();
+		header = READ_LE_UINT32(*difffile);
+		*difffile += 4;
+
+		size = READ_LE_UINT32(*difffile);
+		*difffile += 4;
+
+		switch (header) {
+		case 8L:
+			readBlock(diffcmap, size, difffile);
+			IsPal = true;
+			break;
+
+		case 10L:
+			RawDiffBM._planes[CurBit] = *difffile;
+
+			if (IsBM)
+				(*difffile) += size;
+			else {
+				readBlock(DrawBitMap->_planes[CurBit], size, difffile);
+			}
+
+			CurBit++;
+			break;
+
+		case 11L:
+			(*difffile) += 4;
+			runLengthDecode(DrawBitMap->_planes[CurBit], *difffile);
+			CurBit++;
+			(*difffile) += size - 4;
+			break;
+
+		case 12L:
+			(*difffile) += 4;
+			VRunLengthDecode(DrawBitMap->_planes[CurBit], *difffile, DrawBitMap->_bytesPerRow);
+			CurBit++;
+			(*difffile) += size - 4;
+			break;
+
+		case 20L:
+			unDiff(DrawBitMap->_planes[CurBit], DispBitMap->_planes[CurBit], *difffile, DrawBitMap->_bytesPerRow, false);
+			CurBit++;
+			(*difffile) += size;
+			break;
+
+		case 21L:
+			unDiff(DrawBitMap->_planes[CurBit], DispBitMap->_planes[CurBit], *difffile, DrawBitMap->_bytesPerRow, true);
+			CurBit++;
+			(*difffile) += size;
+			break;
+
+		case 25L:
+			CurBit++;
+			break;
+
+		case 26L:
+			CurBit++;
+			break;
+
+		case 30L:
+		case 31L: {
+			if (waitForEffect) {
+				while (_vm->_music->isSoundEffectActive()) {
+					_vm->_music->updateMusic();
+					_vm->waitTOF();
+				}
+			}
+
+			size -= 8L;
+
+
+			(*difffile) += 4;
+			samplespeed = READ_LE_UINT16(*difffile);
+			(*difffile) += 4;
+
+			byte *music = *difffile;
+			uint32 musicsize = size;
+			(*difffile) += size;
+
+			_vm->_music->playSoundEffect(samplespeed, musicsize, music);
+			break;
+				  }
+		case 65535L:
+			if ((framenumber == 1) || PlayOnce || StopPlayingEnd) {
+				int didTOF = 0;
+
+				if (waitForEffect) {
+					while (_vm->_music->isSoundEffectActive()) {
+						_vm->_music->updateMusic();
+						_vm->waitTOF();
+
+						if (DispBitMap->_flags & BITMAPF_VIDEO)
+							didTOF = 1;
+					}
+				}
+
+				IsPlaying = false;
+				_vm->_event->mouseShow();
+
+				if (!didTOF)
+					_vm->screenUpdate();
+
+				return;
+			}
+
+			framenumber = 4;  /* Random frame number so it never gets back to 2 */
+			*difffile = Buffer;
+			break;
+
+		default:
+			(*difffile) += size;
+			break;
+		}
+	}
+}
+
+/*****************************************************************************/
+/* A separate task launched by readDiff.  Plays the DIFF.                    */
+/*****************************************************************************/
+void Anim::playDiff() {
+	WaitSec   = 0L;
+	WaitMicros = 0L;
+	DelayMicros = 0L;
+	header      = 0;
+	CurBit = 0;
+	framenumber = 0;
+	numchunks   = 1;
+	donepal     = false;
+	StopPlayingEnd = false;
+	difffile    = &storagefordifffile;
+
+	IsPlaying   = true;
+
+	if (DoBlack) {
+		DoBlack = false;
+		blackScreen();
+	}
+
+	start = *startoffile;            /* Make a copy of the pointer to the start of the file    */
+	*difffile = start;               /* Now can modify the file without modifying the original */
+
+	if (start == NULL) {
+		IsPlaying = false;
+		return;
+	}
+
+	continuous = false;
+	uint32 signature = READ_BE_UINT32(*difffile);
+	(*difffile) += 4;
+
+	header = READ_LE_UINT32(*difffile);
+	(*difffile) += 4;
+
+	if ((signature != MKTAG('D', 'I', 'F', 'F')) || (header != 1219009121L)) {
+		IsPlaying = false;
+		return;
+	}
+
+	header = READ_LE_UINT32(*difffile);
+	(*difffile) += 4;
+
+	size = READ_LE_UINT32(*difffile);
+	(*difffile) += 4;
+
+	if (header == 0) {
+		// sizeof(headerdata) != 18, but the padding might be at the end
+		headerdata._version = READ_LE_UINT16(*difffile);
+		(*difffile) += 2;
+		headerdata._width = READ_LE_UINT16(*difffile);
+		(*difffile) += 2;
+		headerdata._height = READ_LE_UINT16(*difffile);
+		(*difffile) += 2;
+		headerdata._depth = *difffile[0];
+		(*difffile)++;
+		headerdata._fps = *difffile[0];
+		(*difffile)++;
+		headerdata._bufferSize = READ_LE_UINT32(*difffile);
+		(*difffile) += 4;
+		headerdata._machine = READ_LE_UINT16(*difffile);
+		(*difffile) += 2;
+		headerdata._flags = READ_LE_UINT32(*difffile);
+		(*difffile) += 4;
+
+		(*difffile) += size - 18;
+
+		continuous = CONTINUOUS & headerdata._flags;
+		diffwidth = headerdata._width;
+		diffheight = headerdata._height;
+		_dataBytesPerRow = diffwidth;
+
+		numchunks = (((int32) diffwidth) * diffheight) / 0x10000;
+
+		if ((uint32)(numchunks * 0x10000) < (uint32)(((int32) diffwidth) * diffheight))
+			numchunks++;
+	} else {
+		return;
+	}
+
+	for (header = 0; header < 8; header++)
+		RawDiffBM._planes[header] = NULL;
+
+	if (headerdata._fps)
+		DelayMicros = ONESECOND / headerdata._fps;
+
+	if (PlayOnce) {
+		while (header != 65535)
+			diffNextFrame();
+	} else
+		diffNextFrame();
+}
+
+/*****************************************************************************/
+/* Stops an animation from running.                                          */
+/*****************************************************************************/
+void Anim::stopDiff() {
+	if (IsPlaying) {
+		if (IsAnim)
+			blackScreen();
+	}
+}
+
+/*****************************************************************************/
+/* Stops an animation from running.                                          */
+/*****************************************************************************/
+void Anim::stopDiffEnd() {
+	if (IsPlaying) {
+		StopPlayingEnd = true;
+		while (IsPlaying) {
+			g_lab->_music->updateMusic();
+			diffNextFrame();
+		}
+	}
+}
+
+/*****************************************************************************/
+/* Stops the continuous sound from playing.                                  */
+/*****************************************************************************/
+void Anim::stopSound() {
+	stopsound = true;
+}
+
+/*****************************************************************************/
+/* Reads in a DIFF file.                                                     */
+/*****************************************************************************/
+bool Anim::readDiff(bool playonce) {
+	PlayOnce = playonce;
+	playDiff();
+	return true;
+}
+
+} // End of namespace Lab
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
new file mode 100644
index 0000000..0472a72
--- /dev/null
+++ b/engines/lab/anim.h
@@ -0,0 +1,124 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#ifndef LAB_DIFF_H
+#define LAB_DIFF_H
+
+#include "common/file.h"
+
+namespace Lab {
+
+class LabEngine;
+#define CONTINUOUS      0xFFFF
+
+struct DIFFHeader {
+	uint16 _version;    // unused
+	uint16 _width;
+	uint16 _height;
+	char _depth;        // unused
+	char _fps;
+	uint32 _bufferSize; // unused
+	uint16 _machine;    // unused
+	uint32 _flags;
+};
+
+struct BitMap {
+	uint16 _bytesPerRow;
+	uint16 _rows;       // unused
+	byte _flags;
+	byte *_planes[16];
+};
+
+#define BITMAPF_NONE  0
+#define BITMAPF_VIDEO (1<<7)
+
+class Anim {
+private:
+	LabEngine *_vm;
+
+	uint32 header;
+	uint16 CurBit;
+	uint16 numchunks;
+	uint32 WaitSec;
+	uint32 WaitMicros;
+	uint32 DelayMicros;
+	bool continuous;
+	bool IsPlaying;
+	bool IsAnim;
+	bool IsPal;
+	bool donepal;
+	uint16 framenumber;
+	bool PlayOnce;
+	byte *Buffer;
+	byte *storagefordifffile;
+	byte **difffile;
+	uint32 size;
+	bool StopPlayingEnd;
+	uint16 samplespeed;
+	byte *start;
+	uint32 diffwidth;
+	uint32 diffheight;
+	bool stopsound;
+
+public:
+	Anim(LabEngine *vm);
+
+	DIFFHeader headerdata;
+	char diffcmap[256 * 3];
+	bool IsBM;          /* Just fill in the RawDIFFBM structure */
+	bool waitForEffect; /* Wait for each sound effect to finish before continuing. */
+	bool DoBlack;       /* Black the screen before new picture  */
+	bool nopalchange;   /* Don't change the palette.            */
+	BitMap RawDiffBM;
+
+	void unDiff(byte *NewBuf, byte *OldBuf, byte *DiffData, uint16 bytesperrow, bool IsV);
+	bool unDIFFMemory(byte *dest,           /* Where to Un-DIFF */
+                  byte *diff,           /* The DIFFed code. */
+                  uint16 headerSize,    /* Size of header (1, 2 or 4 bytes) (only supports 1 currently */
+                  uint16 copySize);     /* Size of minimum copy or skip. (1, 2 or 4 bytes) */
+
+	bool VUnDIFFMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySize, uint16 bytesPerRow);
+	void runLengthDecode(byte *dest, byte *source);
+	void VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow);
+	bool readDiff(bool playonce);
+	void diffNextFrame();
+	void readSound(bool waitTillFinished, Common::File *file);
+	void stopDiff();
+	void stopDiffEnd();
+	void stopSound();
+	void playDiff();
+
+};
+
+} // End of namespace Lab
+
+#endif /* LAB_DIFF_H */
+
+
diff --git a/engines/lab/diff.h b/engines/lab/diff.h
deleted file mode 100644
index 4ff2059..0000000
--- a/engines/lab/diff.h
+++ /dev/null
@@ -1,89 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#ifndef LAB_DIFF_H
-#define LAB_DIFF_H
-
-#include "common/file.h"
-
-namespace Lab {
-
-
-struct DIFFHeader {
-	uint16 _version;    // unused
-	uint16 _width;
-	uint16 _height;
-	char _depth;        // unused
-	char _fps;
-	uint32 _bufferSize; // unused
-	uint16 _machine;    // unused
-	uint32 _flags;
-};
-
-struct BitMap {
-	uint16 _bytesPerRow;
-	uint16 _rows;       // unused
-	byte _flags;
-	byte *_planes[16];
-};
-
-#define BITMAPF_NONE  0
-#define BITMAPF_VIDEO (1<<7)
-
-/* unDiff.c */
-
-void initOffsets(uint16 bytesPerRow);
-
-bool unDIFFMemory(byte *dest,           /* Where to Un-DIFF */
-                  byte *diff,           /* The DIFFed code. */
-                  uint16 headerSize,    /* Size of header (1, 2 or 4 bytes) (only supports 1 currently */
-                  uint16 copySize);     /* Size of minimum copy or skip. (1, 2 or 4 bytes) */
-
-bool VUnDIFFMemory(byte *Dest, byte *diff, uint16 HeaderSize, uint16 CopySize, uint16 bytesperrow);
-void runLengthDecode(byte *Dest, byte *Source);
-void VRunLengthDecode(byte *Dest, byte *Source, uint16 bytesperrow);
-
-/* readDiff.c */
-
-void blackScreen();
-void blackAllScreen();
-void whiteScreen();
-bool readDiff(bool playonce);
-void diffNextFrame();
-void readSound(bool waitTillFinished, Common::File *file);
-void stopDiff();
-void stopDiffEnd();
-void stopSound();
-
-} // End of namespace Lab
-
-#endif /* LAB_DIFF_H */
-
-
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 4f44070..3a7cd6f 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -30,7 +30,7 @@
 
 #include "lab/lab.h"
 #include "lab/labfun.h"
-#include "lab/diff.h"
+#include "lab/anim.h"
 #include "lab/text.h"
 #include "lab/intro.h"
 #include "lab/parsefun.h"
@@ -46,7 +46,7 @@ bool LongWinInFront = false;
 
 TextFont *MsgFont;
 
-extern bool DoBlack, waitForEffect, stopsound, DoNotDrawMessage, nopalchange;
+extern bool stopsound, DoNotDrawMessage;
 
 /* Global parser data */
 
@@ -446,17 +446,17 @@ static const char *getInvName(uint16 CurInv) {
 
 	else if (CurInv == WESTPAPERNUM) {
 		CurFileName = Inventory[CurInv].BInvName;
-		nopalchange = true;
+		g_lab->_anim->nopalchange = true;
 		readPict(CurFileName, false);
-		nopalchange = false;
+		g_lab->_anim->nopalchange = false;
 		doWestPaper();
 	}
 
 	else if (CurInv == NOTESNUM) {
 		CurFileName = Inventory[CurInv].BInvName;
-		nopalchange = true;
+		g_lab->_anim->nopalchange = true;
 		readPict(CurFileName, false);
-		nopalchange = false;
+		g_lab->_anim->nopalchange = false;
 		doNotes();
 	}
 
@@ -503,7 +503,7 @@ bool LabEngine::doUse(uint16 CurInv) {
 	if (CurInv == MAPNUM) {                  /* LAB: Labyrinth specific */
 		drawStaticMessage(kTextUseMap);
 		interfaceOff();
-		stopDiff();
+		_anim->stopDiff();
 		CurFileName = " ";
 		CPtr = NULL;
 		doMap(_roomNum);
@@ -513,7 +513,7 @@ bool LabEngine::doUse(uint16 CurInv) {
 	} else if (CurInv == JOURNALNUM) {         /* LAB: Labyrinth specific */
 		drawStaticMessage(kTextUseJournal);
 		interfaceOff();
-		stopDiff();
+		_anim->stopDiff();
 		CurFileName = " ";
 		CPtr = NULL;
 		doJournal();
@@ -530,18 +530,18 @@ bool LabEngine::doUse(uint16 CurInv) {
 			_conditions->inclElement(LAMPON);
 		}
 
-		DoBlack = false;
-		waitForEffect = true;
+		_anim->DoBlack = false;
+		_anim->waitForEffect = true;
 		readPict("Music:Click", true);
-		waitForEffect = false;
+		_anim->waitForEffect = false;
 
-		DoBlack = false;
+		_anim->DoBlack = false;
 		Test = getInvName(CurInv);
 	} else if (CurInv == BELTNUM) {                    /* LAB: Labyrinth specific */
 		if (!_conditions->in(BELTGLOW))
 			_conditions->inclElement(BELTGLOW);
 
-		DoBlack = false;
+		_anim->DoBlack = false;
 		Test = getInvName(CurInv);
 	} else if (CurInv == WHISKEYNUM) {                 /* LAB: Labyrinth specific */
 		_conditions->inclElement(USEDHELMET);
@@ -643,7 +643,7 @@ void LabEngine::mainGameLoop() {
 
 		if (GotMessage) {
 			if (QuitLab || g_engine->shouldQuit()) {
-				stopDiff();
+				_anim->stopDiff();
 				break;
 			}
 
@@ -711,7 +711,7 @@ void LabEngine::mainGameLoop() {
 			GotMessage = false;
 			_music->checkRoomMusic();
 			_music->updateMusic();
-			diffNextFrame();
+			_anim->diffNextFrame();
 
 			if (_followingCrumbs) {
 				int result = followCrumbs();
@@ -781,7 +781,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 	uint16 NewDir;
 
 
-	DoBlack = false;
+	_anim->DoBlack = false;
 
 	if ((msgClass == RAWKEY) && (!LongWinInFront)) {
 		if (code == 13) { /* The return key */
@@ -808,7 +808,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 					if (Alternate) {
 						eatMessages();
 						Alternate = false;
-						DoBlack = true;
+						_anim->DoBlack = true;
 						DoNotDrawMessage = false;
 
 						MainDisplay = true;
@@ -840,7 +840,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 				if (curMsg == NULL) { /* Does music load and next animation frame when you've run out of messages */
 					_music->updateMusic();
-					diffNextFrame();
+					_anim->diffNextFrame();
 				} else {
 					if (curMsg->msgClass == RAWKEY) {
 						if ((curMsg->code == 'Y') || (curMsg->code == 'y') || (curMsg->code == 'Q') || (curMsg->code == 'q')) {
@@ -856,7 +856,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			}
 
 			if (doit) {
-				stopDiff();
+				_anim->stopDiff();
 				return false;
 			} else {
 				forceDraw = true;
@@ -887,7 +887,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			if ((actionMode == 4) && (gadgetId == 4) && (CPtr != NULL)) {
 				doMainView(&CPtr);
 
-				DoBlack = true;
+				_anim->DoBlack = true;
 				HCPtr = NULL;
 				CPtr = NULL;
 				mayShowCrumbIndicator();
@@ -896,7 +896,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				eatMessages();
 
 				Alternate = true;
-				DoBlack = true;
+				_anim->DoBlack = true;
 				DoNotDrawMessage = false;
 				interfaceOn(); /* Sets the correct gadget list */
 
@@ -957,7 +957,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				NewDir = Direction;
 				processArrow(&NewDir, gadgetId - 6);
 				doTurn(Direction, NewDir, &CPtr);
-				DoBlack = true;
+				_anim->DoBlack = true;
 				Direction = NewDir;
 				forceDraw = true;
 
@@ -968,9 +968,9 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 				if (doGoForward(&CPtr)) {
 					if (OldRoomNum == _roomNum)
-						DoBlack = true;
+						_anim->DoBlack = true;
 				} else {
-					DoBlack = true;
+					_anim->DoBlack = true;
 					processArrow(&Direction, gadgetId - 6);
 
 					if (OldRoomNum != _roomNum) {
@@ -979,7 +979,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 						CurFileName = " ";
 						forceDraw = true;
 					} else {
-						DoBlack = true;
+						_anim->DoBlack = true;
 						drawStaticMessage(kTextNoPath);
 					}
 				}
@@ -1030,12 +1030,12 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			}
 		}
 	} else if ((msgClass == GADGETUP) && Alternate) {
-		DoBlack = true;
+		_anim->DoBlack = true;
 
 		if (gadgetId == 0) {
 			eatMessages();
 			Alternate = false;
-			DoBlack = true;
+			_anim->DoBlack = true;
 			DoNotDrawMessage = false;
 
 			MainDisplay = true;
@@ -1050,7 +1050,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 		if (gadgetId == 0) {
 			interfaceOff();
-			stopDiff();
+			_anim->stopDiff();
 			CurFileName = " ";
 
 			doit = !saveRestoreGame();
@@ -1134,7 +1134,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 					eatMessages();
 					Alternate = false;
-					DoBlack = true;
+					_anim->DoBlack = true;
 					DoNotDrawMessage = false;
 
 					MainDisplay = true;
@@ -1202,7 +1202,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 						drawStaticMessage(kTextNothing);
 				} else if (TempCPtr->GraphicName) {
 					if (*(TempCPtr->GraphicName)) {
-						DoBlack = true;
+						_anim->DoBlack = true;
 						CPtr = TempCPtr;
 					} else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
 						drawStaticMessage(kTextNothing);
@@ -1253,7 +1253,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 	} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) {
 		eatMessages();
 		Alternate = !Alternate;
-		DoBlack = true;
+		_anim->DoBlack = true;
 		DoNotDrawMessage = false;
 		MainDisplay = true;
 		interfaceOn(); /* Sets the correct gadget list */
@@ -1307,7 +1307,7 @@ void LabEngine::go() {
 		Intro intro;
 		intro.introSequence();
 	} else
-		DoBlack = true;
+		_anim->DoBlack = true;
 
 	if (mem) {
 		_event->mouseShow();
@@ -1330,7 +1330,7 @@ void LabEngine::go() {
 		warning("STUB: waitForPress");
 		while (!1) { // 1 means ignore SDL_ProcessInput calls
 			_music->updateMusic();
-			diffNextFrame();
+			_anim->diffNextFrame();
 			waitTOF();
 		}
 	}
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 1adcb2d..145ccb6 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -29,7 +29,7 @@
  */
 
 #include "lab/lab.h"
-#include "lab/diff.h"
+#include "lab/anim.h"
 #include "lab/parsetypes.h"
 #include "lab/labfun.h"
 #include "lab/parsefun.h"
@@ -41,12 +41,7 @@ namespace Lab {
 
 BitMap bit1, bit2, *DispBitMap = &bit1, *DrawBitMap = &bit1;
 
-
-extern BitMap RawDiffBM;
-extern char diffcmap[256 * 3];
-extern bool IsBM, nopalchange;
-
-extern bool DoBlack, stopsound;
+extern bool stopsound;
 extern TextFont *MsgFont;
 extern const char *CurFileName;
 
@@ -54,12 +49,11 @@ extern const char *CurFileName;
 /*------ From readPict.c.  Reads in pictures and animations from disk. ------*/
 /*---------------------------------------------------------------------------*/
 
-
 /*****************************************************************************/
 /* Reads in a picture into the dest bitmap.                                  */
 /*****************************************************************************/
 bool readPict(const char *filename, bool playOnce) {
-	stopDiff();
+	g_lab->_anim->stopDiff();
 
 	byte **file = g_lab->_music->newOpen(filename);
 
@@ -74,7 +68,7 @@ bool readPict(const char *filename, bool playOnce) {
 	DispBitMap->_rows        = g_lab->_screenHeight;
 	DispBitMap->_flags       = BITMAPF_VIDEO;
 
-	readDiff(playOnce);
+	g_lab->_anim->readDiff(playOnce);
 
 	return true;
 }
@@ -90,8 +84,8 @@ bool readMusic(const char *filename, bool waitTillFinished) {
 	if (!file)
 		return false;
 
-	DoBlack = false;
-	readSound(waitTillFinished, file);
+	g_lab->_anim->DoBlack = false;
+	g_lab->_anim->readSound(waitTillFinished, file);
 
 	return true;
 }
@@ -102,7 +96,7 @@ bool readMusic(const char *filename, bool waitTillFinished) {
 byte *readPictToMem(const char *filename, uint16 x, uint16 y) {
 	byte *mem;
 
-	stopDiff();
+	g_lab->_anim->stopDiff();
 
 	allocFile((void **)&mem, (int32)x * (int32)y, "Bitmap");
 	byte *curMem = mem;
@@ -121,7 +115,7 @@ byte *readPictToMem(const char *filename, uint16 x, uint16 y) {
 	DispBitMap->_planes[3] = DispBitMap->_planes[2] + 0x10000;
 	DispBitMap->_planes[4] = DispBitMap->_planes[3] + 0x10000;
 
-	readDiff(true);
+	g_lab->_anim->readDiff(true);
 
 	return mem;
 }
@@ -437,9 +431,6 @@ void LabEngine::doScrollBlack() {
 	_event->mouseShow();
 }
 
-extern BitMap RawDiffBM;
-extern DIFFHeader headerdata;
-
 static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem) {
 	uint32 size, offSet, copysize;
 	uint16 curPage;
@@ -482,23 +473,23 @@ void LabEngine::doScrollWipe(char *filename) {
 		waitTOF();
 	}
 
-	IsBM = true;
+	_anim->IsBM = true;
 	readPict(filename, true);
-	setPalette(diffcmap, 256);
-	IsBM = false;
-	byte *mem = RawDiffBM._planes[0];
+	setPalette(_anim->diffcmap, 256);
+	_anim->IsBM = false;
+	byte *mem = _anim->RawDiffBM._planes[0];
 
 	_music->updateMusic();
 	uint16 by = VGAScaleX(3);
 	uint16 nheight = height;
 
-	while (onrow < headerdata._height) {
+	while (onrow < _anim->headerdata._height) {
 		_music->updateMusic();
 
 		if ((by > nheight) && nheight)
 			by = nheight;
 
-		if ((startline + by) > (headerdata._height - height - 1))
+		if ((startline + by) > (_anim->headerdata._height - height - 1))
 			break;
 
 		if (nheight)
@@ -544,10 +535,10 @@ void LabEngine::doScrollBounce() {
 	_event->mouseHide();
 	int width = VGAScaleX(320);
 	int height = VGAScaleY(149) + SVGACord(2);
-	byte *mem = RawDiffBM._planes[0];
+	byte *mem = _anim->RawDiffBM._planes[0];
 
 	_music->updateMusic();
-	int startline = headerdata._height - height - 1;
+	int startline = _anim->headerdata._height - height - 1;
 
 	for (int i = 0; i < 5; i++) {
 		_music->updateMusic();
@@ -628,7 +619,7 @@ void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 		CurFileName = getPictName(cPtr);
 
 	byte *BitMapMem = readPictToMem(CurFileName, _screenWidth, lastY + 5);
-	setPalette(diffcmap, 256);
+	setPalette(_anim->diffcmap, 256);
 
 	if (BitMapMem) {
 		imSource.Width = _screenWidth;
@@ -697,7 +688,37 @@ void LabEngine::doWipe(uint16 wipeType, CloseDataPtr *cPtr, char *filename) {
 	else if (wipeType == READFIRSTFRAME)
 		readPict(filename, false);
 	else if (wipeType == READNEXTFRAME)
-		diffNextFrame();
+		_anim->diffNextFrame();
+}
+
+static byte blackbuffer[256 * 3];
+
+/*****************************************************************************/
+/* Changes the front screen to black.                                        */
+/*****************************************************************************/
+void blackScreen() {
+	memset(blackbuffer, 0, 248 * 3);
+	g_lab->writeColorRegs(blackbuffer, 8, 248);
+
+	g_system->delayMillis(32);
+}
+
+/*****************************************************************************/
+/* Changes the front screen to white.                                        */
+/*****************************************************************************/
+void whiteScreen() {
+	memset(blackbuffer, 255, 248 * 3);
+	g_lab->writeColorRegs(blackbuffer, 8, 248);
+}
+
+/*****************************************************************************/
+/* Changes the entire screen to black.                                       */
+/*****************************************************************************/
+void blackAllScreen() {
+	memset(blackbuffer, 0, 256 * 3);
+	g_lab->writeColorRegs(blackbuffer, 0, 256);
+
+	g_system->delayMillis(32);
 }
 
 } // End of namespace Lab
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index e7f0187..a35984e 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -32,13 +32,11 @@
 #include "lab/intro.h"
 #include "lab/labfun.h"
 #include "lab/resource.h"
-#include "lab/diff.h"
+#include "lab/anim.h"
 #include "lab/text.h"
 #include "lab/interface.h"
 
 namespace Lab {
-extern bool nopalchange, DoBlack;
-extern char diffcmap[256 * 3];
 extern uint16 *FadePalette;
 
 Intro::Intro() {
@@ -144,7 +142,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isscreen) {
 
 		if (msg == NULL) {
 			g_lab->_music->updateMusic();
-			g_lab->diffNextFrame();
+			g_lab->_anim->diffNextFrame();
 			g_lab->getTime(&secs, &micros);
 			g_lab->anyTimeDiff(lastsecs, lastmicros, secs, micros, &secs, &micros);
 
@@ -239,8 +237,8 @@ void Intro::nReadPict(const char *filename, bool playOnce) {
 	if (_quitIntro)
 		return;
 
-	DoBlack = _introDoBlack;
-	stopDiffEnd();
+	g_lab->_anim->DoBlack = _introDoBlack;
+	g_lab->_anim->stopDiffEnd();
 	readPict(finalFileName.c_str(), playOnce);
 }
 
@@ -256,7 +254,7 @@ void Intro::introSequence() {
 		0x0CB3, 0x0DC4, 0x0DD6, 0x0EE7
 	};
 
-	DoBlack = true;
+	g_lab->_anim->DoBlack = true;
 
 	if (g_lab->getPlatform() != Common::kPlatformWindows) {
 		nReadPict("EA0", true);
@@ -278,12 +276,12 @@ void Intro::introSequence() {
 
 	g_lab->_music->initMusic();
 
-	nopalchange = true;
+	g_lab->_anim->nopalchange = true;
 	if (g_lab->getPlatform() != Common::kPlatformWindows)
 		nReadPict("TNDcycle.pic", true);
 	else
 		nReadPict("TNDcycle2.pic", true);
-	nopalchange = false;
+	g_lab->_anim->nopalchange = false;
 
 	FadePalette = palette;
 
@@ -291,9 +289,9 @@ void Intro::introSequence() {
 		if (_quitIntro)
 			break;
 
-		palette[i] = ((diffcmap[i * 3] >> 2) << 8) +
-		                   ((diffcmap[i * 3 + 1] >> 2) << 4) +
-		                   (diffcmap[i * 3 + 2] >> 2);
+		palette[i] = ((g_lab->_anim->diffcmap[i * 3] >> 2) << 8) +
+		             ((g_lab->_anim->diffcmap[i * 3 + 1] >> 2) << 4) +
+		              (g_lab->_anim->diffcmap[i * 3 + 2] >> 2);
 	}
 
 	g_lab->_music->updateMusic();
@@ -348,14 +346,14 @@ void Intro::introSequence() {
 
 	TextFont *msgFont = g_lab->_resource->getFont("P:Map.fon");
 
-	nopalchange = true;
+	g_lab->_anim->nopalchange = true;
 	nReadPict("Intro.1", true);
-	nopalchange = false;
+	g_lab->_anim->nopalchange = false;
 
 	for (uint16 i = 0; i < 16; i++) {
-		palette[i] = ((diffcmap[i * 3] >> 2) << 8) +
-		             ((diffcmap[i * 3 + 1] >> 2) << 4) +
-		             (diffcmap[i * 3 + 2] >> 2);
+		palette[i] = ((g_lab->_anim->diffcmap[i * 3] >> 2) << 8) +
+		             ((g_lab->_anim->diffcmap[i * 3 + 1] >> 2) << 4) +
+		              (g_lab->_anim->diffcmap[i * 3 + 2] >> 2);
 	}
 
 	doPictText("i.1", msgFont, true);
@@ -395,11 +393,11 @@ void Intro::introSequence() {
 	if (!_quitIntro)
 		for (uint16 i = 0; i < 50; i++) {
 			for (uint16 idx = (8 * 3); idx < (255 * 3); idx++)
-				diffcmap[idx] = 255 - diffcmap[idx];
+				g_lab->_anim->diffcmap[idx] = 255 - g_lab->_anim->diffcmap[idx];
 
 			g_lab->_music->updateMusic();
 			g_lab->waitTOF();
-			g_lab->setPalette(diffcmap, 256);
+			g_lab->setPalette(g_lab->_anim->diffcmap, 256);
 			g_lab->waitTOF();
 			g_lab->waitTOF();
 		}
@@ -438,7 +436,7 @@ void Intro::introSequence() {
 	nReadPict("Daed7", false);
 	doPictText("i.27", msgFont, false);
 	doPictText("i.28", msgFont, false);
-	stopDiffEnd();
+	g_lab->_anim->stopDiffEnd();
 
 	nReadPict("Daed8", true);
 	doPictText("i.29", msgFont, false);
@@ -460,7 +458,7 @@ void Intro::introSequence() {
 	if (_quitIntro) {
 		g_lab->setAPen(0);
 		g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
-		DoBlack = true;
+		g_lab->_anim->DoBlack = true;
 	}
 
 	closeFont(msgFont);
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 7ebfa8c..a6fe4cf 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -38,14 +38,14 @@
 #include "engines/dialogs.h"
 #include "engines/engine.h"
 #include "engines/util.h"
-
 #include "gui/message.h"
+#include "engines/advancedDetector.h"
 
 #include "lab/lab.h"
 #include "lab/labfun.h"
 #include "lab/resource.h"
+#include "lab/anim.h"
 
-#include "engines/advancedDetector.h"
 
 namespace Lab {
 
@@ -91,6 +91,7 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_event = nullptr;
 	_resource = nullptr;
 	_music = nullptr;
+	_anim = nullptr;
 
     _lastMessageLong = false;
     _lastTooLong = false;
@@ -109,6 +110,7 @@ LabEngine::~LabEngine() {
 	delete _event;
 	delete _resource;
 	delete _music;
+	delete _anim;
 }
 
 Common::Error LabEngine::run() {
@@ -120,6 +122,7 @@ Common::Error LabEngine::run() {
 	_event = new EventManager(this);
 	_resource = new Resource(this);
 	_music = new Music(this);
+	_anim = new Anim(this);
 
 	if (getPlatform() == Common::kPlatformWindows) {
 		// Check if this is the Wyrmkeep trial
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index c427b08..9327dbf 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -40,6 +40,7 @@
 #include "lab/mouse.h"
 #include "lab/music.h"
 #include "lab/resource.h"
+#include "lab/anim.h"
 
 struct ADGameDescription;
 
@@ -103,6 +104,7 @@ public:
 	EventManager *_event;
 	Resource *_resource;
 	Music *_music;
+	Anim *_anim;
 
 	int _roomNum;
 	byte *_currentDisplayBuffer;
@@ -175,7 +177,6 @@ public:
 	void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein);
 	void processMap(uint16 CurRoom);
 	void doMap(uint16 CurRoom);
-	void diffNextFrame();
 	void drawJournal(uint16 wipenum, bool needFade);
 	void processJournal();
 	void doJournal();
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 4f7573e..c1a6b35 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -213,6 +213,10 @@ void mouseCombination(Common::Point pos);
 void showTile(const char *filename, bool showsolution);
 void mouseTile(Common::Point pos);
 
+void blackScreen();
+void blackAllScreen();
+void whiteScreen();
+
 } // End of namespace Lab
 
 #endif /* LAB_LABFUN_H */
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 36b01d1..1f4f0db 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -30,7 +30,7 @@
 
 #include "lab/lab.h"
 #include "lab/labfun.h"
-#include "lab/diff.h"
+#include "lab/anim.h"
 #include "lab/text.h"
 #include "lab/mouse.h"
 #include "lab/parsefun.h"
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index c9682f2..4f1ace8 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -2,6 +2,7 @@ MODULE := engines/lab
 
 MODULE_OBJS := \
 	allocroom.o \
+	anim.o \
 	detection.o \
 	engine.o \
 	graphics.o \
@@ -21,7 +22,6 @@ MODULE_OBJS := \
 	special.o \
 	text.o \
 	timing.o \
-	undiff.o \
 	vga.o
 
 
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 04fe70d..5807227 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -35,7 +35,7 @@
 #include "lab/parsetypes.h"
 #include "lab/parsefun.h"
 #include "lab/resource.h"
-#include "lab/diff.h"
+#include "lab/anim.h"
 #include "lab/interface.h"
 
 namespace Lab {
@@ -49,8 +49,7 @@ InventoryData *Inventory;
 uint16 NumInv, ManyRooms, HighestCondition, Direction;
 const char *NewFileName;
 
-extern bool DoNotDrawMessage, IsBM, noupdatediff, QuitLab, MusicOn, DoBlack, LongWinInFront;
-extern char diffcmap[256 * 3];
+extern bool DoNotDrawMessage, noupdatediff, QuitLab, MusicOn, LongWinInFront;
 extern const char *CurFileName;
 extern CloseDataPtr CPtr;
 
@@ -379,7 +378,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 
 		case NOUPDATE:
 			noupdatediff = true;
-			DoBlack = false;
+			g_lab->_anim->DoBlack = false;
 			break;
 
 		case FORCEUPDATE:
@@ -445,7 +444,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 			g_lab->_roomNum   = APtr->Param1;
 			Direction = APtr->Param2 - 1;
 			*LCPtr      = NULL;
-			DoBlack    = true;
+			g_lab->_anim->DoBlack = true;
 			break;
 
 		case SETCLOSEUP:
@@ -485,7 +484,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 
 			while (1) {
 				g_lab->_music->updateMusic();
-				g_lab->diffNextFrame();
+				g_lab->_anim->diffNextFrame();
 				g_lab->getTime(&CurSecs, &CurMicros);
 
 				if ((CurSecs > StartSecs) || ((CurSecs == StartSecs) &&
@@ -520,7 +519,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 		case WAITSOUND:
 			while (g_lab->_music->isSoundEffectActive()) {
 				g_lab->_music->updateMusic();
-				g_lab->diffNextFrame();
+				g_lab->_anim->diffNextFrame();
 				g_lab->waitTOF();
 			}
 
@@ -555,17 +554,17 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 
 		case SPECIALCMD:
 			if (APtr->Param1 == 0)
-				DoBlack = true;
+				g_lab->_anim->DoBlack = true;
 			else if (APtr->Param1 == 1)
-				DoBlack = (CPtr == NULL);
+				g_lab->_anim->DoBlack = (CPtr == NULL);
 			else if (APtr->Param1 == 2)
-				DoBlack = (CPtr != NULL);
+				g_lab->_anim->DoBlack = (CPtr != NULL);
 			else if (APtr->Param1 == 5) { /* inverse the palette */
 				for (uint16 idx = (8 * 3); idx < (255 * 3); idx++)
-					diffcmap[idx] = 255 - diffcmap[idx];
+					g_lab->_anim->diffcmap[idx] = 255 - g_lab->_anim->diffcmap[idx];
 
 				g_lab->waitTOF();
-				g_lab->setPalette(diffcmap, 256);
+				g_lab->setPalette(g_lab->_anim->diffcmap, 256);
 				g_lab->waitTOF();
 				g_lab->waitTOF();
 			} else if (APtr->Param1 == 4) { /* white the palette */
@@ -574,7 +573,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 				g_lab->waitTOF();
 			} else if (APtr->Param1 == 6) { /* Restore the palette */
 				g_lab->waitTOF();
-				g_lab->setPalette(diffcmap, 256);
+				g_lab->setPalette(g_lab->_anim->diffcmap, 256);
 				g_lab->waitTOF();
 				g_lab->waitTOF();
 			} else if (APtr->Param1 == 7) { /* Quick pause */
@@ -595,7 +594,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 	} else {
 		while (g_lab->_music->isSoundEffectActive()) {
 			g_lab->_music->updateMusic();
-			g_lab->diffNextFrame();
+			g_lab->_anim->diffNextFrame();
 			g_lab->waitTOF();
 		}
 	}
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
index abaa4f5..43309ff 100644
--- a/engines/lab/readdiff.cpp
+++ b/engines/lab/readdiff.cpp
@@ -29,400 +29,16 @@
  */
 
 #include "lab/lab.h"
-#include "lab/diff.h"
+#include "lab/anim.h"
 #include "lab/labfun.h"
 #include "lab/mouse.h"
 
 namespace Lab {
-
-static bool PlayOnce = false;
-static bool StopPlayingEnd = false;
-
-static uint32 header, size, WaitSec = 0L, WaitMicros = 0L, DelayMicros = 0L;
-static uint16 CurBit = 0, framenumber = 0, samplespeed, numchunks = 1;
-static byte *Buffer, temp[5];
-static bool donepal = false;
-static byte *storagefordifffile, **difffile = &storagefordifffile;
-static byte *start;
-static uint32 diffwidth, diffheight;
-static byte blackbuffer[256 * 3];
-
-bool DoBlack        = false,     /* Black the screen before new picture  */
-     nopalchange    = false,     /* Don't change the palette.            */
-     IsBM           = false,     /* Just fill in the RawDIFFBM structure */
-     stopsound      = false,
-     waitForEffect  = false;     /* Wait for each sound effect to finish
-                                   before coninuing.                    */
-
-static bool continuous,
-	IsPlaying      = false,
-	IsAnim         = false,
-	IsPal          = false;
+static byte temp[5];
 
 uint16 _dataBytesPerRow;
-DIFFHeader headerdata;
-char diffcmap[256 * 3];
-BitMap RawDiffBM;
-
-extern BitMap *DispBitMap, *DrawBitMap;
-extern byte **startoffile;
-
-#define CONTINUOUS      0xFFFF
-
-
-/*****************************************************************************/
-/* Does the undiffing between the bitmaps.                                   */
-/*****************************************************************************/
-void unDiff(byte *NewBuf, byte *OldBuf, byte *DiffData, uint16 bytesperrow, bool IsV) {
-	byte buftype;
-
-	DiffData++;
-	buftype  = *DiffData;
-	DiffData++;
-
-	if (IsV)
-		VUnDIFFMemory(NewBuf, DiffData, 1, buftype + 1, bytesperrow);
-	else
-		unDIFFMemory(NewBuf, DiffData, 1, buftype + 1);
-}
-
-
-/*****************************************************************************/
-/* Changes the front screen to black.                                        */
-/*****************************************************************************/
-void blackScreen() {
-	memset(blackbuffer, 0, 248 * 3);
-	g_lab->writeColorRegs(blackbuffer, 8, 248);
-
-	g_system->delayMillis(32);
-}
-
-/*****************************************************************************/
-/* Changes the front screen to white.                                        */
-/*****************************************************************************/
-void whiteScreen() {
-	memset(blackbuffer, 255, 248 * 3);
-	g_lab->writeColorRegs(blackbuffer, 8, 248);
-}
-
-/*****************************************************************************/
-/* Changes the entire screen to black.                                       */
-/*****************************************************************************/
-void blackAllScreen() {
-	memset(blackbuffer, 0, 256 * 3);
-	g_lab->writeColorRegs(blackbuffer, 0, 256);
-
-	g_system->delayMillis(32);
-}
-
-void LabEngine::diffNextFrame() {
-	if (header == 65535)  /* Already done. */
-		return;
-
-	if (DispBitMap->_flags & BITMAPF_VIDEO) {
-		DispBitMap->_planes[0] = getCurrentDrawingBuffer();
-		DispBitMap->_planes[1] = DispBitMap->_planes[0] + 0x10000;
-		DispBitMap->_planes[2] = DispBitMap->_planes[1] + 0x10000;
-		DispBitMap->_planes[3] = DispBitMap->_planes[2] + 0x10000;
-		DispBitMap->_planes[4] = DispBitMap->_planes[3] + 0x10000;
-	}
-
-	_event->mouseHide();
-
-	while (1) {
-		if (CurBit >= numchunks) {
-			_event->mouseShow();
-
-			if (!IsBM) {
-				if (headerdata._fps) {
-					waitForTime(WaitSec, WaitMicros);
-					addCurTime(0L, DelayMicros, &WaitSec, &WaitMicros);
-				}
-
-				if (IsPal && !nopalchange) {
-					setPalette(diffcmap, 256);
-					IsPal = false;
-				}
-
-				donepal = true;
-			}
-
-			if (IsPal && !nopalchange && !IsBM && !donepal) {
-				setPalette(diffcmap, 256);
-				IsPal = false;
-			}
-
-			donepal = false;
-
-			framenumber++;
-
-			if ((framenumber == 1) && (continuous || (!PlayOnce)))
-				Buffer = *difffile;
-
-			IsAnim = (framenumber >= 3) && (!PlayOnce);
-			CurBit = 0;
-
-			if (DispBitMap->_flags & BITMAPF_VIDEO)
-				screenUpdate();
-
-			return; /* done with the next frame. */
-		}
-
-		_music->updateMusic();
- 		header = READ_LE_UINT32(*difffile);
-		*difffile += 4;
-
-		size = READ_LE_UINT32(*difffile);
-		*difffile += 4;
-
-		switch (header) {
-		case 8L:
-			readBlock(diffcmap, size, difffile);
-			IsPal = true;
-			break;
-
-		case 10L:
-			RawDiffBM._planes[CurBit] = *difffile;
-
-			if (IsBM)
-				(*difffile) += size;
-			else {
-				readBlock(DrawBitMap->_planes[CurBit], size, difffile);
-			}
-
-			CurBit++;
-			break;
-
-		case 11L:
-			(*difffile) += 4;
-			runLengthDecode(DrawBitMap->_planes[CurBit], *difffile);
-			CurBit++;
-			(*difffile) += size - 4;
-			break;
-
-		case 12L:
-			(*difffile) += 4;
-			VRunLengthDecode(DrawBitMap->_planes[CurBit], *difffile, DrawBitMap->_bytesPerRow);
-			CurBit++;
-			(*difffile) += size - 4;
-			break;
-
-		case 20L:
-			unDiff(DrawBitMap->_planes[CurBit], DispBitMap->_planes[CurBit], *difffile, DrawBitMap->_bytesPerRow, false);
-			CurBit++;
-			(*difffile) += size;
-			break;
-
-		case 21L:
-			unDiff(DrawBitMap->_planes[CurBit], DispBitMap->_planes[CurBit], *difffile, DrawBitMap->_bytesPerRow, true);
-			CurBit++;
-			(*difffile) += size;
-			break;
-
-		case 25L:
-			CurBit++;
-			break;
-
-		case 26L:
-			CurBit++;
-			break;
-
-		case 30L:
-		case 31L: {
-			if (waitForEffect) {
-				while (_music->isSoundEffectActive()) {
-					_music->updateMusic();
-					waitTOF();
-				}
-			}
-
-			size -= 8L;
-
-
-			(*difffile) += 4;
-			samplespeed = READ_LE_UINT16(*difffile);
-			(*difffile) += 4;
-
-			byte *music = *difffile;
-			uint32 musicsize = size;
-			(*difffile) += size;
-
-			_music->playSoundEffect(samplespeed, musicsize, music);
-			break;
-		}
-		case 65535L:
-			if ((framenumber == 1) || PlayOnce || StopPlayingEnd) {
-				int didTOF = 0;
-
-				if (waitForEffect) {
-					while (_music->isSoundEffectActive()) {
-						_music->updateMusic();
-						waitTOF();
-
-						if (DispBitMap->_flags & BITMAPF_VIDEO)
-							didTOF = 1;
-					}
-				}
-
-				IsPlaying = false;
-				_event->mouseShow();
-
-				if (!didTOF)
-					screenUpdate();
-
-				return;
-			}
-
-			framenumber = 4;  /* Random frame number so it never gets back to 2 */
-			*difffile = Buffer;
-			break;
-
-		default:
-			(*difffile) += size;
-			break;
-		}
-	}
-}
-
-/*****************************************************************************/
-/* A separate task launched by readDiff.  Plays the DIFF.                    */
-/*****************************************************************************/
-void playDiff() {
-	WaitSec   = 0L;
-	WaitMicros = 0L;
-	DelayMicros = 0L;
-	header      = 0;
-	CurBit = 0;
-	framenumber = 0;
-	numchunks   = 1;
-	donepal     = false;
-	StopPlayingEnd = false;
-	difffile    = &storagefordifffile;
-
-	IsPlaying   = true;
-
-	if (DoBlack) {
-		DoBlack = false;
-		blackScreen();
-	}
-
-	start = *startoffile;            /* Make a copy of the pointer to the start of the file    */
-	*difffile = start;               /* Now can modify the file without modifying the original */
-
-	if (start == NULL) {
-		IsPlaying = false;
-		return;
-	}
-
-	continuous = false;
-	uint32 signature = READ_BE_UINT32(*difffile);
-	(*difffile) += 4;
-
-	header = READ_LE_UINT32(*difffile);
-	(*difffile) += 4;
-
-	if ((signature != MKTAG('D', 'I', 'F', 'F')) || (header != 1219009121L)) {
-		IsPlaying = false;
-		return;
-	}
-
-	header = READ_LE_UINT32(*difffile);
-	(*difffile) += 4;
-
-	size = READ_LE_UINT32(*difffile);
-	(*difffile) += 4;
-
-	if (header == 0) {
-		// sizeof(headerdata) != 18, but the padding might be at the end
-		headerdata._version = READ_LE_UINT16(*difffile);
-		(*difffile) += 2;
-		headerdata._width = READ_LE_UINT16(*difffile);
-		(*difffile) += 2;
-		headerdata._height = READ_LE_UINT16(*difffile);
-		(*difffile) += 2;
-		headerdata._depth = *difffile[0];
-		(*difffile)++;
-		headerdata._fps = *difffile[0];
-		(*difffile)++;
-		headerdata._bufferSize = READ_LE_UINT32(*difffile);
-		(*difffile) += 4;
-		headerdata._machine = READ_LE_UINT16(*difffile);
-		(*difffile) += 2;
-		headerdata._flags = READ_LE_UINT32(*difffile);
-		(*difffile) += 4;
-
-		(*difffile) += size - 18;
-
-		continuous = CONTINUOUS & headerdata._flags;
-		diffwidth = headerdata._width;
-		diffheight = headerdata._height;
-		_dataBytesPerRow = diffwidth;
-
-		numchunks = (((int32) diffwidth) * diffheight) / 0x10000;
-
-		if ((uint32)(numchunks * 0x10000) < (uint32)(((int32) diffwidth) * diffheight))
-			numchunks++;
-	} else {
-		return;
-	}
-
-	for (header = 0; header < 8; header++)
-		RawDiffBM._planes[header] = NULL;
-
-	if (headerdata._fps)
-		DelayMicros = ONESECOND / headerdata._fps;
-
-	if (PlayOnce) {
-		while (header != 65535)
-			g_lab->diffNextFrame();
-	} else
-		g_lab->diffNextFrame();
-}
-
-
-
-/*****************************************************************************/
-/* Stops an animation from running.                                          */
-/*****************************************************************************/
-void stopDiff() {
-	if (IsPlaying) {
-		if (IsAnim)
-			blackScreen();
-	}
-}
-
-/*****************************************************************************/
-/* Stops an animation from running.                                          */
-/*****************************************************************************/
-void stopDiffEnd() {
-	if (IsPlaying) {
-		StopPlayingEnd = true;
-		while (IsPlaying) {
-			g_lab->_music->updateMusic();
-			g_lab->diffNextFrame();
-		}
-	}
-}
-
-
-/*****************************************************************************/
-/* Stops the continuous sound from playing.                                  */
-/*****************************************************************************/
-void stopSound() {
-	stopsound = true;
-}
-
-/*****************************************************************************/
-/* Reads in a DIFF file.                                                     */
-/*****************************************************************************/
-bool readDiff(bool playonce) {
-	PlayOnce = playonce;
-	playDiff();
-	return true;
-}
-
 
-void readSound(bool waitTillFinished, Common::File *file) {
+void Anim::readSound(bool waitTillFinished, Common::File *file) {
 	uint32 magicBytes = file->readUint32LE();
 	if (magicBytes != 1219009121L)
 		return;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index e23ea70..afe3efb 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -37,7 +37,7 @@
 #include "lab/labfun.h"
 #include "lab/parsefun.h"
 #include "lab/interface.h"
-#include "lab/diff.h"
+#include "lab/anim.h"
 #include "lab/text.h"
 #include "lab/mouse.h"
 #include "lab/parsetypes.h"
@@ -83,9 +83,7 @@ uint16 CurTile[4][4] = {
 
 extern TextFont *MsgFont;
 extern uint16 *FadePalette;
-extern bool nopalchange, DoBlack;
 extern BitMap *DispBitMap, *DrawBitMap;
-extern char diffcmap[3 * 256];
 extern CloseDataPtr CPtr;
 extern InventoryData *Inventory;
 extern uint16 Direction;
@@ -111,7 +109,7 @@ static byte *loadBackPict(const char *fileName, bool tomem) {
 	byte *res = NULL;
 
 	FadePalette = hipal;
-	nopalchange = true;
+	g_lab->_anim->nopalchange = true;
 
 	if (tomem)
 		res = readPictToMem(fileName, g_lab->_screenWidth, g_lab->_screenHeight);
@@ -119,12 +117,12 @@ static byte *loadBackPict(const char *fileName, bool tomem) {
 		readPict(fileName, true);
 
 	for (uint16 i = 0; i < 16; i++) {
-		hipal[i] = ((diffcmap[i * 3] >> 2) << 8) +
-		           ((diffcmap[i * 3 + 1] >> 2) << 4) +
-		           ((diffcmap[i * 3 + 2] >> 2));
+		hipal[i] = ((g_lab->_anim->diffcmap[i * 3] >> 2) << 8) +
+		           ((g_lab->_anim->diffcmap[i * 3 + 1] >> 2) << 4) +
+		           ((g_lab->_anim->diffcmap[i * 3 + 2] >> 2));
 	}
 
-	nopalchange = false;
+	g_lab->_anim->nopalchange = false;
 
 	return res;
 }
@@ -144,10 +142,10 @@ void showCombination(const char *filename) {
 	byte **buffer;
 
 	resetBuffer();
-	DoBlack = true;
-	nopalchange = true;
+	g_lab->_anim->DoBlack = true;
+	g_lab->_anim->nopalchange = true;
 	readPict(filename, true);
-	nopalchange = false;
+	g_lab->_anim->nopalchange = false;
 
 	blackScreen();
 
@@ -160,7 +158,7 @@ void showCombination(const char *filename) {
 
 	doCombination();
 
-	g_lab->setPalette(diffcmap, 256);
+	g_lab->setPalette(g_lab->_anim->diffcmap, 256);
 }
 
 
@@ -287,10 +285,10 @@ void showTile(const char *filename, bool showsolution) {
 	byte **buffer;
 
 	resetBuffer();
-	DoBlack = true;
-	nopalchange = true;
+	g_lab->_anim->DoBlack = true;
+	g_lab->_anim->nopalchange = true;
 	readPict(filename, true);
-	nopalchange = false;
+	g_lab->_anim->nopalchange = false;
 	blackScreen();
 
 	if (showsolution) {
@@ -311,7 +309,7 @@ void showTile(const char *filename, bool showsolution) {
 
 	doTile(showsolution);
 
-	g_lab->setPalette(diffcmap, 256);
+	g_lab->setPalette(g_lab->_anim->diffcmap, 256);
 }
 
 static void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
@@ -425,7 +423,7 @@ static void changeTile(uint16 col, uint16 row) {
 
 		if (check) {
 			g_lab->_conditions->inclElement(BRICKOPEN);  /* unlocked combination */
-			DoBlack = true;
+			g_lab->_anim->DoBlack = true;
 			check = readPict("p:Up/BDOpen", true);
 		}
 	}
@@ -458,7 +456,7 @@ void doNotes() {
 	char *ntext = g_lab->_resource->getText("Lab:Rooms/Notes");
 
 	flowText(noteFont, -2 + SVGACord(1), 0, 0, false, false, true, true, VGAScaleX(25) + SVGACord(15), VGAScaleY(50), VGAScaleX(295) - SVGACord(15), VGAScaleY(148), ntext);
-	g_lab->setPalette(diffcmap, 256);
+	g_lab->setPalette(g_lab->_anim->diffcmap, 256);
 
 	closeFont(noteFont);
 	delete[] ntext;
@@ -502,7 +500,7 @@ void doWestPaper() {
 	delete[] ntext;
 	closeFont(paperFont);
 
-	g_lab->setPalette(diffcmap, 256);
+	g_lab->setPalette(g_lab->_anim->diffcmap, 256);
 	freeAllStolenMem();
 }
 
@@ -674,14 +672,14 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 	if (needFade)
 		fade(true, 0);
 
-	nopalchange = true;
+	g_lab->_anim->nopalchange = true;
 	JBackImage.ImageData = readPictToMem("P:Journal.pic", _screenWidth, _screenHeight);
 	GotBackImage = true;
 
 	eatMessages();
 	_event->mouseShow();
 
-	nopalchange = false;
+	g_lab->_anim->nopalchange = false;
 }
 
 /*****************************************************************************/
diff --git a/engines/lab/undiff.cpp b/engines/lab/undiff.cpp
deleted file mode 100644
index e5f193c..0000000
--- a/engines/lab/undiff.cpp
+++ /dev/null
@@ -1,379 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "common/endian.h"
-#include "lab/lab.h"
-
-namespace Lab {
-
-extern uint16 _dataBytesPerRow;
-
-/*------------------------ unDiff Horizontal Memory -------------------------*/
-
-/*****************************************************************************/
-/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
-/* is also a byte.                                                           */
-/*****************************************************************************/
-static void unDIFFByteByte(byte *dest, byte *diff) {
-	uint16 skip, copy;
-
-	while (1) {
-		skip = *diff;
-		diff++;
-		copy = *diff;
-		diff++;
-
-		if (skip == 255) {
-			if (copy == 0) {
-				skip = READ_LE_UINT16(diff);
-				diff += 2;
-				copy = READ_LE_UINT16(diff);
-				diff += 2;
-			} else if (copy == 255)
-				return;
-		}
-
-		dest += skip;
-		memcpy(dest, diff, copy);
-		dest += copy;
-		diff += copy;
-	}
-}
-
-
-
-/*****************************************************************************/
-/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
-/* is a word.                                                                */
-/*****************************************************************************/
-static void unDIFFByteWord(uint16 *dest, uint16 *diff) {
-	uint16 skip, copy;
-
-	while (1) {
-		skip = ((byte *)diff)[0];
-		copy = ((byte *)diff)[1];
-
-		diff++;
-
-		if (skip == 255) {
-			if (copy == 0) {
-				skip = READ_LE_UINT16(diff);
-				diff++;
-				copy = READ_LE_UINT16(diff);
-				diff++;
-			} else if (copy == 255)
-				return;
-		}
-
-		dest += skip;
-
-		while (copy > 3) {
-			*dest = READ_LE_UINT16(diff);
-			dest++;
-			diff++;
-
-			*dest = READ_LE_UINT16(diff);
-			dest++;
-			diff++;
-
-			*dest = READ_LE_UINT16(diff);
-			dest++;
-			diff++;
-
-			*dest = READ_LE_UINT16(diff);
-			dest++;
-			diff++;
-
-			copy -= 4;
-		}
-
-		while (copy) {
-			*dest = READ_LE_UINT16(diff);
-			dest++;
-			diff++;
-			copy--;
-		}
-	}
-}
-
-
-
-/*****************************************************************************/
-/* UnDiffs a coded DIFF string onto an already initialized piece of memory.  */
-/*****************************************************************************/
-bool unDIFFMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySize) {
-	if (headerSize == 1) {
-		if (copySize == 1)
-			unDIFFByteByte(dest, diff);
-
-		else if (copySize == 2)
-			unDIFFByteWord((uint16 *)dest, (uint16 *)diff);
-
-		else
-			return false;
-	} else
-		error("unDIFFMemory: HeaderSize is %d", headerSize);
-
-	return true;
-}
-
-/*------------------------- unDiff Vertical Memory --------------------------*/
-
-/*****************************************************************************/
-/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
-/* is a byte.                                                                */
-/*****************************************************************************/
-static void VUnDIFFByteByte(byte *Dest, byte *diff, uint16 bytesperrow) {
-	byte *CurPtr;
-	uint16 skip, copy;
-	uint16 counter = 0;
-
-
-	while (counter < _dataBytesPerRow) {
-		CurPtr = Dest + counter;
-
-		for (;;) {
-			skip = *diff;
-			diff++;
-			copy = *diff;
-			diff++;
-
-			if (skip == 255) {
-				counter += copy;
-				break;
-			}
-
-			else {
-				CurPtr += (skip * bytesperrow);
-
-				while (copy) {
-					copy--;
-					*CurPtr = *diff;
-					CurPtr += bytesperrow;
-					diff++;
-				}
-			}
-		}
-	}
-}
-
-
-
-
-/*****************************************************************************/
-/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
-/* is a word.                                                                */
-/*****************************************************************************/
-static void VUnDIFFByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow) {
-	uint16 *CurPtr;
-	uint16 skip, copy;
-	uint16 counter = 0, wordsperrow;
-
-
-	wordsperrow = bytesperrow / 2;
-
-	while (counter < (_dataBytesPerRow >> 1)) {
-		CurPtr = Dest + counter;
-
-		for (;;) {
-			skip = ((byte *)diff)[0];
-			copy = ((byte *)diff)[1];
-
-			diff++;
-
-
-			if (skip == 255) {
-				counter += copy;
-				break;
-			}
-
-			else {
-				CurPtr += (skip * wordsperrow);
-
-				while (copy) {
-					*CurPtr = *diff; //swapUShort(*diff);
-					CurPtr += wordsperrow;
-					diff++;
-					copy--;
-				}
-			}
-		}
-	}
-}
-
-
-
-
-/*****************************************************************************/
-/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
-/* is a long.                                                                */
-/*****************************************************************************/
-static void VUnDIFFByteLong(uint32 *Dest, uint32 *diff, uint16 bytesperrow) {
-	uint32 *CurPtr;
-	uint16 skip, copy;
-	uint16 counter = 0, longsperrow;
-	byte *diff1 = (byte *)diff;
-
-
-	longsperrow = bytesperrow / 4;
-
-	while (counter < (_dataBytesPerRow >> 2)) {
-		CurPtr = Dest + counter;
-
-		for (;;) {
-			skip = *diff1;
-			diff1++;
-
-			copy = *diff1;
-			diff1++;
-
-
-			if (skip == 255) {
-				counter += copy;
-				break;
-			}
-
-			else {
-				CurPtr += (skip * longsperrow);
-
-				while (copy) {
-					*CurPtr = *(uint32 *)diff1; //swapULong(*diff);
-					CurPtr += longsperrow;
-					diff1 += 4;
-					copy--;
-				}
-			}
-		}
-	}
-}
-
-
-
-
-/*****************************************************************************/
-/* UnDiffs a coded DIFF string onto an already initialized piece of memory.  */
-/*****************************************************************************/
-bool VUnDIFFMemory(byte *Dest, byte *diff, uint16 HeaderSize, uint16 CopySize, uint16 bytesperrow) {
-	if (HeaderSize == 1) {
-		if (CopySize == 1)
-			VUnDIFFByteByte(Dest, diff, bytesperrow);
-
-		else if (CopySize == 2)
-			VUnDIFFByteWord((uint16 *)Dest, (uint16 *)diff, bytesperrow);
-
-		else if (CopySize == 4)
-			VUnDIFFByteLong((uint32 *)Dest, (uint32 *)diff, bytesperrow);
-
-		else
-			return false;
-	} else
-		return (false);
-
-	return true;
-}
-
-
-/*****************************************************************************/
-/* Runlength decodes a chunk of memory.                                      */
-/*****************************************************************************/
-void runLengthDecode(byte *Dest, byte *Source) {
-	int8 num;
-	int16 count;
-
-
-	while (1) {
-		num = (int8)*Source;
-		Source++;
-
-		if (num == 127) {
-			return;
-		} else if (num > '\0') {
-			memcpy(Dest, Source, num);
-			Source += num;
-			Dest   += num;
-		} else {
-			count = (int16)(-num);
-			num   = *Source;
-			Source++;
-
-			while (count) {
-				*Dest = num;
-				Dest++;
-				count--;
-			}
-		}
-	}
-}
-
-
-
-
-/*****************************************************************************/
-/* Does a vertical run length decode.                                        */
-/*****************************************************************************/
-void VRunLengthDecode(byte *Dest, byte *Source, uint16 bytesperrow) {
-	int8 num;
-	int16 count;
-	byte *Top = Dest;
-
-	for (uint16 i = 0; i < _dataBytesPerRow; i++) {
-		Dest = Top;
-		Dest += i;
-
-		num = (int8)*Source;
-		Source++;
-
-		while (num != 127) {
-			if (num > '\0') {
-				while (num) {
-					*Dest = *Source;
-					Source++;
-					Dest += bytesperrow;
-					num--;
-				}
-			} else {
-				count = (int16)(-num);
-				num   = (int8)*Source;
-				Source++;
-
-				while (count) {
-					*Dest = num;
-					Dest += bytesperrow;
-					count--;
-				}
-			}
-
-			num = *Source;
-			Source++;
-		}
-	}
-}
-
-} // End of namespace Lab


Commit: 148d64eceb86e6756f0ff77b664bd6592a7dc016
    https://github.com/scummvm/scummvm/commit/148d64eceb86e6756f0ff77b664bd6592a7dc016
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:46+01:00

Commit Message:
LAB: Put Image into a separate class. Leaks memory for now

Changed paths:
  A engines/lab/image.cpp
  A engines/lab/image.h
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/interface.cpp
    engines/lab/lab.h
    engines/lab/labfun.h
    engines/lab/map.cpp
    engines/lab/module.mk
    engines/lab/mouse.cpp
    engines/lab/special.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 3a7cd6f..e401e06 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -31,6 +31,7 @@
 #include "lab/lab.h"
 #include "lab/labfun.h"
 #include "lab/anim.h"
+#include "lab/image.h"
 #include "lab/text.h"
 #include "lab/intro.h"
 #include "lab/parsefun.h"
@@ -223,7 +224,7 @@ bool LabEngine::setUpScreens() {
 	buffer = MovePanelBuffer;
 
 	for (uint16 i = 0; i < 20; i++)
-		readImage(&buffer, &(MoveImages[i]));
+		MoveImages[i] = new Image(&buffer);
 
 	/* Creates the gadgets for the movement control panel */
 	y = VGAScaleY(173) - SVGACord(2);
@@ -287,7 +288,7 @@ bool LabEngine::setUpScreens() {
 
 	if (getPlatform() == Common::kPlatformWindows) {
 		for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++)
-			readImage(&buffer, &(InvImages[imgIdx]));
+			InvImages[imgIdx] = new Image(&buffer);
 
 		InvGadgetList = createButton(24, y, 0, 'm', InvImages[0], InvImages[1]);
 		curgad = InvGadgetList;
@@ -307,7 +308,7 @@ bool LabEngine::setUpScreens() {
 		curgad = curgad->NextGadget;
 	} else {
 		for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++)
-			readImage(&buffer, &(InvImages[imgIdx]));
+			InvImages[imgIdx] = new Image(&buffer);
 
 		InvGadgetList = createButton(58, y, 0, 0, InvImages[0], InvImages[1]);
 		curgad = InvGadgetList;
@@ -345,7 +346,7 @@ void LabEngine::perFlipGadget(uint16 GadID) {
 
 			if (!Alternate) {
 				_event->mouseHide();
-				drawImage(TopGad->Im, TopGad->x, TopGad->y);
+				TopGad->Im->drawImage(TopGad->x, TopGad->y);
 				_event->mouseShow();
 			}
 
@@ -1410,30 +1411,30 @@ int LabEngine::followCrumbs() {
 	return moveDir;
 }
 
+byte dropCrumbs[] = { 0x00 };
+Image dropCrumbsImage(24, 24, dropCrumbs);
+
 void LabEngine::mayShowCrumbIndicator() {
 	if (getPlatform() != Common::kPlatformWindows)
 		return;
 
 	if (_droppingCrumbs && MainDisplay) {
-		static byte dropCrumbs[] = { 0x00 };
-		static Image dropCrumbsImage = { 24, 24, dropCrumbs };
-
 		_event->mouseHide();
-		drawMaskImage(&dropCrumbsImage, 612, 4);
+		dropCrumbsImage.drawMaskImage(612, 4);
 		_event->mouseShow();
 	}
 }
 
+byte dropCrumbsOff[] = { 0x00 };
+Image dropCrumbsOffImage(24, 24, dropCrumbsOff);
+
 void LabEngine::mayShowCrumbIndicatorOff() {
 	if (getPlatform() != Common::kPlatformWindows)
 		return;
 
 	if (MainDisplay) {
-		static byte dropCrumbsOff[] = { 0x00 };
-		static Image dropCrumbsOffImage = { 24, 24, dropCrumbsOff };
-
 		_event->mouseHide();
-		drawMaskImage(&dropCrumbsOffImage, 612, 4);
+		dropCrumbsOffImage.drawMaskImage(612, 4);
 		_event->mouseShow();
 	}
 }
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 145ccb6..16283ea 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -31,6 +31,7 @@
 #include "lab/lab.h"
 #include "lab/anim.h"
 #include "lab/parsetypes.h"
+#include "lab/image.h"
 #include "lab/labfun.h"
 #include "lab/parsefun.h"
 #include "lab/mouse.h"
@@ -376,7 +377,7 @@ void LabEngine::doScrollBlack() {
 	im.Height = height;
 	im.ImageData = mem;
 	_music->updateMusic();
-	readScreenImage(&im, 0, 0);
+	im.readScreenImage(0, 0);
 	_music->updateMusic();
 
 	baseAddr = (uint32 *)getCurrentDrawingBuffer();
diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp
new file mode 100644
index 0000000..636ac82
--- /dev/null
+++ b/engines/lab/image.cpp
@@ -0,0 +1,183 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/lab.h"
+#include "lab/image.h"
+
+namespace Lab {
+
+/*****************************************************************************/
+/* Reads in an image from disk.                                              */
+/*****************************************************************************/
+Image::Image(byte **buffer) {
+	uint32 size;
+
+	Width = READ_LE_UINT16(*buffer);
+	Height = READ_LE_UINT16(*buffer + 2);
+
+	*buffer += 8; /* sizeof(struct Image); */
+
+	size = Width * Height;
+
+	if (1L & size)
+		size++;
+
+	ImageData = (byte *)(*buffer);
+	(*buffer) += size;
+}
+
+/*****************************************************************************/
+/* Draws an image to the screen.                                             */
+/*****************************************************************************/
+void Image::drawImage(uint16 x, uint16 y) {
+	int sx = 0, sy = 0;
+	int dx = x, dy = y;
+	int w = Width;
+	int h = Height;
+
+	if (dx < 0) {
+		sx -= dx;
+		w += dx;
+		dx = 0;
+	}
+
+	if (dy < 0) {
+		sy -= dy;
+		w += dy;
+		dy = 0;
+	}
+
+	if (dx + w > g_lab->_screenWidth)
+		w = g_lab->_screenWidth - dx;
+
+	if (dy + h > g_lab->_screenHeight)
+		h = g_lab->_screenHeight - dy;
+
+	if ((w > 0) && (h > 0)) {
+		byte *s = ImageData + sy * Width + sx;
+		byte *d = g_lab->getCurrentDrawingBuffer() + dy * g_lab->_screenWidth + dx;
+
+		while (h-- > 0) {
+			memcpy(d, s, w);
+			s += Width;
+			d += g_lab->_screenWidth;
+		}
+	}
+}
+
+/*****************************************************************************/
+/* Draws an image to the screen.                                             */
+/*****************************************************************************/
+void Image::drawMaskImage(uint16 x, uint16 y) {
+	int sx = 0, sy = 0;
+	int dx = x, dy = y;
+	int w = Width;
+	int h = Height;
+
+	if (dx < 0) {
+		sx -= dx;
+		w += dx;
+		dx = 0;
+	}
+
+	if (dy < 0) {
+		sy -= dy;
+		w += dy;
+		dy = 0;
+	}
+
+	if (dx + w > g_lab->_screenWidth)
+		w = g_lab->_screenWidth - dx;
+
+	if (dy + h > g_lab->_screenHeight)
+		h = g_lab->_screenHeight - dy;
+
+	if ((w > 0) && (h > 0)) {
+		byte *s = ImageData + sy * Width + sx;
+		byte *d = g_lab->getCurrentDrawingBuffer() + dy * g_lab->_screenWidth + dx;
+
+		while (h-- > 0) {
+			byte *ss = s;
+			byte *dd = d;
+			int ww = w;
+
+			while (ww-- > 0) {
+				byte c = *ss++;
+
+				if (c) *dd++ = c - 1;
+				else dd++;
+			}
+
+			s += Width;
+			d += g_lab->_screenWidth;
+		}
+	}
+}
+
+/*****************************************************************************/
+/* Reads an image from the screen.                                           */
+/*****************************************************************************/
+void Image::readScreenImage(uint16 x, uint16 y) {
+	int sx = 0, sy = 0;
+	int	dx = x, dy = y;
+	int w = Width;
+	int h = Height;
+
+ 	if (dx < 0) {
+		sx -= dx;
+		w += dx;
+		dx = 0;
+	}
+
+	if (dy < 0) {
+		sy -= dy;
+		w += dy;
+		dy = 0;
+	}
+
+	if (dx + w > g_lab->_screenWidth)
+		w = g_lab->_screenWidth - dx;
+
+	if (dy + h > g_lab->_screenHeight)
+		h = g_lab->_screenHeight - dy;
+
+	if ((w > 0) && (h > 0)) {
+		byte *s = ImageData + sy * Width + sx;
+		byte *d = g_lab->getCurrentDrawingBuffer() + dy * g_lab->_screenWidth + dx;
+
+		while (h-- > 0) {
+			memcpy(s, d, w);
+			s += Width;
+			d += g_lab->_screenWidth;
+		}
+	}
+}
+
+} // End of namespace Lab
diff --git a/engines/lab/image.h b/engines/lab/image.h
new file mode 100644
index 0000000..c8a001a
--- /dev/null
+++ b/engines/lab/image.h
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#ifndef LAB_IMAGE_H
+#define LAB_IMAGE_H
+
+namespace Lab {
+
+class Image {
+public:
+	uint16 Width;
+    uint16 Height;
+	byte *ImageData;
+
+    Image() : Width(0), Height(0), ImageData(0) {}
+    Image(int w, int h, byte *d) : Width(w), Height(h), ImageData(d) {}
+    Image(byte **buffer);
+
+    void drawImage(uint16 x, uint16 y);
+    void drawMaskImage(uint16 x, uint16 y);
+    void readScreenImage(uint16 x, uint16 y);
+};
+
+
+} // End of namespace Lab
+
+#endif // LAB_H
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index f786bb8..fc7ba1e 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -30,6 +30,7 @@
 
 #include "lab/lab.h"
 #include "lab/labfun.h"
+#include "lab/image.h"
 #include "lab/interface.h"
 #include "lab/mouse.h"
 #include "common/util.h"
@@ -81,7 +82,7 @@ void freeButtonList(Gadget *gptrlist) {
 /*****************************************************************************/
 void drawGadgetList(Gadget *gadlist) {
 	while (gadlist) {
-		g_lab->drawImage(gadlist->Im, gadlist->x, gadlist->y);
+		gadlist->Im->drawImage(gadlist->x, gadlist->y);
 
 		if (GADGETOFF & gadlist->GadgetFlags)
 			ghoastGadget(gadlist, 1);
@@ -105,7 +106,7 @@ void ghoastGadget(Gadget *curgad, uint16 pencolor) {
 /* Unghoasts a gadget, and makes it available again.                         */
 /*****************************************************************************/
 void unGhoastGadget(Gadget *curgad) {
-	g_lab->drawImage(curgad->Im, curgad->x, curgad->y);
+	curgad->Im->drawImage(curgad->x, curgad->y);
 	curgad->GadgetFlags &= !(GADGETOFF);
 }
 
@@ -132,11 +133,11 @@ Gadget *LabEngine::checkNumGadgetHit(Gadget *gadlist, uint16 key) {
 		        (gadlist->KeyEquiv != 0 && makeGadgetKeyEquiv(key) == gadlist->KeyEquiv))
 		        && !(GADGETOFF & gadlist->GadgetFlags)) {
 			_event->mouseHide();
-			g_lab->drawImage(gadlist->ImAlt, gadlist->x, gadlist->y);
+			gadlist->ImAlt->drawImage(gadlist->x, gadlist->y);
 			_event->mouseShow();
 			g_system->delayMillis(80);
 			_event->mouseHide();
-			g_lab->drawImage(gadlist->Im, gadlist->x, gadlist->y);
+			gadlist->Im->drawImage(gadlist->x, gadlist->y);
 			_event->mouseShow();
 
 			return gadlist;
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 9327dbf..b7cf6e1 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -51,12 +51,6 @@ enum GameFeatures {
 	GF_WINDOWS_TRIAL = 1 << 1
 };
 
-struct Image {
-	uint16 Width;
-	uint16 Height;
-	byte *ImageData;
-};
-
 #define ONESECOND 1000
 
 class LabEngine : public Engine {
@@ -143,7 +137,6 @@ public:
 	void setAPen(byte pennum);
 	void writeColorRegs(byte *buf, uint16 first, uint16 numreg);
 	byte *getCurrentDrawingBuffer();
-	void readScreenImage(Image *Im, uint16 x, uint16 y);
 	void screenUpdate();
 	void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
@@ -153,7 +146,6 @@ public:
 	void setPalette(void *cmap, uint16 numcolors);
 	void drawHLine(uint16 x, uint16 y1, uint16 y2);
 	void drawVLine(uint16 x1, uint16 y, uint16 x2);
-	void drawImage(Image *Im, uint16 x, uint16 y);
 	bool haveNextChar();
 	uint16 getNextChar();
 	void processInput(bool can_delay = false);
@@ -193,7 +185,6 @@ private:
 
 	/*---------- Drawing Routines ----------*/
 
-	void drawMaskImage(Image *Im, uint16 x, uint16 y);
 	Common::Point getMousePos();
 	void changeVolume(int delta);
 	void applyPalette(byte *buf, uint16 first, uint16 numreg, uint16 slow);
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index c1a6b35..52f6034 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -54,7 +54,7 @@ class LabEngine;
 #define EAST    2
 #define WEST    3
 
-struct Image;
+class Image;
 struct TextFont;
 struct Gadget;
 
@@ -188,7 +188,6 @@ char *translateFileName(const char *filename);
 
 void fade(bool fadein, uint16 res);
 void setAmigaPal(uint16 *pal, uint16 numcolors);
-void readImage(byte **buffer, Image **im);
 void doMap(uint16 CurRoom);
 void doJournal();
 void doNotes();
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 1f4f0db..d7a3e12 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -31,6 +31,7 @@
 #include "lab/lab.h"
 #include "lab/labfun.h"
 #include "lab/anim.h"
+#include "lab/image.h"
 #include "lab/text.h"
 #include "lab/mouse.h"
 #include "lab/parsefun.h"
@@ -65,30 +66,6 @@ void setAmigaPal(uint16 *pal, uint16 numcolors) {
 	g_lab->writeColorRegsSmooth(vgapal, 0, 16);
 }
 
-
-/*****************************************************************************/
-/* Reads in an image from disk.                                              */
-/*****************************************************************************/
-void readImage(byte **buffer, Image **im) {
-	uint32 size;
-
-	(*im) = (Image *)(*buffer);
-
-	(*im)->Width = READ_LE_UINT16(*buffer);
-	(*im)->Height = READ_LE_UINT16(*buffer + 2);
-
-	*buffer += 8; /* sizeof(struct Image); */
-
-	size = (*im)->Width * (*im)->Height;
-
-	if (1L & size)
-		size++;
-
-	(*im)->ImageData = (byte *)(*buffer);
-	(*buffer) += size;
-}
-
-
 /*---------------------------------------------------------------------------*/
 /*------------------------------ The Map stuff ------------------------------*/
 /*---------------------------------------------------------------------------*/
@@ -169,30 +146,30 @@ static bool loadMapData() {
 
 	stealBufMem(Size); /* Now freeze that buffer from further use */
 
-	readImage(buffer, &Map);
+	Map = new Image(buffer);
 
-	readImage(buffer, &Room);
-	readImage(buffer, &UpArrowRoom);
-	readImage(buffer, &DownArrowRoom);
-	readImage(buffer, &HRoom);
-	readImage(buffer, &VRoom);
-	readImage(buffer, &Maze);
-	readImage(buffer, &HugeMaze);
+	Room = new Image(buffer);
+	UpArrowRoom = new Image(buffer);
+	DownArrowRoom = new Image(buffer);
+	HRoom = new Image(buffer);
+	VRoom = new Image(buffer);
+	Maze = new Image(buffer);
+	HugeMaze = new Image(buffer);
 
-	readImage(buffer, &MapNorth);
-	readImage(buffer, &MapEast);
-	readImage(buffer, &MapSouth);
-	readImage(buffer, &MapWest);
+	MapNorth = new Image(buffer);
+	MapEast = new Image(buffer);
+	MapSouth = new Image(buffer);
+	MapWest = new Image(buffer);
 
-	readImage(buffer, &Path);
-	readImage(buffer, &Bridge);
+	Path = new Image(buffer);
+	Bridge = new Image(buffer);
 
-	readImage(buffer, &Back);
-	readImage(buffer, &BackAlt);
-	readImage(buffer, &Up);
-	readImage(buffer, &UpAlt);
-	readImage(buffer, &Down);
-	readImage(buffer, &DownAlt);
+	Back = new Image(buffer);
+	BackAlt = new Image(buffer);
+	Up = new Image(buffer);
+	UpAlt = new Image(buffer);
+	Down = new Image(buffer);
+	DownAlt = new Image(buffer);
 
 	backgadget.Im    = Back;
 	backgadget.ImAlt = BackAlt;
@@ -325,27 +302,27 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
 	case UPARROWROOM:
 	case DOWNARROWROOM:
 		if (Maps[CurRoom].SpecialID == NORMAL)
-			g_lab->drawImage(Room, x, y);
+			Room->drawImage(x, y);
 		else if (Maps[CurRoom].SpecialID == DOWNARROWROOM)
-			g_lab->drawImage(DownArrowRoom, x, y);
+			DownArrowRoom->drawImage(x, y);
 		else
-			g_lab->drawImage(UpArrowRoom, x, y);
+			UpArrowRoom->drawImage(x, y);
 
 		offset = (Room->Width - Path->Width) / 2;
 
 		if ((NORTHDOOR & flags) && (y >= Path->Height))
-			g_lab->drawImage(Path, x + offset, y - Path->Height);
+			Path->drawImage(x + offset, y - Path->Height);
 
 		if (SOUTHDOOR & flags)
-			g_lab->drawImage(Path, x + offset, y + Room->Height);
+			Path->drawImage(x + offset, y + Room->Height);
 
 		offset = (Room->Height - Path->Height) / 2;
 
 		if (EASTDOOR & flags)
-			g_lab->drawImage(Path, x + Room->Width, y + offset);
+			Path->drawImage(x + Room->Width, y + offset);
 
 		if (WESTDOOR & flags)
-			g_lab->drawImage(Path, x - Path->Width, y + offset);
+			Path->drawImage(x - Path->Width, y + offset);
 
 		xx = x + (Room->Width - XMark->Width) / 2;
 		xy = y + (Room->Height - XMark->Height) / 2;
@@ -353,7 +330,7 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
 		break;
 
 	case BRIDGEROOM:
-		g_lab->drawImage(Bridge, x, y);
+		Bridge->drawImage(x, y);
 
 		xx = x + (Bridge->Width - XMark->Width) / 2;
 		xy = y + (Bridge->Height - XMark->Height) / 2;
@@ -361,37 +338,37 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
 		break;
 
 	case VCORRIDOR:
-		g_lab->drawImage(VRoom, x, y);
+		VRoom->drawImage(x, y);
 
 		offset = (VRoom->Width - Path->Width) / 2;
 
 		if (NORTHDOOR & flags)
-			g_lab->drawImage(Path, x + offset, y - Path->Height);
+			Path->drawImage(x + offset, y - Path->Height);
 
 		if (SOUTHDOOR & flags)
-			g_lab->drawImage(Path, x + offset, y + VRoom->Height);
+			Path->drawImage(x + offset, y + VRoom->Height);
 
 		offset = (Room->Height - Path->Height) / 2;
 
 		if (EASTDOOR & flags)
-			g_lab->drawImage(Path, x + VRoom->Width, y + offset);
+			Path->drawImage(x + VRoom->Width, y + offset);
 
 		if (WESTDOOR & flags)
-			g_lab->drawImage(Path, x - Path->Width, y + offset);
+			Path->drawImage(x - Path->Width, y + offset);
 
 		if (EASTBDOOR & flags)
-			g_lab->drawImage(Path, x + VRoom->Width, y - offset - Path->Height + VRoom->Height);
+			Path->drawImage(x + VRoom->Width, y - offset - Path->Height + VRoom->Height);
 
 		if (WESTBDOOR & flags)
-			g_lab->drawImage(Path, x - Path->Width, y - offset - Path->Height + VRoom->Height);
+			Path->drawImage(x - Path->Width, y - offset - Path->Height + VRoom->Height);
 
 		offset = (VRoom->Height - Path->Height) / 2;
 
 		if (EASTMDOOR & flags)
-			g_lab->drawImage(Path, x + VRoom->Width, y - offset - Path->Height + VRoom->Height);
+			Path->drawImage(x + VRoom->Width, y - offset - Path->Height + VRoom->Height);
 
 		if (WESTMDOOR & flags)
-			g_lab->drawImage(Path, x - Path->Width, y - offset - Path->Height + VRoom->Height);
+			Path->drawImage(x - Path->Width, y - offset - Path->Height + VRoom->Height);
 
 		xx = x + (VRoom->Width - XMark->Width) / 2;
 		xy = y + (VRoom->Height - XMark->Height) / 2;
@@ -399,37 +376,37 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
 		break;
 
 	case HCORRIDOR:
-		g_lab->drawImage(HRoom, x, y);
+		HRoom->drawImage(x, y);
 
 		offset = (Room->Width - Path->Width) / 2;
 
 		if (NORTHDOOR & flags)
-			g_lab->drawImage(Path, x + offset, y - Path->Height);
+			Path->drawImage(x + offset, y - Path->Height);
 
 		if (SOUTHDOOR & flags)
-			g_lab->drawImage(Path, x + offset, y + Room->Height);
+			Path->drawImage(x + offset, y + Room->Height);
 
 		if (NORTHRDOOR & flags)
-			g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y - Path->Height);
+			Path->drawImage(x - offset - Path->Width + HRoom->Width, y - Path->Height);
 
 		if (SOUTHRDOOR & flags)
-			g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y + Room->Height);
+			Path->drawImage(x - offset - Path->Width + HRoom->Width, y + Room->Height);
 
 		offset = (HRoom->Width - Path->Width) / 2;
 
 		if (NORTHMDOOR & flags)
-			g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y - Path->Height);
+			Path->drawImage(x - offset - Path->Width + HRoom->Width, y - Path->Height);
 
 		if (SOUTHMDOOR & flags)
-			g_lab->drawImage(Path, x - offset - Path->Width + HRoom->Width, y + Room->Height);
+			Path->drawImage(x - offset - Path->Width + HRoom->Width, y + Room->Height);
 
 		offset = (Room->Height - Path->Height) / 2;
 
 		if (EASTDOOR & flags)
-			g_lab->drawImage(Path, x + HRoom->Width, y + offset);
+			Path->drawImage(x + HRoom->Width, y + offset);
 
 		if (WESTDOOR & flags)
-			g_lab->drawImage(Path, x - Path->Width, y + offset);
+			Path->drawImage(x - Path->Width, y + offset);
 
 		xx = x + (HRoom->Width - XMark->Width) / 2;
 		xy = y + (HRoom->Height - XMark->Height) / 2;
@@ -441,7 +418,7 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
 	}
 
 	if (drawx)
-		g_lab->drawImage(XMark, xx, xy);
+		XMark->drawImage(xx, xy);
 }
 
 /*****************************************************************************/
@@ -528,7 +505,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 	setAPen(0);
 	rectFill(0, 0, _screenWidth - 1, _screenHeight - 1);
 
-	drawImage(Map, 0, 0);
+	Map->drawImage(0, 0);
 	drawGadgetList(MapGadgetList);
 
 	for (uint16 i = 1; i <= MaxRooms; i++) {
@@ -562,16 +539,16 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 	// Labyrinth specific code
 	if (Floor == LOWERFLOOR) {
 		if (onFloor(SURMAZEFLOOR))
-			drawImage(Maze, mapScaleX(538), mapScaleY(277));
+			Maze->drawImage(mapScaleX(538), mapScaleY(277));
 	} else if (Floor == MIDDLEFLOOR) {
 		if (onFloor(CARNIVAL))
-			drawImage(Maze, mapScaleX(358), mapScaleY(72));
+			Maze->drawImage(mapScaleX(358), mapScaleY(72));
 
 		if (onFloor(MEDMAZEFLOOR))
-			drawImage(Maze, mapScaleX(557), mapScaleY(325));
+			Maze->drawImage(mapScaleX(557), mapScaleY(325));
 	} else if (Floor == UPPERFLOOR) {
 		if (onFloor(HEDGEMAZEFLOOR))
-			drawImage(HugeMaze, mapScaleX(524), mapScaleY(97));
+			HugeMaze->drawImage(mapScaleX(524), mapScaleY(97));
 	} else if (Floor == SURMAZEFLOOR) {
 		sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str();
 		flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr);
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index 4f1ace8..b21a3ea 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -6,6 +6,7 @@ MODULE_OBJS := \
 	detection.o \
 	engine.o \
 	graphics.o \
+	image.o \
 	interface.o \
 	intro.o \
 	lab.o \
@@ -32,4 +33,3 @@ endif
 
 # Include common rules
 include $(srcdir)/rules.mk
-
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index 9ff5117..4bd6c7f 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -29,6 +29,7 @@
  */
 
 #include "lab/lab.h"
+#include "lab/image.h"
 #include "lab/mouse.h"
 #include "lab/interface.h"
 
@@ -76,14 +77,14 @@ Gadget *EventManager::checkGadgetHit(Gadget *gadlist, Common::Point pos) {
 				hitgad = gadlist;
 			} else {
 				mouseHide();
-				_vm->drawImage(gadlist->ImAlt, gadlist->x, gadlist->y);
+				gadlist->ImAlt->drawImage(gadlist->x, gadlist->y);
 				mouseShow();
 
 				for (uint16 i = 0; i < 3; i++)
 					_vm->waitTOF();
 
 				mouseHide();
-				_vm->drawImage(gadlist->Im, gadlist->x, gadlist->y);
+				gadlist->Im->drawImage(gadlist->x, gadlist->y);
 				mouseShow();
 			}
 
@@ -135,14 +136,14 @@ void EventManager::updateMouse() {
 
 	if (hitgad) {
 		mouseHide();
-		_vm->drawImage(hitgad->ImAlt, hitgad->x, hitgad->y);
+		hitgad->ImAlt->drawImage(hitgad->x, hitgad->y);
 		mouseShow();
 
 		for (uint16 i = 0; i < 3; i++)
 			_vm->waitTOF();
 
 		mouseHide();
-		_vm->drawImage(hitgad->Im, hitgad->x, hitgad->y);
+		hitgad->Im->drawImage(hitgad->x, hitgad->y);
 		mouseShow();
 		doUpdateDisplay = true;
 		hitgad = NULL;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index afe3efb..6f70cb0 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -35,6 +35,7 @@
 
 #include "lab/lab.h"
 #include "lab/labfun.h"
+#include "lab/image.h"
 #include "lab/parsefun.h"
 #include "lab/interface.h"
 #include "lab/anim.h"
@@ -132,7 +133,7 @@ static byte *loadBackPict(const char *fileName, bool tomem) {
 /*****************************************************************************/
 static void doCombination() {
 	for (uint16 i = 0; i <= 5; i++)
-		g_lab->drawImage(Images[combination[i]], VGAScaleX(combx[i]), VGAScaleY(65));
+		Images[combination[i]]->drawImage(VGAScaleX(combx[i]), VGAScaleY(65));
 }
 
 /*****************************************************************************/
@@ -152,7 +153,7 @@ void showCombination(const char *filename) {
 	buffer = g_lab->_music->newOpen("P:Numbers");
 
 	for (uint16 CurBit = 0; CurBit < 10; CurBit++)
-		readImage(buffer, &(Images[CurBit]));
+		Images[CurBit] = new Image(buffer);
 
 	allocFile((void **)&g_lab->_tempScrollData, Images[0]->Width * Images[0]->Height * 2L, "tempdata");
 
@@ -267,7 +268,7 @@ static void doTile(bool showsolution) {
 				num = CurTile[col] [row];
 
 			if (showsolution || num)
-				g_lab->drawImage(Tiles[num], cols + (col * colm), rows + (row * rowm));
+				Tiles[num]->drawImage(cols + (col * colm), rows + (row * rowm));
 
 			col++;
 		}
@@ -303,7 +304,7 @@ void showTile(const char *filename, bool showsolution) {
 		return;
 
 	for (uint16 curBit = start; curBit < 16; curBit++)
-		readImage(buffer, &(Tiles[curBit]));
+		Tiles[curBit] = new Image(buffer);
 
 	allocFile((void **)&g_lab->_tempScrollData, Tiles[1]->Width * Tiles[1]->Height * 2L, "tempdata");
 
@@ -550,12 +551,12 @@ static bool loadJournalData() {
 	if (!buffer)
 		return false;
 
-	readImage(buffer, &(BackG.Im));
-	readImage(buffer, &(BackG.ImAlt));
-	readImage(buffer, &(ForwardG.Im));
-	readImage(buffer, &(ForwardG.ImAlt));
-	readImage(buffer, &(CancelG.Im));
-	readImage(buffer, &(CancelG.ImAlt));
+	BackG.Im = new Image(buffer);
+	BackG.ImAlt = new Image(buffer);
+	ForwardG.Im = new Image(buffer);
+	ForwardG.ImAlt = new Image(buffer);
+	CancelG.Im = new Image(buffer);
+	CancelG.ImAlt = new Image(buffer);
 
 	BackG.KeyEquiv = VKEY_LTARROW;
 	ForwardG.KeyEquiv = VKEY_RTARROW;
@@ -819,7 +820,7 @@ static void getMonImages() {
 	if (!buffer)
 		return;
 
-	readImage(buffer, &MonButton);
+	MonButton = new Image(buffer);
 
 	stealBufMem(bufferSize);  /* Trick: protects the memory where the buttons are so they won't be over-written */
 }
@@ -855,7 +856,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
 		rectFill(0, 0, _screenWidth - 1, y2);
 
 		for (uint16 i = 0; i < numlines; i++)
-			drawImage(MonButton, 0, i * MonGadHeight);
+			MonButton->drawImage(0, i * MonGadHeight);
 	} else if (isinteractive) {
 		setAPen(0);
 		rectFill(0, 0, _screenWidth - 1, y2);
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 326b1f4..4c8169e 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -32,6 +32,7 @@
 #include "common/events.h"
 
 #include "lab/lab.h"
+#include "lab/image.h"
 #include "lab/mouse.h"
 
 namespace Lab {
@@ -250,133 +251,6 @@ byte *LabEngine::getCurrentDrawingBuffer() {
 }
 
 /*****************************************************************************/
-/* Draws an image to the screen.                                             */
-/*****************************************************************************/
-void LabEngine::drawImage(Image *im, uint16 x, uint16 y) {
-	int sx = 0, sy = 0;
-	int dx = x, dy = y;
-	int w = im->Width;
-	int h = im->Height;
-
-	if (dx < 0) {
-		sx -= dx;
-		w += dx;
-		dx = 0;
-	}
-
-	if (dy < 0) {
-		sy -= dy;
-		w += dy;
-		dy = 0;
-	}
-
-	if (dx + w > _screenWidth)
-		w = _screenWidth - dx;
-
-	if (dy + h > _screenHeight)
-		h = _screenHeight - dy;
-
-	if ((w > 0) && (h > 0)) {
-		byte *s = im->ImageData + sy * im->Width + sx;
-		byte *d = getCurrentDrawingBuffer() + dy * _screenWidth + dx;
-
-		while (h-- > 0) {
-			memcpy(d, s, w);
-			s += im->Width;
-			d += _screenWidth;
-		}
-	}
-}
-
-/*****************************************************************************/
-/* Draws an image to the screen.                                             */
-/*****************************************************************************/
-void LabEngine::drawMaskImage(Image *im, uint16 x, uint16 y) {
-	int sx = 0, sy = 0;
-	int dx = x, dy = y;
-	int w = im->Width;
-	int h = im->Height;
-
-	if (dx < 0) {
-		sx -= dx;
-		w += dx;
-		dx = 0;
-	}
-
-	if (dy < 0) {
-		sy -= dy;
-		w += dy;
-		dy = 0;
-	}
-
-	if (dx + w > _screenWidth)
-		w = _screenWidth - dx;
-
-	if (dy + h > _screenHeight)
-		h = _screenHeight - dy;
-
-	if ((w > 0) && (h > 0)) {
-		byte *s = im->ImageData + sy * im->Width + sx;
-		byte *d = getCurrentDrawingBuffer() + dy * _screenWidth + dx;
-
-		while (h-- > 0) {
-			byte *ss = s;
-			byte *dd = d;
-			int ww = w;
-
-			while (ww-- > 0) {
-				byte c = *ss++;
-
-				if (c) *dd++ = c - 1;
-				else dd++;
-			}
-
-			s += im->Width;
-			d += _screenWidth;
-		}
-	}
-}
-
-/*****************************************************************************/
-/* Reads an image from the screen.                                           */
-/*****************************************************************************/
-void LabEngine::readScreenImage(Image *im, uint16 x, uint16 y) {
-	int sx = 0, sy = 0;
-	int	dx = x, dy = y;
-	int w = im->Width;
-	int h = im->Height;
-
-	if (dx < 0) {
-		sx -= dx;
-		w += dx;
-		dx = 0;
-	}
-
-	if (dy < 0) {
-		sy -= dy;
-		w += dy;
-		dy = 0;
-	}
-
-	if (dx + w > _screenWidth)
-		w = _screenWidth - dx;
-
-	if (dy + h > _screenHeight)
-		h = _screenHeight - dy;
-
-	if ((w > 0) && (h > 0)) {
-		byte *s = im->ImageData + sy * im->Width + sx;
-		byte *d = getCurrentDrawingBuffer() + dy * _screenWidth + dx;
-
-		while (h-- > 0) {
-			memcpy(s, d, w);
-			s += im->Width;
-			d += _screenWidth;
-		}
-	}
-}
-
-/*****************************************************************************/
 /* Blits a piece of one image to another.                                    */
 /* NOTE: for our purposes, assumes that ImDest is to be in VGA memory.       */
 /*****************************************************************************/
@@ -448,8 +322,8 @@ void LabEngine::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16
 		im.Width = x2 - x1 + 1 - dx;
 		im.Height = y2 - y1 + 1;
 
-		readScreenImage(&im, x1, y1);
-		drawImage(&im, x1 + dx, y1);
+		im.readScreenImage(x1, y1);
+		im.drawImage(x1 + dx, y1);
 
 		setAPen(0);
 		rectFill(x1, y1, x1 + dx - 1, y2);
@@ -457,8 +331,8 @@ void LabEngine::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16
 		im.Width = x2 - x1 + 1 + dx;
 		im.Height = y2 - y1 + 1;
 
-		readScreenImage(&im, x1 - dx, y1);
-		drawImage(&im, x1, y1);
+		im.readScreenImage(x1 - dx, y1);
+		im.drawImage(x1, y1);
 
 		setAPen(0);
 		rectFill(x2 + dx + 1, y1, x2, y2);
@@ -490,8 +364,8 @@ void LabEngine::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16
 		im.Width = x2 - x1 + 1;
 		im.Height = y2 - y1 + 1 - dy;
 
-		readScreenImage(&im, x1, y1);
-		drawImage(&im, x1, y1 + dy);
+		im.readScreenImage(x1, y1);
+		im.drawImage(x1, y1 + dy);
 
 		setAPen(0);
 		rectFill(x1, y1, x2, y1 + dy - 1);
@@ -499,8 +373,8 @@ void LabEngine::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16
 		im.Width = x2 - x1 + 1;
 		im.Height = y2 - y1 + 1 + dy;
 
-		readScreenImage(&im, x1, y1 - dy);
-		drawImage(&im, x1, y1);
+		im.readScreenImage(x1, y1 - dy);
+		im.drawImage(x1, y1);
 
 		setAPen(0);
 		rectFill(x1, y2 + dy + 1, x2, y2);


Commit: 7651ac738807425996e9542446eb91f4e90063a6
    https://github.com/scummvm/scummvm/commit/7651ac738807425996e9542446eb91f4e90063a6
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:46+01:00

Commit Message:
LAB: Get rid of readdiff.cpp

Changed paths:
  R engines/lab/readdiff.cpp
    engines/lab/anim.cpp
    engines/lab/anim.h



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 44d9eea..689f903 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -33,7 +33,6 @@
 
 namespace Lab {
 
-extern uint16 _dataBytesPerRow;
 extern BitMap *DrawBitMap;
 extern byte **startoffile;
 extern BitMap *DispBitMap;
@@ -75,7 +74,7 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 	diffwidth = 0;
 	diffheight = 0;
 	stopsound = false;
-
+	_dataBytesPerRow = 0;
 
 	for (int i = 0; i < 3 * 256; i++)
 		diffcmap[i] = 0;
@@ -88,7 +87,7 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 /* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
 /* is also a byte.                                                           */
 /*****************************************************************************/
-static void unDIFFByteByte(byte *dest, byte *diff) {
+void Anim::unDIFFByteByte(byte *dest, byte *diff) {
 	uint16 skip, copy;
 
 	while (1) {
@@ -118,7 +117,7 @@ static void unDIFFByteByte(byte *dest, byte *diff) {
 /* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
 /* is a word.                                                                */
 /*****************************************************************************/
-static void unDIFFByteWord(uint16 *dest, uint16 *diff) {
+void Anim::unDIFFByteWord(uint16 *dest, uint16 *diff) {
 	uint16 skip, copy;
 
 	while (1) {
@@ -193,7 +192,7 @@ bool Anim::unDIFFMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySi
 /* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
 /* is a byte.                                                                */
 /*****************************************************************************/
-static void VUnDIFFByteByte(byte *Dest, byte *diff, uint16 bytesperrow) {
+void Anim::VUnDIFFByteByte(byte *Dest, byte *diff, uint16 bytesperrow) {
 	byte *CurPtr;
 	uint16 skip, copy;
 	uint16 counter = 0;
@@ -231,7 +230,7 @@ static void VUnDIFFByteByte(byte *Dest, byte *diff, uint16 bytesperrow) {
 /* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
 /* is a word.                                                                */
 /*****************************************************************************/
-static void VUnDIFFByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow) {
+void Anim::VUnDIFFByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow) {
 	uint16 *CurPtr;
 	uint16 skip, copy;
 	uint16 counter = 0, wordsperrow;
@@ -272,7 +271,7 @@ static void VUnDIFFByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow) {
 /* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
 /* is a long.                                                                */
 /*****************************************************************************/
-static void VUnDIFFByteLong(uint32 *Dest, uint32 *diff, uint16 bytesperrow) {
+void Anim::VUnDIFFByteLong(uint32 *Dest, uint32 *diff, uint16 bytesperrow) {
 	uint32 *CurPtr;
 	uint16 skip, copy;
 	uint16 counter = 0, longsperrow;
@@ -725,4 +724,48 @@ bool Anim::readDiff(bool playonce) {
 	return true;
 }
 
+void Anim::readSound(bool waitTillFinished, Common::File *file) {
+	uint32 magicBytes = file->readUint32LE();
+	if (magicBytes != 1219009121L)
+		return;
+
+	uint32 soundTag = file->readUint32LE();
+	uint32 soundSize = file->readUint32LE();
+
+	if (soundTag == 0)
+		file->skip(soundSize);	// skip the header
+	else
+		return;
+
+	while (soundTag != 65535) {
+		g_lab->_music->updateMusic();
+		soundTag = file->readUint32LE();
+		soundSize = file->readUint32LE() - 8;
+
+		if ((soundTag == 30) || (soundTag == 31)) {
+			if (waitTillFinished) {
+				while (g_lab->_music->isSoundEffectActive()) {
+					g_lab->_music->updateMusic();
+					g_lab->waitTOF();
+				}
+			}
+
+			file->skip(4);
+
+			uint16 sampleRate = file->readUint16LE();
+			file->skip(2);
+			byte *soundData = (byte *)malloc(soundSize);
+			file->read(soundData, soundSize);
+			g_lab->_music->playSoundEffect(sampleRate, soundSize, soundData);
+		} else if (soundTag == 65535L) {
+			if (waitTillFinished) {
+				while (g_lab->_music->isSoundEffectActive()) {
+					g_lab->_music->updateMusic();
+					g_lab->waitTOF();
+				}
+			}
+		} else
+			file->skip(soundSize);
+	}
+}
 } // End of namespace Lab
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 0472a72..62c7e39 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -86,6 +86,13 @@ private:
 	uint32 diffwidth;
 	uint32 diffheight;
 	bool stopsound;
+	uint16 _dataBytesPerRow;
+
+	void unDIFFByteByte(byte *dest, byte *diff);
+	void unDIFFByteWord(uint16 *dest, uint16 *diff);
+	void VUnDIFFByteByte(byte *Dest, byte *diff, uint16 bytesperrow);
+	void VUnDIFFByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow);
+	void VUnDIFFByteLong(uint32 *Dest, uint32 *diff, uint16 bytesperrow);
 
 public:
 	Anim(LabEngine *vm);
diff --git a/engines/lab/readdiff.cpp b/engines/lab/readdiff.cpp
deleted file mode 100644
index 43309ff..0000000
--- a/engines/lab/readdiff.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "lab/lab.h"
-#include "lab/anim.h"
-#include "lab/labfun.h"
-#include "lab/mouse.h"
-
-namespace Lab {
-static byte temp[5];
-
-uint16 _dataBytesPerRow;
-
-void Anim::readSound(bool waitTillFinished, Common::File *file) {
-	uint32 magicBytes = file->readUint32LE();
-	if (magicBytes != 1219009121L)
-		return;
-
-	uint32 soundTag = file->readUint32LE();
-	uint32 soundSize = file->readUint32LE();
-
-	if (soundTag == 0)
-		file->skip(soundSize);	// skip the header
-	else
-		return;
-
-	while (soundTag != 65535) {
-		g_lab->_music->updateMusic();
-		soundTag = file->readUint32LE();
-		soundSize = file->readUint32LE() - 8;
-
-		if ((soundTag == 30) || (soundTag == 31)) {
-			if (waitTillFinished) {
-				while (g_lab->_music->isSoundEffectActive()) {
-					g_lab->_music->updateMusic();
-					g_lab->waitTOF();
-				}
-			}
-
-			file->skip(4);
-
-			uint16 sampleRate = file->readUint16LE();
-			file->skip(2);
-			byte *soundData = (byte *)malloc(soundSize);
-			file->read(soundData, soundSize);
-			g_lab->_music->playSoundEffect(sampleRate, soundSize, soundData);
-		} else if (soundTag == 65535L) {
-			if (waitTillFinished) {
-				while (g_lab->_music->isSoundEffectActive()) {
-					g_lab->_music->updateMusic();
-					g_lab->waitTOF();
-				}
-			}
-		} else
-			file->skip(soundSize);
-	}
-}
-
-} // End of namespace Lab


Commit: 2fb0250e0c26ff7ee24a9b05b22c6d8b177131af
    https://github.com/scummvm/scummvm/commit/2fb0250e0c26ff7ee24a9b05b22c6d8b177131af
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:46+01:00

Commit Message:
LAB: Renaming of Anim

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/intro.cpp
    engines/lab/processroom.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 689f903..908c4e4 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -38,46 +38,46 @@ extern byte **startoffile;
 extern BitMap *DispBitMap;
 
 Anim::Anim(LabEngine *vm) : _vm(vm) {
-	header = 0;
-	CurBit = 0;
-	numchunks = 1;
-	IsBM = false;
-	headerdata._width = 0;
-	headerdata._height = 0;
-	headerdata._fps = 0;
-	headerdata._flags = 0;
-	WaitSec = 0;
-	WaitMicros = 0;
-	DelayMicros = 0;
-	continuous = false;
-	IsPlaying = false;
-	IsAnim = false;
-	IsPal = false;
-	nopalchange = false;
-	donepal = false;
-	framenumber = 0;
-	PlayOnce = false;
-	Buffer = nullptr;
-	storagefordifffile = nullptr;
-	difffile = &storagefordifffile;
-	size = 0;
-	RawDiffBM._bytesPerRow = 0;
-	RawDiffBM._flags = 0;
+	_header = 0;
+	_curBit = 0;
+	_numChunks = 1;
+	_isBM = false;
+	_headerdata._width = 0;
+	_headerdata._height = 0;
+	_headerdata._fps = 0;
+	_headerdata._flags = 0;
+	_waitSec = 0;
+	_waitMicros = 0;
+	_delayMicros = 0;
+	_continuous = false;
+	_isPlaying = false;
+	_isAnim = false;
+	_isPal = false;
+	_noPalChange = false;
+	_donePal = false;
+	_frameNum = 0;
+	_playOnce = false;
+	_buffer = nullptr;
+	_storeDiffFile = nullptr;
+	_diffFile = &_storeDiffFile;
+	_size = 0;
+	_rawDiffBM._bytesPerRow = 0;
+	_rawDiffBM._flags = 0;
 	for (int i = 0; i < 16; i++)
-		RawDiffBM._planes[i] = nullptr;
-	RawDiffBM._rows = 0;
-	waitForEffect = false;
-	StopPlayingEnd = false;
-	samplespeed = 0;
-	DoBlack = false;
-	start = nullptr;
-	diffwidth = 0;
-	diffheight = 0;
-	stopsound = false;
+		_rawDiffBM._planes[i] = nullptr;
+	_rawDiffBM._rows = 0;
+	_waitForEffect = false;
+	_stopPlayingEnd = false;
+	_sampleSpeed = 0;
+	_doBlack = false;
+	_start = nullptr;
+	_diffWidth = 0;
+	_diffHeight = 0;
+	_stopSound = false;
 	_dataBytesPerRow = 0;
 
 	for (int i = 0; i < 3 * 256; i++)
-		diffcmap[i] = 0;
+		_diffPalette[i] = 0;
 
 }
 
@@ -192,14 +192,14 @@ bool Anim::unDIFFMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySi
 /* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
 /* is a byte.                                                                */
 /*****************************************************************************/
-void Anim::VUnDIFFByteByte(byte *Dest, byte *diff, uint16 bytesperrow) {
-	byte *CurPtr;
+void Anim::VUnDIFFByteByte(byte *dest, byte *diff, uint16 bytesPerRow) {
+	byte *curPtr;
 	uint16 skip, copy;
 	uint16 counter = 0;
 
 
 	while (counter < _dataBytesPerRow) {
-		CurPtr = Dest + counter;
+		curPtr = dest + counter;
 
 		for (;;) {
 			skip = *diff;
@@ -213,12 +213,12 @@ void Anim::VUnDIFFByteByte(byte *Dest, byte *diff, uint16 bytesperrow) {
 			}
 
 			else {
-				CurPtr += (skip * bytesperrow);
+				curPtr += (skip * bytesPerRow);
 
 				while (copy) {
 					copy--;
-					*CurPtr = *diff;
-					CurPtr += bytesperrow;
+					*curPtr = *diff;
+					curPtr += bytesPerRow;
 					diff++;
 				}
 			}
@@ -230,16 +230,15 @@ void Anim::VUnDIFFByteByte(byte *Dest, byte *diff, uint16 bytesperrow) {
 /* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
 /* is a word.                                                                */
 /*****************************************************************************/
-void Anim::VUnDIFFByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow) {
-	uint16 *CurPtr;
+void Anim::VUnDIFFByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow) {
+	uint16 *curPtr;
 	uint16 skip, copy;
-	uint16 counter = 0, wordsperrow;
-
+	uint16 counter = 0;
 
-	wordsperrow = bytesperrow / 2;
+	uint16 wordsPerRow = bytesPerRow / 2;
 
 	while (counter < (_dataBytesPerRow >> 1)) {
-		CurPtr = Dest + counter;
+		curPtr = dest + counter;
 
 		for (;;) {
 			skip = ((byte *)diff)[0];
@@ -254,11 +253,11 @@ void Anim::VUnDIFFByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow) {
 			}
 
 			else {
-				CurPtr += (skip * wordsperrow);
+				curPtr += (skip * wordsPerRow);
 
 				while (copy) {
-					*CurPtr = *diff; //swapUShort(*diff);
-					CurPtr += wordsperrow;
+					*curPtr = *diff; //swapUShort(*diff);
+					curPtr += wordsPerRow;
 					diff++;
 					copy--;
 				}
@@ -271,17 +270,17 @@ void Anim::VUnDIFFByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow) {
 /* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
 /* is a long.                                                                */
 /*****************************************************************************/
-void Anim::VUnDIFFByteLong(uint32 *Dest, uint32 *diff, uint16 bytesperrow) {
-	uint32 *CurPtr;
+void Anim::VUnDIFFByteLong(uint32 *dest, uint32 *diff, uint16 bytesPerRow) {
+	uint32 *_curPtr;
 	uint16 skip, copy;
-	uint16 counter = 0, longsperrow;
-	byte *diff1 = (byte *)diff;
 
+	uint16 counter = 0;
+	byte *diff1 = (byte *)diff;
 
-	longsperrow = bytesperrow / 4;
+	uint16 longsperrow = bytesPerRow / 4;
 
 	while (counter < (_dataBytesPerRow >> 2)) {
-		CurPtr = Dest + counter;
+		_curPtr = dest + counter;
 
 		for (;;) {
 			skip = *diff1;
@@ -297,11 +296,11 @@ void Anim::VUnDIFFByteLong(uint32 *Dest, uint32 *diff, uint16 bytesperrow) {
 			}
 
 			else {
-				CurPtr += (skip * longsperrow);
+				_curPtr += (skip * longsperrow);
 
 				while (copy) {
-					*CurPtr = *(uint32 *)diff1; //swapULong(*diff);
-					CurPtr += longsperrow;
+					*_curPtr = *(uint32 *)diff1; //swapULong(*diff);
+					_curPtr += longsperrow;
 					diff1 += 4;
 					copy--;
 				}
@@ -313,17 +312,14 @@ void Anim::VUnDIFFByteLong(uint32 *Dest, uint32 *diff, uint16 bytesperrow) {
 /*****************************************************************************/
 /* UnDiffs a coded DIFF string onto an already initialized piece of memory.  */
 /*****************************************************************************/
-bool Anim::VUnDIFFMemory(byte *Dest, byte *diff, uint16 HeaderSize, uint16 CopySize, uint16 bytesperrow) {
-	if (HeaderSize == 1) {
-		if (CopySize == 1)
-			VUnDIFFByteByte(Dest, diff, bytesperrow);
-
-		else if (CopySize == 2)
-			VUnDIFFByteWord((uint16 *)Dest, (uint16 *)diff, bytesperrow);
-
-		else if (CopySize == 4)
-			VUnDIFFByteLong((uint32 *)Dest, (uint32 *)diff, bytesperrow);
-
+bool Anim::VUnDIFFMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySize, uint16 bytesPerRow) {
+	if (headerSize == 1) {
+		if (copySize == 1)
+			VUnDIFFByteByte(dest, diff, bytesPerRow);
+		else if (copySize == 2)
+			VUnDIFFByteWord((uint16 *)dest, (uint16 *)diff, bytesPerRow);
+		else if (copySize == 4)
+			VUnDIFFByteLong((uint32 *)dest, (uint32 *)diff, bytesPerRow);
 		else
 			return false;
 	} else
@@ -335,29 +331,28 @@ bool Anim::VUnDIFFMemory(byte *Dest, byte *diff, uint16 HeaderSize, uint16 CopyS
 /*****************************************************************************/
 /* Runlength decodes a chunk of memory.                                      */
 /*****************************************************************************/
-void Anim::runLengthDecode(byte *Dest, byte *Source) {
+void Anim::runLengthDecode(byte *dest, byte *source) {
 	int8 num;
 	int16 count;
 
-
 	while (1) {
-		num = (int8)*Source;
-		Source++;
+		num = (int8)*source;
+		source++;
 
 		if (num == 127) {
 			return;
 		} else if (num > '\0') {
-			memcpy(Dest, Source, num);
-			Source += num;
-			Dest   += num;
+			memcpy(dest, source, num);
+			source += num;
+			dest   += num;
 		} else {
 			count = (int16)(-num);
-			num   = *Source;
-			Source++;
+			num   = *source;
+			source++;
 
 			while (count) {
-				*Dest = num;
-				Dest++;
+				*dest = num;
+				dest++;
 				count--;
 			}
 		}
@@ -367,40 +362,40 @@ void Anim::runLengthDecode(byte *Dest, byte *Source) {
 /*****************************************************************************/
 /* Does a vertical run length decode.                                        */
 /*****************************************************************************/
-void Anim::VRunLengthDecode(byte *Dest, byte *Source, uint16 bytesperrow) {
+void Anim::VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow) {
 	int8 num;
 	int16 count;
-	byte *Top = Dest;
+	byte *top = dest;
 
 	for (uint16 i = 0; i < _dataBytesPerRow; i++) {
-		Dest = Top;
-		Dest += i;
+		dest = top;
+		dest += i;
 
-		num = (int8)*Source;
-		Source++;
+		num = (int8)*source;
+		source++;
 
 		while (num != 127) {
 			if (num > '\0') {
 				while (num) {
-					*Dest = *Source;
-					Source++;
-					Dest += bytesperrow;
+					*dest = *source;
+					source++;
+					dest += bytesPerRow;
 					num--;
 				}
 			} else {
 				count = (int16)(-num);
-				num   = (int8)*Source;
-				Source++;
+				num   = (int8)*source;
+				source++;
 
 				while (count) {
-					*Dest = num;
-					Dest += bytesperrow;
+					*dest = num;
+					dest += bytesPerRow;
 					count--;
 				}
 			}
 
-			num = *Source;
-			Source++;
+			num = *source;
+			source++;
 		}
 	}
 }
@@ -408,21 +403,19 @@ void Anim::VRunLengthDecode(byte *Dest, byte *Source, uint16 bytesperrow) {
 /*****************************************************************************/
 /* Does the undiffing between the bitmaps.                                   */
 /*****************************************************************************/
-void Anim::unDiff(byte *NewBuf, byte *OldBuf, byte *DiffData, uint16 bytesperrow, bool IsV) {
-	byte buftype;
+void Anim::unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesPerRow, bool isV) {
+	diffData++;
+	byte bufType = *diffData;
+	diffData++;
 
-	DiffData++;
-	buftype  = *DiffData;
-	DiffData++;
-
-	if (IsV)
-		VUnDIFFMemory(NewBuf, DiffData, 1, buftype + 1, bytesperrow);
+	if (isV)
+		VUnDIFFMemory(newBuf, diffData, 1, bufType + 1, bytesPerRow);
 	else
-		unDIFFMemory(NewBuf, DiffData, 1, buftype + 1);
+		unDIFFMemory(newBuf, diffData, 1, bufType + 1);
 }
 
 void Anim::diffNextFrame() {
-	if (header == 65535)  /* Already done. */
+	if (_header == 65535)  /* Already done. */
 		return;
 
 	if (DispBitMap->_flags & BITMAPF_VIDEO) {
@@ -436,37 +429,37 @@ void Anim::diffNextFrame() {
 	_vm->_event->mouseHide();
 
 	while (1) {
-		if (CurBit >= numchunks) {
+		if (_curBit >= _numChunks) {
 			_vm->_event->mouseShow();
 
-			if (!IsBM) {
-				if (headerdata._fps) {
-					_vm->waitForTime(WaitSec, WaitMicros);
-					_vm->addCurTime(0L, DelayMicros, &WaitSec, &WaitMicros);
+			if (!_isBM) {
+				if (_headerdata._fps) {
+					_vm->waitForTime(_waitSec, _waitMicros);
+					_vm->addCurTime(0L, _delayMicros, &_waitSec, &_waitMicros);
 				}
 
-				if (IsPal && !nopalchange) {
-					_vm->setPalette(diffcmap, 256);
-					IsPal = false;
+				if (_isPal && !_noPalChange) {
+					_vm->setPalette(_diffPalette, 256);
+					_isPal = false;
 				}
 
-				donepal = true;
+				_donePal = true;
 			}
 
-			if (IsPal && !nopalchange && !IsBM && !donepal) {
-				_vm->setPalette(diffcmap, 256);
-				IsPal = false;
+			if (_isPal && !_noPalChange && !_isBM && !_donePal) {
+				_vm->setPalette(_diffPalette, 256);
+				_isPal = false;
 			}
 
-			donepal = false;
+			_donePal = false;
 
-			framenumber++;
+			_frameNum++;
 
-			if ((framenumber == 1) && (continuous || (!PlayOnce)))
-				Buffer = *difffile;
+			if ((_frameNum == 1) && (_continuous || (!_playOnce)))
+				_buffer = *_diffFile;
 
-			IsAnim = (framenumber >= 3) && (!PlayOnce);
-			CurBit = 0;
+			_isAnim = (_frameNum >= 3) && (!_playOnce);
+			_curBit = 0;
 
 			if (DispBitMap->_flags & BITMAPF_VIDEO)
 				_vm->screenUpdate();
@@ -475,92 +468,92 @@ void Anim::diffNextFrame() {
 		}
 
 		_vm->_music->updateMusic();
-		header = READ_LE_UINT32(*difffile);
-		*difffile += 4;
+		_header = READ_LE_UINT32(*_diffFile);
+		*_diffFile += 4;
 
-		size = READ_LE_UINT32(*difffile);
-		*difffile += 4;
+		_size = READ_LE_UINT32(*_diffFile);
+		*_diffFile += 4;
 
-		switch (header) {
+		switch (_header) {
 		case 8L:
-			readBlock(diffcmap, size, difffile);
-			IsPal = true;
+			readBlock(_diffPalette, _size, _diffFile);
+			_isPal = true;
 			break;
 
 		case 10L:
-			RawDiffBM._planes[CurBit] = *difffile;
+			_rawDiffBM._planes[_curBit] = *_diffFile;
 
-			if (IsBM)
-				(*difffile) += size;
+			if (_isBM)
+				(*_diffFile) += _size;
 			else {
-				readBlock(DrawBitMap->_planes[CurBit], size, difffile);
+				readBlock(DrawBitMap->_planes[_curBit], _size, _diffFile);
 			}
 
-			CurBit++;
+			_curBit++;
 			break;
 
 		case 11L:
-			(*difffile) += 4;
-			runLengthDecode(DrawBitMap->_planes[CurBit], *difffile);
-			CurBit++;
-			(*difffile) += size - 4;
+			(*_diffFile) += 4;
+			runLengthDecode(DrawBitMap->_planes[_curBit], *_diffFile);
+			_curBit++;
+			(*_diffFile) += _size - 4;
 			break;
 
 		case 12L:
-			(*difffile) += 4;
-			VRunLengthDecode(DrawBitMap->_planes[CurBit], *difffile, DrawBitMap->_bytesPerRow);
-			CurBit++;
-			(*difffile) += size - 4;
+			(*_diffFile) += 4;
+			VRunLengthDecode(DrawBitMap->_planes[_curBit], *_diffFile, DrawBitMap->_bytesPerRow);
+			_curBit++;
+			(*_diffFile) += _size - 4;
 			break;
 
 		case 20L:
-			unDiff(DrawBitMap->_planes[CurBit], DispBitMap->_planes[CurBit], *difffile, DrawBitMap->_bytesPerRow, false);
-			CurBit++;
-			(*difffile) += size;
+			unDiff(DrawBitMap->_planes[_curBit], DispBitMap->_planes[_curBit], *_diffFile, DrawBitMap->_bytesPerRow, false);
+			_curBit++;
+			(*_diffFile) += _size;
 			break;
 
 		case 21L:
-			unDiff(DrawBitMap->_planes[CurBit], DispBitMap->_planes[CurBit], *difffile, DrawBitMap->_bytesPerRow, true);
-			CurBit++;
-			(*difffile) += size;
+			unDiff(DrawBitMap->_planes[_curBit], DispBitMap->_planes[_curBit], *_diffFile, DrawBitMap->_bytesPerRow, true);
+			_curBit++;
+			(*_diffFile) += _size;
 			break;
 
 		case 25L:
-			CurBit++;
+			_curBit++;
 			break;
 
 		case 26L:
-			CurBit++;
+			_curBit++;
 			break;
 
 		case 30L:
 		case 31L: {
-			if (waitForEffect) {
+			if (_waitForEffect) {
 				while (_vm->_music->isSoundEffectActive()) {
 					_vm->_music->updateMusic();
 					_vm->waitTOF();
 				}
 			}
 
-			size -= 8L;
+			_size -= 8L;
 
 
-			(*difffile) += 4;
-			samplespeed = READ_LE_UINT16(*difffile);
-			(*difffile) += 4;
+			(*_diffFile) += 4;
+			_sampleSpeed = READ_LE_UINT16(*_diffFile);
+			(*_diffFile) += 4;
 
-			byte *music = *difffile;
-			uint32 musicsize = size;
-			(*difffile) += size;
+			byte *music = *_diffFile;
+			uint32 musicsize = _size;
+			(*_diffFile) += _size;
 
-			_vm->_music->playSoundEffect(samplespeed, musicsize, music);
+			_vm->_music->playSoundEffect(_sampleSpeed, musicsize, music);
 			break;
 				  }
 		case 65535L:
-			if ((framenumber == 1) || PlayOnce || StopPlayingEnd) {
+			if ((_frameNum == 1) || _playOnce || _stopPlayingEnd) {
 				int didTOF = 0;
 
-				if (waitForEffect) {
+				if (_waitForEffect) {
 					while (_vm->_music->isSoundEffectActive()) {
 						_vm->_music->updateMusic();
 						_vm->waitTOF();
@@ -570,7 +563,7 @@ void Anim::diffNextFrame() {
 					}
 				}
 
-				IsPlaying = false;
+				_isPlaying = false;
 				_vm->_event->mouseShow();
 
 				if (!didTOF)
@@ -579,12 +572,12 @@ void Anim::diffNextFrame() {
 				return;
 			}
 
-			framenumber = 4;  /* Random frame number so it never gets back to 2 */
-			*difffile = Buffer;
+			_frameNum = 4;  /* Random frame number so it never gets back to 2 */
+			*_diffFile = _buffer;
 			break;
 
 		default:
-			(*difffile) += size;
+			(*_diffFile) += _size;
 			break;
 		}
 	}
@@ -594,92 +587,92 @@ void Anim::diffNextFrame() {
 /* A separate task launched by readDiff.  Plays the DIFF.                    */
 /*****************************************************************************/
 void Anim::playDiff() {
-	WaitSec   = 0L;
-	WaitMicros = 0L;
-	DelayMicros = 0L;
-	header      = 0;
-	CurBit = 0;
-	framenumber = 0;
-	numchunks   = 1;
-	donepal     = false;
-	StopPlayingEnd = false;
-	difffile    = &storagefordifffile;
-
-	IsPlaying   = true;
-
-	if (DoBlack) {
-		DoBlack = false;
+	_waitSec   = 0L;
+	_waitMicros = 0L;
+	_delayMicros = 0L;
+	_header      = 0;
+	_curBit = 0;
+	_frameNum = 0;
+	_numChunks   = 1;
+	_donePal     = false;
+	_stopPlayingEnd = false;
+	_diffFile    = &_storeDiffFile;
+
+	_isPlaying   = true;
+
+	if (_doBlack) {
+		_doBlack = false;
 		blackScreen();
 	}
 
-	start = *startoffile;            /* Make a copy of the pointer to the start of the file    */
-	*difffile = start;               /* Now can modify the file without modifying the original */
+	_start = *startoffile;            /* Make a copy of the pointer to the start of the file    */
+	*_diffFile = _start;               /* Now can modify the file without modifying the original */
 
-	if (start == NULL) {
-		IsPlaying = false;
+	if (_start == NULL) {
+		_isPlaying = false;
 		return;
 	}
 
-	continuous = false;
-	uint32 signature = READ_BE_UINT32(*difffile);
-	(*difffile) += 4;
+	_continuous = false;
+	uint32 signature = READ_BE_UINT32(*_diffFile);
+	(*_diffFile) += 4;
 
-	header = READ_LE_UINT32(*difffile);
-	(*difffile) += 4;
+	_header = READ_LE_UINT32(*_diffFile);
+	(*_diffFile) += 4;
 
-	if ((signature != MKTAG('D', 'I', 'F', 'F')) || (header != 1219009121L)) {
-		IsPlaying = false;
+	if ((signature != MKTAG('D', 'I', 'F', 'F')) || (_header != 1219009121L)) {
+		_isPlaying = false;
 		return;
 	}
 
-	header = READ_LE_UINT32(*difffile);
-	(*difffile) += 4;
+	_header = READ_LE_UINT32(*_diffFile);
+	(*_diffFile) += 4;
 
-	size = READ_LE_UINT32(*difffile);
-	(*difffile) += 4;
+	_size = READ_LE_UINT32(*_diffFile);
+	(*_diffFile) += 4;
 
-	if (header == 0) {
+	if (_header == 0) {
 		// sizeof(headerdata) != 18, but the padding might be at the end
-		headerdata._version = READ_LE_UINT16(*difffile);
-		(*difffile) += 2;
-		headerdata._width = READ_LE_UINT16(*difffile);
-		(*difffile) += 2;
-		headerdata._height = READ_LE_UINT16(*difffile);
-		(*difffile) += 2;
-		headerdata._depth = *difffile[0];
-		(*difffile)++;
-		headerdata._fps = *difffile[0];
-		(*difffile)++;
-		headerdata._bufferSize = READ_LE_UINT32(*difffile);
-		(*difffile) += 4;
-		headerdata._machine = READ_LE_UINT16(*difffile);
-		(*difffile) += 2;
-		headerdata._flags = READ_LE_UINT32(*difffile);
-		(*difffile) += 4;
-
-		(*difffile) += size - 18;
-
-		continuous = CONTINUOUS & headerdata._flags;
-		diffwidth = headerdata._width;
-		diffheight = headerdata._height;
-		_dataBytesPerRow = diffwidth;
-
-		numchunks = (((int32) diffwidth) * diffheight) / 0x10000;
-
-		if ((uint32)(numchunks * 0x10000) < (uint32)(((int32) diffwidth) * diffheight))
-			numchunks++;
+		_headerdata._version = READ_LE_UINT16(*_diffFile);
+		(*_diffFile) += 2;
+		_headerdata._width = READ_LE_UINT16(*_diffFile);
+		(*_diffFile) += 2;
+		_headerdata._height = READ_LE_UINT16(*_diffFile);
+		(*_diffFile) += 2;
+		_headerdata._depth = *_diffFile[0];
+		(*_diffFile)++;
+		_headerdata._fps = *_diffFile[0];
+		(*_diffFile)++;
+		_headerdata._bufferSize = READ_LE_UINT32(*_diffFile);
+		(*_diffFile) += 4;
+		_headerdata._machine = READ_LE_UINT16(*_diffFile);
+		(*_diffFile) += 2;
+		_headerdata._flags = READ_LE_UINT32(*_diffFile);
+		(*_diffFile) += 4;
+
+		(*_diffFile) += _size - 18;
+
+		_continuous = CONTINUOUS & _headerdata._flags;
+		_diffWidth = _headerdata._width;
+		_diffHeight = _headerdata._height;
+		_dataBytesPerRow = _diffWidth;
+
+		_numChunks = (((int32) _diffWidth) * _diffHeight) / 0x10000;
+
+		if ((uint32)(_numChunks * 0x10000) < (uint32)(((int32) _diffWidth) * _diffHeight))
+			_numChunks++;
 	} else {
 		return;
 	}
 
-	for (header = 0; header < 8; header++)
-		RawDiffBM._planes[header] = NULL;
+	for (_header = 0; _header < 8; _header++)
+		_rawDiffBM._planes[_header] = NULL;
 
-	if (headerdata._fps)
-		DelayMicros = ONESECOND / headerdata._fps;
+	if (_headerdata._fps)
+		_delayMicros = ONESECOND / _headerdata._fps;
 
-	if (PlayOnce) {
-		while (header != 65535)
+	if (_playOnce) {
+		while (_header != 65535)
 			diffNextFrame();
 	} else
 		diffNextFrame();
@@ -689,19 +682,17 @@ void Anim::playDiff() {
 /* Stops an animation from running.                                          */
 /*****************************************************************************/
 void Anim::stopDiff() {
-	if (IsPlaying) {
-		if (IsAnim)
-			blackScreen();
-	}
+	if (_isPlaying && _isAnim)
+		blackScreen();
 }
 
 /*****************************************************************************/
 /* Stops an animation from running.                                          */
 /*****************************************************************************/
 void Anim::stopDiffEnd() {
-	if (IsPlaying) {
-		StopPlayingEnd = true;
-		while (IsPlaying) {
+	if (_isPlaying) {
+		_stopPlayingEnd = true;
+		while (_isPlaying) {
 			g_lab->_music->updateMusic();
 			diffNextFrame();
 		}
@@ -712,14 +703,14 @@ void Anim::stopDiffEnd() {
 /* Stops the continuous sound from playing.                                  */
 /*****************************************************************************/
 void Anim::stopSound() {
-	stopsound = true;
+	_stopSound = true;
 }
 
 /*****************************************************************************/
 /* Reads in a DIFF file.                                                     */
 /*****************************************************************************/
-bool Anim::readDiff(bool playonce) {
-	PlayOnce = playonce;
+bool Anim::readDiff(bool playOnce) {
+	_playOnce = playOnce;
 	playDiff();
 	return true;
 }
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 62c7e39..3fed57d 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -63,29 +63,29 @@ class Anim {
 private:
 	LabEngine *_vm;
 
-	uint32 header;
-	uint16 CurBit;
-	uint16 numchunks;
-	uint32 WaitSec;
-	uint32 WaitMicros;
-	uint32 DelayMicros;
-	bool continuous;
-	bool IsPlaying;
-	bool IsAnim;
-	bool IsPal;
-	bool donepal;
-	uint16 framenumber;
-	bool PlayOnce;
-	byte *Buffer;
-	byte *storagefordifffile;
-	byte **difffile;
-	uint32 size;
-	bool StopPlayingEnd;
-	uint16 samplespeed;
-	byte *start;
-	uint32 diffwidth;
-	uint32 diffheight;
-	bool stopsound;
+	uint32 _header;
+	uint16 _curBit;
+	uint16 _numChunks;
+	uint32 _waitSec;
+	uint32 _waitMicros;
+	uint32 _delayMicros;
+	bool _continuous;
+	bool _isPlaying;
+	bool _isAnim;
+	bool _isPal;
+	bool _donePal;
+	uint16 _frameNum;
+	bool _playOnce;
+	byte *_buffer;
+	byte *_storeDiffFile;
+	byte **_diffFile;
+	uint32 _size;
+	bool _stopPlayingEnd;
+	uint16 _sampleSpeed;
+	byte *_start;
+	uint32 _diffWidth;
+	uint32 _diffHeight;
+	bool _stopSound;
 	uint16 _dataBytesPerRow;
 
 	void unDIFFByteByte(byte *dest, byte *diff);
@@ -97,24 +97,24 @@ private:
 public:
 	Anim(LabEngine *vm);
 
-	DIFFHeader headerdata;
-	char diffcmap[256 * 3];
-	bool IsBM;          /* Just fill in the RawDIFFBM structure */
-	bool waitForEffect; /* Wait for each sound effect to finish before continuing. */
-	bool DoBlack;       /* Black the screen before new picture  */
-	bool nopalchange;   /* Don't change the palette.            */
-	BitMap RawDiffBM;
+	DIFFHeader _headerdata;
+	char _diffPalette[256 * 3];
+	bool _isBM;          /* Just fill in the RawDIFFBM structure */
+	bool _waitForEffect; /* Wait for each sound effect to finish before continuing. */
+	bool _doBlack;       /* Black the screen before new picture  */
+	bool _noPalChange;   /* Don't change the palette.            */
+	BitMap _rawDiffBM;
 
-	void unDiff(byte *NewBuf, byte *OldBuf, byte *DiffData, uint16 bytesperrow, bool IsV);
+	void unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesperrow, bool isV);
 	bool unDIFFMemory(byte *dest,           /* Where to Un-DIFF */
-                  byte *diff,           /* The DIFFed code. */
-                  uint16 headerSize,    /* Size of header (1, 2 or 4 bytes) (only supports 1 currently */
-                  uint16 copySize);     /* Size of minimum copy or skip. (1, 2 or 4 bytes) */
+					  byte *diff,           /* The DIFFed code. */
+					  uint16 headerSize,    /* Size of header (1, 2 or 4 bytes) (only supports 1 currently */
+					  uint16 copySize);     /* Size of minimum copy or skip. (1, 2 or 4 bytes) */
 
 	bool VUnDIFFMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySize, uint16 bytesPerRow);
 	void runLengthDecode(byte *dest, byte *source);
 	void VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow);
-	bool readDiff(bool playonce);
+	bool readDiff(bool playOnce);
 	void diffNextFrame();
 	void readSound(bool waitTillFinished, Common::File *file);
 	void stopDiff();
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index e401e06..b884541 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -447,17 +447,17 @@ static const char *getInvName(uint16 CurInv) {
 
 	else if (CurInv == WESTPAPERNUM) {
 		CurFileName = Inventory[CurInv].BInvName;
-		g_lab->_anim->nopalchange = true;
+		g_lab->_anim->_noPalChange = true;
 		readPict(CurFileName, false);
-		g_lab->_anim->nopalchange = false;
+		g_lab->_anim->_noPalChange = false;
 		doWestPaper();
 	}
 
 	else if (CurInv == NOTESNUM) {
 		CurFileName = Inventory[CurInv].BInvName;
-		g_lab->_anim->nopalchange = true;
+		g_lab->_anim->_noPalChange = true;
 		readPict(CurFileName, false);
-		g_lab->_anim->nopalchange = false;
+		g_lab->_anim->_noPalChange = false;
 		doNotes();
 	}
 
@@ -531,18 +531,18 @@ bool LabEngine::doUse(uint16 CurInv) {
 			_conditions->inclElement(LAMPON);
 		}
 
-		_anim->DoBlack = false;
-		_anim->waitForEffect = true;
+		_anim->_doBlack = false;
+		_anim->_waitForEffect = true;
 		readPict("Music:Click", true);
-		_anim->waitForEffect = false;
+		_anim->_waitForEffect = false;
 
-		_anim->DoBlack = false;
+		_anim->_doBlack = false;
 		Test = getInvName(CurInv);
 	} else if (CurInv == BELTNUM) {                    /* LAB: Labyrinth specific */
 		if (!_conditions->in(BELTGLOW))
 			_conditions->inclElement(BELTGLOW);
 
-		_anim->DoBlack = false;
+		_anim->_doBlack = false;
 		Test = getInvName(CurInv);
 	} else if (CurInv == WHISKEYNUM) {                 /* LAB: Labyrinth specific */
 		_conditions->inclElement(USEDHELMET);
@@ -782,7 +782,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 	uint16 NewDir;
 
 
-	_anim->DoBlack = false;
+	_anim->_doBlack = false;
 
 	if ((msgClass == RAWKEY) && (!LongWinInFront)) {
 		if (code == 13) { /* The return key */
@@ -809,7 +809,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 					if (Alternate) {
 						eatMessages();
 						Alternate = false;
-						_anim->DoBlack = true;
+						_anim->_doBlack = true;
 						DoNotDrawMessage = false;
 
 						MainDisplay = true;
@@ -888,7 +888,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			if ((actionMode == 4) && (gadgetId == 4) && (CPtr != NULL)) {
 				doMainView(&CPtr);
 
-				_anim->DoBlack = true;
+				_anim->_doBlack = true;
 				HCPtr = NULL;
 				CPtr = NULL;
 				mayShowCrumbIndicator();
@@ -897,7 +897,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				eatMessages();
 
 				Alternate = true;
-				_anim->DoBlack = true;
+				_anim->_doBlack = true;
 				DoNotDrawMessage = false;
 				interfaceOn(); /* Sets the correct gadget list */
 
@@ -958,7 +958,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				NewDir = Direction;
 				processArrow(&NewDir, gadgetId - 6);
 				doTurn(Direction, NewDir, &CPtr);
-				_anim->DoBlack = true;
+				_anim->_doBlack = true;
 				Direction = NewDir;
 				forceDraw = true;
 
@@ -969,9 +969,9 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 				if (doGoForward(&CPtr)) {
 					if (OldRoomNum == _roomNum)
-						_anim->DoBlack = true;
+						_anim->_doBlack = true;
 				} else {
-					_anim->DoBlack = true;
+					_anim->_doBlack = true;
 					processArrow(&Direction, gadgetId - 6);
 
 					if (OldRoomNum != _roomNum) {
@@ -980,7 +980,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 						CurFileName = " ";
 						forceDraw = true;
 					} else {
-						_anim->DoBlack = true;
+						_anim->_doBlack = true;
 						drawStaticMessage(kTextNoPath);
 					}
 				}
@@ -1031,12 +1031,12 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			}
 		}
 	} else if ((msgClass == GADGETUP) && Alternate) {
-		_anim->DoBlack = true;
+		_anim->_doBlack = true;
 
 		if (gadgetId == 0) {
 			eatMessages();
 			Alternate = false;
-			_anim->DoBlack = true;
+			_anim->_doBlack = true;
 			DoNotDrawMessage = false;
 
 			MainDisplay = true;
@@ -1135,7 +1135,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 					eatMessages();
 					Alternate = false;
-					_anim->DoBlack = true;
+					_anim->_doBlack = true;
 					DoNotDrawMessage = false;
 
 					MainDisplay = true;
@@ -1203,7 +1203,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 						drawStaticMessage(kTextNothing);
 				} else if (TempCPtr->GraphicName) {
 					if (*(TempCPtr->GraphicName)) {
-						_anim->DoBlack = true;
+						_anim->_doBlack = true;
 						CPtr = TempCPtr;
 					} else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
 						drawStaticMessage(kTextNothing);
@@ -1254,7 +1254,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 	} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) {
 		eatMessages();
 		Alternate = !Alternate;
-		_anim->DoBlack = true;
+		_anim->_doBlack = true;
 		DoNotDrawMessage = false;
 		MainDisplay = true;
 		interfaceOn(); /* Sets the correct gadget list */
@@ -1308,7 +1308,7 @@ void LabEngine::go() {
 		Intro intro;
 		intro.introSequence();
 	} else
-		_anim->DoBlack = true;
+		_anim->_doBlack = true;
 
 	if (mem) {
 		_event->mouseShow();
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 16283ea..54a4f35 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -85,7 +85,7 @@ bool readMusic(const char *filename, bool waitTillFinished) {
 	if (!file)
 		return false;
 
-	g_lab->_anim->DoBlack = false;
+	g_lab->_anim->_doBlack = false;
 	g_lab->_anim->readSound(waitTillFinished, file);
 
 	return true;
@@ -474,23 +474,23 @@ void LabEngine::doScrollWipe(char *filename) {
 		waitTOF();
 	}
 
-	_anim->IsBM = true;
+	_anim->_isBM = true;
 	readPict(filename, true);
-	setPalette(_anim->diffcmap, 256);
-	_anim->IsBM = false;
-	byte *mem = _anim->RawDiffBM._planes[0];
+	setPalette(_anim->_diffPalette, 256);
+	_anim->_isBM = false;
+	byte *mem = _anim->_rawDiffBM._planes[0];
 
 	_music->updateMusic();
 	uint16 by = VGAScaleX(3);
 	uint16 nheight = height;
 
-	while (onrow < _anim->headerdata._height) {
+	while (onrow < _anim->_headerdata._height) {
 		_music->updateMusic();
 
 		if ((by > nheight) && nheight)
 			by = nheight;
 
-		if ((startline + by) > (_anim->headerdata._height - height - 1))
+		if ((startline + by) > (_anim->_headerdata._height - height - 1))
 			break;
 
 		if (nheight)
@@ -536,10 +536,10 @@ void LabEngine::doScrollBounce() {
 	_event->mouseHide();
 	int width = VGAScaleX(320);
 	int height = VGAScaleY(149) + SVGACord(2);
-	byte *mem = _anim->RawDiffBM._planes[0];
+	byte *mem = _anim->_rawDiffBM._planes[0];
 
 	_music->updateMusic();
-	int startline = _anim->headerdata._height - height - 1;
+	int startline = _anim->_headerdata._height - height - 1;
 
 	for (int i = 0; i < 5; i++) {
 		_music->updateMusic();
@@ -620,7 +620,7 @@ void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 		CurFileName = getPictName(cPtr);
 
 	byte *BitMapMem = readPictToMem(CurFileName, _screenWidth, lastY + 5);
-	setPalette(_anim->diffcmap, 256);
+	setPalette(_anim->_diffPalette, 256);
 
 	if (BitMapMem) {
 		imSource.Width = _screenWidth;
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index a35984e..adc4fd2 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -237,7 +237,7 @@ void Intro::nReadPict(const char *filename, bool playOnce) {
 	if (_quitIntro)
 		return;
 
-	g_lab->_anim->DoBlack = _introDoBlack;
+	g_lab->_anim->_doBlack = _introDoBlack;
 	g_lab->_anim->stopDiffEnd();
 	readPict(finalFileName.c_str(), playOnce);
 }
@@ -254,7 +254,7 @@ void Intro::introSequence() {
 		0x0CB3, 0x0DC4, 0x0DD6, 0x0EE7
 	};
 
-	g_lab->_anim->DoBlack = true;
+	g_lab->_anim->_doBlack = true;
 
 	if (g_lab->getPlatform() != Common::kPlatformWindows) {
 		nReadPict("EA0", true);
@@ -276,12 +276,12 @@ void Intro::introSequence() {
 
 	g_lab->_music->initMusic();
 
-	g_lab->_anim->nopalchange = true;
+	g_lab->_anim->_noPalChange = true;
 	if (g_lab->getPlatform() != Common::kPlatformWindows)
 		nReadPict("TNDcycle.pic", true);
 	else
 		nReadPict("TNDcycle2.pic", true);
-	g_lab->_anim->nopalchange = false;
+	g_lab->_anim->_noPalChange = false;
 
 	FadePalette = palette;
 
@@ -289,9 +289,9 @@ void Intro::introSequence() {
 		if (_quitIntro)
 			break;
 
-		palette[i] = ((g_lab->_anim->diffcmap[i * 3] >> 2) << 8) +
-		             ((g_lab->_anim->diffcmap[i * 3 + 1] >> 2) << 4) +
-		              (g_lab->_anim->diffcmap[i * 3 + 2] >> 2);
+		palette[i] = ((g_lab->_anim->_diffPalette[i * 3] >> 2) << 8) +
+		             ((g_lab->_anim->_diffPalette[i * 3 + 1] >> 2) << 4) +
+		              (g_lab->_anim->_diffPalette[i * 3 + 2] >> 2);
 	}
 
 	g_lab->_music->updateMusic();
@@ -346,14 +346,14 @@ void Intro::introSequence() {
 
 	TextFont *msgFont = g_lab->_resource->getFont("P:Map.fon");
 
-	g_lab->_anim->nopalchange = true;
+	g_lab->_anim->_noPalChange = true;
 	nReadPict("Intro.1", true);
-	g_lab->_anim->nopalchange = false;
+	g_lab->_anim->_noPalChange = false;
 
 	for (uint16 i = 0; i < 16; i++) {
-		palette[i] = ((g_lab->_anim->diffcmap[i * 3] >> 2) << 8) +
-		             ((g_lab->_anim->diffcmap[i * 3 + 1] >> 2) << 4) +
-		              (g_lab->_anim->diffcmap[i * 3 + 2] >> 2);
+		palette[i] = ((g_lab->_anim->_diffPalette[i * 3] >> 2) << 8) +
+		             ((g_lab->_anim->_diffPalette[i * 3 + 1] >> 2) << 4) +
+		              (g_lab->_anim->_diffPalette[i * 3 + 2] >> 2);
 	}
 
 	doPictText("i.1", msgFont, true);
@@ -393,11 +393,11 @@ void Intro::introSequence() {
 	if (!_quitIntro)
 		for (uint16 i = 0; i < 50; i++) {
 			for (uint16 idx = (8 * 3); idx < (255 * 3); idx++)
-				g_lab->_anim->diffcmap[idx] = 255 - g_lab->_anim->diffcmap[idx];
+				g_lab->_anim->_diffPalette[idx] = 255 - g_lab->_anim->_diffPalette[idx];
 
 			g_lab->_music->updateMusic();
 			g_lab->waitTOF();
-			g_lab->setPalette(g_lab->_anim->diffcmap, 256);
+			g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
 			g_lab->waitTOF();
 			g_lab->waitTOF();
 		}
@@ -458,7 +458,7 @@ void Intro::introSequence() {
 	if (_quitIntro) {
 		g_lab->setAPen(0);
 		g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
-		g_lab->_anim->DoBlack = true;
+		g_lab->_anim->_doBlack = true;
 	}
 
 	closeFont(msgFont);
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 5807227..0145c83 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -378,7 +378,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 
 		case NOUPDATE:
 			noupdatediff = true;
-			g_lab->_anim->DoBlack = false;
+			g_lab->_anim->_doBlack = false;
 			break;
 
 		case FORCEUPDATE:
@@ -444,7 +444,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 			g_lab->_roomNum   = APtr->Param1;
 			Direction = APtr->Param2 - 1;
 			*LCPtr      = NULL;
-			g_lab->_anim->DoBlack = true;
+			g_lab->_anim->_doBlack = true;
 			break;
 
 		case SETCLOSEUP:
@@ -554,17 +554,17 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 
 		case SPECIALCMD:
 			if (APtr->Param1 == 0)
-				g_lab->_anim->DoBlack = true;
+				g_lab->_anim->_doBlack = true;
 			else if (APtr->Param1 == 1)
-				g_lab->_anim->DoBlack = (CPtr == NULL);
+				g_lab->_anim->_doBlack = (CPtr == NULL);
 			else if (APtr->Param1 == 2)
-				g_lab->_anim->DoBlack = (CPtr != NULL);
+				g_lab->_anim->_doBlack = (CPtr != NULL);
 			else if (APtr->Param1 == 5) { /* inverse the palette */
 				for (uint16 idx = (8 * 3); idx < (255 * 3); idx++)
-					g_lab->_anim->diffcmap[idx] = 255 - g_lab->_anim->diffcmap[idx];
+					g_lab->_anim->_diffPalette[idx] = 255 - g_lab->_anim->_diffPalette[idx];
 
 				g_lab->waitTOF();
-				g_lab->setPalette(g_lab->_anim->diffcmap, 256);
+				g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
 				g_lab->waitTOF();
 				g_lab->waitTOF();
 			} else if (APtr->Param1 == 4) { /* white the palette */
@@ -573,7 +573,7 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 				g_lab->waitTOF();
 			} else if (APtr->Param1 == 6) { /* Restore the palette */
 				g_lab->waitTOF();
-				g_lab->setPalette(g_lab->_anim->diffcmap, 256);
+				g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
 				g_lab->waitTOF();
 				g_lab->waitTOF();
 			} else if (APtr->Param1 == 7) { /* Quick pause */
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 6f70cb0..2744d3d 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -110,7 +110,7 @@ static byte *loadBackPict(const char *fileName, bool tomem) {
 	byte *res = NULL;
 
 	FadePalette = hipal;
-	g_lab->_anim->nopalchange = true;
+	g_lab->_anim->_noPalChange = true;
 
 	if (tomem)
 		res = readPictToMem(fileName, g_lab->_screenWidth, g_lab->_screenHeight);
@@ -118,12 +118,12 @@ static byte *loadBackPict(const char *fileName, bool tomem) {
 		readPict(fileName, true);
 
 	for (uint16 i = 0; i < 16; i++) {
-		hipal[i] = ((g_lab->_anim->diffcmap[i * 3] >> 2) << 8) +
-		           ((g_lab->_anim->diffcmap[i * 3 + 1] >> 2) << 4) +
-		           ((g_lab->_anim->diffcmap[i * 3 + 2] >> 2));
+		hipal[i] = ((g_lab->_anim->_diffPalette[i * 3] >> 2) << 8) +
+		           ((g_lab->_anim->_diffPalette[i * 3 + 1] >> 2) << 4) +
+		           ((g_lab->_anim->_diffPalette[i * 3 + 2] >> 2));
 	}
 
-	g_lab->_anim->nopalchange = false;
+	g_lab->_anim->_noPalChange = false;
 
 	return res;
 }
@@ -143,10 +143,10 @@ void showCombination(const char *filename) {
 	byte **buffer;
 
 	resetBuffer();
-	g_lab->_anim->DoBlack = true;
-	g_lab->_anim->nopalchange = true;
+	g_lab->_anim->_doBlack = true;
+	g_lab->_anim->_noPalChange = true;
 	readPict(filename, true);
-	g_lab->_anim->nopalchange = false;
+	g_lab->_anim->_noPalChange = false;
 
 	blackScreen();
 
@@ -159,7 +159,7 @@ void showCombination(const char *filename) {
 
 	doCombination();
 
-	g_lab->setPalette(g_lab->_anim->diffcmap, 256);
+	g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
 }
 
 
@@ -286,10 +286,10 @@ void showTile(const char *filename, bool showsolution) {
 	byte **buffer;
 
 	resetBuffer();
-	g_lab->_anim->DoBlack = true;
-	g_lab->_anim->nopalchange = true;
+	g_lab->_anim->_doBlack = true;
+	g_lab->_anim->_noPalChange = true;
 	readPict(filename, true);
-	g_lab->_anim->nopalchange = false;
+	g_lab->_anim->_noPalChange = false;
 	blackScreen();
 
 	if (showsolution) {
@@ -310,7 +310,7 @@ void showTile(const char *filename, bool showsolution) {
 
 	doTile(showsolution);
 
-	g_lab->setPalette(g_lab->_anim->diffcmap, 256);
+	g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
 }
 
 static void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
@@ -424,7 +424,7 @@ static void changeTile(uint16 col, uint16 row) {
 
 		if (check) {
 			g_lab->_conditions->inclElement(BRICKOPEN);  /* unlocked combination */
-			g_lab->_anim->DoBlack = true;
+			g_lab->_anim->_doBlack = true;
 			check = readPict("p:Up/BDOpen", true);
 		}
 	}
@@ -457,7 +457,7 @@ void doNotes() {
 	char *ntext = g_lab->_resource->getText("Lab:Rooms/Notes");
 
 	flowText(noteFont, -2 + SVGACord(1), 0, 0, false, false, true, true, VGAScaleX(25) + SVGACord(15), VGAScaleY(50), VGAScaleX(295) - SVGACord(15), VGAScaleY(148), ntext);
-	g_lab->setPalette(g_lab->_anim->diffcmap, 256);
+	g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
 
 	closeFont(noteFont);
 	delete[] ntext;
@@ -501,7 +501,7 @@ void doWestPaper() {
 	delete[] ntext;
 	closeFont(paperFont);
 
-	g_lab->setPalette(g_lab->_anim->diffcmap, 256);
+	g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
 	freeAllStolenMem();
 }
 
@@ -673,14 +673,14 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 	if (needFade)
 		fade(true, 0);
 
-	g_lab->_anim->nopalchange = true;
+	g_lab->_anim->_noPalChange = true;
 	JBackImage.ImageData = readPictToMem("P:Journal.pic", _screenWidth, _screenHeight);
 	GotBackImage = true;
 
 	eatMessages();
 	_event->mouseShow();
 
-	g_lab->_anim->nopalchange = false;
+	g_lab->_anim->_noPalChange = false;
 }
 
 /*****************************************************************************/


Commit: 53d92be11f8ffb65f73d81874df9340f9f99a215
    https://github.com/scummvm/scummvm/commit/53d92be11f8ffb65f73d81874df9340f9f99a215
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:46+01:00

Commit Message:
LAB: remove the use of g_lab in Anim

Changed paths:
    engines/lab/anim.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 908c4e4..f4cae84 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -419,7 +419,7 @@ void Anim::diffNextFrame() {
 		return;
 
 	if (DispBitMap->_flags & BITMAPF_VIDEO) {
-		DispBitMap->_planes[0] = g_lab->getCurrentDrawingBuffer();
+		DispBitMap->_planes[0] = _vm->getCurrentDrawingBuffer();
 		DispBitMap->_planes[1] = DispBitMap->_planes[0] + 0x10000;
 		DispBitMap->_planes[2] = DispBitMap->_planes[1] + 0x10000;
 		DispBitMap->_planes[3] = DispBitMap->_planes[2] + 0x10000;
@@ -693,7 +693,7 @@ void Anim::stopDiffEnd() {
 	if (_isPlaying) {
 		_stopPlayingEnd = true;
 		while (_isPlaying) {
-			g_lab->_music->updateMusic();
+			_vm->_music->updateMusic();
 			diffNextFrame();
 		}
 	}
@@ -729,15 +729,15 @@ void Anim::readSound(bool waitTillFinished, Common::File *file) {
 		return;
 
 	while (soundTag != 65535) {
-		g_lab->_music->updateMusic();
+		_vm->_music->updateMusic();
 		soundTag = file->readUint32LE();
 		soundSize = file->readUint32LE() - 8;
 
 		if ((soundTag == 30) || (soundTag == 31)) {
 			if (waitTillFinished) {
-				while (g_lab->_music->isSoundEffectActive()) {
-					g_lab->_music->updateMusic();
-					g_lab->waitTOF();
+				while (_vm->_music->isSoundEffectActive()) {
+					_vm->_music->updateMusic();
+					_vm->waitTOF();
 				}
 			}
 
@@ -747,12 +747,12 @@ void Anim::readSound(bool waitTillFinished, Common::File *file) {
 			file->skip(2);
 			byte *soundData = (byte *)malloc(soundSize);
 			file->read(soundData, soundSize);
-			g_lab->_music->playSoundEffect(sampleRate, soundSize, soundData);
+			_vm->_music->playSoundEffect(sampleRate, soundSize, soundData);
 		} else if (soundTag == 65535L) {
 			if (waitTillFinished) {
-				while (g_lab->_music->isSoundEffectActive()) {
-					g_lab->_music->updateMusic();
-					g_lab->waitTOF();
+				while (_vm->_music->isSoundEffectActive()) {
+					_vm->_music->updateMusic();
+					_vm->waitTOF();
 				}
 			}
 		} else


Commit: 66bf8885585975ae860c8c3d175b960b6a7e9590
    https://github.com/scummvm/scummvm/commit/66bf8885585975ae860c8c3d175b960b6a7e9590
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:46+01:00

Commit Message:
LAB: Rework and renaming in the Event class

Changed paths:
    engines/lab/interface.cpp
    engines/lab/mouse.cpp
    engines/lab/mouse.h



diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index fc7ba1e..21b5764 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -164,7 +164,6 @@ static bool keyPress(uint16 *KeyCode) {
 }
 
 IntuiMessage IMessage;
-extern Gadget *ScreenGadgetList;
 
 IntuiMessage *LabEngine::getMsg() {
 	Gadget *curgad;
@@ -190,7 +189,7 @@ IntuiMessage *LabEngine::getMsg() {
 		IMessage.msgClass = MOUSEBUTTONS;
 		return &IMessage;
 	} else if (keyPress(&IMessage.code)) { /* Keyboard key */
-		curgad = checkNumGadgetHit(ScreenGadgetList, IMessage.code);
+		curgad = checkNumGadgetHit(_event->_screenGadgetList, IMessage.code);
 
 		if (curgad) {
 			IMessage.msgClass = GADGETUP;
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index 4bd6c7f..879bd08 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -35,13 +35,6 @@
 
 namespace Lab {
 
-static bool LeftClick = false;
-static bool RightClick = false;
-
-static bool MouseHidden = true;
-static int32 NumHidden   = 1;
-static Gadget *LastGadgetHit = NULL;
-Gadget *ScreenGadgetList = NULL;
 static byte MouseData[] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
 						   1, 7, 1, 0, 0, 0, 0, 0, 0, 0,
 						   1, 7, 7, 1, 0, 0, 0, 0, 0, 0,
@@ -67,30 +60,30 @@ static Gadget *hitgad = NULL;
 /* Checks whether or not the cords fall within one of the gadgets in a list  */
 /* of gadgets.                                                               */
 /*****************************************************************************/
-Gadget *EventManager::checkGadgetHit(Gadget *gadlist, Common::Point pos) {
-	while (gadlist != NULL) {
-		if ((pos.x >= gadlist->x) && (pos.y >= gadlist->y) &&
-		    (pos.x <= (gadlist->x + gadlist->Im->Width)) &&
-		    (pos.y <= (gadlist->y + gadlist->Im->Height)) &&
-		     !(GADGETOFF & gadlist->GadgetFlags)) {
+Gadget *EventManager::checkGadgetHit(Gadget *gadgetList, Common::Point pos) {
+	while (gadgetList != NULL) {
+		if ((pos.x >= gadgetList->x) && (pos.y >= gadgetList->y) &&
+		    (pos.x <= (gadgetList->x + gadgetList->Im->Width)) &&
+		    (pos.y <= (gadgetList->y + gadgetList->Im->Height)) &&
+		     !(GADGETOFF & gadgetList->GadgetFlags)) {
 			if (_vm->_isHiRes) {
-				hitgad = gadlist;
+				hitgad = gadgetList;
 			} else {
 				mouseHide();
-				gadlist->ImAlt->drawImage(gadlist->x, gadlist->y);
+				gadgetList->ImAlt->drawImage(gadgetList->x, gadgetList->y);
 				mouseShow();
 
 				for (uint16 i = 0; i < 3; i++)
 					_vm->waitTOF();
 
 				mouseHide();
-				gadlist->Im->drawImage(gadlist->x, gadlist->y);
+				gadgetList->Im->drawImage(gadgetList->x, gadgetList->y);
 				mouseShow();
 			}
 
-			return gadlist;
+			return gadgetList;
 		} else {
-			gadlist = gadlist->NextGadget;
+			gadgetList = gadgetList->NextGadget;
 		}
 	}
 
@@ -99,39 +92,46 @@ Gadget *EventManager::checkGadgetHit(Gadget *gadlist, Common::Point pos) {
 
 
 
-void EventManager::attachGadgetList(Gadget *GadList) {
-	if (ScreenGadgetList != GadList)
-		LastGadgetHit = NULL;
+void EventManager::attachGadgetList(Gadget *gadgetList) {
+	if (_screenGadgetList != gadgetList)
+		_lastGadgetHit = nullptr;
 
-	ScreenGadgetList = GadList;
+	_screenGadgetList = gadgetList;
 }
 
 EventManager::EventManager(LabEngine *vm) : _vm(vm) {
+	_leftClick = false;
+	_rightClick = false;
+
+	_mouseHidden = true;
+	_numHidden   = 1;
+	_lastGadgetHit = nullptr;
+	_screenGadgetList = nullptr;
 }
 
 void EventManager::mouseHandler(int flag, Common::Point pos) {
-	if (NumHidden >= 2)
+	if (_numHidden >= 2)
 		return;
 
 	if (flag & 0x02) { /* Left mouse button click */
 		Gadget *tmp = NULL;
-		if (ScreenGadgetList)
-			tmp = checkGadgetHit(ScreenGadgetList, _vm->_isHiRes ? pos : Common::Point(pos.x / 2, pos.y));
+		if (_screenGadgetList)
+			tmp = checkGadgetHit(_screenGadgetList, _vm->_isHiRes ? pos : Common::Point(pos.x / 2, pos.y));
 
 		if (tmp)
-			LastGadgetHit = tmp;
+			_lastGadgetHit = tmp;
 		else
-			LeftClick = true;
+			_leftClick = true;
 	}
 
 	if (flag & 0x08) /* Right mouse button click */
-		RightClick = true;
+		_rightClick = true;
 }
 
 void EventManager::updateMouse() {
 	bool doUpdateDisplay = false;
 
-	if (!MouseHidden)
+	if (!_mouseHidden)
 		doUpdateDisplay = true;
 
 	if (hitgad) {
@@ -169,12 +169,12 @@ void EventManager::initMouse() {
 /* Shows the mouse.                                                          */
 /*****************************************************************************/
 void EventManager::mouseShow() {
-	if (NumHidden)
-		NumHidden--;
+	if (_numHidden)
+		_numHidden--;
 
-	if ((NumHidden == 0) && MouseHidden) {
+	if ((_numHidden == 0) && _mouseHidden) {
 		_vm->processInput();
-		MouseHidden = false;
+		_mouseHidden = false;
 	}
 
 	g_system->showMouse(true);
@@ -184,10 +184,10 @@ void EventManager::mouseShow() {
 /* Hides the mouse.                                                          */
 /*****************************************************************************/
 void EventManager::mouseHide() {
-	NumHidden++;
+	_numHidden++;
 
-	if (NumHidden && !MouseHidden) {
-		MouseHidden = true;
+	if (_numHidden && !_mouseHidden) {
+		_mouseHidden = true;
 
 		g_system->showMouse(false);
 	}
@@ -214,7 +214,7 @@ void EventManager::setMousePos(Common::Point pos) {
 	else
 		g_system->warpMouse(pos.x * 2, pos.y);
 
-	if (!MouseHidden)
+	if (!_mouseHidden)
 		_vm->processInput();
 }
 
@@ -226,17 +226,17 @@ void EventManager::setMousePos(Common::Point pos) {
 /*****************************************************************************/
 bool EventManager::mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
 	if (leftbutton) {
-		if (LeftClick) {
+		if (_leftClick) {
 			*x = (!_vm->_isHiRes) ? (uint16)_vm->_mousePos.x / 2 : (uint16)_vm->_mousePos.x;
 			*y = (uint16)_vm->_mousePos.y;
-			LeftClick = false;
+			_leftClick = false;
 			return true;
 		}
 	} else {
-		if (RightClick) {
+		if (_rightClick) {
 			*x = (!_vm->_isHiRes) ? (uint16)_vm->_mousePos.x / 2 : (uint16)_vm->_mousePos.x;
 			*y = (uint16)_vm->_mousePos.y;
-			RightClick = false;
+			_rightClick = false;
 			return true;
 		}
 	}
@@ -245,10 +245,10 @@ bool EventManager::mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
 }
 
 Gadget *EventManager::mouseGadget() {
-	Gadget *Temp = LastGadgetHit;
+	Gadget *temp = _lastGadgetHit;
 
-	LastGadgetHit = nullptr;
-	return Temp;
+	_lastGadgetHit = nullptr;
+	return temp;
 }
 
 } // End of namespace Lab
diff --git a/engines/lab/mouse.h b/engines/lab/mouse.h
index 4bccb17..0ff7d60 100644
--- a/engines/lab/mouse.h
+++ b/engines/lab/mouse.h
@@ -42,20 +42,28 @@ class LabEngine;
 class EventManager {
 private:
 	LabEngine *_vm;
+	bool _leftClick;
+	bool _rightClick;
+
+	bool _mouseHidden;
+	int32 _numHidden;
+	Gadget *_lastGadgetHit;
 
 public:
 	EventManager (LabEngine *vm);
 
-	Gadget *checkGadgetHit(Gadget *gadlist, Common::Point pos);
+	Gadget *_screenGadgetList;
+
+	Gadget *checkGadgetHit(Gadget *gadgetList, Common::Point pos);
 	void initMouse();
 	void updateMouse();
 	void mouseShow();
 	void mouseHide();
 	Common::Point getMousePos();
 	void setMousePos(Common::Point pos);
-	bool mouseButton(uint16 *x, uint16 *y, bool leftbutton);
+	bool mouseButton(uint16 *x, uint16 *y, bool leftButton);
 	Gadget *mouseGadget();
-	void attachGadgetList(Gadget *GadList);
+	void attachGadgetList(Gadget *gadgetList);
 	void mouseHandler(int flag, Common::Point pos);
 };
 


Commit: 6b24481358464510b5310f8c32cd3bc617286b17
    https://github.com/scummvm/scummvm/commit/6b24481358464510b5310f8c32cd3bc617286b17
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:46+01:00

Commit Message:
LAB: Move functions related to keyboard events to Event

Changed paths:
    engines/lab/engine.cpp
    engines/lab/interface.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/mouse.cpp
    engines/lab/mouse.h
    engines/lab/music.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index b884541..70ab45d 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -640,7 +640,7 @@ void LabEngine::mainGameLoop() {
 	/* Set up initial picture. */
 
 	while (1) {
-		processInput(true);
+		_event->processInput(true);
 
 		if (GotMessage) {
 			if (QuitLab || g_engine->shouldQuit()) {
@@ -729,7 +729,7 @@ void LabEngine::mainGameLoop() {
 					GotMessage = true;
 					mayShowCrumbIndicator();
 					screenUpdate();
-					if (!from_crumbs(GADGETUP, code, 0, getMousePos(), curInv, curMsg, forceDraw, code, actionMode))
+					if (!from_crumbs(GADGETUP, code, 0, _event->updateAndGetMousePos(), curInv, curMsg, forceDraw, code, actionMode))
 						break;
 				}
 			}
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 21b5764..dff74be 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -149,20 +149,6 @@ Gadget *LabEngine::checkNumGadgetHit(Gadget *gadlist, uint16 key) {
 	return NULL;
 }
 
-
-
-/*****************************************************************************/
-/* Checks whether or not a key has been pressed.                             */
-/*****************************************************************************/
-static bool keyPress(uint16 *KeyCode) {
-	if (g_lab->haveNextChar()) {
-        *KeyCode = g_lab->getNextChar();
-		return true;
-	}
-
-	return false;
-}
-
 IntuiMessage IMessage;
 
 IntuiMessage *LabEngine::getMsg() {
@@ -188,7 +174,7 @@ IntuiMessage *LabEngine::getMsg() {
 		IMessage.qualifier = IEQUALIFIER_RBUTTON | Qualifiers;
 		IMessage.msgClass = MOUSEBUTTONS;
 		return &IMessage;
-	} else if (keyPress(&IMessage.code)) { /* Keyboard key */
+	} else if (_event->keyPress(&IMessage.code)) { /* Keyboard key */
 		curgad = checkNumGadgetHit(_event->_screenGadgetList, IMessage.code);
 
 		if (curgad) {
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index a6fe4cf..22ab503 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -66,12 +66,6 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 
     _lastWaitTOFTicks = 0;
 
-	_mousePos = Common::Point(0, 0);
-	_mouseAtEdge = false;
-
-    _nextKeyIn = 0;
-    _nextKeyOut = 0;
-
 	_isHiRes = false;
 	_roomNum = -1;
 	for (int i = 0; i < MAX_CRUMBS; i++) {
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index b7cf6e1..348ce11 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -102,7 +102,6 @@ public:
 
 	int _roomNum;
 	byte *_currentDisplayBuffer;
-	Common::Point _mousePos;
 
 	CrumbData _breadCrumbs[MAX_CRUMBS];
 	uint16 _numCrumbs;
@@ -114,17 +113,10 @@ public:
 	bool _isCrumbWaiting;
 	byte *_tempScrollData;
 	bool _isHiRes;
-
-private:
 	byte *_displayBuffer;
 
+private:
 	int _lastWaitTOFTicks;
-
-	uint16 _nextKeyIn;
-	uint16 _keyBuf[64];
-	uint16 _nextKeyOut;
-	bool _mouseAtEdge;
-
 	bool _lastMessageLong;
 	bool _lastTooLong;
 
@@ -146,9 +138,6 @@ public:
 	void setPalette(void *cmap, uint16 numcolors);
 	void drawHLine(uint16 x, uint16 y1, uint16 y2);
 	void drawVLine(uint16 x1, uint16 y, uint16 x2);
-	bool haveNextChar();
-	uint16 getNextChar();
-	void processInput(bool can_delay = false);
 	void writeColorReg(byte *buf, uint16 regnum);
 	void writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg);
 
@@ -180,13 +169,13 @@ public:
 	void drawDirection(CloseDataPtr LCPtr);
 	int followCrumbs();
 
+	void changeVolume(int delta);
+
 private:
 	void quickWaitTOF();
 
 	/*---------- Drawing Routines ----------*/
 
-	Common::Point getMousePos();
-	void changeVolume(int delta);
 	void applyPalette(byte *buf, uint16 first, uint16 numreg, uint16 slow);
 
 	// engine.cpp
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index 879bd08..38b8935 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -54,8 +54,6 @@ static byte MouseData[] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
 #define MOUSE_WIDTH 10
 #define MOUSE_HEIGHT 15
 
-static Gadget *hitgad = NULL;
-
 /*****************************************************************************/
 /* Checks whether or not the cords fall within one of the gadgets in a list  */
 /* of gadgets.                                                               */
@@ -67,7 +65,7 @@ Gadget *EventManager::checkGadgetHit(Gadget *gadgetList, Common::Point pos) {
 		    (pos.y <= (gadgetList->y + gadgetList->Im->Height)) &&
 		     !(GADGETOFF & gadgetList->GadgetFlags)) {
 			if (_vm->_isHiRes) {
-				hitgad = gadgetList;
+				_hitGadget = gadgetList;
 			} else {
 				mouseHide();
 				gadgetList->ImAlt->drawImage(gadgetList->x, gadgetList->y);
@@ -107,6 +105,15 @@ EventManager::EventManager(LabEngine *vm) : _vm(vm) {
 	_numHidden   = 1;
 	_lastGadgetHit = nullptr;
 	_screenGadgetList = nullptr;
+	_hitGadget = nullptr;
+	_nextKeyIn = 0;
+	_nextKeyOut = 0;
+	_mousePos = Common::Point(0, 0);
+	_mouseAtEdge = false;
+
+	for (int i = 0; i < 64; i++)
+		_keyBuf[i] = 0;
+
 }
 
 void EventManager::mouseHandler(int flag, Common::Point pos) {
@@ -134,19 +141,19 @@ void EventManager::updateMouse() {
 	if (!_mouseHidden)
 		doUpdateDisplay = true;
 
-	if (hitgad) {
+	if (_hitGadget) {
 		mouseHide();
-		hitgad->ImAlt->drawImage(hitgad->x, hitgad->y);
+		_hitGadget->ImAlt->drawImage(_hitGadget->x, _hitGadget->y);
 		mouseShow();
 
 		for (uint16 i = 0; i < 3; i++)
 			_vm->waitTOF();
 
 		mouseHide();
-		hitgad->Im->drawImage(hitgad->x, hitgad->y);
+		_hitGadget->Im->drawImage(_hitGadget->x, _hitGadget->y);
 		mouseShow();
 		doUpdateDisplay = true;
-		hitgad = NULL;
+		_hitGadget = nullptr;
 	}
 
 	if (doUpdateDisplay)
@@ -173,7 +180,7 @@ void EventManager::mouseShow() {
 		_numHidden--;
 
 	if ((_numHidden == 0) && _mouseHidden) {
-		_vm->processInput();
+		processInput();
 		_mouseHidden = false;
 	}
 
@@ -199,9 +206,9 @@ void EventManager::mouseHide() {
 /*****************************************************************************/
 Common::Point EventManager::getMousePos() {
 	if (_vm->_isHiRes)
-		return _vm->_mousePos;
+		return _mousePos;
 	else
-		return Common::Point(_vm->_mousePos.x / 2, _vm->_mousePos.y);
+		return Common::Point(_mousePos.x / 2, _mousePos.y);
 }
 
 
@@ -215,7 +222,7 @@ void EventManager::setMousePos(Common::Point pos) {
 		g_system->warpMouse(pos.x * 2, pos.y);
 
 	if (!_mouseHidden)
-		_vm->processInput();
+		processInput();
 }
 
 
@@ -227,15 +234,15 @@ void EventManager::setMousePos(Common::Point pos) {
 bool EventManager::mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
 	if (leftbutton) {
 		if (_leftClick) {
-			*x = (!_vm->_isHiRes) ? (uint16)_vm->_mousePos.x / 2 : (uint16)_vm->_mousePos.x;
-			*y = (uint16)_vm->_mousePos.y;
+			*x = (!_vm->_isHiRes) ? (uint16)_mousePos.x / 2 : (uint16)_mousePos.x;
+			*y = (uint16)_mousePos.y;
 			_leftClick = false;
 			return true;
 		}
 	} else {
 		if (_rightClick) {
-			*x = (!_vm->_isHiRes) ? (uint16)_vm->_mousePos.x / 2 : (uint16)_vm->_mousePos.x;
-			*y = (uint16)_vm->_mousePos.y;
+			*x = (!_vm->_isHiRes) ? (uint16)_mousePos.x / 2 : (uint16)_mousePos.x;
+			*y = (uint16)_mousePos.y;
 			_rightClick = false;
 			return true;
 		}
@@ -251,4 +258,124 @@ Gadget *EventManager::mouseGadget() {
 	return temp;
 }
 
+/*****************************************************************************/
+/* Checks whether or not a key has been pressed.                             */
+/*****************************************************************************/
+bool EventManager::keyPress(uint16 *keyCode) {
+	if (haveNextChar()) {
+		*keyCode = getNextChar();
+		return true;
+	}
+
+	return false;
+}
+
+bool EventManager::haveNextChar() {
+	processInput();
+	return _nextKeyIn != _nextKeyOut;
+}
+
+void EventManager::processInput(bool can_delay) {
+	Common::Event event;
+
+	if (1 /*!g_IgnoreProcessInput*/) {
+		int flags = 0;
+		while (g_system->getEventManager()->pollEvent(event)) {
+			switch (event.type) {
+			case Common::EVENT_RBUTTONDOWN:
+				flags |= 8;
+				mouseHandler(flags, _mousePos);
+				break;
+
+			case Common::EVENT_LBUTTONDOWN:
+				flags |= 2;
+				mouseHandler(flags, _mousePos);
+				break;
+
+			case Common::EVENT_MOUSEMOVE: {
+				int lastMouseAtEdge = _mouseAtEdge;
+				_mouseAtEdge = false;
+				_mousePos.x = event.mouse.x;
+				if (event.mouse.x <= 0) {
+					_mousePos.x = 0;
+					_mouseAtEdge = true;
+				}
+				if (_mousePos.x > _vm->_screenWidth - 1) {
+					_mousePos.x = _vm->_screenWidth;
+					_mouseAtEdge = true;
+				}
+
+				_mousePos.y = event.mouse.y;
+				if (event.mouse.y <= 0) {
+					_mousePos.y = 0;
+					_mouseAtEdge = true;
+				}
+				if (_mousePos.y > _vm->_screenHeight - 1) {
+					_mousePos.y = _vm->_screenHeight;
+					_mouseAtEdge = true;
+				}
+
+				if (!lastMouseAtEdge || !_mouseAtEdge)
+					mouseHandler(1, _mousePos);
+				}
+				break;
+
+			case Common::EVENT_KEYDOWN:
+				switch (event.kbd.keycode) {
+				case Common::KEYCODE_LEFTBRACKET:
+					_vm->changeVolume(-1);
+					break;
+
+				case Common::KEYCODE_RIGHTBRACKET:
+					_vm->changeVolume(1);
+					break;
+
+				case Common::KEYCODE_z:
+					//saveSettings();
+					break;
+
+				default: {
+					int n = ((((unsigned int)((_nextKeyIn + 1) >> 31) >> 26) + (byte)_nextKeyIn + 1) & 0x3F)
+						- ((unsigned int)((_nextKeyIn + 1) >> 31) >> 26);
+					if (n != _nextKeyOut) {
+						_keyBuf[_nextKeyIn] = event.kbd.keycode;
+						_nextKeyIn = n;
+					}
+					}
+				}
+				break;
+
+			case Common::EVENT_QUIT:
+			case Common::EVENT_RTL:
+			default:
+				break;
+			}
+
+			g_system->copyRectToScreen(_vm->_displayBuffer, _vm->_screenWidth, 0, 0, _vm->_screenWidth, _vm->_screenHeight);
+			g_system->updateScreen();
+		}
+	}
+
+	if (can_delay)
+		g_system->delayMillis(10);
+}
+
+uint16 EventManager::getNextChar() {
+	uint16 c = 0;
+
+	processInput();
+	if (_nextKeyIn != _nextKeyOut) {
+		c = _keyBuf[_nextKeyOut];
+		_nextKeyOut = ((((unsigned int)((_nextKeyOut + 1) >> 31) >> 26) + (byte)_nextKeyOut + 1) & 0x3F)
+			- ((unsigned int)((_nextKeyOut + 1) >> 31) >> 26);
+	}
+
+	return c;
+}
+
+Common::Point EventManager::updateAndGetMousePos() {
+	processInput();
+
+	return _mousePos;
+}
 } // End of namespace Lab
diff --git a/engines/lab/mouse.h b/engines/lab/mouse.h
index 0ff7d60..b3b3e30d 100644
--- a/engines/lab/mouse.h
+++ b/engines/lab/mouse.h
@@ -48,11 +48,17 @@ private:
 	bool _mouseHidden;
 	int32 _numHidden;
 	Gadget *_lastGadgetHit;
+	uint16 _nextKeyIn;
+	uint16 _nextKeyOut;
+	Common::Point _mousePos;
+	bool _mouseAtEdge;
+	uint16 _keyBuf[64];
 
 public:
 	EventManager (LabEngine *vm);
 
 	Gadget *_screenGadgetList;
+	Gadget *_hitGadget;
 
 	Gadget *checkGadgetHit(Gadget *gadgetList, Common::Point pos);
 	void initMouse();
@@ -65,6 +71,11 @@ public:
 	Gadget *mouseGadget();
 	void attachGadgetList(Gadget *gadgetList);
 	void mouseHandler(int flag, Common::Point pos);
+	bool keyPress(uint16 *keyCode);
+	bool haveNextChar();
+	void processInput(bool can_delay = false);
+	uint16 getNextChar();
+	Common::Point updateAndGetMousePos();
 };
 
 } // End of namespace Lab
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 8d51320..7f8df15 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -68,8 +68,7 @@ Music::Music(LabEngine *vm) : _vm(vm) {
 /* it from the Audio device.                                                 */
 /*****************************************************************************/
 void Music::updateMusic() {
-	_vm->processInput();
-
+	_vm->_event->processInput();
 	_vm->_event->updateMouse();
 
 	if (_musicOn && getPlayingBufferCount() < MAXBUFFERS) {
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 4c8169e..3525e77 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -62,120 +62,12 @@ void LabEngine::changeVolume(int delta) {
 	warning("STUB: changeVolume()");
 }
 
-uint16 LabEngine::getNextChar() {
-	uint16 c = 0;
-
-	processInput();
-	if (_nextKeyIn != _nextKeyOut) {
-		c = _keyBuf[_nextKeyOut];
-		_nextKeyOut = ((((unsigned int)((_nextKeyOut + 1) >> 31) >> 26) + (byte)_nextKeyOut + 1) & 0x3F)
-                 - ((unsigned int)((_nextKeyOut + 1) >> 31) >> 26);
-  	}
-
-	return c;
-}
-
-bool LabEngine::haveNextChar() {
-	processInput();
-	return _nextKeyIn != _nextKeyOut;
-}
-
-void LabEngine::processInput(bool can_delay) {
-	Common::Event event;
-
-	if (1 /*!g_IgnoreProcessInput*/) {
-		int flags = 0;
-		while (g_system->getEventManager()->pollEvent(event)) {
-			switch (event.type) {
-			case Common::EVENT_RBUTTONDOWN:
-				flags |= 8;
-				_event->mouseHandler(flags, _mousePos);
-				break;
-
-			case Common::EVENT_LBUTTONDOWN:
-				flags |= 2;
-				_event->mouseHandler(flags, _mousePos);
-				break;
-
-			case Common::EVENT_MOUSEMOVE: {
-				int lastMouseAtEdge = _mouseAtEdge;
-				_mouseAtEdge = false;
-				_mousePos.x = event.mouse.x;
-				if (event.mouse.x <= 0) {
-					_mousePos.x = 0;
-					_mouseAtEdge = true;
-				}
-				if (_mousePos.x > _screenWidth - 1) {
-					_mousePos.x = _screenWidth;
-					_mouseAtEdge = true;
-				}
-
-				_mousePos.y = event.mouse.y;
-				if (event.mouse.y <= 0) {
-					_mousePos.y = 0;
-					_mouseAtEdge = true;
-				}
-				if (_mousePos.y > _screenHeight - 1) {
-					_mousePos.y = _screenHeight;
-					_mouseAtEdge = true;
-				}
-
-				if (!lastMouseAtEdge || !_mouseAtEdge)
-					_event->mouseHandler(1, _mousePos);
-				}
-				break;
-
-			case Common::EVENT_KEYDOWN:
-				switch (event.kbd.keycode) {
-				case Common::KEYCODE_LEFTBRACKET:
-					changeVolume(-1);
-					break;
-
-				case Common::KEYCODE_RIGHTBRACKET:
-					changeVolume(1);
-					break;
-
-				case Common::KEYCODE_z:
-					//saveSettings();
-					break;
-
-				default: {
-					int n = ((((unsigned int)((_nextKeyIn + 1) >> 31) >> 26) + (byte)_nextKeyIn + 1) & 0x3F)
-					- ((unsigned int)((_nextKeyIn + 1) >> 31) >> 26);
-					if (n != _nextKeyOut) {
-						_keyBuf[_nextKeyIn] = event.kbd.keycode;
-						_nextKeyIn = n;
-					}
-				}
-				}
-				break;
-
-			case Common::EVENT_QUIT:
-			case Common::EVENT_RTL:
-			default:
-				break;
-			}
-
-			g_system->copyRectToScreen(_displayBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight);
-			g_system->updateScreen();
-		}
-	}
-
-	if (can_delay)
-		g_system->delayMillis(10);
-}
-
-Common::Point LabEngine::getMousePos() {
-	processInput();
-
-	return _mousePos;
-}
 
 void LabEngine::waitTOF() {
 	g_system->copyRectToScreen(_displayBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight);
 	g_system->updateScreen();
 
-  	processInput();
+  	_event->processInput();
 
   	uint32 now;
 
@@ -237,7 +129,7 @@ void LabEngine::screenUpdate() {
 	g_system->copyRectToScreen(_displayBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight);
 	g_system->updateScreen();
 
-	processInput();
+	_event->processInput();
 }
 
 /*****************************************************************************/


Commit: d2dbf1924442056a8bf1b7cd5c7eab56e0689b7c
    https://github.com/scummvm/scummvm/commit/d2dbf1924442056a8bf1b7cd5c7eab56e0689b7c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:47+01:00

Commit Message:
LAB: Fix module.mk after readdiff.cpp removal

Changed paths:
    engines/lab/module.mk



diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index b21a3ea..53b9f4e 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -17,7 +17,6 @@ MODULE_OBJS := \
 	mouse.o \
 	music.o \
 	processroom.o \
-	readdiff.o \
 	resource.o \
 	savegame.o \
 	special.o \


Commit: 9ac98357bdf0cfeb51242d84450c865eb5cb61c8
    https://github.com/scummvm/scummvm/commit/9ac98357bdf0cfeb51242d84450c865eb5cb61c8
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:47+01:00

Commit Message:
LAB: Get rid of g_lab in Intro

Changed paths:
    engines/lab/engine.cpp
    engines/lab/intro.cpp
    engines/lab/intro.h



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 70ab45d..ba9e492 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -1305,8 +1305,9 @@ void LabEngine::go() {
 	_event->mouseHide();
 
 	if (doIntro && mem) {
-		Intro intro;
-		intro.introSequence();
+		Intro *intro = new Intro(this);
+		intro->introSequence();
+		delete intro;
 	} else
 		_anim->_doBlack = true;
 
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index adc4fd2..b283585 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -39,7 +39,7 @@
 namespace Lab {
 extern uint16 *FadePalette;
 
-Intro::Intro() {
+Intro::Intro(LabEngine *vm) : _vm(vm) {
 	_quitIntro = false;
 }
 
@@ -49,7 +49,7 @@ Intro::Intro() {
 /******************************************************************************/
 void Intro::introEatMessages() {
 	while (1) {
-		IntuiMessage *msg = g_lab->getMsg();
+		IntuiMessage *msg = _vm->getMsg();
 
 		if (g_engine->shouldQuit()) {
 			_quitIntro = true;
@@ -68,87 +68,85 @@ void Intro::introEatMessages() {
 }
 
 
-
-
 /*****************************************************************************/
 /* Reads in a picture.                                                       */
 /*****************************************************************************/
-void Intro::doPictText(const char *filename, TextFont *msgFont, bool isscreen) {
-	uint32 lastsecs = 0L, lastmicros = 0L, secs = 0L, micros = 0L;
-	IntuiMessage *msg;
+void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 	char path[50] = "Lab:rooms/Intro/";
-	byte *curplace, **tfile;
-	bool drawNextText = true, end = false, begin = true;
-
-	int32 cls, code, Drawn;
-	int16 qualifier;
-	uint timedelay;
-
 	strcat(path, filename);
 
-	if (isscreen) {
-		g_lab->_music->updateMusic();
-		timedelay = 35;
+	uint timeDelay;
+	if (isScreen) {
+		_vm->_music->updateMusic();
+		timeDelay = 35;
 	} else {
-		g_lab->_music->updateMusic();
-		timedelay = 7;
+		_vm->_music->updateMusic();
+		timeDelay = 7;
 	}
 
 	if (_quitIntro)
 		return;
 
+	uint32 lastSecs = 0L, lastMicros = 0L, secs = 0L, micros = 0L;
+	IntuiMessage *msg;
+	byte *curPlace, **tFile;
+	bool drawNextText = true, end = false, begin = true;
+
+	int32 cls, code, Drawn;
+	int16 qualifier;
+
 	while (1) {
 		if (drawNextText) {
 			if (begin) {
 				begin = false;
 
-				tfile = g_lab->_music->newOpen(path);
+				tFile = _vm->_music->newOpen(path);
 
-				if (!tfile)
+				if (!tFile)
 					return;
 
-				curplace = *tfile;
-			} else if (isscreen)
+				curPlace = *tFile;
+			} else if (isScreen)
 				fade(false, 0);
 
-			if (isscreen) {
-				g_lab->setAPen(7);
-				g_lab->rectFill(VGAScaleX(10), VGAScaleY(10), VGAScaleX(310), VGAScaleY(190));
+			if (isScreen) {
+				_vm->setAPen(7);
+				_vm->rectFill(VGAScaleX(10), VGAScaleY(10), VGAScaleX(310), VGAScaleY(190));
 
-				Drawn = flowText(msgFont, (!g_lab->_isHiRes) * -1, 5, 7, false, false, true, true, VGAScaleX(14), VGAScaleY(11), VGAScaleX(306), VGAScaleY(189), (char *)curplace);
+				Drawn = flowText(msgFont, (!_vm->_isHiRes) * -1, 5, 7, false, false, true, true, VGAScaleX(14), VGAScaleY(11), VGAScaleX(306), VGAScaleY(189), (char *)curPlace);
 				fade(true, 0);
 			} else {
-				Drawn = g_lab->longDrawMessage((char *)curplace);
+				Drawn = _vm->longDrawMessage((char *)curPlace);
 			}
 
-			curplace += Drawn;
+			curPlace += Drawn;
 
-			end = (*curplace == 0);
+			end = (*curPlace == 0);
 
 			drawNextText = false;
 			introEatMessages();
 
 			if (_quitIntro) {
-				if (isscreen)
+				if (isScreen)
 					fade(false, 0);
 
 				return;
 			}
 
-			g_lab->getTime(&lastsecs, &lastmicros);
+			_vm->getTime(&lastSecs, &lastMicros);
 		}
 
-		msg = g_lab->getMsg();
+		msg = _vm->getMsg();
 
 		if (msg == NULL) {
-			g_lab->_music->updateMusic();
-			g_lab->_anim->diffNextFrame();
-			g_lab->getTime(&secs, &micros);
-			g_lab->anyTimeDiff(lastsecs, lastmicros, secs, micros, &secs, &micros);
+			_vm->_music->updateMusic();
+			_vm->_anim->diffNextFrame();
+			_vm->getTime(&secs, &micros);
+			_vm->anyTimeDiff(lastSecs, lastMicros, secs, micros, &secs, &micros);
 
-			if (secs > timedelay) {
+			if (secs > timeDelay) {
 				if (end) {
-					if (isscreen)
+					if (isScreen)
 						fade(false, 0);
 
 					return;
@@ -157,7 +155,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isscreen) {
 				}
 			}
 
-			g_lab->waitTOF();
+			_vm->waitTOF();
 		} else {
 			cls       = msg->msgClass;
 			qualifier = msg->qualifier;
@@ -167,7 +165,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isscreen) {
 			        ((cls == RAWKEY) && (code == 27))) {
 				_quitIntro = true;
 
-				if (isscreen)
+				if (isScreen)
 					fade(false, 0);
 
 				return;
@@ -176,7 +174,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isscreen) {
 			else if (cls == MOUSEBUTTONS) {
 				if (IEQUALIFIER_LEFTBUTTON & qualifier) {
 					if (end) {
-						if (isscreen)
+						if (isScreen)
 							fade(false, 0);
 
 						return;
@@ -187,7 +185,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isscreen) {
 				introEatMessages();
 
 				if (_quitIntro) {
-					if (isscreen)
+					if (isScreen)
 						fade(false, 0);
 
 					return;
@@ -195,7 +193,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isscreen) {
 			}
 
 			if (end) {
-				if (isscreen)
+				if (isScreen)
 					fade(false, 0);
 
 				return;
@@ -205,44 +203,37 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isscreen) {
 	}
 }
 
-
-
-
-
 /*****************************************************************************/
 /* Does a one second delay, but checks the music while doing it.             */
 /*****************************************************************************/
 void Intro::musicDelay() {
-	g_lab->_music->updateMusic();
+	_vm->_music->updateMusic();
 
 	if (_quitIntro)
 		return;
 
 	for (uint16 i = 0; i < 20; i++) {
-		g_lab->_music->updateMusic();
-		g_lab->waitTOF();
-		g_lab->waitTOF();
-		g_lab->waitTOF();
+		_vm->_music->updateMusic();
+		_vm->waitTOF();
+		_vm->waitTOF();
+		_vm->waitTOF();
 	}
 }
 
-
-
 void Intro::nReadPict(const char *filename, bool playOnce) {
 	Common::String finalFileName = Common::String("P:Intro/") + filename;
 
-	g_lab->_music->updateMusic();
+	_vm->_music->updateMusic();
 	introEatMessages();
 
 	if (_quitIntro)
 		return;
 
-	g_lab->_anim->_doBlack = _introDoBlack;
-	g_lab->_anim->stopDiffEnd();
+	_vm->_anim->_doBlack = _introDoBlack;
+	_vm->_anim->stopDiffEnd();
 	readPict(finalFileName.c_str(), playOnce);
 }
 
-
 /*****************************************************************************/
 /* Does the introduction sequence for Labyrinth.                             */
 /*****************************************************************************/
@@ -254,9 +245,9 @@ void Intro::introSequence() {
 		0x0CB3, 0x0DC4, 0x0DD6, 0x0EE7
 	};
 
-	g_lab->_anim->_doBlack = true;
+	_vm->_anim->_doBlack = true;
 
-	if (g_lab->getPlatform() != Common::kPlatformWindows) {
+	if (_vm->getPlatform() != Common::kPlatformWindows) {
 		nReadPict("EA0", true);
 		nReadPict("EA1", true);
 		nReadPict("EA2", true);
@@ -274,14 +265,14 @@ void Intro::introSequence() {
 
 	blackAllScreen();
 
-	g_lab->_music->initMusic();
+	_vm->_music->initMusic();
 
-	g_lab->_anim->_noPalChange = true;
-	if (g_lab->getPlatform() != Common::kPlatformWindows)
+	_vm->_anim->_noPalChange = true;
+	if (_vm->getPlatform() != Common::kPlatformWindows)
 		nReadPict("TNDcycle.pic", true);
 	else
 		nReadPict("TNDcycle2.pic", true);
-	g_lab->_anim->_noPalChange = false;
+	_vm->_anim->_noPalChange = false;
 
 	FadePalette = palette;
 
@@ -289,19 +280,19 @@ void Intro::introSequence() {
 		if (_quitIntro)
 			break;
 
-		palette[i] = ((g_lab->_anim->_diffPalette[i * 3] >> 2) << 8) +
-		             ((g_lab->_anim->_diffPalette[i * 3 + 1] >> 2) << 4) +
-		              (g_lab->_anim->_diffPalette[i * 3 + 2] >> 2);
+		palette[i] = ((_vm->_anim->_diffPalette[i * 3] >> 2) << 8) +
+		             ((_vm->_anim->_diffPalette[i * 3 + 1] >> 2) << 4) +
+		              (_vm->_anim->_diffPalette[i * 3 + 2] >> 2);
 	}
 
-	g_lab->_music->updateMusic();
+	_vm->_music->updateMusic();
 	fade(true, 0);
 
 	for (int times = 0; times < 150; times++) {
 		if (_quitIntro)
 			break;
 
-		g_lab->_music->updateMusic();
+		_vm->_music->updateMusic();
 		uint16 temp = palette[2];
 
 		for (uint16 i = 2; i < 15; i++)
@@ -310,13 +301,13 @@ void Intro::introSequence() {
 		palette[15] = temp;
 
 		setAmigaPal(palette, 16);
-		g_lab->waitTOF();
+		_vm->waitTOF();
 	}
 
 	fade(false, 0);
 	blackAllScreen();
 
-	g_lab->_music->updateMusic();
+	_vm->_music->updateMusic();
 
 	nReadPict("Title.A", true);
 	nReadPict("AB", true);
@@ -325,35 +316,35 @@ void Intro::introSequence() {
 	nReadPict("AC", true);
 	musicDelay();
 
-	if (g_lab->getPlatform() == Common::kPlatformWindows)
+	if (_vm->getPlatform() == Common::kPlatformWindows)
 		musicDelay(); // more credits on this page now
 
 	nReadPict("CA", true);
 	nReadPict("AD", true);
 	musicDelay();
 
-	if (g_lab->getPlatform() == Common::kPlatformWindows)
+	if (_vm->getPlatform() == Common::kPlatformWindows)
 		musicDelay(); // more credits on this page now
 
 	nReadPict("DA", true);
 	musicDelay();
 
-	g_lab->_music->newOpen("p:Intro/Intro.1");  /* load the picture into the buffer */
+	_vm->_music->newOpen("p:Intro/Intro.1");  /* load the picture into the buffer */
 
-	g_lab->_music->updateMusic();
+	_vm->_music->updateMusic();
 	blackAllScreen();
-	g_lab->_music->updateMusic();
+	_vm->_music->updateMusic();
 
-	TextFont *msgFont = g_lab->_resource->getFont("P:Map.fon");
+	TextFont *msgFont = _vm->_resource->getFont("P:Map.fon");
 
-	g_lab->_anim->_noPalChange = true;
+	_vm->_anim->_noPalChange = true;
 	nReadPict("Intro.1", true);
-	g_lab->_anim->_noPalChange = false;
+	_vm->_anim->_noPalChange = false;
 
 	for (uint16 i = 0; i < 16; i++) {
-		palette[i] = ((g_lab->_anim->_diffPalette[i * 3] >> 2) << 8) +
-		             ((g_lab->_anim->_diffPalette[i * 3 + 1] >> 2) << 4) +
-		              (g_lab->_anim->_diffPalette[i * 3 + 2] >> 2);
+		palette[i] = ((_vm->_anim->_diffPalette[i * 3] >> 2) << 8) +
+		             ((_vm->_anim->_diffPalette[i * 3 + 1] >> 2) << 4) +
+		              (_vm->_anim->_diffPalette[i * 3 + 2] >> 2);
 	}
 
 	doPictText("i.1", msgFont, true);
@@ -363,7 +354,7 @@ void Intro::introSequence() {
 	freeAllStolenMem();
 
 	blackAllScreen();
-	g_lab->_music->updateMusic();
+	_vm->_music->updateMusic();
 
 	_introDoBlack = true;
 	nReadPict("Station1", true);
@@ -393,13 +384,13 @@ void Intro::introSequence() {
 	if (!_quitIntro)
 		for (uint16 i = 0; i < 50; i++) {
 			for (uint16 idx = (8 * 3); idx < (255 * 3); idx++)
-				g_lab->_anim->_diffPalette[idx] = 255 - g_lab->_anim->_diffPalette[idx];
+				_vm->_anim->_diffPalette[idx] = 255 - _vm->_anim->_diffPalette[idx];
 
-			g_lab->_music->updateMusic();
-			g_lab->waitTOF();
-			g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
-			g_lab->waitTOF();
-			g_lab->waitTOF();
+			_vm->_music->updateMusic();
+			_vm->waitTOF();
+			_vm->setPalette(_vm->_anim->_diffPalette, 256);
+			_vm->waitTOF();
+			_vm->waitTOF();
 		}
 
 	doPictText("i.12", msgFont, false);
@@ -436,7 +427,7 @@ void Intro::introSequence() {
 	nReadPict("Daed7", false);
 	doPictText("i.27", msgFont, false);
 	doPictText("i.28", msgFont, false);
-	g_lab->_anim->stopDiffEnd();
+	_vm->_anim->stopDiffEnd();
 
 	nReadPict("Daed8", true);
 	doPictText("i.29", msgFont, false);
@@ -456,9 +447,9 @@ void Intro::introSequence() {
 	nReadPict("SubX", true);
 
 	if (_quitIntro) {
-		g_lab->setAPen(0);
-		g_lab->rectFill(0, 0, g_lab->_screenWidth - 1, g_lab->_screenHeight - 1);
-		g_lab->_anim->_doBlack = true;
+		_vm->setAPen(0);
+		_vm->rectFill(0, 0, _vm->_screenWidth - 1, _vm->_screenHeight - 1);
+		_vm->_anim->_doBlack = true;
 	}
 
 	closeFont(msgFont);
diff --git a/engines/lab/intro.h b/engines/lab/intro.h
index 2979bcd..47b61da 100644
--- a/engines/lab/intro.h
+++ b/engines/lab/intro.h
@@ -38,7 +38,7 @@ namespace Lab {
 
 class Intro {
 public:
-	Intro();
+	Intro(LabEngine *vm);
 	void introSequence();
 
 private:
@@ -47,6 +47,7 @@ private:
 	void musicDelay();
 	void nReadPict(const char *Filename, bool PlayOnce);
 
+	LabEngine *_vm;
 	bool _quitIntro, _introDoBlack;
 };
 


Commit: 1d13083b29c3b4bd3e1423a4cbdc6dc32a50de22
    https://github.com/scummvm/scummvm/commit/1d13083b29c3b4bd3e1423a4cbdc6dc32a50de22
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:47+01:00

Commit Message:
LAB: Clean up includes in Intro

Changed paths:
    engines/lab/intro.cpp



diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index b283585..43cbed6 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -30,11 +30,7 @@
 
 #include "lab/lab.h"
 #include "lab/intro.h"
-#include "lab/labfun.h"
-#include "lab/resource.h"
 #include "lab/anim.h"
-#include "lab/text.h"
-#include "lab/interface.h"
 
 namespace Lab {
 extern uint16 *FadePalette;


Commit: 8fa64824a2dc1b5b2470f2ae4830f5573f5d01df
    https://github.com/scummvm/scummvm/commit/8fa64824a2dc1b5b2470f2ae4830f5573f5d01df
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:47+01:00

Commit Message:
LAB: Some renaming, move a couple of variables to game engine

Changed paths:
    engines/lab/detection.cpp
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/interface.cpp
    engines/lab/interface.h
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/labfun.h
    engines/lab/map.cpp
    engines/lab/mouse.cpp
    engines/lab/parsetypes.h
    engines/lab/processroom.cpp
    engines/lab/savegame.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/detection.cpp b/engines/lab/detection.cpp
index ddb6aa3..3b01d77 100644
--- a/engines/lab/detection.cpp
+++ b/engines/lab/detection.cpp
@@ -194,7 +194,7 @@ SaveStateList LabMetaEngine::listSaves(const char *target) const {
 	            Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
 	            if (in) {
 					if (Lab::readSaveGameHeader(in, header))
-	                    saveList.push_back(SaveStateDescriptor(slotNum, header.desc.getDescription()));
+	                    saveList.push_back(SaveStateDescriptor(slotNum, header._descr.getDescription()));
 	                delete in;
 	            }
 	        }
@@ -242,13 +242,13 @@ SaveStateDescriptor LabMetaEngine::querySaveMetaInfos(const char *target, int sl
 	    delete in;
 
 	    if (successfulRead) {
-	        SaveStateDescriptor desc(slot, header.desc.getDescription());
+	        SaveStateDescriptor desc(slot, header._descr.getDescription());
 			// Do not allow save slot 0 (used for auto-saving) to be deleted or
 			// overwritten.
 			//desc.setDeletableFlag(slot != 0);
 			//desc.setWriteProtectedFlag(slot == 0);
 
-	        return header.desc;
+	        return header._descr;
 	    }
 	}
 
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index ba9e492..fe3c428 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -41,8 +41,6 @@
 
 namespace Lab {
 
-const char *CurFileName = " ";
-
 bool LongWinInFront = false;
 
 TextFont *MsgFont;
@@ -56,10 +54,7 @@ extern InventoryData *Inventory;
 extern uint16 NumInv, ManyRooms, HighestCondition, Direction;
 CloseDataPtr CPtr;
 
-bool Alternate = false, ispal = false, noupdatediff = false, MainDisplay = true, QuitLab = false;
-
-extern const char *NewFileName;  /* When ProcessRoom.c decides to change the filename
-                                    of the current picture. */
+bool ispal = false, noupdatediff = false, MainDisplay = true, QuitLab = false;
 
 #define BUFFERSIZE 850000L
 
@@ -100,11 +95,6 @@ extern const char *NewFileName;  /* When ProcessRoom.c decides to change the fil
 #define TERMINALMONITOR      81
 #define LEVERSMONITOR        82
 
-
-static Image *MoveImages[20], *InvImages[10];
-static Gadget *MoveGadgetList, *InvGadgetList;
-
-
 static char initcolors[] = { '\x00', '\x00', '\x00', '\x30',
 							 '\x30', '\x30', '\x10', '\x10',
 							 '\x10', '\x14', '\x14', '\x14',
@@ -112,9 +102,6 @@ static char initcolors[] = { '\x00', '\x00', '\x00', '\x30',
 							 '\x24', '\x24', '\x2c', '\x2c',
 							 '\x2c', '\x08', '\x08', '\x08'};
 
-
-
-
 /******************************************************************************/
 /* Draws the control panel display.                                           */
 /******************************************************************************/
@@ -133,10 +120,10 @@ void LabEngine::drawPanel() {
 	setAPen(0);
 	drawHLine(0, VGAScaleY(170), VGAScaleX(319));     /* First black line to separate buttons */
 
-	if (!Alternate) {
+	if (!_alternate) {
 		setAPen(4);
 		drawHLine(0, VGAScaleY(170) + 1, VGAScaleX(319)); /* The horizontal lines under the black one */
-		drawGadgetList(MoveGadgetList);
+		drawGadgetList(_moveGadgetList);
 	} else {
 		if (getPlatform() != Common::kPlatformWindows) {
 			drawVLine(VGAScaleX(124), VGAScaleY(170) + 1, VGAScaleY(199)); /* Vertical Black lines */
@@ -162,7 +149,7 @@ void LabEngine::drawPanel() {
 			drawVLine(VGAScaleX(232), VGAScaleY(170) + 2, VGAScaleY(198));
 		}
 
-		drawGadgetList(InvGadgetList);
+		drawGadgetList(_invGadgetList);
 	}
 
 	_event->mouseShow();
@@ -171,38 +158,32 @@ void LabEngine::drawPanel() {
 /******************************************************************************/
 /* Draws the message for the room.                                            */
 /******************************************************************************/
-void LabEngine::drawRoomMessage(uint16 CurInv, CloseDataPtr cptr) {
+void LabEngine::drawRoomMessage(uint16 curInv, CloseDataPtr closePtr) {
 	if (_lastTooLong) {
 		_lastTooLong = false;
 		return;
 	}
 
-	if (Alternate) {
-		if ((CurInv <= NumInv) && _conditions->in(CurInv) && Inventory[CurInv].BInvName) {
-			if ((CurInv == LAMPNUM) && _conditions->in(LAMPON))  /* LAB: Labyrith specific */
+	if (_alternate) {
+		if ((curInv <= NumInv) && _conditions->in(curInv) && Inventory[curInv].BInvName) {
+			if ((curInv == LAMPNUM) && _conditions->in(LAMPON))  /* LAB: Labyrinth specific */
 				drawStaticMessage(kTextLampOn);
-			else if (Inventory[CurInv].Many > 1) {
-				Common::String roomMessage = Common::String(Inventory[CurInv].name) + "  (" + Common::String::format("%d", Inventory[CurInv].Many) + ")";
+			else if (Inventory[curInv].Many > 1) {
+				Common::String roomMessage = Common::String(Inventory[curInv].name) + "  (" + Common::String::format("%d", Inventory[curInv].Many) + ")";
 				drawMessage(roomMessage.c_str());
 			} else
-				drawMessage(Inventory[CurInv].name);
+				drawMessage(Inventory[curInv].name);
 		}
 	} else
-		drawDirection(cptr);
+		drawDirection(closePtr);
 
 	_lastTooLong = _lastMessageLong;
 }
 
-
 /******************************************************************************/
 /* Sets up the Labyrinth screens, and opens up the initial windows.           */
 /******************************************************************************/
 bool LabEngine::setUpScreens() {
-	byte *buffer;
-	byte *MovePanelBuffer, *InvPanelBuffer;
-	Gadget *curgad;
-	uint16 y;
-
 	if (!createScreen(_isHiRes))
 		return false;
 
@@ -215,60 +196,61 @@ bool LabEngine::setUpScreens() {
 	if (file.err() || file.size() == 0)
 		return false;
 
-	if (!(MovePanelBuffer = (byte *)calloc(file.size(), 1)))
+	byte *movePanelBuffer;
+	if (!(movePanelBuffer = (byte *)calloc(file.size(), 1)))
 		return false;
 
-	file.read(MovePanelBuffer, file.size());
+	file.read(movePanelBuffer, file.size());
 	file.close();
 
-	buffer = MovePanelBuffer;
+	byte *buffer = movePanelBuffer;
 
 	for (uint16 i = 0; i < 20; i++)
-		MoveImages[i] = new Image(&buffer);
+		_moveImages[i] = new Image(&buffer);
 
 	/* Creates the gadgets for the movement control panel */
-	y = VGAScaleY(173) - SVGACord(2);
+	uint16 y = VGAScaleY(173) - SVGACord(2);
 
 	if (getPlatform() == Common::kPlatformWindows) {
-		MoveGadgetList = createButton(1, y, 0, 't', MoveImages[0], MoveImages[1]);
-		curgad = MoveGadgetList;
-		curgad->NextGadget = createButton(33, y, 1, 'm', MoveImages[2], MoveImages[3]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(65, y, 2, 'o', MoveImages[4], MoveImages[5]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(97, y, 3, 'c', MoveImages[6], MoveImages[7]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(129, y, 4, 'l', MoveImages[8], MoveImages[9]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(161, y, 5, 'i', MoveImages[12], MoveImages[13]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(193, y, 6, VKEY_LTARROW, MoveImages[14], MoveImages[15]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(225, y, 7, VKEY_UPARROW, MoveImages[16], MoveImages[17]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(257, y, 8, VKEY_RTARROW, MoveImages[18], MoveImages[19]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(289, y, 9, 'p', MoveImages[10], MoveImages[11]);
+		_moveGadgetList = createButton(1, y, 0, 't', _moveImages[0], _moveImages[1]);
+		Gadget *curGadget = _moveGadgetList;
+		curGadget->NextGadget = createButton(33, y, 1, 'm', _moveImages[2], _moveImages[3]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(65, y, 2, 'o', _moveImages[4], _moveImages[5]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(97, y, 3, 'c', _moveImages[6], _moveImages[7]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(129, y, 4, 'l', _moveImages[8], _moveImages[9]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(161, y, 5, 'i', _moveImages[12], _moveImages[13]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(193, y, 6, VKEY_LTARROW, _moveImages[14], _moveImages[15]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(225, y, 7, VKEY_UPARROW, _moveImages[16], _moveImages[17]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(257, y, 8, VKEY_RTARROW, _moveImages[18], _moveImages[19]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(289, y, 9, 'p', _moveImages[10], _moveImages[11]);
 	} else {
-		MoveGadgetList = createButton(1, y, 0, 0, MoveImages[0], MoveImages[1]);
-		curgad = MoveGadgetList;
-		curgad->NextGadget = createButton(33, y, 1, 0, MoveImages[2], MoveImages[3]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(65, y, 2, 0, MoveImages[4], MoveImages[5]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(97, y, 3, 0, MoveImages[6], MoveImages[7]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(129, y, 4, 0, MoveImages[8], MoveImages[9]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(161, y, 5, 0, MoveImages[12], MoveImages[13]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(193, y, 6, 0, MoveImages[14], MoveImages[15]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(225, y, 7, 0, MoveImages[16], MoveImages[17]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(257, y, 8, 0, MoveImages[18], MoveImages[19]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(289, y, 9, 0, MoveImages[10], MoveImages[11]);
+		_moveGadgetList = createButton(1, y, 0, 0, _moveImages[0], _moveImages[1]);
+		Gadget *curGadget = _moveGadgetList;
+		curGadget->NextGadget = createButton(33, y, 1, 0, _moveImages[2], _moveImages[3]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(65, y, 2, 0, _moveImages[4], _moveImages[5]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(97, y, 3, 0, _moveImages[6], _moveImages[7]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(129, y, 4, 0, _moveImages[8], _moveImages[9]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(161, y, 5, 0, _moveImages[12], _moveImages[13]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(193, y, 6, 0, _moveImages[14], _moveImages[15]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(225, y, 7, 0, _moveImages[16], _moveImages[17]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(257, y, 8, 0, _moveImages[18], _moveImages[19]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(289, y, 9, 0, _moveImages[10], _moveImages[11]);
 	}
 
 	file.open(translateFileName("P:Inv"));
@@ -278,95 +260,89 @@ bool LabEngine::setUpScreens() {
 	if (file.err() || file.size() == 0)
 		return false;
 
-	if (!(InvPanelBuffer = (byte *)calloc(file.size(), 1)))
+	byte *invPanelBuffer;
+	if (!(invPanelBuffer = (byte *)calloc(file.size(), 1)))
 		return false;
 
-	file.read(InvPanelBuffer, file.size());
+	file.read(invPanelBuffer, file.size());
 	file.close();
 
-	buffer = InvPanelBuffer;
+	buffer = invPanelBuffer;
 
 	if (getPlatform() == Common::kPlatformWindows) {
 		for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++)
-			InvImages[imgIdx] = new Image(&buffer);
-
-		InvGadgetList = createButton(24, y, 0, 'm', InvImages[0], InvImages[1]);
-		curgad = InvGadgetList;
-		curgad->NextGadget = createButton(56, y, 1, 'g', InvImages[2], InvImages[3]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(94, y, 2, 'u', InvImages[4], InvImages[5]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(126, y, 3, 'l', MoveImages[8], MoveImages[9]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(164, y, 4, VKEY_LTARROW, MoveImages[14], MoveImages[15]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(196, y, 5, VKEY_RTARROW, MoveImages[18], MoveImages[19]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(234, y, 6, 'b', InvImages[6], InvImages[7]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(266, y, 7, 'f', InvImages[8], InvImages[9]);
-		curgad = curgad->NextGadget;
+			_invImages[imgIdx] = new Image(&buffer);
+
+		_invGadgetList = createButton(24, y, 0, 'm', _invImages[0], _invImages[1]);
+		Gadget *curGadget = _invGadgetList;
+		curGadget->NextGadget = createButton(56, y, 1, 'g', _invImages[2], _invImages[3]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(94, y, 2, 'u', _invImages[4], _invImages[5]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(126, y, 3, 'l', _moveImages[8], _moveImages[9]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(164, y, 4, VKEY_LTARROW, _moveImages[14], _moveImages[15]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(196, y, 5, VKEY_RTARROW, _moveImages[18], _moveImages[19]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(234, y, 6, 'b', _invImages[6], _invImages[7]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(266, y, 7, 'f', _invImages[8], _invImages[9]);
+		curGadget = curGadget->NextGadget;
 	} else {
 		for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++)
-			InvImages[imgIdx] = new Image(&buffer);
-
-		InvGadgetList = createButton(58, y, 0, 0, InvImages[0], InvImages[1]);
-		curgad = InvGadgetList;
-		curgad->NextGadget = createButton(90, y, 1, 0, InvImages[2], InvImages[3]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(128, y, 2, 0, InvImages[4], InvImages[5]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(160, y, 3, 0, MoveImages[8], MoveImages[9]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(198, y, 4, 0, MoveImages[14], MoveImages[15]);
-		curgad = curgad->NextGadget;
-		curgad->NextGadget = createButton(230, y, 5, 0, MoveImages[18], MoveImages[19]);
-		curgad = curgad->NextGadget;
+			_invImages[imgIdx] = new Image(&buffer);
+
+		_invGadgetList = createButton(58, y, 0, 0, _invImages[0], _invImages[1]);
+		Gadget *curGadget = _invGadgetList;
+		curGadget->NextGadget = createButton(90, y, 1, 0, _invImages[2], _invImages[3]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(128, y, 2, 0, _invImages[4], _invImages[5]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(160, y, 3, 0, _moveImages[8], _moveImages[9]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(198, y, 4, 0, _moveImages[14], _moveImages[15]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(230, y, 5, 0, _moveImages[18], _moveImages[19]);
+		curGadget = curGadget->NextGadget;
 	}
 
 	return true;
 }
 
-
-
 /******************************************************************************/
-/* Permanently flips the imagry of a gadget.                                  */
+/* Permanently flips the imagery of a gadget.                                 */
 /******************************************************************************/
-void LabEngine::perFlipGadget(uint16 GadID) {
-	Image *Temp;
-	Gadget *TopGad;
-
-	TopGad = MoveGadgetList;
+void LabEngine::perFlipGadget(uint16 gadgetId) {
+	Gadget *topGadget = _moveGadgetList;
 
-	while (TopGad) {
-		if (TopGad->GadgetID == GadID) {
-			Temp = TopGad->Im;
-			TopGad->Im = TopGad->ImAlt;
-			TopGad->ImAlt = Temp;
+	while (topGadget) {
+		if (topGadget->GadgetID == gadgetId) {
+			Image *tmpImage = topGadget->_image;
+			topGadget->_image = topGadget->_altImage;
+			topGadget->_altImage = tmpImage;
 
-			if (!Alternate) {
+			if (!_alternate) {
 				_event->mouseHide();
-				TopGad->Im->drawImage(TopGad->x, TopGad->y);
+				topGadget->_image->drawImage(topGadget->x, topGadget->y);
 				_event->mouseShow();
 			}
 
 			return;
 		} else
-			TopGad = TopGad->NextGadget;
+			topGadget = topGadget->NextGadget;
 	}
 }
 
-
-
 /******************************************************************************/
 /* Eats all the available messages.                                           */
 /******************************************************************************/
 void LabEngine::eatMessages() {
-	IntuiMessage *Msg;
+	IntuiMessage *msg;
 
 	do {
-		Msg = getMsg();
-	} while (Msg);
+		msg = getMsg();
+	} while (msg);
 
 	return;
 }
@@ -374,8 +350,8 @@ void LabEngine::eatMessages() {
 /******************************************************************************/
 /* Checks whether the close up is one of the special case closeups.           */
 /******************************************************************************/
-bool LabEngine::doCloseUp(CloseDataPtr cptr) {
-	if (cptr == NULL)
+bool LabEngine::doCloseUp(CloseDataPtr closePtr) {
+	if (closePtr == NULL)
 		return false;
 
 	int monltmargin, monrtmargin, montopmargin, lutertmargin;
@@ -392,46 +368,43 @@ bool LabEngine::doCloseUp(CloseDataPtr cptr) {
 		lutertmargin = 128;
 	}
 
-	switch (cptr->CloseUpType) {
+	switch (closePtr->CloseUpType) {
 	case MUSEUMMONITOR:
 	case LIBRARYMONITOR:
 	case WINDOWMONITOR:
-		doMonitor(cptr->GraphicName, cptr->Message, false, monltmargin, montopmargin, monrtmargin, 165);
+		doMonitor(closePtr->GraphicName, closePtr->Message, false, monltmargin, montopmargin, monrtmargin, 165);
 		break;
 	case GRAMAPHONEMONITOR:
-		doMonitor(cptr->GraphicName, cptr->Message, false, monltmargin, montopmargin, 171, 165);
+		doMonitor(closePtr->GraphicName, closePtr->Message, false, monltmargin, montopmargin, 171, 165);
 		break;
 	case UNICYCLEMONITOR:
-		doMonitor(cptr->GraphicName, cptr->Message, false, 100, montopmargin, monrtmargin, 165);
+		doMonitor(closePtr->GraphicName, closePtr->Message, false, 100, montopmargin, monrtmargin, 165);
 		break;
 	case STATUEMONITOR:
-		doMonitor(cptr->GraphicName, cptr->Message, false, 117, montopmargin, monrtmargin, 165);
+		doMonitor(closePtr->GraphicName, closePtr->Message, false, 117, montopmargin, monrtmargin, 165);
 		break;
 	case TALISMANMONITOR:
-		doMonitor(cptr->GraphicName, cptr->Message, false, monltmargin, montopmargin, 184, 165);
+		doMonitor(closePtr->GraphicName, closePtr->Message, false, monltmargin, montopmargin, 184, 165);
 		break;
 	case LUTEMONITOR:
-		doMonitor(cptr->GraphicName, cptr->Message, false, monltmargin, montopmargin, lutertmargin, 165);
+		doMonitor(closePtr->GraphicName, closePtr->Message, false, monltmargin, montopmargin, lutertmargin, 165);
 		break;
 	case CLOCKMONITOR:
-		doMonitor(cptr->GraphicName, cptr->Message, false, monltmargin, montopmargin, 206, 165);
+		doMonitor(closePtr->GraphicName, closePtr->Message, false, monltmargin, montopmargin, 206, 165);
 		break;
 	case TERMINALMONITOR:
-		doMonitor(cptr->GraphicName, cptr->Message, true, monltmargin, montopmargin, monrtmargin, 165);
+		doMonitor(closePtr->GraphicName, closePtr->Message, true, monltmargin, montopmargin, monrtmargin, 165);
 		break;
 	default:
 		return false;
 	}
 
-	CurFileName = " ";
+	_curFileName = " ";
 	drawPanel();
 
 	return true;
 }
 
-
-
-
 /******************************************************************************/
 /* Gets the current inventory name.                                           */
 /******************************************************************************/
@@ -442,21 +415,19 @@ static const char *getInvName(uint16 CurInv) {
 	if ((CurInv == LAMPNUM) && g_lab->_conditions->in(LAMPON))
 		return "P:Mines/120";
 
-	else if ((CurInv == BELTNUM) && g_lab->_conditions->in(BELTGLOW))
+	if ((CurInv == BELTNUM) && g_lab->_conditions->in(BELTGLOW))
 		return "P:Future/BeltGlow";
 
-	else if (CurInv == WESTPAPERNUM) {
-		CurFileName = Inventory[CurInv].BInvName;
+	if (CurInv == WESTPAPERNUM) {
+		g_lab->_curFileName = Inventory[CurInv].BInvName;
 		g_lab->_anim->_noPalChange = true;
-		readPict(CurFileName, false);
+		readPict(g_lab->_curFileName, false);
 		g_lab->_anim->_noPalChange = false;
 		doWestPaper();
-	}
-
-	else if (CurInv == NOTESNUM) {
-		CurFileName = Inventory[CurInv].BInvName;
+	} else if (CurInv == NOTESNUM) {
+		g_lab->_curFileName = Inventory[CurInv].BInvName;
 		g_lab->_anim->_noPalChange = true;
-		readPict(CurFileName, false);
+		readPict(g_lab->_curFileName, false);
 		g_lab->_anim->_noPalChange = false;
 		doNotes();
 	}
@@ -464,16 +435,14 @@ static const char *getInvName(uint16 CurInv) {
 	return Inventory[CurInv].BInvName;
 }
 
-static bool interfaceisoff = false;
-
 /******************************************************************************/
 /* Turns the interface off.                                                   */
 /******************************************************************************/
 void LabEngine::interfaceOff() {
-	if (!interfaceisoff) {
+	if (!_interfaceOff) {
 		_event->attachGadgetList(NULL);
 		_event->mouseHide();
-		interfaceisoff = true;
+		_interfaceOff = true;
 	}
 }
 
@@ -481,22 +450,19 @@ void LabEngine::interfaceOff() {
 /* Turns the interface on.                                                    */
 /******************************************************************************/
 void LabEngine::interfaceOn() {
-	if (interfaceisoff) {
-		interfaceisoff = false;
-
+	if (_interfaceOff) {
+		_interfaceOff = false;
 		_event->mouseShow();
 	}
 
 	if (LongWinInFront)
 		_event->attachGadgetList(NULL);
-	else if (Alternate)
-		_event->attachGadgetList(InvGadgetList);
+	else if (_alternate)
+		_event->attachGadgetList(_invGadgetList);
 	else
-		_event->attachGadgetList(MoveGadgetList);
+		_event->attachGadgetList(_moveGadgetList);
 }
 
-static const char *Test;
-
 /******************************************************************************/
 /* If the user hits the "Use" gadget; things that can get used on themselves. */
 /******************************************************************************/
@@ -505,7 +471,7 @@ bool LabEngine::doUse(uint16 CurInv) {
 		drawStaticMessage(kTextUseMap);
 		interfaceOff();
 		_anim->stopDiff();
-		CurFileName = " ";
+		_curFileName = " ";
 		CPtr = NULL;
 		doMap(_roomNum);
 		setPalette(initcolors, 8);
@@ -515,7 +481,7 @@ bool LabEngine::doUse(uint16 CurInv) {
 		drawStaticMessage(kTextUseJournal);
 		interfaceOff();
 		_anim->stopDiff();
-		CurFileName = " ";
+		_curFileName = " ";
 		CPtr = NULL;
 		doJournal();
 		drawPanel();
@@ -537,13 +503,13 @@ bool LabEngine::doUse(uint16 CurInv) {
 		_anim->_waitForEffect = false;
 
 		_anim->_doBlack = false;
-		Test = getInvName(CurInv);
+		_nextFileName = getInvName(CurInv);
 	} else if (CurInv == BELTNUM) {                    /* LAB: Labyrinth specific */
 		if (!_conditions->in(BELTGLOW))
 			_conditions->inclElement(BELTGLOW);
 
 		_anim->_doBlack = false;
-		Test = getInvName(CurInv);
+		_nextFileName = getInvName(CurInv);
 	} else if (CurInv == WHISKEYNUM) {                 /* LAB: Labyrinth specific */
 		_conditions->inclElement(USEDHELMET);
 		drawStaticMessage(kTextUseWhiskey);
@@ -559,9 +525,6 @@ bool LabEngine::doUse(uint16 CurInv) {
 	return true;
 }
 
-
-
-
 /******************************************************************************/
 /* Decrements the current inventory number.                                   */
 /******************************************************************************/
@@ -575,7 +538,7 @@ void LabEngine::decIncInv(uint16 *CurInv, bool dec) {
 
 	while (*CurInv && (*CurInv <= NumInv)) {
 		if (_conditions->in(*CurInv) && Inventory[*CurInv].BInvName) {
-			Test = getInvName(*CurInv);
+			_nextFileName = getInvName(*CurInv);
 			break;
 		}
 
@@ -593,7 +556,7 @@ void LabEngine::decIncInv(uint16 *CurInv, bool dec) {
 
 		while (*CurInv && (*CurInv <= NumInv)) {
 			if (_conditions->in(*CurInv) && Inventory[*CurInv].BInvName) {
-				Test = getInvName(*CurInv);
+				_nextFileName = getInvName(*CurInv);
 				break;
 			}
 
@@ -660,32 +623,30 @@ void LabEngine::mainGameLoop() {
 
 			/* Sets the current picture properly on the screen */
 			if (MainDisplay)
-				Test = getPictName(&CPtr);
+				_nextFileName = getPictName(&CPtr);
 
 			if (noupdatediff) {
 				_roomsFound->inclElement(_roomNum); /* Potentially entered another room */
-				forceDraw = (strcmp(Test, CurFileName) != 0) || forceDraw;
+				forceDraw |= (strcmp(_nextFileName, _curFileName) != 0);
 
 				noupdatediff = false;
-				CurFileName = Test;
-			}
-
-			else if (strcmp(Test, CurFileName) != 0) {
+				_curFileName = _nextFileName;
+			} else if (strcmp(_nextFileName, _curFileName) != 0) {
 				interfaceOff();
 				_roomsFound->inclElement(_roomNum); /* Potentially entered another room */
-				CurFileName = Test;
+				_curFileName = _nextFileName;
 
 				if (CPtr) {
 					if ((CPtr->CloseUpType == SPECIALLOCK) && MainDisplay)  /* LAB: Labyrinth specific code */
-						showCombination(CurFileName);
+						showCombination(_curFileName);
 					else if (((CPtr->CloseUpType == SPECIALBRICK)  ||
 					          (CPtr->CloseUpType == SPECIALBRICKNOMOUSE)) &&
 					         MainDisplay) /* LAB: Labyrinth specific code */
-						showTile(CurFileName, (bool)(CPtr->CloseUpType == SPECIALBRICKNOMOUSE));
+						showTile(_curFileName, (bool)(CPtr->CloseUpType == SPECIALBRICKNOMOUSE));
 					else
-						readPict(CurFileName, false);
+						readPict(_curFileName, false);
 				} else
-					readPict(CurFileName, false);
+					readPict(_curFileName, false);
 
 				drawRoomMessage(curInv, CPtr);
 				forceDraw = false;
@@ -806,9 +767,9 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 					_isCrumbWaiting = false;
 					getTime(&_crumbSecs, &_crumbMicros);
 
-					if (Alternate) {
+					if (_alternate) {
 						eatMessages();
-						Alternate = false;
+						_alternate = false;
 						_anim->_doBlack = true;
 						DoNotDrawMessage = false;
 
@@ -883,7 +844,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			drawRoomMessage(curInv, CPtr);
 			screenUpdate();
 		}
-	} else if ((msgClass == GADGETUP) && !Alternate) {
+	} else if ((msgClass == GADGETUP) && !_alternate) {
 		if (gadgetId <= 5) {
 			if ((actionMode == 4) && (gadgetId == 4) && (CPtr != NULL)) {
 				doMainView(&CPtr);
@@ -896,7 +857,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			} else if (gadgetId == 5) {
 				eatMessages();
 
-				Alternate = true;
+				_alternate = true;
 				_anim->_doBlack = true;
 				DoNotDrawMessage = false;
 				interfaceOn(); /* Sets the correct gadget list */
@@ -905,7 +866,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 				if (LastInv && _conditions->in(LastInv)) {
 					curInv = LastInv;
-					Test = getInvName(curInv);
+					_nextFileName = getInvName(curInv);
 				} else
 					decIncInv(&curInv, false);
 
@@ -951,7 +912,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				else
 					drawStaticMessage(kTextTurnRight);
 
-				CurFileName = " ";
+				_curFileName = " ";
 
 				OldDirection = Direction;
 
@@ -977,7 +938,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 					if (OldRoomNum != _roomNum) {
 						drawStaticMessage(kTextGoForward);
 						_roomsFound->inclElement(_roomNum); /* Potentially entered a new room */
-						CurFileName = " ";
+						_curFileName = " ";
 						forceDraw = true;
 					} else {
 						_anim->_doBlack = true;
@@ -1030,12 +991,12 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				screenUpdate();
 			}
 		}
-	} else if ((msgClass == GADGETUP) && Alternate) {
+	} else if ((msgClass == GADGETUP) && _alternate) {
 		_anim->_doBlack = true;
 
 		if (gadgetId == 0) {
 			eatMessages();
-			Alternate = false;
+			_alternate = false;
 			_anim->_doBlack = true;
 			DoNotDrawMessage = false;
 
@@ -1052,7 +1013,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 		if (gadgetId == 0) {
 			interfaceOff();
 			_anim->stopDiff();
-			CurFileName = " ";
+			_curFileName = " ";
 
 			doit = !saveRestoreGame();
 			CPtr = NULL;
@@ -1062,7 +1023,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			curInv = MAPNUM;
 			LastInv = MAPNUM;
 
-			Test = getInvName(curInv);
+			_nextFileName = getInvName(curInv);
 
 			drawPanel();
 
@@ -1101,7 +1062,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 			if ((curInv <= NumInv) && _conditions->in(curInv) &&
 			        Inventory[curInv].BInvName)
-				Test = getInvName(curInv);
+				_nextFileName = getInvName(curInv);
 
 			screenUpdate();
 		} else if (gadgetId == 3) { /* Left gadget */
@@ -1134,7 +1095,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 					getTime(&_crumbSecs, &_crumbMicros);
 
 					eatMessages();
-					Alternate = false;
+					_alternate = false;
 					_anim->_doBlack = true;
 					DoNotDrawMessage = false;
 
@@ -1176,20 +1137,20 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 			if (actionMode == 0) { /* Take something. */
 				if (doActionRule(Common::Point(curPos.x, curPos.y), actionMode, _roomNum, &CPtr))
-					CurFileName = NewFileName;
+					_curFileName = _newFileName;
 				else if (takeItem(curPos.x, curPos.y, &CPtr))
 					drawStaticMessage(kTextTakeItem);
 				else if (doActionRule(curPos, TAKEDEF - 1, _roomNum, &CPtr))
-					CurFileName = NewFileName;
+					_curFileName = _newFileName;
 				else if (doActionRule(curPos, TAKE - 1, 0, &CPtr))
-					CurFileName = NewFileName;
+					_curFileName = _newFileName;
 				else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
 					drawStaticMessage(kTextNothing);
 			} else if ((actionMode == 1) /* Manipulate an object */  ||
 			         (actionMode == 2) /* Open up a "door" */      ||
 			         (actionMode == 3)) { /* Close a "door" */
 				if (doActionRule(curPos, actionMode, _roomNum, &CPtr))
-					CurFileName = NewFileName;
+					_curFileName = _newFileName;
 				else if (!doActionRule(curPos, actionMode, 0, &CPtr)) {
 					if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
 						drawStaticMessage(kTextNothing);
@@ -1212,7 +1173,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			} else if ((actionMode == 5)  &&
 			         _conditions->in(curInv)) { /* Use an item on something else */
 				if (doOperateRule(curPos.x, curPos.y, curInv, &CPtr)) {
-					CurFileName = NewFileName;
+					_curFileName = _newFileName;
 
 					if (!_conditions->in(curInv))
 						decIncInv(&curInv, false);
@@ -1253,13 +1214,13 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			_event->setMousePos(Common::Point(scaleX((HCPtr->x1 + HCPtr->x2) / 2), scaleY((HCPtr->y1 + HCPtr->y2) / 2)));
 	} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) {
 		eatMessages();
-		Alternate = !Alternate;
+		_alternate = !_alternate;
 		_anim->_doBlack = true;
 		DoNotDrawMessage = false;
 		MainDisplay = true;
 		interfaceOn(); /* Sets the correct gadget list */
 
-		if (Alternate) {
+		if (_alternate) {
 			if (LastInv && _conditions->in(LastInv))
 				curInv = LastInv;
 			else
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 54a4f35..975f054 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -44,7 +44,6 @@ BitMap bit1, bit2, *DispBitMap = &bit1, *DrawBitMap = &bit1;
 
 extern bool stopsound;
 extern TextFont *MsgFont;
-extern const char *CurFileName;
 
 /*---------------------------------------------------------------------------*/
 /*------ From readPict.c.  Reads in pictures and animations from disk. ------*/
@@ -613,13 +612,13 @@ void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 	}
 
 	if (filename == NULL)
-		CurFileName = getPictName(cPtr);
+		g_lab->_curFileName = getPictName(cPtr);
 	else if (filename[0] > ' ')
-		CurFileName = filename;
+		g_lab->_curFileName = filename;
 	else
-		CurFileName = getPictName(cPtr);
+		g_lab->_curFileName = getPictName(cPtr);
 
-	byte *BitMapMem = readPictToMem(CurFileName, _screenWidth, lastY + 5);
+	byte *BitMapMem = readPictToMem(g_lab->_curFileName, _screenWidth, lastY + 5);
 	setPalette(_anim->_diffPalette, 256);
 
 	if (BitMapMem) {
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index dff74be..d9df22a 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -51,8 +51,8 @@ Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image
 		gptr->y = y;
 		gptr->GadgetID = id;
 		gptr->KeyEquiv = key;
-		gptr->Im = im;
-		gptr->ImAlt = imalt;
+		gptr->_image = im;
+		gptr->_altImage = imalt;
 		gptr->NextGadget = NULL;
 
 		return gptr;
@@ -82,7 +82,7 @@ void freeButtonList(Gadget *gptrlist) {
 /*****************************************************************************/
 void drawGadgetList(Gadget *gadlist) {
 	while (gadlist) {
-		gadlist->Im->drawImage(gadlist->x, gadlist->y);
+		gadlist->_image->drawImage(gadlist->x, gadlist->y);
 
 		if (GADGETOFF & gadlist->GadgetFlags)
 			ghoastGadget(gadlist, 1);
@@ -96,7 +96,7 @@ void drawGadgetList(Gadget *gadlist) {
 /* Ghoasts a gadget, and makes it unavailable for using.                     */
 /*****************************************************************************/
 void ghoastGadget(Gadget *curgad, uint16 pencolor) {
-	g_lab->ghoastRect(pencolor, curgad->x, curgad->y, curgad->x + curgad->Im->Width - 1, curgad->y + curgad->Im->Height - 1);
+	g_lab->ghoastRect(pencolor, curgad->x, curgad->y, curgad->x + curgad->_image->Width - 1, curgad->y + curgad->_image->Height - 1);
 	curgad->GadgetFlags |= GADGETOFF;
 }
 
@@ -106,7 +106,7 @@ void ghoastGadget(Gadget *curgad, uint16 pencolor) {
 /* Unghoasts a gadget, and makes it available again.                         */
 /*****************************************************************************/
 void unGhoastGadget(Gadget *curgad) {
-	curgad->Im->drawImage(curgad->x, curgad->y);
+	curgad->_image->drawImage(curgad->x, curgad->y);
 	curgad->GadgetFlags &= !(GADGETOFF);
 }
 
@@ -133,11 +133,11 @@ Gadget *LabEngine::checkNumGadgetHit(Gadget *gadlist, uint16 key) {
 		        (gadlist->KeyEquiv != 0 && makeGadgetKeyEquiv(key) == gadlist->KeyEquiv))
 		        && !(GADGETOFF & gadlist->GadgetFlags)) {
 			_event->mouseHide();
-			gadlist->ImAlt->drawImage(gadlist->x, gadlist->y);
+			gadlist->_altImage->drawImage(gadlist->x, gadlist->y);
 			_event->mouseShow();
 			g_system->delayMillis(80);
 			_event->mouseHide();
-			gadlist->Im->drawImage(gadlist->x, gadlist->y);
+			gadlist->_image->drawImage(gadlist->x, gadlist->y);
 			_event->mouseShow();
 
 			return gadlist;
diff --git a/engines/lab/interface.h b/engines/lab/interface.h
index 524c4ff..ceeb4a8 100644
--- a/engines/lab/interface.h
+++ b/engines/lab/interface.h
@@ -46,7 +46,7 @@ struct Gadget {
 	uint16 x, y, GadgetID;
 	uint16 KeyEquiv; // if not zero, a key that activates gadget
 	uint32 GadgetFlags;
-	Image *Im, *ImAlt;
+	Image *_image, *_altImage;
 	Gadget *NextGadget;
 };
 
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 22ab503..1c95746 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -89,6 +89,20 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 
     _lastMessageLong = false;
     _lastTooLong = false;
+	_interfaceOff = false;
+	_alternate = false;
+
+	for (int i = 0; i < 20; i++)
+		_moveImages[20] = nullptr;
+	
+	for (int i = 0; i < 10; i++)
+		_invImages[10] = nullptr;
+
+	_moveGadgetList = nullptr;
+	_invGadgetList = nullptr;
+	_curFileName = nullptr;
+	_nextFileName = nullptr;
+	_newFileName = nullptr;
 
 	//const Common::FSNode gameDataDir(ConfMan.get("path"));
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 348ce11..a439a3a 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -86,6 +86,12 @@ public:
 
 private:
 	uint32 _extraGameFeatures;
+	bool _interfaceOff;
+	bool _alternate;
+	Image *_moveImages[20];
+	Image *_invImages[10];
+	Gadget *_moveGadgetList;
+	Gadget *_invGadgetList;
 
 	// timing.cpp
 	void microDelay(uint32 secs, uint32 micros);
@@ -114,6 +120,11 @@ public:
 	byte *_tempScrollData;
 	bool _isHiRes;
 	byte *_displayBuffer;
+	const char *_curFileName;
+	const char *_nextFileName;
+	const char *_newFileName;  /* When ProcessRoom.c decides to change the filename
+                                    of the current picture. */
+
 
 private:
 	int _lastWaitTOFTicks;
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 52f6034..b20667b 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -59,10 +59,10 @@ struct TextFont;
 struct Gadget;
 
 struct SaveGameHeader {
-	byte version;
-	SaveStateDescriptor desc;
-	uint16 roomNumber;
-	uint16 direction;
+	byte _version;
+	SaveStateDescriptor _descr;
+	uint16 _roomNumber;
+	uint16 _direction;
 };
 
 /*----------------------------*/
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index d7a3e12..43f8fd3 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -171,12 +171,12 @@ static bool loadMapData() {
 	Down = new Image(buffer);
 	DownAlt = new Image(buffer);
 
-	backgadget.Im    = Back;
-	backgadget.ImAlt = BackAlt;
-	upgadget.Im      = Up;
-	upgadget.ImAlt   = UpAlt;
-	downgadget.Im    = Down;
-	downgadget.ImAlt = DownAlt;
+	backgadget._image    = Back;
+	backgadget._altImage = BackAlt;
+	upgadget._image      = Up;
+	upgadget._altImage   = UpAlt;
+	downgadget._image    = Down;
+	downgadget._altImage = DownAlt;
 
 	counter = 0;
 	gptr = MapGadgetList;
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index 38b8935..b676f2c 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -61,21 +61,21 @@ static byte MouseData[] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
 Gadget *EventManager::checkGadgetHit(Gadget *gadgetList, Common::Point pos) {
 	while (gadgetList != NULL) {
 		if ((pos.x >= gadgetList->x) && (pos.y >= gadgetList->y) &&
-		    (pos.x <= (gadgetList->x + gadgetList->Im->Width)) &&
-		    (pos.y <= (gadgetList->y + gadgetList->Im->Height)) &&
+		    (pos.x <= (gadgetList->x + gadgetList->_image->Width)) &&
+		    (pos.y <= (gadgetList->y + gadgetList->_image->Height)) &&
 		     !(GADGETOFF & gadgetList->GadgetFlags)) {
 			if (_vm->_isHiRes) {
 				_hitGadget = gadgetList;
 			} else {
 				mouseHide();
-				gadgetList->ImAlt->drawImage(gadgetList->x, gadgetList->y);
+				gadgetList->_altImage->drawImage(gadgetList->x, gadgetList->y);
 				mouseShow();
 
 				for (uint16 i = 0; i < 3; i++)
 					_vm->waitTOF();
 
 				mouseHide();
-				gadgetList->Im->drawImage(gadgetList->x, gadgetList->y);
+				gadgetList->_image->drawImage(gadgetList->x, gadgetList->y);
 				mouseShow();
 			}
 
@@ -143,14 +143,14 @@ void EventManager::updateMouse() {
 
 	if (_hitGadget) {
 		mouseHide();
-		_hitGadget->ImAlt->drawImage(_hitGadget->x, _hitGadget->y);
+		_hitGadget->_altImage->drawImage(_hitGadget->x, _hitGadget->y);
 		mouseShow();
 
 		for (uint16 i = 0; i < 3; i++)
 			_vm->waitTOF();
 
 		mouseHide();
-		_hitGadget->Im->drawImage(_hitGadget->x, _hitGadget->y);
+		_hitGadget->_image->drawImage(_hitGadget->x, _hitGadget->y);
 		mouseShow();
 		doUpdateDisplay = true;
 		_hitGadget = nullptr;
diff --git a/engines/lab/parsetypes.h b/engines/lab/parsetypes.h
index 3ca441a..82174b8 100644
--- a/engines/lab/parsetypes.h
+++ b/engines/lab/parsetypes.h
@@ -185,8 +185,6 @@ struct InventoryData {
 #define     MULTIMAZEF2     10
 #define     MULTIMAZEF3     11
 
-
-
 struct MapData {
 	uint16 x, y, PageNumber, SpecialID;
 	uint32 MapFlags;
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 0145c83..3eeb00d 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -47,10 +47,8 @@ namespace Lab {
 RoomData *_rooms;
 InventoryData *Inventory;
 uint16 NumInv, ManyRooms, HighestCondition, Direction;
-const char *NewFileName;
 
 extern bool DoNotDrawMessage, noupdatediff, QuitLab, MusicOn, LongWinInFront;
-extern const char *CurFileName;
 extern CloseDataPtr CPtr;
 
 /*****************************************************************************/
@@ -382,15 +380,15 @@ static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
 			break;
 
 		case FORCEUPDATE:
-			CurFileName = " ";
+			g_lab->_curFileName = " ";
 			break;
 
 		case SHOWCURPICT:
 			Test = getPictName(LCPtr);
 
-			if (strcmp(Test, CurFileName) != 0) {
-				CurFileName = Test;
-				readPict(CurFileName, true);
+			if (strcmp(Test, g_lab->_curFileName) != 0) {
+				g_lab->_curFileName = Test;
+				readPict(g_lab->_curFileName, true);
 			}
 
 			break;
@@ -642,9 +640,9 @@ bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *
 	CloseDataPtr TLCPtr;
 
 	if (roomNum)
-		NewFileName = NOFILE;
+		g_lab->_newFileName = NOFILE;
 	else
-		NewFileName = CurFileName;
+		g_lab->_newFileName = g_lab->_curFileName;
 
 	TLCPtr = getObject(pos.x, pos.y, *LCPtr);
 
@@ -694,7 +692,7 @@ static bool doOperateRuleSub(int16 ItemNum, int16 roomNum, CloseDataPtr LCPtr, C
 bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *LCPtr) {
 	CloseDataPtr TLCPtr;
 
-	NewFileName = NOFILE;
+	g_lab->_newFileName = NOFILE;
 
 	TLCPtr = getObject(x, y, *LCPtr);
 
@@ -707,7 +705,7 @@ bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *LCPtr) {
 	else if (doOperateRuleSub(ItemNum, g_lab->_roomNum, *LCPtr, LCPtr, true))
 		return true;
 	else {
-		NewFileName = CurFileName;
+		g_lab->_newFileName = g_lab->_curFileName;
 
 		if (doOperateRuleSub(ItemNum, 0, TLCPtr, LCPtr, false))
 			return true;
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index d54e6cb..41f7b27 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -89,10 +89,10 @@ bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
 		return false;
 
 	// Read in the version
-	header.version = in->readByte();
+	header._version = in->readByte();
 
 	// Check that the save version isn't newer than this binary
-	if (header.version > SAVEGAME_VERSION)
+	if (header._version > SAVEGAME_VERSION)
 		return false;
 
 	// Read in the save name
@@ -100,10 +100,10 @@ bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
 	char ch;
 	while ((ch = (char)in->readByte()) != '\0')
 		saveName += ch;
-	header.desc.setDescription(saveName);
+	header._descr.setDescription(saveName);
 
 	// Get the thumbnail
-	header.desc.setThumbnail(Graphics::loadThumbnail(*in));
+	header._descr.setThumbnail(Graphics::loadThumbnail(*in));
 
 	uint32 saveDate = in->readUint32BE();
 	uint16 saveTime = in->readUint16BE();
@@ -112,13 +112,13 @@ bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
 	int day = (saveDate >> 24) & 0xFF;
 	int month = (saveDate >> 16) & 0xFF;
 	int year = saveDate & 0xFFFF;
-	header.desc.setSaveDate(year, month, day);
+	header._descr.setSaveDate(year, month, day);
 
 	int hour = (saveTime >> 8) & 0xFF;
 	int minutes = saveTime & 0xFF;
-	header.desc.setSaveTime(hour, minutes);
+	header._descr.setSaveTime(hour, minutes);
 
-	header.desc.setPlayTime(playTime * 1000);
+	header._descr.setPlayTime(playTime * 1000);
 	g_engine->setTotalPlayTime(playTime * 1000);
 
 	return true;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 2744d3d..6c5ff02 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -551,12 +551,12 @@ static bool loadJournalData() {
 	if (!buffer)
 		return false;
 
-	BackG.Im = new Image(buffer);
-	BackG.ImAlt = new Image(buffer);
-	ForwardG.Im = new Image(buffer);
-	ForwardG.ImAlt = new Image(buffer);
-	CancelG.Im = new Image(buffer);
-	CancelG.ImAlt = new Image(buffer);
+	BackG._image = new Image(buffer);
+	BackG._altImage = new Image(buffer);
+	ForwardG._image = new Image(buffer);
+	ForwardG._altImage = new Image(buffer);
+	CancelG._image = new Image(buffer);
+	CancelG._altImage = new Image(buffer);
 
 	BackG.KeyEquiv = VKEY_LTARROW;
 	ForwardG.KeyEquiv = VKEY_RTARROW;


Commit: 88ede5d2d5865f88db1f77f127089574ec2a5e1c
    https://github.com/scummvm/scummvm/commit/88ede5d2d5865f88db1f77f127089574ec2a5e1c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:47+01:00

Commit Message:
LAB: Rename Image class members

Changed paths:
    engines/lab/graphics.cpp
    engines/lab/image.cpp
    engines/lab/image.h
    engines/lab/interface.cpp
    engines/lab/map.cpp
    engines/lab/mouse.cpp
    engines/lab/resource.cpp
    engines/lab/special.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 975f054..ce0b497 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -267,8 +267,8 @@ uint32 flowTextToMem(Image *destIm, void *font,     /* the TextAttr pointer */
 	uint32 res, vgabyte = g_lab->_screenBytesPerPage;
 	byte *tmp = g_lab->_currentDisplayBuffer;
 
-	g_lab->_currentDisplayBuffer = destIm->ImageData;
-	g_lab->_screenBytesPerPage = (uint32)destIm->Width * (int32)destIm->Height;
+	g_lab->_currentDisplayBuffer = destIm->_imageData;
+	g_lab->_screenBytesPerPage = (uint32)destIm->_width * (int32)destIm->_height;
 
 	res = flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str);
 
@@ -372,9 +372,9 @@ void LabEngine::doScrollBlack() {
 
 	allocFile((void **)&mem, (int32)width * (int32)height, "Temp Mem");
 
-	im.Width = width;
-	im.Height = height;
-	im.ImageData = mem;
+	im._width = width;
+	im._height = height;
+	im._imageData = mem;
 	_music->updateMusic();
 	im.readScreenImage(0, 0);
 	_music->updateMusic();
@@ -622,13 +622,13 @@ void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 	setPalette(_anim->_diffPalette, 256);
 
 	if (BitMapMem) {
-		imSource.Width = _screenWidth;
-		imSource.Height = lastY;
-		imSource.ImageData = BitMapMem;
+		imSource._width = _screenWidth;
+		imSource._height = lastY;
+		imSource._imageData = BitMapMem;
 
-		imDest.Width = _screenWidth;
-		imDest.Height = _screenHeight;
-		imDest.ImageData = getCurrentDrawingBuffer();
+		imDest._width = _screenWidth;
+		imDest._height = _screenHeight;
+		imDest._imageData = getCurrentDrawingBuffer();
 
 		for (uint16 i = 0; i < 2; i++) {
 			curY = i * 2;
@@ -640,7 +640,7 @@ void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 					linesdone = 0;
 				}
 
-				imDest.ImageData = getCurrentDrawingBuffer();
+				imDest._imageData = getCurrentDrawingBuffer();
 
 				bltBitMap(&imSource, 0, curY, &imDest, 0, curY, _screenWidth, 2);
 				ghoastRect(0, 0, curY, _screenWidth - 1, curY + 1);
@@ -659,7 +659,7 @@ void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 					linesdone = 0;
 				}
 
-				imDest.ImageData = getCurrentDrawingBuffer();
+				imDest._imageData = getCurrentDrawingBuffer();
 
 				if (curY == lastY)
 					bltBitMap(&imSource, 0, curY, &imDest, 0, curY, _screenWidth, 1);
diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp
index 636ac82..2107f7a 100644
--- a/engines/lab/image.cpp
+++ b/engines/lab/image.cpp
@@ -39,17 +39,17 @@ namespace Lab {
 Image::Image(byte **buffer) {
 	uint32 size;
 
-	Width = READ_LE_UINT16(*buffer);
-	Height = READ_LE_UINT16(*buffer + 2);
+	_width = READ_LE_UINT16(*buffer);
+	_height = READ_LE_UINT16(*buffer + 2);
 
 	*buffer += 8; /* sizeof(struct Image); */
 
-	size = Width * Height;
+	size = _width * _height;
 
 	if (1L & size)
 		size++;
 
-	ImageData = (byte *)(*buffer);
+	_imageData = (byte *)(*buffer);
 	(*buffer) += size;
 }
 
@@ -59,8 +59,8 @@ Image::Image(byte **buffer) {
 void Image::drawImage(uint16 x, uint16 y) {
 	int sx = 0, sy = 0;
 	int dx = x, dy = y;
-	int w = Width;
-	int h = Height;
+	int w = _width;
+	int h = _height;
 
 	if (dx < 0) {
 		sx -= dx;
@@ -81,12 +81,12 @@ void Image::drawImage(uint16 x, uint16 y) {
 		h = g_lab->_screenHeight - dy;
 
 	if ((w > 0) && (h > 0)) {
-		byte *s = ImageData + sy * Width + sx;
+		byte *s = _imageData + sy * _width + sx;
 		byte *d = g_lab->getCurrentDrawingBuffer() + dy * g_lab->_screenWidth + dx;
 
 		while (h-- > 0) {
 			memcpy(d, s, w);
-			s += Width;
+			s += _width;
 			d += g_lab->_screenWidth;
 		}
 	}
@@ -98,8 +98,8 @@ void Image::drawImage(uint16 x, uint16 y) {
 void Image::drawMaskImage(uint16 x, uint16 y) {
 	int sx = 0, sy = 0;
 	int dx = x, dy = y;
-	int w = Width;
-	int h = Height;
+	int w = _width;
+	int h = _height;
 
 	if (dx < 0) {
 		sx -= dx;
@@ -120,7 +120,7 @@ void Image::drawMaskImage(uint16 x, uint16 y) {
 		h = g_lab->_screenHeight - dy;
 
 	if ((w > 0) && (h > 0)) {
-		byte *s = ImageData + sy * Width + sx;
+		byte *s = _imageData + sy * _width + sx;
 		byte *d = g_lab->getCurrentDrawingBuffer() + dy * g_lab->_screenWidth + dx;
 
 		while (h-- > 0) {
@@ -135,7 +135,7 @@ void Image::drawMaskImage(uint16 x, uint16 y) {
 				else dd++;
 			}
 
-			s += Width;
+			s += _width;
 			d += g_lab->_screenWidth;
 		}
 	}
@@ -147,8 +147,8 @@ void Image::drawMaskImage(uint16 x, uint16 y) {
 void Image::readScreenImage(uint16 x, uint16 y) {
 	int sx = 0, sy = 0;
 	int	dx = x, dy = y;
-	int w = Width;
-	int h = Height;
+	int w = _width;
+	int h = _height;
 
  	if (dx < 0) {
 		sx -= dx;
@@ -169,12 +169,12 @@ void Image::readScreenImage(uint16 x, uint16 y) {
 		h = g_lab->_screenHeight - dy;
 
 	if ((w > 0) && (h > 0)) {
-		byte *s = ImageData + sy * Width + sx;
+		byte *s = _imageData + sy * _width + sx;
 		byte *d = g_lab->getCurrentDrawingBuffer() + dy * g_lab->_screenWidth + dx;
 
 		while (h-- > 0) {
 			memcpy(s, d, w);
-			s += Width;
+			s += _width;
 			d += g_lab->_screenWidth;
 		}
 	}
diff --git a/engines/lab/image.h b/engines/lab/image.h
index c8a001a..2befa93 100644
--- a/engines/lab/image.h
+++ b/engines/lab/image.h
@@ -35,12 +35,12 @@ namespace Lab {
 
 class Image {
 public:
-	uint16 Width;
-    uint16 Height;
-	byte *ImageData;
+	uint16 _width;
+    uint16 _height;
+	byte *_imageData;
 
-    Image() : Width(0), Height(0), ImageData(0) {}
-    Image(int w, int h, byte *d) : Width(w), Height(h), ImageData(d) {}
+    Image() : _width(0), _height(0), _imageData(0) {}
+    Image(int w, int h, byte *d) : _width(w), _height(h), _imageData(d) {}
     Image(byte **buffer);
 
     void drawImage(uint16 x, uint16 y);
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index d9df22a..ada510b 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -96,7 +96,7 @@ void drawGadgetList(Gadget *gadlist) {
 /* Ghoasts a gadget, and makes it unavailable for using.                     */
 /*****************************************************************************/
 void ghoastGadget(Gadget *curgad, uint16 pencolor) {
-	g_lab->ghoastRect(pencolor, curgad->x, curgad->y, curgad->x + curgad->_image->Width - 1, curgad->y + curgad->_image->Height - 1);
+	g_lab->ghoastRect(pencolor, curgad->x, curgad->y, curgad->x + curgad->_image->_width - 1, curgad->y + curgad->_image->_height - 1);
 	curgad->GadgetFlags |= GADGETOFF;
 }
 
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 43f8fd3..0690ed0 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -265,23 +265,23 @@ static void roomCords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16
 	case NORMAL:
 	case UPARROWROOM:
 	case DOWNARROWROOM:
-		(*x2) += Room->Width;
-		(*y2) += Room->Height;
+		(*x2) += Room->_width;
+		(*y2) += Room->_height;
 		break;
 
 	case BRIDGEROOM:
-		(*x2) += Bridge->Width;
-		(*y2) += Bridge->Height;
+		(*x2) += Bridge->_width;
+		(*y2) += Bridge->_height;
 		break;
 
 	case VCORRIDOR:
-		(*x2) += VRoom->Width;
-		(*y2) += VRoom->Height;
+		(*x2) += VRoom->_width;
+		(*y2) += VRoom->_height;
 		break;
 
 	case HCORRIDOR:
-		(*x2) += HRoom->Width;
-		(*y2) += HRoom->Height;
+		(*x2) += HRoom->_width;
+		(*y2) += HRoom->_height;
 		break;
 	}
 }
@@ -308,108 +308,108 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
 		else
 			UpArrowRoom->drawImage(x, y);
 
-		offset = (Room->Width - Path->Width) / 2;
+		offset = (Room->_width - Path->_width) / 2;
 
-		if ((NORTHDOOR & flags) && (y >= Path->Height))
-			Path->drawImage(x + offset, y - Path->Height);
+		if ((NORTHDOOR & flags) && (y >= Path->_height))
+			Path->drawImage(x + offset, y - Path->_height);
 
 		if (SOUTHDOOR & flags)
-			Path->drawImage(x + offset, y + Room->Height);
+			Path->drawImage(x + offset, y + Room->_height);
 
-		offset = (Room->Height - Path->Height) / 2;
+		offset = (Room->_height - Path->_height) / 2;
 
 		if (EASTDOOR & flags)
-			Path->drawImage(x + Room->Width, y + offset);
+			Path->drawImage(x + Room->_width, y + offset);
 
 		if (WESTDOOR & flags)
-			Path->drawImage(x - Path->Width, y + offset);
+			Path->drawImage(x - Path->_width, y + offset);
 
-		xx = x + (Room->Width - XMark->Width) / 2;
-		xy = y + (Room->Height - XMark->Height) / 2;
+		xx = x + (Room->_width - XMark->_width) / 2;
+		xy = y + (Room->_height - XMark->_height) / 2;
 
 		break;
 
 	case BRIDGEROOM:
 		Bridge->drawImage(x, y);
 
-		xx = x + (Bridge->Width - XMark->Width) / 2;
-		xy = y + (Bridge->Height - XMark->Height) / 2;
+		xx = x + (Bridge->_width - XMark->_width) / 2;
+		xy = y + (Bridge->_height - XMark->_height) / 2;
 
 		break;
 
 	case VCORRIDOR:
 		VRoom->drawImage(x, y);
 
-		offset = (VRoom->Width - Path->Width) / 2;
+		offset = (VRoom->_width - Path->_width) / 2;
 
 		if (NORTHDOOR & flags)
-			Path->drawImage(x + offset, y - Path->Height);
+			Path->drawImage(x + offset, y - Path->_height);
 
 		if (SOUTHDOOR & flags)
-			Path->drawImage(x + offset, y + VRoom->Height);
+			Path->drawImage(x + offset, y + VRoom->_height);
 
-		offset = (Room->Height - Path->Height) / 2;
+		offset = (Room->_height - Path->_height) / 2;
 
 		if (EASTDOOR & flags)
-			Path->drawImage(x + VRoom->Width, y + offset);
+			Path->drawImage(x + VRoom->_width, y + offset);
 
 		if (WESTDOOR & flags)
-			Path->drawImage(x - Path->Width, y + offset);
+			Path->drawImage(x - Path->_width, y + offset);
 
 		if (EASTBDOOR & flags)
-			Path->drawImage(x + VRoom->Width, y - offset - Path->Height + VRoom->Height);
+			Path->drawImage(x + VRoom->_width, y - offset - Path->_height + VRoom->_height);
 
 		if (WESTBDOOR & flags)
-			Path->drawImage(x - Path->Width, y - offset - Path->Height + VRoom->Height);
+			Path->drawImage(x - Path->_width, y - offset - Path->_height + VRoom->_height);
 
-		offset = (VRoom->Height - Path->Height) / 2;
+		offset = (VRoom->_height - Path->_height) / 2;
 
 		if (EASTMDOOR & flags)
-			Path->drawImage(x + VRoom->Width, y - offset - Path->Height + VRoom->Height);
+			Path->drawImage(x + VRoom->_width, y - offset - Path->_height + VRoom->_height);
 
 		if (WESTMDOOR & flags)
-			Path->drawImage(x - Path->Width, y - offset - Path->Height + VRoom->Height);
+			Path->drawImage(x - Path->_width, y - offset - Path->_height + VRoom->_height);
 
-		xx = x + (VRoom->Width - XMark->Width) / 2;
-		xy = y + (VRoom->Height - XMark->Height) / 2;
+		xx = x + (VRoom->_width - XMark->_width) / 2;
+		xy = y + (VRoom->_height - XMark->_height) / 2;
 
 		break;
 
 	case HCORRIDOR:
 		HRoom->drawImage(x, y);
 
-		offset = (Room->Width - Path->Width) / 2;
+		offset = (Room->_width - Path->_width) / 2;
 
 		if (NORTHDOOR & flags)
-			Path->drawImage(x + offset, y - Path->Height);
+			Path->drawImage(x + offset, y - Path->_height);
 
 		if (SOUTHDOOR & flags)
-			Path->drawImage(x + offset, y + Room->Height);
+			Path->drawImage(x + offset, y + Room->_height);
 
 		if (NORTHRDOOR & flags)
-			Path->drawImage(x - offset - Path->Width + HRoom->Width, y - Path->Height);
+			Path->drawImage(x - offset - Path->_width + HRoom->_width, y - Path->_height);
 
 		if (SOUTHRDOOR & flags)
-			Path->drawImage(x - offset - Path->Width + HRoom->Width, y + Room->Height);
+			Path->drawImage(x - offset - Path->_width + HRoom->_width, y + Room->_height);
 
-		offset = (HRoom->Width - Path->Width) / 2;
+		offset = (HRoom->_width - Path->_width) / 2;
 
 		if (NORTHMDOOR & flags)
-			Path->drawImage(x - offset - Path->Width + HRoom->Width, y - Path->Height);
+			Path->drawImage(x - offset - Path->_width + HRoom->_width, y - Path->_height);
 
 		if (SOUTHMDOOR & flags)
-			Path->drawImage(x - offset - Path->Width + HRoom->Width, y + Room->Height);
+			Path->drawImage(x - offset - Path->_width + HRoom->_width, y + Room->_height);
 
-		offset = (Room->Height - Path->Height) / 2;
+		offset = (Room->_height - Path->_height) / 2;
 
 		if (EASTDOOR & flags)
-			Path->drawImage(x + HRoom->Width, y + offset);
+			Path->drawImage(x + HRoom->_width, y + offset);
 
 		if (WESTDOOR & flags)
-			Path->drawImage(x - Path->Width, y + offset);
+			Path->drawImage(x - Path->_width, y + offset);
 
-		xx = x + (HRoom->Width - XMark->Width) / 2;
-		xy = y + (HRoom->Height - XMark->Height) / 2;
+		xx = x + (HRoom->_width - XMark->_width) / 2;
+		xy = y + (HRoom->_height - XMark->_height) / 2;
 
 		break;
 
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
index b676f2c..45dd53f 100644
--- a/engines/lab/mouse.cpp
+++ b/engines/lab/mouse.cpp
@@ -61,8 +61,8 @@ static byte MouseData[] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
 Gadget *EventManager::checkGadgetHit(Gadget *gadgetList, Common::Point pos) {
 	while (gadgetList != NULL) {
 		if ((pos.x >= gadgetList->x) && (pos.y >= gadgetList->y) &&
-		    (pos.x <= (gadgetList->x + gadgetList->_image->Width)) &&
-		    (pos.y <= (gadgetList->y + gadgetList->_image->Height)) &&
+		    (pos.x <= (gadgetList->x + gadgetList->_image->_width)) &&
+		    (pos.y <= (gadgetList->y + gadgetList->_image->_height)) &&
 		     !(GADGETOFF & gadgetList->GadgetFlags)) {
 			if (_vm->_isHiRes) {
 				_hitGadget = gadgetList;
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index b1ad528..70233de 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -300,7 +300,7 @@ CloseData *Resource::readCloseUps(uint16 depth, Common::File *file) {
 			prev = closeup;
 		}
 	} while (c != '\0');
-	
+
 	return head;
 }
 
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 6c5ff02..4d71b44 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -155,7 +155,7 @@ void showCombination(const char *filename) {
 	for (uint16 CurBit = 0; CurBit < 10; CurBit++)
 		Images[CurBit] = new Image(buffer);
 
-	allocFile((void **)&g_lab->_tempScrollData, Images[0]->Width * Images[0]->Height * 2L, "tempdata");
+	allocFile((void **)&g_lab->_tempScrollData, Images[0]->_width * Images[0]->_height * 2L, "tempdata");
 
 	doCombination();
 
@@ -179,22 +179,22 @@ static void changeCombination(uint16 number) {
 
 	combnum = combination[number];
 
-	display.ImageData = g_lab->getCurrentDrawingBuffer();
-	display.Width     = g_lab->_screenWidth;
-	display.Height    = g_lab->_screenHeight;
+	display._imageData = g_lab->getCurrentDrawingBuffer();
+	display._width     = g_lab->_screenWidth;
+	display._height    = g_lab->_screenHeight;
 
-	for (uint16 i = 1; i <= (Images[combnum]->Height / 2); i++) {
+	for (uint16 i = 1; i <= (Images[combnum]->_height / 2); i++) {
 		if (g_lab->_isHiRes) {
 			if (i & 1)
 				g_lab->waitTOF();
 		} else
 			g_lab->waitTOF();
 
-		display.ImageData = g_lab->getCurrentDrawingBuffer();
+		display._imageData = g_lab->getCurrentDrawingBuffer();
 
-		g_lab->scrollDisplayY(2, VGAScaleX(combx[number]), VGAScaleY(65), VGAScaleX(combx[number]) + (Images[combnum])->Width - 1, VGAScaleY(65) + (Images[combnum])->Height);
+		g_lab->scrollDisplayY(2, VGAScaleX(combx[number]), VGAScaleY(65), VGAScaleX(combx[number]) + (Images[combnum])->_width - 1, VGAScaleY(65) + (Images[combnum])->_height);
 
-		g_lab->bltBitMap(Images[combnum], 0, (Images[combnum])->Height - (2 * i), &(display), VGAScaleX(combx[number]), VGAScaleY(65), (Images[combnum])->Width, 2);
+		g_lab->bltBitMap(Images[combnum], 0, (Images[combnum])->_height - (2 * i), &(display), VGAScaleX(combx[number]), VGAScaleY(65), (Images[combnum])->_width, 2);
 	}
 
 	for (uint16 i = 0; i < 6; i++)
@@ -306,7 +306,7 @@ void showTile(const char *filename, bool showsolution) {
 	for (uint16 curBit = start; curBit < 16; curBit++)
 		Tiles[curBit] = new Image(buffer);
 
-	allocFile((void **)&g_lab->_tempScrollData, Tiles[1]->Width * Tiles[1]->Height * 2L, "tempdata");
+	allocFile((void **)&g_lab->_tempScrollData, Tiles[1]->_width * Tiles[1]->_height * 2L, "tempdata");
 
 	doTile(showsolution);
 
@@ -625,14 +625,14 @@ static void turnPage(bool FromLeft) {
 		for (int i = 0; i < g_lab->_screenWidth; i += 8) {
 			g_lab->_music->updateMusic();
 			g_lab->waitTOF();
-			ScreenImage.ImageData = g_lab->getCurrentDrawingBuffer();
+			ScreenImage._imageData = g_lab->getCurrentDrawingBuffer();
 			g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight);
 		}
 	} else {
 		for (int i = (g_lab->_screenWidth - 8); i > 0; i -= 8) {
 			g_lab->_music->updateMusic();
 			g_lab->waitTOF();
-			ScreenImage.ImageData = g_lab->getCurrentDrawingBuffer();
+			ScreenImage._imageData = g_lab->getCurrentDrawingBuffer();
 			g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight);
 		}
 	}
@@ -648,11 +648,11 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 	_music->updateMusic();
 
 	if (!GotBackImage)
-		JBackImage.ImageData = loadBackPict("P:Journal.pic", true);
+		JBackImage._imageData = loadBackPict("P:Journal.pic", true);
 
 	drawJournalText();
 
-	ScreenImage.ImageData = getCurrentDrawingBuffer();
+	ScreenImage._imageData = getCurrentDrawingBuffer();
 
 	if (wipenum == 0)
 		bltBitMap(&JBackImage, 0, 0, &ScreenImage, 0, 0, _screenWidth, _screenHeight);
@@ -674,7 +674,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 		fade(true, 0);
 
 	g_lab->_anim->_noPalChange = true;
-	JBackImage.ImageData = readPictToMem("P:Journal.pic", _screenWidth, _screenHeight);
+	JBackImage._imageData = readPictToMem("P:Journal.pic", _screenWidth, _screenHeight);
 	GotBackImage = true;
 
 	eatMessages();
@@ -735,15 +735,15 @@ void LabEngine::doJournal() {
 	lastpage    = false;
 	GotBackImage = false;
 
-	JBackImage.Width = _screenWidth;
-	JBackImage.Height = _screenHeight;
-	JBackImage.ImageData   = NULL;
+	JBackImage._width = _screenWidth;
+	JBackImage._height = _screenHeight;
+	JBackImage._imageData   = NULL;
 
 	BackG.NextGadget = &CancelG;
 	CancelG.NextGadget = &ForwardG;
 
 	ScreenImage = JBackImage;
-	ScreenImage.ImageData = getCurrentDrawingBuffer();
+	ScreenImage._imageData = getCurrentDrawingBuffer();
 
 	_music->updateMusic();
 	loadJournalData();
@@ -757,7 +757,7 @@ void LabEngine::doJournal() {
 	fade(false, 0);
 	_event->mouseHide();
 
-	ScreenImage.ImageData = getCurrentDrawingBuffer();
+	ScreenImage._imageData = getCurrentDrawingBuffer();
 
 	setAPen(0);
 	rectFill(0, 0, _screenWidth - 1, _screenHeight - 1);
@@ -844,8 +844,8 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
 		text += 2;
 
 		fheight = textHeight(monitorFont);
-		x1 = MonButton->Width + VGAScaleX(3);
-		MonGadHeight = MonButton->Height + VGAScaleY(3);
+		x1 = MonButton->_width + VGAScaleX(3);
+		MonGadHeight = MonButton->_height + VGAScaleY(3);
 
 		if (MonGadHeight > fheight)
 			yspacing = MonGadHeight - fheight;
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 3525e77..9ccb5f5 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -169,20 +169,20 @@ void LabEngine::bltBitMap(Image *imSource, uint16 xs, uint16 ys, Image *imDest,
 		dy = 0;
 	}
 
-	if (dx + w > imDest->Width)
-		w = imDest->Width - dx;
+	if (dx + w > imDest->_width)
+		w = imDest->_width - dx;
 
-	if (dy + h > imDest->Height)
-		h = imDest->Height - dy;
+	if (dy + h > imDest->_height)
+		h = imDest->_height - dy;
 
 	if (w > 0 && h > 0) {
-		byte *s = imSource->ImageData + sy * imSource->Width + sx;
-		byte *d = imDest->ImageData + dy * imDest->Width + dx;
+		byte *s = imSource->_imageData + sy * imSource->_width + sx;
+		byte *d = imDest->_imageData + dy * imDest->_width + dx;
 
 		while (h-- > 0) {
 			memcpy(d, s, w);
-			s += imSource->Width;
-			d += imDest->Width;
+			s += imSource->_width;
+			d += imDest->_width;
 		}
 	}
 }
@@ -196,7 +196,7 @@ void LabEngine::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16
 	Image im;
 	uint16 temp;
 
-	im.ImageData = _tempScrollData;
+	im._imageData = _tempScrollData;
 
 	if (x1 > x2) {
 		temp = x2;
@@ -211,8 +211,8 @@ void LabEngine::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16
 	}
 
 	if (dx > 0) {
-		im.Width = x2 - x1 + 1 - dx;
-		im.Height = y2 - y1 + 1;
+		im._width = x2 - x1 + 1 - dx;
+		im._height = y2 - y1 + 1;
 
 		im.readScreenImage(x1, y1);
 		im.drawImage(x1 + dx, y1);
@@ -220,8 +220,8 @@ void LabEngine::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16
 		setAPen(0);
 		rectFill(x1, y1, x1 + dx - 1, y2);
 	} else if (dx < 0) {
-		im.Width = x2 - x1 + 1 + dx;
-		im.Height = y2 - y1 + 1;
+		im._width = x2 - x1 + 1 + dx;
+		im._height = y2 - y1 + 1;
 
 		im.readScreenImage(x1 - dx, y1);
 		im.drawImage(x1, y1);
@@ -238,7 +238,7 @@ void LabEngine::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16
 	Image im;
 	uint16 temp;
 
-	im.ImageData = _tempScrollData;
+	im._imageData = _tempScrollData;
 
 	if (x1 > x2) {
 		temp = x2;
@@ -253,8 +253,8 @@ void LabEngine::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16
 	}
 
 	if (dy > 0) {
-		im.Width = x2 - x1 + 1;
-		im.Height = y2 - y1 + 1 - dy;
+		im._width = x2 - x1 + 1;
+		im._height = y2 - y1 + 1 - dy;
 
 		im.readScreenImage(x1, y1);
 		im.drawImage(x1, y1 + dy);
@@ -262,8 +262,8 @@ void LabEngine::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16
 		setAPen(0);
 		rectFill(x1, y1, x2, y1 + dy - 1);
 	} else if (dy < 0) {
-		im.Width = x2 - x1 + 1;
-		im.Height = y2 - y1 + 1 + dy;
+		im._width = x2 - x1 + 1;
+		im._height = y2 - y1 + 1 + dy;
 
 		im.readScreenImage(x1, y1 - dy);
 		im.drawImage(x1, y1);


Commit: 17d6e5e8608dfbf70fb08507da1ac196e04c0654
    https://github.com/scummvm/scummvm/commit/17d6e5e8608dfbf70fb08507da1ac196e04c0654
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:47+01:00

Commit Message:
LAB: Moved bltBitMap to Image class

Changed paths:
    engines/lab/graphics.cpp
    engines/lab/image.cpp
    engines/lab/image.h
    engines/lab/lab.h
    engines/lab/special.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index ce0b497..2f2109a 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -642,7 +642,7 @@ void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 
 				imDest._imageData = getCurrentDrawingBuffer();
 
-				bltBitMap(&imSource, 0, curY, &imDest, 0, curY, _screenWidth, 2);
+				imSource.bltBitMap(0, curY, &imDest, 0, curY, _screenWidth, 2);
 				ghoastRect(0, 0, curY, _screenWidth - 1, curY + 1);
 				curY += 4;
 				linesdone++;
@@ -662,9 +662,9 @@ void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 				imDest._imageData = getCurrentDrawingBuffer();
 
 				if (curY == lastY)
-					bltBitMap(&imSource, 0, curY, &imDest, 0, curY, _screenWidth, 1);
+					imSource.bltBitMap(0, curY, &imDest, 0, curY, _screenWidth, 1);
 				else
-					bltBitMap(&imSource, 0, curY, &imDest, 0, curY, _screenWidth, 2);
+					imSource.bltBitMap(0, curY, &imDest, 0, curY, _screenWidth, 2);
 
 				curY += 4;
 				linesdone++;
diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp
index 2107f7a..0fd7425 100644
--- a/engines/lab/image.cpp
+++ b/engines/lab/image.cpp
@@ -180,4 +180,49 @@ void Image::readScreenImage(uint16 x, uint16 y) {
 	}
 }
 
+/*****************************************************************************/
+/* Blits a piece of one image to another.                                    */
+/* NOTE: for our purposes, assumes that ImDest is to be in VGA memory.       */
+/*****************************************************************************/
+void Image::bltBitMap(uint16 xs, uint16 ys, Image *imDest,
+					uint16 xd, uint16 yd, uint16 width, uint16 height) {
+	// I think the old code assumed that the source image data was valid for the given box.
+	// I will proceed on that assumption.
+	int sx = xs;
+	int sy = ys;
+	int dx = xd;
+	int dy = yd;
+	int w = width;
+	int h = height;
+
+	if (dx < 0) {
+		sx -= dx;
+		w += dx;
+		dx = 0;
+	}
+
+	if (dy < 0) {
+		sy -= dy;
+		w += dy;
+		dy = 0;
+	}
+
+	if (dx + w > imDest->_width)
+		w = imDest->_width - dx;
+
+	if (dy + h > imDest->_height)
+		h = imDest->_height - dy;
+
+	if (w > 0 && h > 0) {
+		byte *s = _imageData + sy * _width + sx;
+		byte *d = imDest->_imageData + dy * imDest->_width + dx;
+
+		while (h-- > 0) {
+			memcpy(d, s, w);
+			s += _width;
+			d += imDest->_width;
+		}
+	}
+}
+
 } // End of namespace Lab
diff --git a/engines/lab/image.h b/engines/lab/image.h
index 2befa93..450c177 100644
--- a/engines/lab/image.h
+++ b/engines/lab/image.h
@@ -46,6 +46,7 @@ public:
     void drawImage(uint16 x, uint16 y);
     void drawMaskImage(uint16 x, uint16 y);
     void readScreenImage(uint16 x, uint16 y);
+	void bltBitMap(uint16 xs, uint16 ys, Image *ImDest, uint16 xd, uint16 yd, uint16 width, uint16 height);
 };
 
 
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index a439a3a..f4b223a 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -145,7 +145,6 @@ public:
 	void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-	void bltBitMap(Image *ImSource, uint16 xs, uint16 ys, Image *ImDest, uint16 xd, uint16 yd, uint16 width, uint16 height);
 	void setPalette(void *cmap, uint16 numcolors);
 	void drawHLine(uint16 x, uint16 y1, uint16 y2);
 	void drawVLine(uint16 x1, uint16 y, uint16 x2);
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 4d71b44..419e0d3 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -194,7 +194,7 @@ static void changeCombination(uint16 number) {
 
 		g_lab->scrollDisplayY(2, VGAScaleX(combx[number]), VGAScaleY(65), VGAScaleX(combx[number]) + (Images[combnum])->_width - 1, VGAScaleY(65) + (Images[combnum])->_height);
 
-		g_lab->bltBitMap(Images[combnum], 0, (Images[combnum])->_height - (2 * i), &(display), VGAScaleX(combx[number]), VGAScaleY(65), (Images[combnum])->_width, 2);
+		Images[combnum]->bltBitMap(0, (Images[combnum])->_height - (2 * i), &(display), VGAScaleX(combx[number]), VGAScaleY(65), (Images[combnum])->_width, 2);
 	}
 
 	for (uint16 i = 0; i < 6; i++)
@@ -626,14 +626,14 @@ static void turnPage(bool FromLeft) {
 			g_lab->_music->updateMusic();
 			g_lab->waitTOF();
 			ScreenImage._imageData = g_lab->getCurrentDrawingBuffer();
-			g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight);
+			JBackImage.bltBitMap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight);
 		}
 	} else {
 		for (int i = (g_lab->_screenWidth - 8); i > 0; i -= 8) {
 			g_lab->_music->updateMusic();
 			g_lab->waitTOF();
 			ScreenImage._imageData = g_lab->getCurrentDrawingBuffer();
-			g_lab->bltBitMap(&JBackImage, i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight);
+			JBackImage.bltBitMap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight);
 		}
 	}
 }
@@ -655,7 +655,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 	ScreenImage._imageData = getCurrentDrawingBuffer();
 
 	if (wipenum == 0)
-		bltBitMap(&JBackImage, 0, 0, &ScreenImage, 0, 0, _screenWidth, _screenHeight);
+		JBackImage.bltBitMap(0, 0, &ScreenImage, 0, 0, _screenWidth, _screenHeight);
 	else
 		turnPage((bool)(wipenum == 1));
 
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 9ccb5f5..959218e 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -143,51 +143,6 @@ byte *LabEngine::getCurrentDrawingBuffer() {
 }
 
 /*****************************************************************************/
-/* Blits a piece of one image to another.                                    */
-/* NOTE: for our purposes, assumes that ImDest is to be in VGA memory.       */
-/*****************************************************************************/
-void LabEngine::bltBitMap(Image *imSource, uint16 xs, uint16 ys, Image *imDest,
-					uint16 xd, uint16 yd, uint16 width, uint16 height) {
-	// I think the old code assumed that the source image data was valid for the given box.
-	// I will proceed on that assumption.
-	int sx = xs;
-	int sy = ys;
-	int dx = xd;
-	int dy = yd;
-	int w = width;
-	int h = height;
-
-	if (dx < 0) {
-		sx -= dx;
-		w += dx;
-		dx = 0;
-	}
-
-	if (dy < 0) {
-		sy -= dy;
-		w += dy;
-		dy = 0;
-	}
-
-	if (dx + w > imDest->_width)
-		w = imDest->_width - dx;
-
-	if (dy + h > imDest->_height)
-		h = imDest->_height - dy;
-
-	if (w > 0 && h > 0) {
-		byte *s = imSource->_imageData + sy * imSource->_width + sx;
-		byte *d = imDest->_imageData + dy * imDest->_width + dx;
-
-		while (h-- > 0) {
-			memcpy(d, s, w);
-			s += imSource->_width;
-			d += imDest->_width;
-		}
-	}
-}
-
-/*****************************************************************************/
 /* Scrolls the display in the x direction by blitting.                       */
 /* The _tempScrollData variable must be initialized to some memory, or this   */
 /* function will fail.                                                       */


Commit: ab2519f57b50a8d92a7f6fa192f453e2cf0e6888
    https://github.com/scummvm/scummvm/commit/ab2519f57b50a8d92a7f6fa192f453e2cf0e6888
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:47+01:00

Commit Message:
LAB: Get rid of machine.cpp

Changed paths:
  R engines/lab/machine.cpp
    engines/lab/graphics.cpp
    engines/lab/labfile.cpp
    engines/lab/module.mk



diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 2f2109a..9de6400 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -45,6 +45,76 @@ BitMap bit1, bit2, *DispBitMap = &bit1, *DrawBitMap = &bit1;
 extern bool stopsound;
 extern TextFont *MsgFont;
 
+
+/*****************************************************************************/
+/* Scales the x co-ordinates to that of the new display.  In the room parser */
+/* file, co-ordinates are set up on a 360x336 display.                       */
+/*****************************************************************************/
+uint16 scaleX(uint16 x) {
+	if (g_lab->_isHiRes)
+		return (uint16)((x * 16) / 9);
+	else
+		return (uint16)((x * 8) / 9);
+}
+
+/*****************************************************************************/
+/* Scales the y co-ordinates to that of the new display.  In the room parser */
+/* file, co-ordinates are set up on a 368x336 display.                       */
+/*****************************************************************************/
+uint16 scaleY(uint16 y) {
+	if (g_lab->_isHiRes)
+		return (y + (y / 14));
+	else
+		return ((y * 10) / 24);
+}
+
+/*****************************************************************************/
+/* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
+/*****************************************************************************/
+int16 VGAScaleX(int16 x) {
+	if (g_lab->_isHiRes)
+		return (x * 2);
+	else
+		return x;
+}
+
+/*****************************************************************************/
+/* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
+/*****************************************************************************/
+int16 VGAScaleY(int16 y) {
+	if (g_lab->_isHiRes)
+		return ((y * 12) / 5);
+	else
+		return y;
+}
+
+uint16 SVGACord(uint16 cord) {
+	if (g_lab->_isHiRes)
+		return cord;
+	else
+		return 0;
+}
+
+/*****************************************************************************/
+/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
+/*****************************************************************************/
+int VGAUnScaleX(int x) {
+	if (g_lab->_isHiRes)
+		return (x / 2);
+	else
+		return x;
+}
+
+/*****************************************************************************/
+/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
+/*****************************************************************************/
+int VGAUnScaleY(int y) {
+	if (g_lab->_isHiRes)
+		return ((y * 5) / 12);
+	else
+		return y;
+}
+
 /*---------------------------------------------------------------------------*/
 /*------ From readPict.c.  Reads in pictures and animations from disk. ------*/
 /*---------------------------------------------------------------------------*/
diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
index 83f3b0f..99a02c1 100644
--- a/engines/lab/labfile.cpp
+++ b/engines/lab/labfile.cpp
@@ -28,6 +28,7 @@
  *
  */
 
+#include "lab/lab.h"
 #include "lab/labfun.h"
 #include "lab/mouse.h"
 #include "common/file.h"
@@ -309,4 +310,46 @@ void freeAllStolenMem() {
 	_memPlace = buffer;
 }
 
+static char NewFileName[255];
+
+/*****************************************************************************/
+/* Modifies the filename so that paths and stuff are correct.  Should mostly  */
+/* deal with assigns and the '/' instead of '\' on IBM systems.              */
+/*                                                                           */
+/* NOTE: Make a *copy* of the string, and modify that.  It would be a real   */
+/* *bad* idea to modify the original.  Since Labyrinth only focuses its      */
+/* attention to one file at a time, it would be fine to have one variable    */
+/* not on the stack which is used to store the new filename.                 */
+/*****************************************************************************/
+char *translateFileName(const char *filename) {
+	Common::String fileNameStr = filename;
+	fileNameStr.toUppercase();
+	Common::String fileNameStrFinal;
+
+	if (fileNameStr.hasPrefix("P:")) {
+		if (g_lab->_isHiRes)
+			fileNameStrFinal = "GAME/SPICT/";
+		else
+			fileNameStrFinal = "GAME/PICT/";
+	} else if (fileNameStr.hasPrefix("LAB:"))
+		fileNameStrFinal = "GAME/";
+	else if (fileNameStr.hasPrefix("MUSIC:"))
+		fileNameStrFinal = "GAME/MUSIC/";
+
+	if (fileNameStr.contains(':')) {
+		while (fileNameStr[0] != ':') {
+			fileNameStr.deleteChar(0);
+		}
+
+		fileNameStr.deleteChar(0);
+	}
+
+	fileNameStrFinal += fileNameStr;
+
+	strcpy(NewFileName, fileNameStrFinal.c_str());
+
+	return NewFileName;
+}
+
+
 } // End of namespace Lab
diff --git a/engines/lab/machine.cpp b/engines/lab/machine.cpp
deleted file mode 100644
index 0667772..0000000
--- a/engines/lab/machine.cpp
+++ /dev/null
@@ -1,146 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "common/str.h"
-#include "lab/lab.h"
-
-namespace Lab {
-
-/*****************************************************************************/
-/* Scales the x co-ordinates to that of the new display.  In the room parser */
-/* file, co-ordinates are set up on a 360x336 display.                       */
-/*****************************************************************************/
-uint16 scaleX(uint16 x) {
-	if (g_lab->_isHiRes)
-		return (uint16)((x * 16) / 9);
-	else
-		return (uint16)((x * 8) / 9);
-}
-
-/*****************************************************************************/
-/* Scales the y co-ordinates to that of the new display.  In the room parser */
-/* file, co-ordinates are set up on a 368x336 display.                       */
-/*****************************************************************************/
-uint16 scaleY(uint16 y) {
-	if (g_lab->_isHiRes)
-		return (y + (y / 14));
-	else
-		return ((y * 10) / 24);
-}
-
-/*****************************************************************************/
-/* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
-/*****************************************************************************/
-int16 VGAScaleX(int16 x) {
-	if (g_lab->_isHiRes)
-		return (x * 2);
-	else
-		return x;
-}
-
-/*****************************************************************************/
-/* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
-/*****************************************************************************/
-int16 VGAScaleY(int16 y) {
-	if (g_lab->_isHiRes)
-		return ((y * 12) / 5);
-	else
-		return y;
-}
-
-uint16 SVGACord(uint16 cord) {
-	if (g_lab->_isHiRes)
-		return cord;
-	else
-		return 0;
-}
-
-/*****************************************************************************/
-/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
-/*****************************************************************************/
-int VGAUnScaleX(int x) {
-	if (g_lab->_isHiRes)
-		return (x / 2);
-	else
-		return x;
-}
-
-/*****************************************************************************/
-/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
-/*****************************************************************************/
-int VGAUnScaleY(int y) {
-	if (g_lab->_isHiRes)
-		return ((y * 5) / 12);
-	else
-		return y;
-}
-
-static char NewFileName[255];
-
-/*****************************************************************************/
-/* Modifies the filename so that paths and stuff are correct.  Should mostly  */
-/* deal with assigns and the '/' instead of '\' on IBM systems.              */
-/*                                                                           */
-/* NOTE: Make a *copy* of the string, and modify that.  It would be a real   */
-/* *bad* idea to modify the original.  Since Labyrinth only focuses its      */
-/* attention to one file at a time, it would be fine to have one variable    */
-/* not on the stack which is used to store the new filename.                 */
-/*****************************************************************************/
-char *translateFileName(const char *filename) {
-	Common::String fileNameStr = filename;
-	fileNameStr.toUppercase();
-	Common::String fileNameStrFinal;
-
-	if (fileNameStr.hasPrefix("P:")) {
-		if (g_lab->_isHiRes)
-			fileNameStrFinal = "GAME/SPICT/";
-		else
-			fileNameStrFinal = "GAME/PICT/";
-	} else if (fileNameStr.hasPrefix("LAB:"))
-		fileNameStrFinal = "GAME/";
-	else if (fileNameStr.hasPrefix("MUSIC:"))
-		fileNameStrFinal = "GAME/MUSIC/";
-
-	if (fileNameStr.contains(':')) {
-		while (fileNameStr[0] != ':') {
-			fileNameStr.deleteChar(0);
-		}
-
-		fileNameStr.deleteChar(0);
-	}
-
-	fileNameStrFinal += fileNameStr;
-
-	strcpy(NewFileName, fileNameStrFinal.c_str());
-
-	return NewFileName;
-}
-
-} // End of namespace Lab
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index 53b9f4e..cfe867a 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -12,7 +12,6 @@ MODULE_OBJS := \
 	lab.o \
 	labfile.o \
 	labsets.o \
-	machine.o \
 	map.o \
 	mouse.o \
 	music.o \


Commit: adbb0ce0c52e2a9f0f6c52adf1d83bf351e8e1fb
    https://github.com/scummvm/scummvm/commit/adbb0ce0c52e2a9f0f6c52adf1d83bf351e8e1fb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:47+01:00

Commit Message:
LAB: Renamed mouse.* to eventman.*

Changed paths:
  A engines/lab/eventman.cpp
  A engines/lab/eventman.h
  R engines/lab/mouse.cpp
  R engines/lab/mouse.h
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/interface.cpp
    engines/lab/lab.h
    engines/lab/labfile.cpp
    engines/lab/map.cpp
    engines/lab/module.mk
    engines/lab/music.cpp
    engines/lab/special.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index fe3c428..1823fe6 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -36,7 +36,6 @@
 #include "lab/intro.h"
 #include "lab/parsefun.h"
 #include "lab/interface.h"
-#include "lab/mouse.h"
 #include "lab/resource.h"
 
 namespace Lab {
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
new file mode 100644
index 0000000..751f387
--- /dev/null
+++ b/engines/lab/eventman.cpp
@@ -0,0 +1,380 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/lab.h"
+#include "lab/image.h"
+#include "lab/interface.h"
+
+namespace Lab {
+
+static byte MouseData[] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
+						   1, 7, 1, 0, 0, 0, 0, 0, 0, 0,
+						   1, 7, 7, 1, 0, 0, 0, 0, 0, 0,
+						   1, 7, 7, 7, 1, 0, 0, 0, 0, 0,
+						   1, 7, 7, 7, 7, 1, 0, 0, 0, 0,
+						   1, 7, 7, 7, 7, 7, 1, 0, 0, 0,
+						   1, 7, 7, 7, 7, 7, 7, 1, 0, 0,
+						   1, 7, 7, 7, 7, 7, 7, 7, 1, 0,
+						   1, 7, 7, 7, 7, 7, 1, 1, 1, 1,
+						   1, 7, 7, 1, 7, 7, 1, 0, 0, 0,
+						   1, 7, 1, 0, 1, 7, 7, 1, 0, 0,
+						   1, 1, 0, 0, 1, 7, 7, 1, 0, 0,
+						   0, 0, 0, 0, 0, 1, 7, 7, 1, 0,
+						   0, 0, 0, 0, 0, 1, 7, 7, 1, 0,
+						   0, 0, 0, 0, 0, 0, 1, 1, 0, 0};
+
+#define MOUSE_WIDTH 10
+#define MOUSE_HEIGHT 15
+
+/*****************************************************************************/
+/* Checks whether or not the cords fall within one of the gadgets in a list  */
+/* of gadgets.                                                               */
+/*****************************************************************************/
+Gadget *EventManager::checkGadgetHit(Gadget *gadgetList, Common::Point pos) {
+	while (gadgetList != NULL) {
+		if ((pos.x >= gadgetList->x) && (pos.y >= gadgetList->y) &&
+		    (pos.x <= (gadgetList->x + gadgetList->_image->_width)) &&
+		    (pos.y <= (gadgetList->y + gadgetList->_image->_height)) &&
+		     !(GADGETOFF & gadgetList->GadgetFlags)) {
+			if (_vm->_isHiRes) {
+				_hitGadget = gadgetList;
+			} else {
+				mouseHide();
+				gadgetList->_altImage->drawImage(gadgetList->x, gadgetList->y);
+				mouseShow();
+
+				for (uint16 i = 0; i < 3; i++)
+					_vm->waitTOF();
+
+				mouseHide();
+				gadgetList->_image->drawImage(gadgetList->x, gadgetList->y);
+				mouseShow();
+			}
+
+			return gadgetList;
+		} else {
+			gadgetList = gadgetList->NextGadget;
+		}
+	}
+
+	return NULL;
+}
+
+
+
+void EventManager::attachGadgetList(Gadget *gadgetList) {
+	if (_screenGadgetList != gadgetList)
+		_lastGadgetHit = nullptr;
+
+	_screenGadgetList = gadgetList;
+}
+
+EventManager::EventManager(LabEngine *vm) : _vm(vm) {
+	_leftClick = false;
+	_rightClick = false;
+
+	_mouseHidden = true;
+	_numHidden   = 1;
+	_lastGadgetHit = nullptr;
+	_screenGadgetList = nullptr;
+	_hitGadget = nullptr;
+	_nextKeyIn = 0;
+	_nextKeyOut = 0;
+	_mousePos = Common::Point(0, 0);
+	_mouseAtEdge = false;
+
+	for (int i = 0; i < 64; i++)
+		_keyBuf[i] = 0;
+
+}
+
+void EventManager::mouseHandler(int flag, Common::Point pos) {
+	if (_numHidden >= 2)
+		return;
+
+	if (flag & 0x02) { /* Left mouse button click */
+		Gadget *tmp = NULL;
+		if (_screenGadgetList)
+			tmp = checkGadgetHit(_screenGadgetList, _vm->_isHiRes ? pos : Common::Point(pos.x / 2, pos.y));
+
+		if (tmp)
+			_lastGadgetHit = tmp;
+		else
+			_leftClick = true;
+	}
+
+	if (flag & 0x08) /* Right mouse button click */
+		_rightClick = true;
+}
+
+void EventManager::updateMouse() {
+	bool doUpdateDisplay = false;
+
+	if (!_mouseHidden)
+		doUpdateDisplay = true;
+
+	if (_hitGadget) {
+		mouseHide();
+		_hitGadget->_altImage->drawImage(_hitGadget->x, _hitGadget->y);
+		mouseShow();
+
+		for (uint16 i = 0; i < 3; i++)
+			_vm->waitTOF();
+
+		mouseHide();
+		_hitGadget->_image->drawImage(_hitGadget->x, _hitGadget->y);
+		mouseShow();
+		doUpdateDisplay = true;
+		_hitGadget = nullptr;
+	}
+
+	if (doUpdateDisplay)
+		_vm->screenUpdate();
+}
+
+
+/*****************************************************************************/
+/* Initializes the mouse.                                                    */
+/*****************************************************************************/
+void EventManager::initMouse() {
+	g_system->setMouseCursor(MouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0);
+	g_system->showMouse(false);
+
+	setMousePos(Common::Point(0, 0));
+}
+
+
+/*****************************************************************************/
+/* Shows the mouse.                                                          */
+/*****************************************************************************/
+void EventManager::mouseShow() {
+	if (_numHidden)
+		_numHidden--;
+
+	if ((_numHidden == 0) && _mouseHidden) {
+		processInput();
+		_mouseHidden = false;
+	}
+
+	g_system->showMouse(true);
+}
+
+/*****************************************************************************/
+/* Hides the mouse.                                                          */
+/*****************************************************************************/
+void EventManager::mouseHide() {
+	_numHidden++;
+
+	if (_numHidden && !_mouseHidden) {
+		_mouseHidden = true;
+
+		g_system->showMouse(false);
+	}
+}
+
+/*****************************************************************************/
+/* Gets the current mouse co-ordinates.  NOTE: On IBM version, will scale    */
+/* from virtual to screen co-ordinates automatically.                        */
+/*****************************************************************************/
+Common::Point EventManager::getMousePos() {
+	if (_vm->_isHiRes)
+		return _mousePos;
+	else
+		return Common::Point(_mousePos.x / 2, _mousePos.y);
+}
+
+
+/*****************************************************************************/
+/* Moves the mouse to new co-ordinates.                                      */
+/*****************************************************************************/
+void EventManager::setMousePos(Common::Point pos) {
+	if (_vm->_isHiRes)
+		g_system->warpMouse(pos.x, pos.y);
+	else
+		g_system->warpMouse(pos.x * 2, pos.y);
+
+	if (!_mouseHidden)
+		processInput();
+}
+
+
+/*****************************************************************************/
+/* Checks whether or not the mouse buttons have been pressed, and the last   */
+/* co-ordinates of the button press.  leftbutton tells whether to check the  */
+/* left or right button.                                                     */
+/*****************************************************************************/
+bool EventManager::mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
+	if (leftbutton) {
+		if (_leftClick) {
+			*x = (!_vm->_isHiRes) ? (uint16)_mousePos.x / 2 : (uint16)_mousePos.x;
+			*y = (uint16)_mousePos.y;
+			_leftClick = false;
+			return true;
+		}
+	} else {
+		if (_rightClick) {
+			*x = (!_vm->_isHiRes) ? (uint16)_mousePos.x / 2 : (uint16)_mousePos.x;
+			*y = (uint16)_mousePos.y;
+			_rightClick = false;
+			return true;
+		}
+	}
+
+	return false;
+}
+
+Gadget *EventManager::mouseGadget() {
+	Gadget *temp = _lastGadgetHit;
+
+	_lastGadgetHit = nullptr;
+	return temp;
+}
+
+/*****************************************************************************/
+/* Checks whether or not a key has been pressed.                             */
+/*****************************************************************************/
+bool EventManager::keyPress(uint16 *keyCode) {
+	if (haveNextChar()) {
+		*keyCode = getNextChar();
+		return true;
+	}
+
+	return false;
+}
+
+bool EventManager::haveNextChar() {
+	processInput();
+	return _nextKeyIn != _nextKeyOut;
+}
+
+void EventManager::processInput(bool can_delay) {
+	Common::Event event;
+
+	if (1 /*!g_IgnoreProcessInput*/) {
+		int flags = 0;
+		while (g_system->getEventManager()->pollEvent(event)) {
+			switch (event.type) {
+			case Common::EVENT_RBUTTONDOWN:
+				flags |= 8;
+				mouseHandler(flags, _mousePos);
+				break;
+
+			case Common::EVENT_LBUTTONDOWN:
+				flags |= 2;
+				mouseHandler(flags, _mousePos);
+				break;
+
+			case Common::EVENT_MOUSEMOVE: {
+				int lastMouseAtEdge = _mouseAtEdge;
+				_mouseAtEdge = false;
+				_mousePos.x = event.mouse.x;
+				if (event.mouse.x <= 0) {
+					_mousePos.x = 0;
+					_mouseAtEdge = true;
+				}
+				if (_mousePos.x > _vm->_screenWidth - 1) {
+					_mousePos.x = _vm->_screenWidth;
+					_mouseAtEdge = true;
+				}
+
+				_mousePos.y = event.mouse.y;
+				if (event.mouse.y <= 0) {
+					_mousePos.y = 0;
+					_mouseAtEdge = true;
+				}
+				if (_mousePos.y > _vm->_screenHeight - 1) {
+					_mousePos.y = _vm->_screenHeight;
+					_mouseAtEdge = true;
+				}
+
+				if (!lastMouseAtEdge || !_mouseAtEdge)
+					mouseHandler(1, _mousePos);
+				}
+				break;
+
+			case Common::EVENT_KEYDOWN:
+				switch (event.kbd.keycode) {
+				case Common::KEYCODE_LEFTBRACKET:
+					_vm->changeVolume(-1);
+					break;
+
+				case Common::KEYCODE_RIGHTBRACKET:
+					_vm->changeVolume(1);
+					break;
+
+				case Common::KEYCODE_z:
+					//saveSettings();
+					break;
+
+				default: {
+					int n = ((((unsigned int)((_nextKeyIn + 1) >> 31) >> 26) + (byte)_nextKeyIn + 1) & 0x3F)
+						- ((unsigned int)((_nextKeyIn + 1) >> 31) >> 26);
+					if (n != _nextKeyOut) {
+						_keyBuf[_nextKeyIn] = event.kbd.keycode;
+						_nextKeyIn = n;
+					}
+					}
+				}
+				break;
+
+			case Common::EVENT_QUIT:
+			case Common::EVENT_RTL:
+			default:
+				break;
+			}
+
+			g_system->copyRectToScreen(_vm->_displayBuffer, _vm->_screenWidth, 0, 0, _vm->_screenWidth, _vm->_screenHeight);
+			g_system->updateScreen();
+		}
+	}
+
+	if (can_delay)
+		g_system->delayMillis(10);
+}
+
+uint16 EventManager::getNextChar() {
+	uint16 c = 0;
+
+	processInput();
+	if (_nextKeyIn != _nextKeyOut) {
+		c = _keyBuf[_nextKeyOut];
+		_nextKeyOut = ((((unsigned int)((_nextKeyOut + 1) >> 31) >> 26) + (byte)_nextKeyOut + 1) & 0x3F)
+			- ((unsigned int)((_nextKeyOut + 1) >> 31) >> 26);
+	}
+
+	return c;
+}
+
+Common::Point EventManager::updateAndGetMousePos() {
+	processInput();
+
+	return _mousePos;
+}
+} // End of namespace Lab
diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h
new file mode 100644
index 0000000..156fb96
--- /dev/null
+++ b/engines/lab/eventman.h
@@ -0,0 +1,81 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#ifndef LAB_EVENTMAN_H
+#define LAB_EVENTMAN_H
+
+namespace Lab {
+
+struct Gadget;
+
+class LabEngine;
+
+class EventManager {
+private:
+	LabEngine *_vm;
+	bool _leftClick;
+	bool _rightClick;
+
+	bool _mouseHidden;
+	int32 _numHidden;
+	Gadget *_lastGadgetHit;
+	uint16 _nextKeyIn;
+	uint16 _nextKeyOut;
+	Common::Point _mousePos;
+	bool _mouseAtEdge;
+	uint16 _keyBuf[64];
+
+public:
+	EventManager (LabEngine *vm);
+
+	Gadget *_screenGadgetList;
+	Gadget *_hitGadget;
+
+	Gadget *checkGadgetHit(Gadget *gadgetList, Common::Point pos);
+	void initMouse();
+	void updateMouse();
+	void mouseShow();
+	void mouseHide();
+	Common::Point getMousePos();
+	void setMousePos(Common::Point pos);
+	bool mouseButton(uint16 *x, uint16 *y, bool leftButton);
+	Gadget *mouseGadget();
+	void attachGadgetList(Gadget *gadgetList);
+	void mouseHandler(int flag, Common::Point pos);
+	bool keyPress(uint16 *keyCode);
+	bool haveNextChar();
+	void processInput(bool can_delay = false);
+	uint16 getNextChar();
+	Common::Point updateAndGetMousePos();
+};
+
+} // End of namespace Lab
+
+#endif /* LAB_EVENTMAN_H */
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 9de6400..4c2d3d7 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -34,7 +34,6 @@
 #include "lab/image.h"
 #include "lab/labfun.h"
 #include "lab/parsefun.h"
-#include "lab/mouse.h"
 #include "lab/text.h"
 #include "lab/resource.h"
 
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index ada510b..9a51978 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -32,7 +32,6 @@
 #include "lab/labfun.h"
 #include "lab/image.h"
 #include "lab/interface.h"
-#include "lab/mouse.h"
 #include "common/util.h"
 
 namespace Lab {
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index f4b223a..6135f5e 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -37,7 +37,7 @@
 #include "engines/engine.h"
 #include "lab/labfun.h"
 #include "lab/interface.h"
-#include "lab/mouse.h"
+#include "lab/eventman.h"
 #include "lab/music.h"
 #include "lab/resource.h"
 #include "lab/anim.h"
diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
index 99a02c1..3a34f80 100644
--- a/engines/lab/labfile.cpp
+++ b/engines/lab/labfile.cpp
@@ -30,7 +30,6 @@
 
 #include "lab/lab.h"
 #include "lab/labfun.h"
-#include "lab/mouse.h"
 #include "common/file.h"
 
 namespace Lab {
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 0690ed0..efc1825 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -33,7 +33,6 @@
 #include "lab/anim.h"
 #include "lab/image.h"
 #include "lab/text.h"
-#include "lab/mouse.h"
 #include "lab/parsefun.h"
 #include "lab/parsetypes.h"
 #include "lab/resource.h"
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index cfe867a..67d6b28 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -5,6 +5,7 @@ MODULE_OBJS := \
 	anim.o \
 	detection.o \
 	engine.o \
+	eventman.o \
 	graphics.o \
 	image.o \
 	interface.o \
@@ -13,7 +14,6 @@ MODULE_OBJS := \
 	labfile.o \
 	labsets.o \
 	map.o \
-	mouse.o \
 	music.o \
 	processroom.o \
 	resource.o \
diff --git a/engines/lab/mouse.cpp b/engines/lab/mouse.cpp
deleted file mode 100644
index 45dd53f..0000000
--- a/engines/lab/mouse.cpp
+++ /dev/null
@@ -1,381 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "lab/lab.h"
-#include "lab/image.h"
-#include "lab/mouse.h"
-#include "lab/interface.h"
-
-namespace Lab {
-
-static byte MouseData[] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
-						   1, 7, 1, 0, 0, 0, 0, 0, 0, 0,
-						   1, 7, 7, 1, 0, 0, 0, 0, 0, 0,
-						   1, 7, 7, 7, 1, 0, 0, 0, 0, 0,
-						   1, 7, 7, 7, 7, 1, 0, 0, 0, 0,
-						   1, 7, 7, 7, 7, 7, 1, 0, 0, 0,
-						   1, 7, 7, 7, 7, 7, 7, 1, 0, 0,
-						   1, 7, 7, 7, 7, 7, 7, 7, 1, 0,
-						   1, 7, 7, 7, 7, 7, 1, 1, 1, 1,
-						   1, 7, 7, 1, 7, 7, 1, 0, 0, 0,
-						   1, 7, 1, 0, 1, 7, 7, 1, 0, 0,
-						   1, 1, 0, 0, 1, 7, 7, 1, 0, 0,
-						   0, 0, 0, 0, 0, 1, 7, 7, 1, 0,
-						   0, 0, 0, 0, 0, 1, 7, 7, 1, 0,
-						   0, 0, 0, 0, 0, 0, 1, 1, 0, 0};
-
-#define MOUSE_WIDTH 10
-#define MOUSE_HEIGHT 15
-
-/*****************************************************************************/
-/* Checks whether or not the cords fall within one of the gadgets in a list  */
-/* of gadgets.                                                               */
-/*****************************************************************************/
-Gadget *EventManager::checkGadgetHit(Gadget *gadgetList, Common::Point pos) {
-	while (gadgetList != NULL) {
-		if ((pos.x >= gadgetList->x) && (pos.y >= gadgetList->y) &&
-		    (pos.x <= (gadgetList->x + gadgetList->_image->_width)) &&
-		    (pos.y <= (gadgetList->y + gadgetList->_image->_height)) &&
-		     !(GADGETOFF & gadgetList->GadgetFlags)) {
-			if (_vm->_isHiRes) {
-				_hitGadget = gadgetList;
-			} else {
-				mouseHide();
-				gadgetList->_altImage->drawImage(gadgetList->x, gadgetList->y);
-				mouseShow();
-
-				for (uint16 i = 0; i < 3; i++)
-					_vm->waitTOF();
-
-				mouseHide();
-				gadgetList->_image->drawImage(gadgetList->x, gadgetList->y);
-				mouseShow();
-			}
-
-			return gadgetList;
-		} else {
-			gadgetList = gadgetList->NextGadget;
-		}
-	}
-
-	return NULL;
-}
-
-
-
-void EventManager::attachGadgetList(Gadget *gadgetList) {
-	if (_screenGadgetList != gadgetList)
-		_lastGadgetHit = nullptr;
-
-	_screenGadgetList = gadgetList;
-}
-
-EventManager::EventManager(LabEngine *vm) : _vm(vm) {
-	_leftClick = false;
-	_rightClick = false;
-
-	_mouseHidden = true;
-	_numHidden   = 1;
-	_lastGadgetHit = nullptr;
-	_screenGadgetList = nullptr;
-	_hitGadget = nullptr;
-	_nextKeyIn = 0;
-	_nextKeyOut = 0;
-	_mousePos = Common::Point(0, 0);
-	_mouseAtEdge = false;
-
-	for (int i = 0; i < 64; i++)
-		_keyBuf[i] = 0;
-
-}
-
-void EventManager::mouseHandler(int flag, Common::Point pos) {
-	if (_numHidden >= 2)
-		return;
-
-	if (flag & 0x02) { /* Left mouse button click */
-		Gadget *tmp = NULL;
-		if (_screenGadgetList)
-			tmp = checkGadgetHit(_screenGadgetList, _vm->_isHiRes ? pos : Common::Point(pos.x / 2, pos.y));
-
-		if (tmp)
-			_lastGadgetHit = tmp;
-		else
-			_leftClick = true;
-	}
-
-	if (flag & 0x08) /* Right mouse button click */
-		_rightClick = true;
-}
-
-void EventManager::updateMouse() {
-	bool doUpdateDisplay = false;
-
-	if (!_mouseHidden)
-		doUpdateDisplay = true;
-
-	if (_hitGadget) {
-		mouseHide();
-		_hitGadget->_altImage->drawImage(_hitGadget->x, _hitGadget->y);
-		mouseShow();
-
-		for (uint16 i = 0; i < 3; i++)
-			_vm->waitTOF();
-
-		mouseHide();
-		_hitGadget->_image->drawImage(_hitGadget->x, _hitGadget->y);
-		mouseShow();
-		doUpdateDisplay = true;
-		_hitGadget = nullptr;
-	}
-
-	if (doUpdateDisplay)
-		_vm->screenUpdate();
-}
-
-
-/*****************************************************************************/
-/* Initializes the mouse.                                                    */
-/*****************************************************************************/
-void EventManager::initMouse() {
-	g_system->setMouseCursor(MouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0);
-	g_system->showMouse(false);
-
-	setMousePos(Common::Point(0, 0));
-}
-
-
-/*****************************************************************************/
-/* Shows the mouse.                                                          */
-/*****************************************************************************/
-void EventManager::mouseShow() {
-	if (_numHidden)
-		_numHidden--;
-
-	if ((_numHidden == 0) && _mouseHidden) {
-		processInput();
-		_mouseHidden = false;
-	}
-
-	g_system->showMouse(true);
-}
-
-/*****************************************************************************/
-/* Hides the mouse.                                                          */
-/*****************************************************************************/
-void EventManager::mouseHide() {
-	_numHidden++;
-
-	if (_numHidden && !_mouseHidden) {
-		_mouseHidden = true;
-
-		g_system->showMouse(false);
-	}
-}
-
-/*****************************************************************************/
-/* Gets the current mouse co-ordinates.  NOTE: On IBM version, will scale    */
-/* from virtual to screen co-ordinates automatically.                        */
-/*****************************************************************************/
-Common::Point EventManager::getMousePos() {
-	if (_vm->_isHiRes)
-		return _mousePos;
-	else
-		return Common::Point(_mousePos.x / 2, _mousePos.y);
-}
-
-
-/*****************************************************************************/
-/* Moves the mouse to new co-ordinates.                                      */
-/*****************************************************************************/
-void EventManager::setMousePos(Common::Point pos) {
-	if (_vm->_isHiRes)
-		g_system->warpMouse(pos.x, pos.y);
-	else
-		g_system->warpMouse(pos.x * 2, pos.y);
-
-	if (!_mouseHidden)
-		processInput();
-}
-
-
-/*****************************************************************************/
-/* Checks whether or not the mouse buttons have been pressed, and the last   */
-/* co-ordinates of the button press.  leftbutton tells whether to check the  */
-/* left or right button.                                                     */
-/*****************************************************************************/
-bool EventManager::mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
-	if (leftbutton) {
-		if (_leftClick) {
-			*x = (!_vm->_isHiRes) ? (uint16)_mousePos.x / 2 : (uint16)_mousePos.x;
-			*y = (uint16)_mousePos.y;
-			_leftClick = false;
-			return true;
-		}
-	} else {
-		if (_rightClick) {
-			*x = (!_vm->_isHiRes) ? (uint16)_mousePos.x / 2 : (uint16)_mousePos.x;
-			*y = (uint16)_mousePos.y;
-			_rightClick = false;
-			return true;
-		}
-	}
-
-	return false;
-}
-
-Gadget *EventManager::mouseGadget() {
-	Gadget *temp = _lastGadgetHit;
-
-	_lastGadgetHit = nullptr;
-	return temp;
-}
-
-/*****************************************************************************/
-/* Checks whether or not a key has been pressed.                             */
-/*****************************************************************************/
-bool EventManager::keyPress(uint16 *keyCode) {
-	if (haveNextChar()) {
-		*keyCode = getNextChar();
-		return true;
-	}
-
-	return false;
-}
-
-bool EventManager::haveNextChar() {
-	processInput();
-	return _nextKeyIn != _nextKeyOut;
-}
-
-void EventManager::processInput(bool can_delay) {
-	Common::Event event;
-
-	if (1 /*!g_IgnoreProcessInput*/) {
-		int flags = 0;
-		while (g_system->getEventManager()->pollEvent(event)) {
-			switch (event.type) {
-			case Common::EVENT_RBUTTONDOWN:
-				flags |= 8;
-				mouseHandler(flags, _mousePos);
-				break;
-
-			case Common::EVENT_LBUTTONDOWN:
-				flags |= 2;
-				mouseHandler(flags, _mousePos);
-				break;
-
-			case Common::EVENT_MOUSEMOVE: {
-				int lastMouseAtEdge = _mouseAtEdge;
-				_mouseAtEdge = false;
-				_mousePos.x = event.mouse.x;
-				if (event.mouse.x <= 0) {
-					_mousePos.x = 0;
-					_mouseAtEdge = true;
-				}
-				if (_mousePos.x > _vm->_screenWidth - 1) {
-					_mousePos.x = _vm->_screenWidth;
-					_mouseAtEdge = true;
-				}
-
-				_mousePos.y = event.mouse.y;
-				if (event.mouse.y <= 0) {
-					_mousePos.y = 0;
-					_mouseAtEdge = true;
-				}
-				if (_mousePos.y > _vm->_screenHeight - 1) {
-					_mousePos.y = _vm->_screenHeight;
-					_mouseAtEdge = true;
-				}
-
-				if (!lastMouseAtEdge || !_mouseAtEdge)
-					mouseHandler(1, _mousePos);
-				}
-				break;
-
-			case Common::EVENT_KEYDOWN:
-				switch (event.kbd.keycode) {
-				case Common::KEYCODE_LEFTBRACKET:
-					_vm->changeVolume(-1);
-					break;
-
-				case Common::KEYCODE_RIGHTBRACKET:
-					_vm->changeVolume(1);
-					break;
-
-				case Common::KEYCODE_z:
-					//saveSettings();
-					break;
-
-				default: {
-					int n = ((((unsigned int)((_nextKeyIn + 1) >> 31) >> 26) + (byte)_nextKeyIn + 1) & 0x3F)
-						- ((unsigned int)((_nextKeyIn + 1) >> 31) >> 26);
-					if (n != _nextKeyOut) {
-						_keyBuf[_nextKeyIn] = event.kbd.keycode;
-						_nextKeyIn = n;
-					}
-					}
-				}
-				break;
-
-			case Common::EVENT_QUIT:
-			case Common::EVENT_RTL:
-			default:
-				break;
-			}
-
-			g_system->copyRectToScreen(_vm->_displayBuffer, _vm->_screenWidth, 0, 0, _vm->_screenWidth, _vm->_screenHeight);
-			g_system->updateScreen();
-		}
-	}
-
-	if (can_delay)
-		g_system->delayMillis(10);
-}
-
-uint16 EventManager::getNextChar() {
-	uint16 c = 0;
-
-	processInput();
-	if (_nextKeyIn != _nextKeyOut) {
-		c = _keyBuf[_nextKeyOut];
-		_nextKeyOut = ((((unsigned int)((_nextKeyOut + 1) >> 31) >> 26) + (byte)_nextKeyOut + 1) & 0x3F)
-			- ((unsigned int)((_nextKeyOut + 1) >> 31) >> 26);
-	}
-
-	return c;
-}
-
-Common::Point EventManager::updateAndGetMousePos() {
-	processInput();
-
-	return _mousePos;
-}
-} // End of namespace Lab
diff --git a/engines/lab/mouse.h b/engines/lab/mouse.h
deleted file mode 100644
index b3b3e30d..0000000
--- a/engines/lab/mouse.h
+++ /dev/null
@@ -1,83 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "common/events.h"
-
-#ifndef LAB_MOUSE_H
-#define LAB_MOUSE_H
-
-namespace Lab {
-
-struct Gadget;
-
-class LabEngine;
-
-class EventManager {
-private:
-	LabEngine *_vm;
-	bool _leftClick;
-	bool _rightClick;
-
-	bool _mouseHidden;
-	int32 _numHidden;
-	Gadget *_lastGadgetHit;
-	uint16 _nextKeyIn;
-	uint16 _nextKeyOut;
-	Common::Point _mousePos;
-	bool _mouseAtEdge;
-	uint16 _keyBuf[64];
-
-public:
-	EventManager (LabEngine *vm);
-
-	Gadget *_screenGadgetList;
-	Gadget *_hitGadget;
-
-	Gadget *checkGadgetHit(Gadget *gadgetList, Common::Point pos);
-	void initMouse();
-	void updateMouse();
-	void mouseShow();
-	void mouseHide();
-	Common::Point getMousePos();
-	void setMousePos(Common::Point pos);
-	bool mouseButton(uint16 *x, uint16 *y, bool leftButton);
-	Gadget *mouseGadget();
-	void attachGadgetList(Gadget *gadgetList);
-	void mouseHandler(int flag, Common::Point pos);
-	bool keyPress(uint16 *keyCode);
-	bool haveNextChar();
-	void processInput(bool can_delay = false);
-	uint16 getNextChar();
-	Common::Point updateAndGetMousePos();
-};
-
-} // End of namespace Lab
-
-#endif /* LAB_MOUSE_H */
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 7f8df15..6a7bb4b 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -31,7 +31,6 @@
 #include "audio/mixer.h"
 
 #include "lab/labfun.h"
-#include "lab/mouse.h"
 #include "lab/music.h"
 #include "lab/lab.h"
 
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 419e0d3..401d897 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -40,7 +40,6 @@
 #include "lab/interface.h"
 #include "lab/anim.h"
 #include "lab/text.h"
-#include "lab/mouse.h"
 #include "lab/parsetypes.h"
 #include "lab/resource.h"
 
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 959218e..d64953c 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -33,7 +33,6 @@
 
 #include "lab/lab.h"
 #include "lab/image.h"
-#include "lab/mouse.h"
 
 namespace Lab {
 


Commit: 69bdfae23586a4a03197d0e7b6a722068538ff2f
    https://github.com/scummvm/scummvm/commit/69bdfae23586a4a03197d0e7b6a722068538ff2f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:47+01:00

Commit Message:
LAB: Plug memory leak

Changed paths:
    engines/lab/engine.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/labsets.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 1823fe6..1994827 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -309,6 +309,20 @@ bool LabEngine::setUpScreens() {
 	return true;
 }
 
+void LabEngine::freeScreens() {
+	for (uint16 i = 0; i < 20; i++)
+		delete _moveImages[i];
+
+	if (getPlatform() == Common::kPlatformWindows) {
+		for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++)
+			delete _invImages[imgIdx];
+	} else {
+		for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++)
+			delete _invImages[imgIdx];
+	}
+}
+
+
 /******************************************************************************/
 /* Permanently flips the imagery of a gadget.                                 */
 /******************************************************************************/
@@ -1302,6 +1316,8 @@ void LabEngine::go() {
 	freeRoomBuffer();
 	freeBuffer();
 
+	freeScreens();
+
 	_music->freeMusic();
 }
 
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 1c95746..ba5efec 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -94,7 +94,7 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 
 	for (int i = 0; i < 20; i++)
 		_moveImages[20] = nullptr;
-	
+
 	for (int i = 0; i < 10; i++)
 		_invImages[10] = nullptr;
 
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 6135f5e..d494815 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -190,6 +190,7 @@ private:
 
 	// engine.cpp
 	bool setUpScreens();
+	void freeScreens();
 	void perFlipGadget(uint16 gadID);
 	bool doCloseUp(CloseDataPtr cptr);
 	void mainGameLoop();
diff --git a/engines/lab/labsets.cpp b/engines/lab/labsets.cpp
index 2ab9abf..21c495d 100644
--- a/engines/lab/labsets.cpp
+++ b/engines/lab/labsets.cpp
@@ -34,7 +34,7 @@
 
 namespace Lab {
 
-	LargeSet::LargeSet(uint16 last, LabEngine *vm) : _vm(vm) {
+LargeSet::LargeSet(uint16 last, LabEngine *vm) : _vm(vm) {
 	last = (((last + 15) >> 4) << 4);
 
 	_array = (uint16 *)calloc(last >> 3, 2);


Commit: 38ed7f930f3ce409a8f8927aa895ec684c748345
    https://github.com/scummvm/scummvm/commit/38ed7f930f3ce409a8f8927aa895ec684c748345
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:47+01:00

Commit Message:
LAB: Renames and moved static variables to class

Changed paths:
    engines/lab/lab.cpp



diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index ba5efec..6dc8800 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -104,6 +104,16 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_nextFileName = nullptr;
 	_newFileName = nullptr;
 
+    for (int i = 0; i < 20; i++)
+        _moveImages[i] = 0;
+
+    for (int i = 0; i < 10; i++)
+        _invImages[10] = 0;
+
+    _moveGadgetList = 0;
+    _invGadgetList = 0;
+
+
 	//const Common::FSNode gameDataDir(ConfMan.get("path"));
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game/pict");


Commit: 44e098b06de2aa30fae873c4dcc1fc5fb39a8af1
    https://github.com/scummvm/scummvm/commit/44e098b06de2aa30fae873c4dcc1fc5fb39a8af1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:47+01:00

Commit Message:
LAB: More renames

Changed paths:
    engines/lab/engine.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/processroom.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 1994827..da8197e 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -421,11 +421,11 @@ bool LabEngine::doCloseUp(CloseDataPtr closePtr) {
 /******************************************************************************/
 /* Gets the current inventory name.                                           */
 /******************************************************************************/
-static const char *getInvName(uint16 CurInv) {
+const char *LabEngine::getInvName(uint16 CurInv) {
 	if (MainDisplay)
 		return Inventory[CurInv].BInvName;
 
-	if ((CurInv == LAMPNUM) && g_lab->_conditions->in(LAMPON))
+	if ((CurInv == LAMPNUM) && _conditions->in(LAMPON))
 		return "P:Mines/120";
 
 	if ((CurInv == BELTNUM) && g_lab->_conditions->in(BELTGLOW))
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 6dc8800..f741476 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -113,6 +113,7 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
     _moveGadgetList = 0;
     _invGadgetList = 0;
 
+    _curFileName = " ";
 
 	//const Common::FSNode gameDataDir(ConfMan.get("path"));
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index d494815..faedce9 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -197,6 +197,7 @@ private:
 	bool doUse(uint16 curInv);
 	void mayShowCrumbIndicator();
 	void mayShowCrumbIndicatorOff();
+	const char *getInvName(uint16 curInv);
 };
 
 extern LabEngine *g_lab;
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 3eeb00d..9f2948b 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -322,7 +322,7 @@ bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
 /*****************************************************************************/
 /* Processes the action list.                                                */
 /*****************************************************************************/
-static void doActions(Action * APtr, CloseDataPtr *LCPtr) {
+static void doActions(Action *APtr, CloseDataPtr *LCPtr) {
 	CloseDataPtr TLCPtr;
 	bool FirstLoaded = true;
 	char **str, *Test;


Commit: a8b6003751087e922f11b6c750ddbf45b305a119
    https://github.com/scummvm/scummvm/commit/a8b6003751087e922f11b6c750ddbf45b305a119
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:48+01:00

Commit Message:
LAB: Merged in allocroom.cpp

Changed paths:
  R engines/lab/allocroom.cpp
    engines/lab/engine.cpp
    engines/lab/module.mk



diff --git a/engines/lab/allocroom.cpp b/engines/lab/allocroom.cpp
deleted file mode 100644
index 22617cb..0000000
--- a/engines/lab/allocroom.cpp
+++ /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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "lab/parsetypes.h"
-
-namespace Lab {
-
-/* Have to make sure that ROOMBUFFERSIZE is bigger than the biggest piece of memory
-   that we need */
-#define ROOMBUFFERSIZE (2 * 20480L)
-
-extern RoomData *_rooms;
-
-static void *_roomBuffer = nullptr;
-static uint16 _curMarker  = 0;
-static void *_memPlace = nullptr;
-
-/*****************************************************************************/
-/* Allocates the memory for the room buffers.                                */
-/*****************************************************************************/
-bool initRoomBuffer() {
-	_curMarker = 0;
-
-	if ((_roomBuffer = calloc(ROOMBUFFERSIZE, 1))) {
-		_memPlace = _roomBuffer;
-
-		return true;
-	} else
-		return false;
-}
-
-/*****************************************************************************/
-/* Frees the memory for the room buffers.                                    */
-/*****************************************************************************/
-void freeRoomBuffer() {
-	if (_roomBuffer) {
-		free(_roomBuffer);
-		_roomBuffer = nullptr;
-	}
-}
-
-} // End of namespace Lab
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index da8197e..1b9a45b 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -1416,4 +1416,36 @@ void LabEngine::mayShowCrumbIndicatorOff() {
 	}
 }
 
+/* Have to make sure that ROOMBUFFERSIZE is bigger than the biggest piece of memory
+   that we need */
+#define ROOMBUFFERSIZE (2 * 20480L)
+
+static void *_roomBuffer = nullptr;
+static uint16 _curMarker  = 0;
+static void *_memPlace = nullptr;
+
+/*****************************************************************************/
+/* Allocates the memory for the room buffers.                                */
+/*****************************************************************************/
+bool initRoomBuffer() {
+	_curMarker = 0;
+
+	if ((_roomBuffer = calloc(ROOMBUFFERSIZE, 1))) {
+		_memPlace = _roomBuffer;
+
+		return true;
+	} else
+		return false;
+}
+
+/*****************************************************************************/
+/* Frees the memory for the room buffers.                                    */
+/*****************************************************************************/
+void freeRoomBuffer() {
+	if (_roomBuffer) {
+		free(_roomBuffer);
+		_roomBuffer = nullptr;
+	}
+}
+
 } // End of namespace Lab
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index 67d6b28..18bb7e6 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -1,7 +1,6 @@
 MODULE := engines/lab
 
 MODULE_OBJS := \
-	allocroom.o \
 	anim.o \
 	detection.o \
 	engine.o \


Commit: d1e8e6dfbd5daf507fc837c10f0830adabb280ce
    https://github.com/scummvm/scummvm/commit/d1e8e6dfbd5daf507fc837c10f0830adabb280ce
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:48+01:00

Commit Message:
LAB: Fix bug during initialization

Changed paths:
    engines/lab/lab.cpp



diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index f741476..944689b 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -93,10 +93,10 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_alternate = false;
 
 	for (int i = 0; i < 20; i++)
-		_moveImages[20] = nullptr;
+		_moveImages[i] = nullptr;
 
 	for (int i = 0; i < 10; i++)
-		_invImages[10] = nullptr;
+		_invImages[i] = nullptr;
 
 	_moveGadgetList = nullptr;
 	_invGadgetList = nullptr;


Commit: 5c246e4189317a8ffa9e5af306b56320e8295b2e
    https://github.com/scummvm/scummvm/commit/5c246e4189317a8ffa9e5af306b56320e8295b2e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:48+01:00

Commit Message:
LAB: Remove leftover after rebase/merge

Changed paths:
    engines/lab/lab.cpp



diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 944689b..3e38b69 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -104,12 +104,6 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_nextFileName = nullptr;
 	_newFileName = nullptr;
 
-    for (int i = 0; i < 20; i++)
-        _moveImages[i] = 0;
-
-    for (int i = 0; i < 10; i++)
-        _invImages[10] = 0;
-
     _moveGadgetList = 0;
     _invGadgetList = 0;
 


Commit: 646c29d5a34fa85c7dd6915de31c28465e7797a1
    https://github.com/scummvm/scummvm/commit/646c29d5a34fa85c7dd6915de31c28465e7797a1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:48+01:00

Commit Message:
LAB: Renames and moved vars to classes

Changed paths:
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/parsefun.h
    engines/lab/processroom.cpp
    engines/lab/savegame.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 1b9a45b..33a6422 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -40,10 +40,6 @@
 
 namespace Lab {
 
-bool LongWinInFront = false;
-
-TextFont *MsgFont;
-
 extern bool stopsound, DoNotDrawMessage;
 
 /* Global parser data */
@@ -468,7 +464,7 @@ void LabEngine::interfaceOn() {
 		_event->mouseShow();
 	}
 
-	if (LongWinInFront)
+	if (_longWinInFront)
 		_event->attachGadgetList(NULL);
 	else if (_alternate)
 		_event->attachGadgetList(_invGadgetList);
@@ -608,7 +604,7 @@ void LabEngine::mainGameLoop() {
 
 	_conditions->readInitialConditions("LAB:Conditio");
 
-	LongWinInFront = false;
+	_longWinInFront = false;
 	drawPanel();
 
 	perFlipGadget(actionMode);
@@ -758,7 +754,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 	_anim->_doBlack = false;
 
-	if ((msgClass == RAWKEY) && (!LongWinInFront)) {
+	if ((msgClass == RAWKEY) && (!_longWinInFront)) {
 		if (code == 13) { /* The return key */
 			msgClass     = MOUSEBUTTONS;
 			Qualifier = IEQUALIFIER_LEFTBUTTON;
@@ -846,12 +842,12 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 		eatMessages();
 	}
 
-	if (LongWinInFront) {
+	if (_longWinInFront) {
 		if ((msgClass == RAWKEY) ||
 		        ((msgClass == MOUSEBUTTONS) &&
 		         ((IEQUALIFIER_LEFTBUTTON & Qualifier) ||
 		          (IEQUALIFIER_RBUTTON & Qualifier)))) {
-			LongWinInFront = false;
+			_longWinInFront = false;
 			DoNotDrawMessage = false;
 			drawPanel();
 			drawRoomMessage(curInv, CPtr);
@@ -1274,7 +1270,7 @@ void LabEngine::go() {
 	if (!doIntro)
 		_music->initMusic();
 
-	MsgFont = _resource->getFont("P:AvanteG.12");
+	_msgFont = _resource->getFont("P:AvanteG.12");
 
 	_event->mouseHide();
 
@@ -1311,7 +1307,7 @@ void LabEngine::go() {
 		}
 	}
 
-	closeFont(MsgFont);
+	closeFont(_msgFont);
 
 	freeRoomBuffer();
 	freeBuffer();
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 4c2d3d7..6fa29d8 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -42,8 +42,6 @@ namespace Lab {
 BitMap bit1, bit2, *DispBitMap = &bit1, *DrawBitMap = &bit1;
 
 extern bool stopsound;
-extern TextFont *MsgFont;
-
 
 /*****************************************************************************/
 /* Scales the x co-ordinates to that of the new display.  In the room parser */
@@ -194,8 +192,6 @@ byte *readPictToMem(const char *filename, uint16 x, uint16 y) {
 /*---------------------------------------------------------------------------*/
 bool DoNotDrawMessage = false;
 
-extern bool LongWinInFront, Alternate;
-
 /*----- The flowText routines -----*/
 
 /******************************************************************************/
@@ -266,7 +262,7 @@ uint32 flowText(void *font,      /* the TextAttr pointer */
                 bool output,                  /* Whether to output any text */
                 uint16 x1,               /* Cords */
                 uint16 y1, uint16 x2, uint16 y2, const char *str) { /* The text itself */
-	TextFont *msgfont = (TextFont *)font;
+	TextFont *_msgFont = (TextFont *)font;
 	char linebuffer[256];
 	const char *temp;
 	uint16 numlines, actlines, fontheight, width;
@@ -282,7 +278,7 @@ uint32 flowText(void *font,      /* the TextAttr pointer */
 
 	g_lab->setAPen(pencolor);
 
-	fontheight = textHeight(msgfont) + spacing;
+	fontheight = textHeight(_msgFont) + spacing;
 	numlines   = (y2 - y1 + 1) / fontheight;
 	width      = x2 - x1 + 1;
 	y          = y1;
@@ -292,7 +288,7 @@ uint32 flowText(void *font,      /* the TextAttr pointer */
 		actlines = 0;
 
 		while (temp[0]) {
-			getLine(msgfont, linebuffer, &temp, width);
+			getLine(_msgFont, linebuffer, &temp, width);
 			actlines++;
 		}
 
@@ -303,15 +299,15 @@ uint32 flowText(void *font,      /* the TextAttr pointer */
 	temp = str;
 
 	while (numlines && str[0]) {
-		getLine(msgfont, linebuffer, &str, width);
+		getLine(_msgFont, linebuffer, &str, width);
 
 		x = x1;
 
 		if (centerh)
-			x += (width - textLength(msgfont, linebuffer, strlen(linebuffer))) / 2;
+			x += (width - textLength(_msgFont, linebuffer, strlen(linebuffer))) / 2;
 
 		if (output)
-			text(msgfont, x, y, pencolor, linebuffer, strlen(linebuffer));
+			text(_msgFont, x, y, pencolor, linebuffer, strlen(linebuffer));
 
 		numlines--;
 		y += fontheight;
@@ -370,8 +366,8 @@ int32 LabEngine::longDrawMessage(const char *str) {
 	_event->mouseHide();
 	strcpy(newText, str);
 
-	if (!LongWinInFront) {
-		LongWinInFront = true;
+	if (!_longWinInFront) {
+		_longWinInFront = true;
 		setAPen(3);                 /* Clear Area */
 		rectFill(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319), VGAScaleY(199));
 	}
@@ -379,7 +375,7 @@ int32 LabEngine::longDrawMessage(const char *str) {
 	createBox(198);
 	_event->mouseShow();
 
-	return flowText(MsgFont, 0, 1, 7, false, true, true, true, VGAScaleX(6), VGAScaleY(155), VGAScaleX(313), VGAScaleY(195), str);
+	return flowText(_msgFont, 0, 1, 7, false, true, true, true, VGAScaleX(6), VGAScaleY(155), VGAScaleX(313), VGAScaleY(195), str);
 }
 
 void LabEngine::drawStaticMessage(byte index) {
@@ -396,18 +392,18 @@ void LabEngine::drawMessage(const char *str) {
 	}
 
 	if (str) {
-		if ((textLength(MsgFont, str, strlen(str)) > VGAScaleX(306))) {
+		if ((textLength(_msgFont, str, strlen(str)) > VGAScaleX(306))) {
 			longDrawMessage(str);
 			_lastMessageLong = true;
 		} else {
-			if (LongWinInFront) {
-				LongWinInFront = false;
+			if (_longWinInFront) {
+				_longWinInFront = false;
 				drawPanel();
 			}
 
 			_event->mouseHide();
 			createBox(168);
-			text(MsgFont, VGAScaleX(7), VGAScaleY(155) + SVGACord(2), 1, str, strlen(str));
+			text(_msgFont, VGAScaleX(7), VGAScaleY(155) + SVGACord(2), 1, str, strlen(str));
 			_event->mouseShow();
 			_lastMessageLong = false;
 		}
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 3e38b69..7bb05c8 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -109,6 +109,9 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 
     _curFileName = " ";
 
+    _longWinInFront = false;
+    _msgFont = 0;
+
 	//const Common::FSNode gameDataDir(ConfMan.get("path"));
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game/pict");
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index faedce9..3e96d04 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -130,6 +130,10 @@ private:
 	int _lastWaitTOFTicks;
 	bool _lastMessageLong;
 	bool _lastTooLong;
+	TextFont *_msgFont;
+
+public:
+	bool _longWinInFront;
 
 private:
 	bool createScreen(bool HiRes);
@@ -161,8 +165,8 @@ public:
 	void doScrollBlack();
 	void doScrollWipe(char *filename);
 	void doScrollBounce();
-	void doWipe(uint16 WipeType, CloseDataPtr *CPtr, char *filename);
-	void doTransWipe(CloseDataPtr *CPtr, char *filename);
+	void doWipe(uint16 WipeType, CloseDataPtr *cPtr, char *filename);
+	void doTransWipe(CloseDataPtr *cPtr, char *filename);
 	Gadget *checkNumGadgetHit(Gadget *gadlist, uint16 key);
 	IntuiMessage *getMsg();
 	void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein);
@@ -176,7 +180,7 @@ public:
 	void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void eatMessages();
 	void drawStaticMessage(byte index);
-	void drawDirection(CloseDataPtr LCPtr);
+	void drawDirection(CloseDataPtr lcPtr);
 	int followCrumbs();
 
 	void changeVolume(int delta);
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index efc1825..05c60b1 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -81,8 +81,6 @@ static MapData *Maps;
 
 extern char *LOWERFLOORS, *MIDDLEFLOORS, *UPPERFLOORS, *MEDMAZEFLOORS, *HEDGEMAZEFLOORS, *SURMAZEFLOORS, *CARNIVALFLOOR, *SURMAZEMSG;
 
-extern TextFont *MsgFont;
-
 uint16 *FadePalette;
 
 static uint16 MapGadX[3] = {101, 55, 8}, MapGadY[3] = {105, 105, 105};
@@ -550,7 +548,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 			HugeMaze->drawImage(mapScaleX(524), mapScaleY(97));
 	} else if (Floor == SURMAZEFLOOR) {
 		sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str();
-		flowText(MsgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr);
+		flowText(_msgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr);
 	}
 
 	switch (Floor) {
@@ -581,10 +579,10 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 	}
 
 	if (sptr)
-		flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(75), VGAScaleX(134), VGAScaleY(97), sptr);
+		flowText(_msgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(75), VGAScaleX(134), VGAScaleY(97), sptr);
 
 	if ((sptr = _rooms[CurMsg]._roomMsg))
-		flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr);
+		flowText(_msgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr);
 
 	if (fadein)
 		fade(true, 0);
@@ -739,7 +737,7 @@ void LabEngine::processMap(uint16 CurRoom) {
 							_event->mouseHide();
 							setAPen(3);
 							rectFill(VGAScaleX(13), VGAScaleY(148), VGAScaleX(135), VGAScaleY(186));
-							flowText(MsgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr);
+							flowText(_msgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr);
 
 							if (Maps[OldMsg].PageNumber == CurFloor)
 								drawRoom(OldMsg, (bool)(OldMsg == CurRoom));
diff --git a/engines/lab/parsefun.h b/engines/lab/parsefun.h
index 46c26b6..37ff977 100644
--- a/engines/lab/parsefun.h
+++ b/engines/lab/parsefun.h
@@ -49,16 +49,16 @@ void freeRoomBuffer();
 /* From ProcessRoom.c */
 
 ViewData *getViewData(uint16 RoomNum, uint16 Direction);
-char *getPictName(CloseDataPtr *LCPtr);
-void drawDirection(CloseDataPtr LCPtr);
+char *getPictName(CloseDataPtr *lcptr);
+void drawDirection(CloseDataPtr lcptr);
 bool processArrow(uint16 *Direction, uint16 Arrow);
 void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords = false);
 bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr);
-bool doActionRule(Common::Point pos, int16 action, int16 RoomNum, CloseDataPtr *LCPtr);
-bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *LCPtr);
-bool doGoForward(CloseDataPtr *LCPtr);
-bool doTurn(uint16 from, uint16 to, CloseDataPtr *LCPtr);
-bool doMainView(CloseDataPtr *LCPtr);
+bool doActionRule(Common::Point pos, int16 action, int16 RoomNum, CloseDataPtr *lcptr);
+bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *lcptr);
+bool doGoForward(CloseDataPtr *lcptr);
+bool doTurn(uint16 from, uint16 to, CloseDataPtr *lcptr);
+bool doMainView(CloseDataPtr *lcptr);
 
 } // End of namespace Lab
 
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 9f2948b..30f26d4 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -48,7 +48,7 @@ RoomData *_rooms;
 InventoryData *Inventory;
 uint16 NumInv, ManyRooms, HighestCondition, Direction;
 
-extern bool DoNotDrawMessage, noupdatediff, QuitLab, MusicOn, LongWinInFront;
+extern bool DoNotDrawMessage, noupdatediff, QuitLab, MusicOn;
 extern CloseDataPtr CPtr;
 
 /*****************************************************************************/
@@ -116,24 +116,24 @@ ViewData *getViewData(uint16 roomNum, uint16 direction) {
 /*****************************************************************************/
 /* Gets an object, if any, from the user's click on the screen.              */
 /*****************************************************************************/
-static CloseData *getObject(uint16 x, uint16 y, CloseDataPtr LCPtr) {
+static CloseData *getObject(uint16 x, uint16 y, CloseDataPtr lcptr) {
 	ViewData *VPtr;
 
-	if (LCPtr == NULL) {
+	if (lcptr == NULL) {
 		VPtr = getViewData(g_lab->_roomNum, Direction);
-		LCPtr = VPtr->closeUps;
+		lcptr = VPtr->closeUps;
 	}
 
 	else
-		LCPtr = LCPtr->SubCloseUps;
+		lcptr = lcptr->SubCloseUps;
 
 
-	while (LCPtr != NULL) {
-		if ((x >= scaleX(LCPtr->x1)) && (y >= scaleY(LCPtr->y1)) &&
-		        (x <= scaleX(LCPtr->x2)) && (y <= scaleY(LCPtr->y2)))
-			return LCPtr;
+	while (lcptr != NULL) {
+		if ((x >= scaleX(lcptr->x1)) && (y >= scaleY(lcptr->y1)) &&
+		        (x <= scaleX(lcptr->x2)) && (y <= scaleY(lcptr->y2)))
+			return lcptr;
 
-		LCPtr = LCPtr->NextCloseUp;
+		lcptr = lcptr->NextCloseUp;
 	}
 
 	return NULL;
@@ -168,14 +168,14 @@ static CloseDataPtr findCPtrMatch(CloseDataPtr Main, CloseDataPtr List) {
 /*****************************************************************************/
 /* Returns the current picture name.                                         */
 /*****************************************************************************/
-char *getPictName(CloseDataPtr *LCPtr) {
+char *getPictName(CloseDataPtr *lcptr) {
 	ViewData *ViewPtr = getViewData(g_lab->_roomNum, Direction);
 
-	if (*LCPtr != NULL) {
-		*LCPtr = findCPtrMatch(*LCPtr, ViewPtr->closeUps);
+	if (*lcptr != NULL) {
+		*lcptr = findCPtrMatch(*lcptr, ViewPtr->closeUps);
 
-		if (*LCPtr)
-			return (*LCPtr)->GraphicName;
+		if (*lcptr)
+			return (*lcptr)->GraphicName;
 	}
 
 	return ViewPtr->GraphicName;
@@ -184,9 +184,9 @@ char *getPictName(CloseDataPtr *LCPtr) {
 /*****************************************************************************/
 /* Draws the current direction to the screen.                                */
 /*****************************************************************************/
-void LabEngine::drawDirection(CloseDataPtr LCPtr) {
-	if (LCPtr != NULL && LCPtr->Message) {
-		drawMessage(LCPtr->Message);
+void LabEngine::drawDirection(CloseDataPtr lcptr) {
+	if (lcptr != NULL && lcptr->Message) {
+		drawMessage(lcptr->Message);
 		return;
 	}
 
@@ -257,34 +257,34 @@ bool processArrow(uint16 *direction, uint16 Arrow) {
 /*****************************************************************************/
 void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords) {
 	ViewData *VPtr;
-	CloseDataPtr LCPtr;
+	CloseDataPtr lcptr;
 	uint16 x1, y1, x2, y2;
 
 	if (*cptr == NULL) {
 		VPtr = getViewData(g_lab->_roomNum, Direction);
-		LCPtr = VPtr->closeUps;
+		lcptr = VPtr->closeUps;
 	} else
-		LCPtr = (*cptr)->SubCloseUps;
+		lcptr = (*cptr)->SubCloseUps;
 
-	while (LCPtr != NULL) {
+	while (lcptr != NULL) {
 		if (!useAbsoluteCoords) {
-			x1 = LCPtr->x1;
-			y1 = LCPtr->y1;
-			x2 = LCPtr->x2;
-			y2 = LCPtr->y2;
+			x1 = lcptr->x1;
+			y1 = lcptr->y1;
+			x2 = lcptr->x2;
+			y2 = lcptr->y2;
 		} else {
-			x1 = scaleX(LCPtr->x1);
-			y1 = scaleY(LCPtr->y1);
-			x2 = scaleX(LCPtr->x2);
-			y2 = scaleY(LCPtr->y2);
+			x1 = scaleX(lcptr->x1);
+			y1 = scaleY(lcptr->y1);
+			x2 = scaleX(lcptr->x2);
+			y2 = scaleY(lcptr->y2);
 		}
 
-		if (pos.x >= x1 && pos.y >= y1 && pos.x <= x2 && pos.y <= y2 && LCPtr->GraphicName) {
-			*cptr = LCPtr;
+		if (pos.x >= x1 && pos.y >= y1 && pos.x <= x2 && pos.y <= y2 && lcptr->GraphicName) {
+			*cptr = lcptr;
 			return;
 		}
 
-		LCPtr = LCPtr->NextCloseUp;
+		lcptr = lcptr->NextCloseUp;
 	}
 }
 
@@ -293,27 +293,27 @@ void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords)
 /*****************************************************************************/
 bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
 	ViewData *VPtr;
-	CloseDataPtr LCPtr;
+	CloseDataPtr lcptr;
 
 	if (*cptr == NULL) {
 		VPtr = getViewData(g_lab->_roomNum, Direction);
-		LCPtr = VPtr->closeUps;
+		lcptr = VPtr->closeUps;
 	} else if ((*cptr)->CloseUpType < 0) {
 		g_lab->_conditions->inclElement(abs((*cptr)->CloseUpType));
 		return true;
 	} else
-		LCPtr = (*cptr)->SubCloseUps;
+		lcptr = (*cptr)->SubCloseUps;
 
 
-	while (LCPtr != NULL) {
-		if ((x >= scaleX(LCPtr->x1)) && (y >= scaleY(LCPtr->y1)) &&
-		        (x <= scaleX(LCPtr->x2)) && (y <= scaleY(LCPtr->y2)) &&
-		        (LCPtr->CloseUpType < 0)) {
-			g_lab->_conditions->inclElement(abs(LCPtr->CloseUpType));
+	while (lcptr != NULL) {
+		if ((x >= scaleX(lcptr->x1)) && (y >= scaleY(lcptr->y1)) &&
+		        (x <= scaleX(lcptr->x2)) && (y <= scaleY(lcptr->y2)) &&
+		        (lcptr->CloseUpType < 0)) {
+			g_lab->_conditions->inclElement(abs(lcptr->CloseUpType));
 			return true;
 		}
 
-		LCPtr = LCPtr->NextCloseUp;
+		lcptr = lcptr->NextCloseUp;
 	}
 
 	return false;
@@ -322,8 +322,8 @@ bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
 /*****************************************************************************/
 /* Processes the action list.                                                */
 /*****************************************************************************/
-static void doActions(Action *APtr, CloseDataPtr *LCPtr) {
-	CloseDataPtr TLCPtr;
+static void doActions(Action *APtr, CloseDataPtr *lcptr) {
+	CloseDataPtr tlcptr;
 	bool FirstLoaded = true;
 	char **str, *Test;
 	uint32 StartSecs, StartMicros, CurSecs, CurMicros;
@@ -371,7 +371,7 @@ static void doActions(Action *APtr, CloseDataPtr *LCPtr) {
 			break;
 
 		case WIPECMD:
-			g_lab->doWipe(APtr->Param1, LCPtr, (char *)APtr->Data);
+			g_lab->doWipe(APtr->Param1, lcptr, (char *)APtr->Data);
 			break;
 
 		case NOUPDATE:
@@ -384,7 +384,7 @@ static void doActions(Action *APtr, CloseDataPtr *LCPtr) {
 			break;
 
 		case SHOWCURPICT:
-			Test = getPictName(LCPtr);
+			Test = getPictName(lcptr);
 
 			if (strcmp(Test, g_lab->_curFileName) != 0) {
 				g_lab->_curFileName = Test;
@@ -404,7 +404,7 @@ static void doActions(Action *APtr, CloseDataPtr *LCPtr) {
 		case SHOWMESSAGE:
 			DoNotDrawMessage = false;
 
-			if (LongWinInFront)
+			if (g_lab->_longWinInFront)
 				g_lab->longDrawMessage((char *)APtr->Data);
 			else
 				g_lab->drawMessage((char *)APtr->Data);
@@ -413,7 +413,7 @@ static void doActions(Action *APtr, CloseDataPtr *LCPtr) {
 			break;
 
 		case CSHOWMESSAGE:
-			if (*LCPtr == NULL) {
+			if (*lcptr == NULL) {
 				DoNotDrawMessage = false;
 				g_lab->drawMessage((char *)APtr->Data);
 				DoNotDrawMessage = true;
@@ -432,7 +432,7 @@ static void doActions(Action *APtr, CloseDataPtr *LCPtr) {
 			if (APtr->Param1 & 0x8000) {
 				// This is a Wyrmkeep Windows trial version, thus stop at this
 				// point, since we can't check for game payment status
-				readPict(getPictName(LCPtr), true);
+				readPict(getPictName(lcptr), true);
 				APtr = NULL;
 				GUI::MessageDialog trialMessage("This is the end of the trial version. You can play the full game using the original interpreter from Wyrmkeep");
 				trialMessage.runModal();
@@ -441,20 +441,20 @@ static void doActions(Action *APtr, CloseDataPtr *LCPtr) {
 
 			g_lab->_roomNum   = APtr->Param1;
 			Direction = APtr->Param2 - 1;
-			*LCPtr      = NULL;
+			*lcptr      = NULL;
 			g_lab->_anim->_doBlack = true;
 			break;
 
 		case SETCLOSEUP:
-			TLCPtr = getObject(scaleX(APtr->Param1), scaleY(APtr->Param2), *LCPtr);
+			tlcptr = getObject(scaleX(APtr->Param1), scaleY(APtr->Param2), *lcptr);
 
-			if (TLCPtr)
-				*LCPtr = TLCPtr;
+			if (tlcptr)
+				*lcptr = tlcptr;
 
 			break;
 
 		case MAINVIEW:
-			*LCPtr = NULL;
+			*lcptr = NULL;
 			break;
 
 		case SUBINV:
@@ -603,10 +603,10 @@ static void doActions(Action *APtr, CloseDataPtr *LCPtr) {
 /*****************************************************************************/
 /* Does the work for doActionRule.                                           */
 /*****************************************************************************/
-static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr LCPtr, CloseDataPtr *Set, bool AllowDefaults) {
+static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr lcptr, CloseDataPtr *Set, bool AllowDefaults) {
 	action++;
 
-	if (LCPtr) {
+	if (lcptr) {
 		RuleList *rules = _rooms[g_lab->_roomNum]._rules;
 
 		if ((rules == NULL) && (roomNum == 0)) {
@@ -617,10 +617,10 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr LCPtr, Clo
 		for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 			if (((*rule)->RuleType == ACTION) &&
 				(((*rule)->Param1 == action) || (((*rule)->Param1 == 0) && AllowDefaults))) {
-				if ((((*rule)->Param2 == LCPtr->CloseUpType) ||
+				if ((((*rule)->Param2 == lcptr->CloseUpType) ||
 					(((*rule)->Param2 == 0) && AllowDefaults))
 				        ||
-						((action == 1) && ((*rule)->Param2 == (-LCPtr->CloseUpType)))) {
+						((action == 1) && ((*rule)->Param2 == (-lcptr->CloseUpType)))) {
 					if (checkConditions((*rule)->Condition)) {
 						doActions((*rule)->ActionList, Set);
 						return true;
@@ -636,23 +636,23 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr LCPtr, Clo
 /*****************************************************************************/
 /* Goes through the rules if an action is taken.                             */
 /*****************************************************************************/
-bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *LCPtr) {
-	CloseDataPtr TLCPtr;
+bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *lcptr) {
+	CloseDataPtr tlcptr;
 
 	if (roomNum)
 		g_lab->_newFileName = NOFILE;
 	else
 		g_lab->_newFileName = g_lab->_curFileName;
 
-	TLCPtr = getObject(pos.x, pos.y, *LCPtr);
+	tlcptr = getObject(pos.x, pos.y, *lcptr);
 
-	if (doActionRuleSub(action, roomNum, TLCPtr, LCPtr, false))
+	if (doActionRuleSub(action, roomNum, tlcptr, lcptr, false))
 		return true;
-	else if (doActionRuleSub(action, roomNum, *LCPtr, LCPtr, false))
+	else if (doActionRuleSub(action, roomNum, *lcptr, lcptr, false))
 		return true;
-	else if (doActionRuleSub(action, roomNum, TLCPtr, LCPtr, true))
+	else if (doActionRuleSub(action, roomNum, tlcptr, lcptr, true))
 		return true;
-	else if (doActionRuleSub(action, roomNum, *LCPtr, LCPtr, true))
+	else if (doActionRuleSub(action, roomNum, *lcptr, lcptr, true))
 		return true;
 
 	return false;
@@ -661,9 +661,9 @@ bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *
 /*****************************************************************************/
 /* Does the work for doActionRule.                                           */
 /*****************************************************************************/
-static bool doOperateRuleSub(int16 ItemNum, int16 roomNum, CloseDataPtr LCPtr, CloseDataPtr *Set, bool AllowDefaults) {
-	if (LCPtr)
-		if (LCPtr->CloseUpType > 0) {
+static bool doOperateRuleSub(int16 ItemNum, int16 roomNum, CloseDataPtr lcptr, CloseDataPtr *Set, bool AllowDefaults) {
+	if (lcptr)
+		if (lcptr->CloseUpType > 0) {
 			RuleList *rules = _rooms[roomNum]._rules;
 
 			if ((rules == NULL) && (roomNum == 0)) {
@@ -674,7 +674,7 @@ static bool doOperateRuleSub(int16 ItemNum, int16 roomNum, CloseDataPtr LCPtr, C
 			for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 				if (((*rule)->RuleType == OPERATE) &&
 				        (((*rule)->Param1 == ItemNum) || (((*rule)->Param1 == 0) && AllowDefaults)) &&
-						(((*rule)->Param2 == LCPtr->CloseUpType) || (((*rule)->Param2 == 0) && AllowDefaults))) {
+						(((*rule)->Param2 == lcptr->CloseUpType) || (((*rule)->Param2 == 0) && AllowDefaults))) {
 					if (checkConditions((*rule)->Condition)) {
 						doActions((*rule)->ActionList, Set);
 						return true;
@@ -689,31 +689,31 @@ static bool doOperateRuleSub(int16 ItemNum, int16 roomNum, CloseDataPtr LCPtr, C
 /*****************************************************************************/
 /* Goes thru the rules if the user tries to operate an item on an object.    */
 /*****************************************************************************/
-bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *LCPtr) {
-	CloseDataPtr TLCPtr;
+bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *lcptr) {
+	CloseDataPtr tlcptr;
 
 	g_lab->_newFileName = NOFILE;
 
-	TLCPtr = getObject(x, y, *LCPtr);
+	tlcptr = getObject(x, y, *lcptr);
 
-	if (doOperateRuleSub(ItemNum, g_lab->_roomNum, TLCPtr, LCPtr, false))
+	if (doOperateRuleSub(ItemNum, g_lab->_roomNum, tlcptr, lcptr, false))
 		return true;
-	else if (doOperateRuleSub(ItemNum, g_lab->_roomNum, *LCPtr, LCPtr, false))
+	else if (doOperateRuleSub(ItemNum, g_lab->_roomNum, *lcptr, lcptr, false))
 		return true;
-	else if (doOperateRuleSub(ItemNum, g_lab->_roomNum, TLCPtr, LCPtr, true))
+	else if (doOperateRuleSub(ItemNum, g_lab->_roomNum, tlcptr, lcptr, true))
 		return true;
-	else if (doOperateRuleSub(ItemNum, g_lab->_roomNum, *LCPtr, LCPtr, true))
+	else if (doOperateRuleSub(ItemNum, g_lab->_roomNum, *lcptr, lcptr, true))
 		return true;
 	else {
 		g_lab->_newFileName = g_lab->_curFileName;
 
-		if (doOperateRuleSub(ItemNum, 0, TLCPtr, LCPtr, false))
+		if (doOperateRuleSub(ItemNum, 0, tlcptr, lcptr, false))
 			return true;
-		else if (doOperateRuleSub(ItemNum, 0, *LCPtr, LCPtr, false))
+		else if (doOperateRuleSub(ItemNum, 0, *lcptr, lcptr, false))
 			return true;
-		else if (doOperateRuleSub(ItemNum, 0, TLCPtr, LCPtr, true))
+		else if (doOperateRuleSub(ItemNum, 0, tlcptr, lcptr, true))
 			return true;
-		else if (doOperateRuleSub(ItemNum, 0, *LCPtr, LCPtr, true))
+		else if (doOperateRuleSub(ItemNum, 0, *lcptr, lcptr, true))
 			return true;
 	}
 
@@ -723,13 +723,13 @@ bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *LCPtr) {
 /*****************************************************************************/
 /* Goes thru the rules if the user tries to go forward.                      */
 /*****************************************************************************/
-bool doGoForward(CloseDataPtr *LCPtr) {
+bool doGoForward(CloseDataPtr *lcptr) {
 	RuleList *rules = _rooms[g_lab->_roomNum]._rules;
 
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 		if (((*rule)->RuleType == GOFORWARD) && ((*rule)->Param1 == (Direction + 1))) {
 			if (checkConditions((*rule)->Condition)) {
-				doActions((*rule)->ActionList, LCPtr);
+				doActions((*rule)->ActionList, lcptr);
 				return true;
 			}
 		}
@@ -741,7 +741,7 @@ bool doGoForward(CloseDataPtr *LCPtr) {
 /*****************************************************************************/
 /* Goes thru the rules if the user tries to turn.                            */
 /*****************************************************************************/
-bool doTurn(uint16 from, uint16 to, CloseDataPtr *LCPtr) {
+bool doTurn(uint16 from, uint16 to, CloseDataPtr *lcptr) {
 	from++;
 	to++;
 
@@ -752,7 +752,7 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *LCPtr) {
 		        (((*rule)->RuleType == TURNFROMTO) &&
 		         ((*rule)->Param1   == from) && ((*rule)->Param2 == to))) {
 			if (checkConditions((*rule)->Condition)) {
-				doActions((*rule)->ActionList, LCPtr);
+				doActions((*rule)->ActionList, lcptr);
 				return true;
 			}
 		}
@@ -764,12 +764,12 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *LCPtr) {
 /*****************************************************************************/
 /* Goes thru the rules if the user tries to go to the main view              */
 /*****************************************************************************/
-bool doMainView(CloseDataPtr *LCPtr) {
+bool doMainView(CloseDataPtr *lcptr) {
 	RuleList *rules = _rooms[g_lab->_roomNum]._rules;
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 		if ((*rule)->RuleType == GOMAINVIEW) {
 			if (checkConditions((*rule)->Condition)) {
-				doActions((*rule)->ActionList, LCPtr);
+				doActions((*rule)->ActionList, lcptr);
 				return true;
 			}
 		}
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 41f7b27..bfe089c 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -53,7 +53,7 @@ namespace Lab {
 /* Lab: Labyrinth specific */
 extern byte combination[6];
 extern uint16 CurTile[4] [4];
-extern char *getPictName(CloseDataPtr *LCPtr);
+extern char *getPictName(CloseDataPtr *lcptr);
 
 void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName) {
 	out->writeUint32BE(SAVEGAME_ID);
@@ -83,7 +83,7 @@ void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveNam
 
 bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
 	uint32 id = in->readUint32BE();
-	
+
 	// Check if it's a valid ScummVM savegame
 	if (id != SAVEGAME_ID)
 		return false;
@@ -137,8 +137,8 @@ bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc)
 		return false;
 
 	// Load scene pic
-	CloseDataPtr CPtr = NULL;
-	readPict(getPictName(&CPtr), true);
+	CloseDataPtr cPtr = NULL;
+	readPict(getPictName(&cPtr), true);
 
 	writeSaveGameHeader(file, desc);
 	file->writeUint16LE(g_lab->_roomNum);
@@ -185,7 +185,7 @@ bool loadGame(uint16 *Direction, uint16 *Quarters, int slot) {
 	Common::String fileName = g_lab->generateSaveFileName(slot);
 	Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
 	Common::InSaveFile *file = saveFileManager->openForLoading(fileName);
-	
+
 	if (!file)
 		return false;
 
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 401d897..8e63d36 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -81,7 +81,6 @@ uint16 CurTile[4][4] = {
 	{ 10, 13, 12, 0 }
 };
 
-extern TextFont *MsgFont;
 extern uint16 *FadePalette;
 extern BitMap *DispBitMap, *DrawBitMap;
 extern CloseDataPtr CPtr;


Commit: c67a9e867c2f40edcdecbc5077dfc2a6edcb443e
    https://github.com/scummvm/scummvm/commit/c67a9e867c2f40edcdecbc5077dfc2a6edcb443e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:48+01:00

Commit Message:
LAB: More renames

Changed paths:
    engines/lab/engine.cpp
    engines/lab/labfun.h
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 33a6422..de9b567 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -746,7 +746,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 	uint16 OldRoomNum, OldDirection = 0;
 	uint16 LastInv = MAPNUM, Old;
-	CloseDataPtr OldCPtr, TempCPtr, HCPtr = NULL;
+	CloseDataPtr oldcptr, tempcptr, hcptr = NULL;
 	ViewData *VPtr;
 	bool doit;
 	uint16 NewDir;
@@ -859,7 +859,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				doMainView(&CPtr);
 
 				_anim->_doBlack = true;
-				HCPtr = NULL;
+				hcptr = NULL;
 				CPtr = NULL;
 				mayShowCrumbIndicator();
 				screenUpdate();
@@ -913,7 +913,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			screenUpdate();
 		} else if (gadgetId >= 6) { /* Arrow Gadgets */
 			CPtr = NULL;
-			HCPtr = NULL;
+			hcptr = NULL;
 
 			if ((gadgetId == 6) || (gadgetId == 8)) {
 				if (gadgetId == 6)
@@ -1141,7 +1141,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 
 		if (doit) {
-			HCPtr = NULL;
+			hcptr = NULL;
 			eatMessages();
 
 			if (actionMode == 0) { /* Take something. */
@@ -1165,16 +1165,16 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 						drawStaticMessage(kTextNothing);
 				}
 			} else if (actionMode == 4) { /* Look at closeups */
-				TempCPtr = CPtr;
-				setCurClose(curPos, &TempCPtr);
+				tempcptr = CPtr;
+				setCurClose(curPos, &tempcptr);
 
-				if (CPtr == TempCPtr) {
+				if (CPtr == tempcptr) {
 					if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
 						drawStaticMessage(kTextNothing);
-				} else if (TempCPtr->GraphicName) {
-					if (*(TempCPtr->GraphicName)) {
+				} else if (tempcptr->GraphicName) {
+					if (*(tempcptr->GraphicName)) {
 						_anim->_doBlack = true;
-						CPtr = TempCPtr;
+						CPtr = tempcptr;
 					} else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
 						drawStaticMessage(kTextNothing);
 				} else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
@@ -1195,32 +1195,32 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 		screenUpdate();
 	} else if (msgClass == DELTAMOVE) {
 		VPtr = getViewData(_roomNum, Direction);
-		OldCPtr = VPtr->closeUps;
+		oldcptr = VPtr->closeUps;
 
-		if (HCPtr == NULL) {
-			TempCPtr = CPtr;
-			setCurClose(curPos, &TempCPtr);
+		if (hcptr == NULL) {
+			tempcptr = CPtr;
+			setCurClose(curPos, &tempcptr);
 
-			if ((TempCPtr == NULL) || (TempCPtr == CPtr)) {
+			if ((tempcptr == NULL) || (tempcptr == CPtr)) {
 				if (CPtr == NULL)
-					HCPtr = OldCPtr;
+					hcptr = oldcptr;
 				else
-					HCPtr = CPtr->SubCloseUps;
+					hcptr = CPtr->SubCloseUps;
 			} else
-				HCPtr = TempCPtr->NextCloseUp;
+				hcptr = tempcptr->NextCloseUp;
 		} else
-			HCPtr = HCPtr->NextCloseUp;
+			hcptr = hcptr->NextCloseUp;
 
 
-		if (HCPtr == NULL) {
+		if (hcptr == NULL) {
 			if (CPtr == NULL)
-				HCPtr = OldCPtr;
+				hcptr = oldcptr;
 			else
-				HCPtr = CPtr->SubCloseUps;
+				hcptr = CPtr->SubCloseUps;
 		}
 
-		if (HCPtr)
-			_event->setMousePos(Common::Point(scaleX((HCPtr->x1 + HCPtr->x2) / 2), scaleY((HCPtr->y1 + HCPtr->y2) / 2)));
+		if (hcptr)
+			_event->setMousePos(Common::Point(scaleX((hcptr->x1 + hcptr->x2) / 2), scaleY((hcptr->y1 + hcptr->y2) / 2)));
 	} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) {
 		eatMessages();
 		_alternate = !_alternate;
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index b20667b..ad84402 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -105,7 +105,7 @@ int32 longDrawMessage(const char *text);
 
 /* The Wipes */
 
-void doWipe(uint16 WipeType, CloseDataPtr *CPtr, char *filename);
+void doWipe(uint16 WipeType, CloseDataPtr *cptr, char *filename);
 
 /* Double Buffer stuff */
 
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 8e63d36..946c8af 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -892,17 +892,17 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 	uint32 Class;
 	uint16 Qualifier, Code, MouseX, MouseY;
 	const char *Test = " ", *StartFileName = TextFileName;
-	CloseDataPtr StartCPtr = CPtr, TestCPtr, LastCPtr[10];
+	CloseDataPtr startcptr = CPtr, testcptr, lastcptr[10];
 	uint16 depth = 0;
 
-	LastCPtr[0] = CPtr;
+	lastcptr[0] = CPtr;
 
 	while (1) {
 		if (isinteractive) {
 			if (CPtr == NULL)
-				CPtr = StartCPtr;
+				CPtr = startcptr;
 
-			if (CPtr == StartCPtr)
+			if (CPtr == startcptr)
 				Test = StartFileName;
 			else
 				Test = CPtr->GraphicName;
@@ -955,7 +955,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 
 							if (depth) {
 								depth--;
-								CPtr = LastCPtr[depth];
+								CPtr = lastcptr[depth];
 							}
 						} else if (monitorPage > 0) {
 							monitorPage = 0;
@@ -963,13 +963,13 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 						}
 					}
 				} else if (isinteractive) {
-					TestCPtr = CPtr;
+					testcptr = CPtr;
 					MouseY = 64 + (MouseY / MonGadHeight) * 42;
 					MouseX = 101;
 					setCurClose(Common::Point(MouseX, MouseY), &CPtr, true);
 
-					if (TestCPtr != CPtr) {
-						LastCPtr[depth] = TestCPtr;
+					if (testcptr != CPtr) {
+						lastcptr[depth] = testcptr;
 						depth++;
 					}
 				}


Commit: 4424463f0618b8ae4a8416cf76024644497a79ad
    https://github.com/scummvm/scummvm/commit/4424463f0618b8ae4a8416cf76024644497a79ad
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:48+01:00

Commit Message:
LAB: Moved CPtr to engine class

Changed paths:
    engines/lab/engine.cpp
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/processroom.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index de9b567..35672fb 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -47,7 +47,6 @@ extern bool stopsound, DoNotDrawMessage;
 extern RoomData *_rooms;
 extern InventoryData *Inventory;
 extern uint16 NumInv, ManyRooms, HighestCondition, Direction;
-CloseDataPtr CPtr;
 
 bool ispal = false, noupdatediff = false, MainDisplay = true, QuitLab = false;
 
@@ -481,7 +480,7 @@ bool LabEngine::doUse(uint16 CurInv) {
 		interfaceOff();
 		_anim->stopDiff();
 		_curFileName = " ";
-		CPtr = NULL;
+		_cptr = NULL;
 		doMap(_roomNum);
 		setPalette(initcolors, 8);
 		drawMessage(NULL);
@@ -491,7 +490,7 @@ bool LabEngine::doUse(uint16 CurInv) {
 		interfaceOff();
 		_anim->stopDiff();
 		_curFileName = " ";
-		CPtr = NULL;
+		_cptr = NULL;
 		doJournal();
 		drawPanel();
 		drawMessage(NULL);
@@ -589,7 +588,7 @@ void LabEngine::mainGameLoop() {
 
 	setPalette(initcolors, 8);
 
-	CPtr    = NULL;
+	_cptr    = NULL;
 	_roomNum = 1;
 	Direction = NORTH;
 
@@ -623,8 +622,8 @@ void LabEngine::mainGameLoop() {
 			_music->resumeBackMusic();
 
 			/* Sees what kind of close up we're in and does the appropriate stuff, if any. */
-			if (doCloseUp(CPtr)) {
-				CPtr = NULL;
+			if (doCloseUp(_cptr)) {
+				_cptr = NULL;
 
 				mayShowCrumbIndicator();
 				screenUpdate();
@@ -632,7 +631,7 @@ void LabEngine::mainGameLoop() {
 
 			/* Sets the current picture properly on the screen */
 			if (MainDisplay)
-				_nextFileName = getPictName(&CPtr);
+				_nextFileName = getPictName(&_cptr);
 
 			if (noupdatediff) {
 				_roomsFound->inclElement(_roomNum); /* Potentially entered another room */
@@ -645,19 +644,19 @@ void LabEngine::mainGameLoop() {
 				_roomsFound->inclElement(_roomNum); /* Potentially entered another room */
 				_curFileName = _nextFileName;
 
-				if (CPtr) {
-					if ((CPtr->CloseUpType == SPECIALLOCK) && MainDisplay)  /* LAB: Labyrinth specific code */
+				if (_cptr) {
+					if ((_cptr->CloseUpType == SPECIALLOCK) && MainDisplay)  /* LAB: Labyrinth specific code */
 						showCombination(_curFileName);
-					else if (((CPtr->CloseUpType == SPECIALBRICK)  ||
-					          (CPtr->CloseUpType == SPECIALBRICKNOMOUSE)) &&
+					else if (((_cptr->CloseUpType == SPECIALBRICK)  ||
+					          (_cptr->CloseUpType == SPECIALBRICKNOMOUSE)) &&
 					         MainDisplay) /* LAB: Labyrinth specific code */
-						showTile(_curFileName, (bool)(CPtr->CloseUpType == SPECIALBRICKNOMOUSE));
+						showTile(_curFileName, (bool)(_cptr->CloseUpType == SPECIALBRICKNOMOUSE));
 					else
 						readPict(_curFileName, false);
 				} else
 					readPict(_curFileName, false);
 
-				drawRoomMessage(curInv, CPtr);
+				drawRoomMessage(curInv, _cptr);
 				forceDraw = false;
 
 				mayShowCrumbIndicator();
@@ -668,7 +667,7 @@ void LabEngine::mainGameLoop() {
 			}
 
 			if (forceDraw) {
-				drawRoomMessage(curInv, CPtr);
+				drawRoomMessage(curInv, _cptr);
 				forceDraw = false;
 				screenUpdate();
 			}
@@ -785,7 +784,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 						MainDisplay = true;
 						interfaceOn(); /* Sets the correct gadget list */
 						drawPanel();
-						drawRoomMessage(curInv, CPtr);
+						drawRoomMessage(curInv, _cptr);
 						screenUpdate();
 					}
 				} else {
@@ -836,7 +835,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 		} else if (code == 9) { /* TAB key */
 			msgClass = DELTAMOVE;
 		} else if (code == 27) { /* ESC key */
-			CPtr = NULL;
+			_cptr = NULL;
 		}
 
 		eatMessages();
@@ -850,17 +849,17 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			_longWinInFront = false;
 			DoNotDrawMessage = false;
 			drawPanel();
-			drawRoomMessage(curInv, CPtr);
+			drawRoomMessage(curInv, _cptr);
 			screenUpdate();
 		}
 	} else if ((msgClass == GADGETUP) && !_alternate) {
 		if (gadgetId <= 5) {
-			if ((actionMode == 4) && (gadgetId == 4) && (CPtr != NULL)) {
-				doMainView(&CPtr);
+			if ((actionMode == 4) && (gadgetId == 4) && (_cptr != NULL)) {
+				doMainView(&_cptr);
 
 				_anim->_doBlack = true;
 				hcptr = NULL;
-				CPtr = NULL;
+				_cptr = NULL;
 				mayShowCrumbIndicator();
 				screenUpdate();
 			} else if (gadgetId == 5) {
@@ -880,7 +879,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 					decIncInv(&curInv, false);
 
 				drawPanel();
-				drawRoomMessage(curInv, CPtr);
+				drawRoomMessage(curInv, _cptr);
 
 				mayShowCrumbIndicator();
 				screenUpdate();
@@ -912,7 +911,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			mayShowCrumbIndicator();
 			screenUpdate();
 		} else if (gadgetId >= 6) { /* Arrow Gadgets */
-			CPtr = NULL;
+			_cptr = NULL;
 			hcptr = NULL;
 
 			if ((gadgetId == 6) || (gadgetId == 8)) {
@@ -927,7 +926,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 				NewDir = Direction;
 				processArrow(&NewDir, gadgetId - 6);
-				doTurn(Direction, NewDir, &CPtr);
+				doTurn(Direction, NewDir, &_cptr);
 				_anim->_doBlack = true;
 				Direction = NewDir;
 				forceDraw = true;
@@ -937,7 +936,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			} else if (gadgetId == 7) {
 				OldRoomNum = _roomNum;
 
-				if (doGoForward(&CPtr)) {
+				if (doGoForward(&_cptr)) {
 					if (OldRoomNum == _roomNum)
 						_anim->_doBlack = true;
 				} else {
@@ -1012,7 +1011,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			MainDisplay = true;
 			interfaceOn(); /* Sets the correct gadget list */
 			drawPanel();
-			drawRoomMessage(curInv, CPtr);
+			drawRoomMessage(curInv, _cptr);
 
 			screenUpdate();
 		}
@@ -1025,7 +1024,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			_curFileName = " ";
 
 			doit = !saveRestoreGame();
-			CPtr = NULL;
+			_cptr = NULL;
 
 			MainDisplay = true;
 
@@ -1078,14 +1077,14 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			decIncInv(&curInv, true);
 			LastInv = curInv;
 			DoNotDrawMessage = false;
-			drawRoomMessage(curInv, CPtr);
+			drawRoomMessage(curInv, _cptr);
 
 			screenUpdate();
 		} else if (gadgetId == 4) { /* Right gadget */
 			decIncInv(&curInv, false);
 			LastInv = curInv;
 			DoNotDrawMessage = false;
-			drawRoomMessage(curInv, CPtr);
+			drawRoomMessage(curInv, _cptr);
 
 			screenUpdate();
 		} else if (gadgetId == 5) { /* bread crumbs */
@@ -1111,7 +1110,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 					MainDisplay = true;
 					interfaceOn(); /* Sets the correct gadget list */
 					drawPanel();
-					drawRoomMessage(curInv, CPtr);
+					drawRoomMessage(curInv, _cptr);
 					screenUpdate();
 				} else {
 					_breadCrumbs[0]._roomNum = 0;
@@ -1129,10 +1128,10 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 		doit = false;
 
-		if (CPtr) {
-			if ((CPtr->CloseUpType == SPECIALLOCK) && MainDisplay) /* LAB: Labyrinth specific code */
+		if (_cptr) {
+			if ((_cptr->CloseUpType == SPECIALLOCK) && MainDisplay) /* LAB: Labyrinth specific code */
 				mouseCombination(curPos);
-			else if ((CPtr->CloseUpType == SPECIALBRICK) && MainDisplay)
+			else if ((_cptr->CloseUpType == SPECIALBRICK) && MainDisplay)
 				mouseTile(curPos);
 			else
 				doit = true;
@@ -1145,43 +1144,43 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			eatMessages();
 
 			if (actionMode == 0) { /* Take something. */
-				if (doActionRule(Common::Point(curPos.x, curPos.y), actionMode, _roomNum, &CPtr))
+				if (doActionRule(Common::Point(curPos.x, curPos.y), actionMode, _roomNum, &_cptr))
 					_curFileName = _newFileName;
-				else if (takeItem(curPos.x, curPos.y, &CPtr))
+				else if (takeItem(curPos.x, curPos.y, &_cptr))
 					drawStaticMessage(kTextTakeItem);
-				else if (doActionRule(curPos, TAKEDEF - 1, _roomNum, &CPtr))
+				else if (doActionRule(curPos, TAKEDEF - 1, _roomNum, &_cptr))
 					_curFileName = _newFileName;
-				else if (doActionRule(curPos, TAKE - 1, 0, &CPtr))
+				else if (doActionRule(curPos, TAKE - 1, 0, &_cptr))
 					_curFileName = _newFileName;
 				else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
 					drawStaticMessage(kTextNothing);
 			} else if ((actionMode == 1) /* Manipulate an object */  ||
 			         (actionMode == 2) /* Open up a "door" */      ||
 			         (actionMode == 3)) { /* Close a "door" */
-				if (doActionRule(curPos, actionMode, _roomNum, &CPtr))
+				if (doActionRule(curPos, actionMode, _roomNum, &_cptr))
 					_curFileName = _newFileName;
-				else if (!doActionRule(curPos, actionMode, 0, &CPtr)) {
+				else if (!doActionRule(curPos, actionMode, 0, &_cptr)) {
 					if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
 						drawStaticMessage(kTextNothing);
 				}
 			} else if (actionMode == 4) { /* Look at closeups */
-				tempcptr = CPtr;
+				tempcptr = _cptr;
 				setCurClose(curPos, &tempcptr);
 
-				if (CPtr == tempcptr) {
+				if (_cptr == tempcptr) {
 					if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
 						drawStaticMessage(kTextNothing);
 				} else if (tempcptr->GraphicName) {
 					if (*(tempcptr->GraphicName)) {
 						_anim->_doBlack = true;
-						CPtr = tempcptr;
+						_cptr = tempcptr;
 					} else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
 						drawStaticMessage(kTextNothing);
 				} else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
 					drawStaticMessage(kTextNothing);
 			} else if ((actionMode == 5)  &&
 			         _conditions->in(curInv)) { /* Use an item on something else */
-				if (doOperateRule(curPos.x, curPos.y, curInv, &CPtr)) {
+				if (doOperateRule(curPos.x, curPos.y, curInv, &_cptr)) {
 					_curFileName = _newFileName;
 
 					if (!_conditions->in(curInv))
@@ -1198,14 +1197,14 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 		oldcptr = VPtr->closeUps;
 
 		if (hcptr == NULL) {
-			tempcptr = CPtr;
+			tempcptr = _cptr;
 			setCurClose(curPos, &tempcptr);
 
-			if ((tempcptr == NULL) || (tempcptr == CPtr)) {
-				if (CPtr == NULL)
+			if ((tempcptr == NULL) || (tempcptr == _cptr)) {
+				if (_cptr == NULL)
 					hcptr = oldcptr;
 				else
-					hcptr = CPtr->SubCloseUps;
+					hcptr = _cptr->SubCloseUps;
 			} else
 				hcptr = tempcptr->NextCloseUp;
 		} else
@@ -1213,10 +1212,10 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 
 		if (hcptr == NULL) {
-			if (CPtr == NULL)
+			if (_cptr == NULL)
 				hcptr = oldcptr;
 			else
-				hcptr = CPtr->SubCloseUps;
+				hcptr = _cptr->SubCloseUps;
 		}
 
 		if (hcptr)
@@ -1237,7 +1236,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 		}
 
 		drawPanel();
-		drawRoomMessage(curInv, CPtr);
+		drawRoomMessage(curInv, _cptr);
 
 		mayShowCrumbIndicator();
 		screenUpdate();
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 3e96d04..44f8045 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -134,6 +134,7 @@ private:
 
 public:
 	bool _longWinInFront;
+	CloseDataPtr _cptr;
 
 private:
 	bool createScreen(bool HiRes);
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 05c60b1..b5855ea 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -43,8 +43,6 @@ namespace Lab {
 
 extern uint16 Direction;
 
-extern CloseDataPtr CPtr;
-
 /*****************************************************************************/
 /* Converts an Amiga palette (up to 16 colors) to a VGA palette, then sets   */
 /* the VGA palette.                                                          */
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 30f26d4..0d6b5e3 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -49,7 +49,6 @@ InventoryData *Inventory;
 uint16 NumInv, ManyRooms, HighestCondition, Direction;
 
 extern bool DoNotDrawMessage, noupdatediff, QuitLab, MusicOn;
-extern CloseDataPtr CPtr;
 
 /*****************************************************************************/
 /* Generates a random number.                                                */
@@ -554,9 +553,9 @@ static void doActions(Action *APtr, CloseDataPtr *lcptr) {
 			if (APtr->Param1 == 0)
 				g_lab->_anim->_doBlack = true;
 			else if (APtr->Param1 == 1)
-				g_lab->_anim->_doBlack = (CPtr == NULL);
+				g_lab->_anim->_doBlack = (g_lab->_cptr == NULL);
 			else if (APtr->Param1 == 2)
-				g_lab->_anim->_doBlack = (CPtr != NULL);
+				g_lab->_anim->_doBlack = (g_lab->_cptr != NULL);
 			else if (APtr->Param1 == 5) { /* inverse the palette */
 				for (uint16 idx = (8 * 3); idx < (255 * 3); idx++)
 					g_lab->_anim->_diffPalette[idx] = 255 - g_lab->_anim->_diffPalette[idx];
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 946c8af..1881056 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -83,7 +83,6 @@ uint16 CurTile[4][4] = {
 
 extern uint16 *FadePalette;
 extern BitMap *DispBitMap, *DrawBitMap;
-extern CloseDataPtr CPtr;
 extern InventoryData *Inventory;
 extern uint16 Direction;
 
@@ -892,20 +891,20 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 	uint32 Class;
 	uint16 Qualifier, Code, MouseX, MouseY;
 	const char *Test = " ", *StartFileName = TextFileName;
-	CloseDataPtr startcptr = CPtr, testcptr, lastcptr[10];
+	CloseDataPtr startcptr = _cptr, testcptr, lastcptr[10];
 	uint16 depth = 0;
 
-	lastcptr[0] = CPtr;
+	lastcptr[0] = _cptr;
 
 	while (1) {
 		if (isinteractive) {
-			if (CPtr == NULL)
-				CPtr = startcptr;
+			if (_cptr == NULL)
+				_cptr = startcptr;
 
-			if (CPtr == startcptr)
+			if (_cptr == startcptr)
 				Test = StartFileName;
 			else
-				Test = CPtr->GraphicName;
+				Test = _cptr->GraphicName;
 
 			if (strcmp(Test, TextFileName)) {
 				monitorPage      = 0;
@@ -955,7 +954,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 
 							if (depth) {
 								depth--;
-								CPtr = lastcptr[depth];
+								_cptr = lastcptr[depth];
 							}
 						} else if (monitorPage > 0) {
 							monitorPage = 0;
@@ -963,12 +962,12 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 						}
 					}
 				} else if (isinteractive) {
-					testcptr = CPtr;
+					testcptr = _cptr;
 					MouseY = 64 + (MouseY / MonGadHeight) * 42;
 					MouseX = 101;
-					setCurClose(Common::Point(MouseX, MouseY), &CPtr, true);
+					setCurClose(Common::Point(MouseX, MouseY), &_cptr, true);
 
-					if (testcptr != CPtr) {
+					if (testcptr != _cptr) {
 						lastcptr[depth] = testcptr;
 						depth++;
 					}


Commit: 3b40199ab64382f7422abeb5bf6def43588496a8
    https://github.com/scummvm/scummvm/commit/3b40199ab64382f7422abeb5bf6def43588496a8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:48+01:00

Commit Message:
LAB: Move doActions() to LabEngine class

Changed paths:
    engines/lab/lab.h
    engines/lab/processroom.cpp



diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 44f8045..afe191b 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -131,8 +131,6 @@ private:
 	bool _lastMessageLong;
 	bool _lastTooLong;
 	TextFont *_msgFont;
-
-public:
 	bool _longWinInFront;
 	CloseDataPtr _cptr;
 
@@ -203,6 +201,10 @@ private:
 	void mayShowCrumbIndicator();
 	void mayShowCrumbIndicatorOff();
 	const char *getInvName(uint16 curInv);
+
+public:
+	void doActions(Action *aPtr, CloseDataPtr *lcptr);
+
 };
 
 extern LabEngine *g_lab;
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 0d6b5e3..e621795 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -321,92 +321,92 @@ bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
 /*****************************************************************************/
 /* Processes the action list.                                                */
 /*****************************************************************************/
-static void doActions(Action *APtr, CloseDataPtr *lcptr) {
+void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 	CloseDataPtr tlcptr;
-	bool FirstLoaded = true;
-	char **str, *Test;
-	uint32 StartSecs, StartMicros, CurSecs, CurMicros;
+	bool firstLoaded = true;
+	char **str;
+	uint32 startSecs, startMicros, curSecs, curMicros;
 
-	while (APtr) {
-		g_lab->_music->updateMusic();
+	while (aptr) {
+		_music->updateMusic();
 
-		switch (APtr->ActionType) {
+		switch (aptr->ActionType) {
 		case PLAYSOUND:
-			g_lab->_music->_loopSoundEffect = false;
-			g_lab->_music->_waitTillFinished = true;
-			readMusic((char *)APtr->Data, true);
-			g_lab->_music->_waitTillFinished = false;
+			_music->_loopSoundEffect = false;
+			_music->_waitTillFinished = true;
+			readMusic((char *)aptr->Data, true);
+			_music->_waitTillFinished = false;
 			break;
 
 		case PLAYSOUNDB:
-			g_lab->_music->_loopSoundEffect = false;
-			g_lab->_music->_waitTillFinished = false;
-			readMusic((char *)APtr->Data, false);
+			_music->_loopSoundEffect = false;
+			_music->_waitTillFinished = false;
+			readMusic((char *)aptr->Data, false);
 			break;
 
 		case PLAYSOUNDCONT:
-			g_lab->_music->_doNotFilestopSoundEffect = true;
-			g_lab->_music->_loopSoundEffect = true;
-			readMusic((char *)APtr->Data, g_lab->_music->_waitTillFinished);
+			_music->_doNotFilestopSoundEffect = true;
+			_music->_loopSoundEffect = true;
+			readMusic((char *)aptr->Data, _music->_waitTillFinished);
 			break;
 
 		case SHOWDIFF:
-			readPict((char *)APtr->Data, true);
+			readPict((char *)aptr->Data, true);
 			break;
 
 		case SHOWDIFFCONT:
-			readPict((char *)APtr->Data, false);
+			readPict((char *)aptr->Data, false);
 			break;
 
 		case LOADDIFF:
-			if (FirstLoaded) {
+			if (firstLoaded) {
 				resetBuffer();
-				FirstLoaded = false;
+				firstLoaded = false;
 			}
 
-			if (APtr->Data)
-				g_lab->_music->newOpen((char *)APtr->Data);          /* Puts a file into memory */
+			if (aptr->Data)
+				_music->newOpen((char *)aptr->Data);          /* Puts a file into memory */
 
 			break;
 
 		case WIPECMD:
-			g_lab->doWipe(APtr->Param1, lcptr, (char *)APtr->Data);
+			doWipe(aptr->Param1, lcptr, (char *)aptr->Data);
 			break;
 
 		case NOUPDATE:
 			noupdatediff = true;
-			g_lab->_anim->_doBlack = false;
+			_anim->_doBlack = false;
 			break;
 
 		case FORCEUPDATE:
-			g_lab->_curFileName = " ";
+			_curFileName = " ";
 			break;
 
-		case SHOWCURPICT:
-			Test = getPictName(lcptr);
+		case SHOWCURPICT: {
+				char *test = getPictName(lcptr);
 
-			if (strcmp(Test, g_lab->_curFileName) != 0) {
-				g_lab->_curFileName = Test;
-				readPict(g_lab->_curFileName, true);
+				if (strcmp(test, _curFileName) != 0) {
+					_curFileName = test;
+					readPict(_curFileName, true);
+				}
 			}
-
 			break;
 
 		case SETELEMENT:
-			g_lab->_conditions->inclElement(APtr->Param1);
+			_conditions->inclElement(aptr->Param1);
 			break;
 
 		case UNSETELEMENT:
-			g_lab->_conditions->exclElement(APtr->Param1);
+			_conditions->exclElement(aptr->Param1);
 			break;
 
 		case SHOWMESSAGE:
 			DoNotDrawMessage = false;
 
-			if (g_lab->_longWinInFront)
-				g_lab->longDrawMessage((char *)APtr->Data);
+			if (_longWinInFront)
+				longDrawMessage((char *)aptr->Data);
 			else
-				g_lab->drawMessage((char *)APtr->Data);
+				drawMessage((char *)aptr->Data);
 
 			DoNotDrawMessage = true;
 			break;
@@ -414,38 +414,38 @@ static void doActions(Action *APtr, CloseDataPtr *lcptr) {
 		case CSHOWMESSAGE:
 			if (*lcptr == NULL) {
 				DoNotDrawMessage = false;
-				g_lab->drawMessage((char *)APtr->Data);
+				drawMessage((char *)aptr->Data);
 				DoNotDrawMessage = true;
 			}
 
 			break;
 
 		case SHOWMESSAGES:
-			str = (char **)APtr->Data;
+			str = (char **)aptr->Data;
 			DoNotDrawMessage = false;
-			g_lab->drawMessage(str[getRandom(APtr->Param1)]);
+			drawMessage(str[getRandom(aptr->Param1)]);
 			DoNotDrawMessage = true;
 			break;
 
 		case SETPOSITION:
-			if (APtr->Param1 & 0x8000) {
+			if (aptr->Param1 & 0x8000) {
 				// This is a Wyrmkeep Windows trial version, thus stop at this
 				// point, since we can't check for game payment status
 				readPict(getPictName(lcptr), true);
-				APtr = NULL;
+				aptr = NULL;
 				GUI::MessageDialog trialMessage("This is the end of the trial version. You can play the full game using the original interpreter from Wyrmkeep");
 				trialMessage.runModal();
 				continue;
 			}
 
-			g_lab->_roomNum   = APtr->Param1;
-			Direction = APtr->Param2 - 1;
+			_roomNum   = aptr->Param1;
+			Direction = aptr->Param2 - 1;
 			*lcptr      = NULL;
-			g_lab->_anim->_doBlack = true;
+			_anim->_doBlack = true;
 			break;
 
 		case SETCLOSEUP:
-			tlcptr = getObject(scaleX(APtr->Param1), scaleY(APtr->Param2), *lcptr);
+			tlcptr = getObject(scaleX(aptr->Param1), scaleY(aptr->Param2), *lcptr);
 
 			if (tlcptr)
 				*lcptr = tlcptr;
@@ -457,17 +457,17 @@ static void doActions(Action *APtr, CloseDataPtr *lcptr) {
 			break;
 
 		case SUBINV:
-			if (Inventory[APtr->Param1].Many)
-				(Inventory[APtr->Param1].Many)--;
+			if (Inventory[aptr->Param1].Many)
+				(Inventory[aptr->Param1].Many)--;
 
-			if (Inventory[APtr->Param1].Many == 0)
-				g_lab->_conditions->exclElement(APtr->Param1);
+			if (Inventory[aptr->Param1].Many == 0)
+				_conditions->exclElement(aptr->Param1);
 
 			break;
 
 		case ADDINV:
-			(Inventory[APtr->Param1].Many) += APtr->Param2;
-			g_lab->_conditions->inclElement(APtr->Param1);
+			(Inventory[aptr->Param1].Many) += aptr->Param2;
+			_conditions->inclElement(aptr->Param1);
 			break;
 
 		case SHOWDIR:
@@ -475,66 +475,66 @@ static void doActions(Action *APtr, CloseDataPtr *lcptr) {
 			break;
 
 		case WAITSECS:
-			g_lab->addCurTime(APtr->Param1, 0, &StartSecs, &StartMicros);
+			addCurTime(aptr->Param1, 0, &startSecs, &startMicros);
 
-			g_lab->screenUpdate();
+			screenUpdate();
 
 			while (1) {
-				g_lab->_music->updateMusic();
-				g_lab->_anim->diffNextFrame();
-				g_lab->getTime(&CurSecs, &CurMicros);
+				_music->updateMusic();
+				_anim->diffNextFrame();
+				getTime(&curSecs, &curMicros);
 
-				if ((CurSecs > StartSecs) || ((CurSecs == StartSecs) &&
-				                              (CurMicros >= StartMicros)))
+				if ((curSecs > startSecs) || ((curSecs == startSecs) &&
+				                              (curMicros >= startMicros)))
 					break;
 			}
 
 			break;
 
 		case STOPMUSIC:
-			g_lab->_music->setMusic(false);
+			_music->setMusic(false);
 			break;
 
 		case STARTMUSIC:
-			g_lab->_music->setMusic(true);
+			_music->setMusic(true);
 			break;
 
 		case CHANGEMUSIC:
-			g_lab->_music->changeMusic((const char *)APtr->Data);
-			g_lab->_music->setMusicReset(false);
+			_music->changeMusic((const char *)aptr->Data);
+			_music->setMusicReset(false);
 			break;
 
 		case RESETMUSIC:
-			g_lab->_music->resetMusic();
-			g_lab->_music->setMusicReset(true);
+			_music->resetMusic();
+			_music->setMusicReset(true);
 			break;
 
 		case FILLMUSIC:
-			g_lab->_music->updateMusic();
+			_music->updateMusic();
 			break;
 
 		case WAITSOUND:
-			while (g_lab->_music->isSoundEffectActive()) {
-				g_lab->_music->updateMusic();
-				g_lab->_anim->diffNextFrame();
-				g_lab->waitTOF();
+			while (_music->isSoundEffectActive()) {
+				_music->updateMusic();
+				_anim->diffNextFrame();
+				waitTOF();
 			}
 
 			break;
 
 		case CLEARSOUND:
-			if (g_lab->_music->_loopSoundEffect) {
-				g_lab->_music->_loopSoundEffect = false;
-				g_lab->_music->stopSoundEffect();
-			} else if (g_lab->_music->isSoundEffectActive())
-				g_lab->_music->stopSoundEffect();
+			if (_music->_loopSoundEffect) {
+				_music->_loopSoundEffect = false;
+				_music->stopSoundEffect();
+			} else if (_music->isSoundEffectActive())
+				_music->stopSoundEffect();
 
 			break;
 
 		case WINMUSIC:
-			g_lab->_music->_winmusic = true;
-			g_lab->_music->freeMusic();
-			g_lab->_music->initMusic();
+			_music->_winmusic = true;
+			_music->freeMusic();
+			_music->initMusic();
 			break;
 
 		case WINGAME:
@@ -550,53 +550,53 @@ static void doActions(Action *APtr, CloseDataPtr *lcptr) {
 			break;
 
 		case SPECIALCMD:
-			if (APtr->Param1 == 0)
-				g_lab->_anim->_doBlack = true;
-			else if (APtr->Param1 == 1)
-				g_lab->_anim->_doBlack = (g_lab->_cptr == NULL);
-			else if (APtr->Param1 == 2)
-				g_lab->_anim->_doBlack = (g_lab->_cptr != NULL);
-			else if (APtr->Param1 == 5) { /* inverse the palette */
+			if (aptr->Param1 == 0)
+				_anim->_doBlack = true;
+			else if (aptr->Param1 == 1)
+				_anim->_doBlack = (_cptr == NULL);
+			else if (aptr->Param1 == 2)
+				_anim->_doBlack = (_cptr != NULL);
+			else if (aptr->Param1 == 5) { /* inverse the palette */
 				for (uint16 idx = (8 * 3); idx < (255 * 3); idx++)
-					g_lab->_anim->_diffPalette[idx] = 255 - g_lab->_anim->_diffPalette[idx];
+					_anim->_diffPalette[idx] = 255 - _anim->_diffPalette[idx];
 
-				g_lab->waitTOF();
-				g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
-				g_lab->waitTOF();
-				g_lab->waitTOF();
-			} else if (APtr->Param1 == 4) { /* white the palette */
+				waitTOF();
+				setPalette(_anim->_diffPalette, 256);
+				waitTOF();
+				waitTOF();
+			} else if (aptr->Param1 == 4) { /* white the palette */
 				whiteScreen();
-				g_lab->waitTOF();
-				g_lab->waitTOF();
-			} else if (APtr->Param1 == 6) { /* Restore the palette */
-				g_lab->waitTOF();
-				g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
-				g_lab->waitTOF();
-				g_lab->waitTOF();
-			} else if (APtr->Param1 == 7) { /* Quick pause */
-				g_lab->waitTOF();
-				g_lab->waitTOF();
-				g_lab->waitTOF();
+				waitTOF();
+				waitTOF();
+			} else if (aptr->Param1 == 6) { /* Restore the palette */
+				waitTOF();
+				setPalette(_anim->_diffPalette, 256);
+				waitTOF();
+				waitTOF();
+			} else if (aptr->Param1 == 7) { /* Quick pause */
+				waitTOF();
+				waitTOF();
+				waitTOF();
 			}
 
 			break;
 		}
 
-		APtr = APtr->NextAction;
+		aptr = aptr->NextAction;
 	}
 
-	if (g_lab->_music->_loopSoundEffect) {
-		g_lab->_music->_loopSoundEffect = false;
-		g_lab->_music->stopSoundEffect();
+	if (_music->_loopSoundEffect) {
+		_music->_loopSoundEffect = false;
+		_music->stopSoundEffect();
 	} else {
-		while (g_lab->_music->isSoundEffectActive()) {
-			g_lab->_music->updateMusic();
-			g_lab->_anim->diffNextFrame();
-			g_lab->waitTOF();
+		while (_music->isSoundEffectActive()) {
+			_music->updateMusic();
+			_anim->diffNextFrame();
+			waitTOF();
 		}
 	}
 
-	g_lab->_music->_doNotFilestopSoundEffect = false;
+	_music->_doNotFilestopSoundEffect = false;
 }
 
 /*****************************************************************************/
@@ -621,7 +621,7 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr lcptr, Clo
 				        ||
 						((action == 1) && ((*rule)->Param2 == (-lcptr->CloseUpType)))) {
 					if (checkConditions((*rule)->Condition)) {
-						doActions((*rule)->ActionList, Set);
+						g_lab->doActions((*rule)->ActionList, Set);
 						return true;
 					}
 				}
@@ -675,7 +675,7 @@ static bool doOperateRuleSub(int16 ItemNum, int16 roomNum, CloseDataPtr lcptr, C
 				        (((*rule)->Param1 == ItemNum) || (((*rule)->Param1 == 0) && AllowDefaults)) &&
 						(((*rule)->Param2 == lcptr->CloseUpType) || (((*rule)->Param2 == 0) && AllowDefaults))) {
 					if (checkConditions((*rule)->Condition)) {
-						doActions((*rule)->ActionList, Set);
+						g_lab->doActions((*rule)->ActionList, Set);
 						return true;
 					}
 				}
@@ -728,7 +728,7 @@ bool doGoForward(CloseDataPtr *lcptr) {
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 		if (((*rule)->RuleType == GOFORWARD) && ((*rule)->Param1 == (Direction + 1))) {
 			if (checkConditions((*rule)->Condition)) {
-				doActions((*rule)->ActionList, lcptr);
+				g_lab->doActions((*rule)->ActionList, lcptr);
 				return true;
 			}
 		}
@@ -751,7 +751,7 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *lcptr) {
 		        (((*rule)->RuleType == TURNFROMTO) &&
 		         ((*rule)->Param1   == from) && ((*rule)->Param2 == to))) {
 			if (checkConditions((*rule)->Condition)) {
-				doActions((*rule)->ActionList, lcptr);
+				g_lab->doActions((*rule)->ActionList, lcptr);
 				return true;
 			}
 		}
@@ -768,7 +768,7 @@ bool doMainView(CloseDataPtr *lcptr) {
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 		if ((*rule)->RuleType == GOMAINVIEW) {
 			if (checkConditions((*rule)->Condition)) {
-				doActions((*rule)->ActionList, lcptr);
+				g_lab->doActions((*rule)->ActionList, lcptr);
 				return true;
 			}
 		}


Commit: f76f0d957a3945a6a503ab0c26da0f08ed4842a3
    https://github.com/scummvm/scummvm/commit/f76f0d957a3945a6a503ab0c26da0f08ed4842a3
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:48+01:00

Commit Message:
LAB: Merge room views into an array

Changed paths:
    engines/lab/parsetypes.h
    engines/lab/processroom.cpp
    engines/lab/resource.cpp



diff --git a/engines/lab/parsetypes.h b/engines/lab/parsetypes.h
index 82174b8..6be1ba2 100644
--- a/engines/lab/parsetypes.h
+++ b/engines/lab/parsetypes.h
@@ -140,7 +140,7 @@ struct RoomData {
 
 	byte _wipeType;
 
-	ViewData *_northView, *_southView, *_eastView, *_westView;
+	ViewData *_view[4];
 	RuleList *_rules;
 	char *_roomMsg;
 };
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index e621795..1858aeb 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -93,14 +93,7 @@ ViewData *getViewData(uint16 roomNum, uint16 direction) {
 	if (!_rooms[roomNum]._roomMsg)
 		g_lab->_resource->readViews(roomNum);
 
-	if (direction == NORTH)
-		view = _rooms[roomNum]._northView;
-	else if (direction == SOUTH)
-		view = _rooms[roomNum]._southView;
-	else if (direction == EAST)
-		view = _rooms[roomNum]._eastView;
-	else if (direction == WEST)
-		view = _rooms[roomNum]._westView;
+	view = _rooms[roomNum]._view[direction];
 
 	do {
 		if (checkConditions(view->Condition))
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 70233de..b1507fe 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -115,10 +115,10 @@ bool Resource::readRoomData(const char *fileName) {
 		_rooms[i]._westDoor = dataFile->readUint16LE();
 		_rooms[i]._wipeType = dataFile->readByte();
 
-		_rooms[i]._northView = nullptr;
-		_rooms[i]._southView = nullptr;
-		_rooms[i]._eastView = nullptr;
-		_rooms[i]._westView = nullptr;
+		_rooms[i]._view[NORTH] = nullptr;
+		_rooms[i]._view[SOUTH] = nullptr;
+		_rooms[i]._view[EAST] = nullptr;
+		_rooms[i]._view[WEST] = nullptr;
 		_rooms[i]._rules = nullptr;
 		_rooms[i]._roomMsg = nullptr;
 	}
@@ -154,10 +154,10 @@ bool Resource::readViews(uint16 roomNum) {
 	allocroom = roomNum;
 
 	_rooms[roomNum]._roomMsg = readString(dataFile);
-	_rooms[roomNum]._northView = readView(dataFile);
-	_rooms[roomNum]._southView = readView(dataFile);
-	_rooms[roomNum]._eastView = readView(dataFile);
-	_rooms[roomNum]._westView = readView(dataFile);
+	_rooms[roomNum]._view[NORTH] = readView(dataFile);
+	_rooms[roomNum]._view[SOUTH] = readView(dataFile);
+	_rooms[roomNum]._view[EAST] = readView(dataFile);
+	_rooms[roomNum]._view[WEST] = readView(dataFile);
 	_rooms[roomNum]._rules = readRule(dataFile);
 
 	_vm->_music->updateMusic();


Commit: 23b70db958604649f5a324a09da56c5dc86a57c0
    https://github.com/scummvm/scummvm/commit/23b70db958604649f5a324a09da56c5dc86a57c0
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:48+01:00

Commit Message:
LAB: Cleanup of palette code

Changed paths:
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index afe191b..9586a48 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -74,7 +74,7 @@ public:
 
 	int _screenWidth;
 	int _screenHeight;
-	int _screenBytesPerPage;
+	uint32 _screenBytesPerPage;
 
 
 	// timing.cpp
@@ -151,8 +151,6 @@ public:
 	void setPalette(void *cmap, uint16 numcolors);
 	void drawHLine(uint16 x, uint16 y1, uint16 y2);
 	void drawVLine(uint16 x1, uint16 y, uint16 x2);
-	void writeColorReg(byte *buf, uint16 regnum);
-	void writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg);
 
 	void drawPanel();
 	void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr);
@@ -185,12 +183,6 @@ public:
 	void changeVolume(int delta);
 
 private:
-	void quickWaitTOF();
-
-	/*---------- Drawing Routines ----------*/
-
-	void applyPalette(byte *buf, uint16 first, uint16 numreg, uint16 slow);
-
 	// engine.cpp
 	bool setUpScreens();
 	void freeScreens();
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index b5855ea..9ce9f08 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -60,7 +60,8 @@ void setAmigaPal(uint16 *pal, uint16 numcolors) {
 		vgapal[vgacount++] = (byte)(((pal[i] & 0x00f)) << 2);
 	}
 
-	g_lab->writeColorRegsSmooth(vgapal, 0, 16);
+	g_lab->writeColorRegs(vgapal, 0, 16);
+	g_lab->waitTOF();
 }
 
 /*---------------------------------------------------------------------------*/
@@ -620,7 +621,7 @@ void LabEngine::processMap(uint16 CurRoom) {
 			}
 
 			waitTOF();
-			writeColorReg(newcolor, 1);
+			writeColorRegs(newcolor, 1, 1);
 			_event->updateMouse();
 			waitTOF();
 			_event->updateMouse();
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index d64953c..73f80b2 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -49,7 +49,7 @@ bool LabEngine::createScreen(bool hiRes) {
 	}
 	_screenBytesPerPage = _screenWidth * _screenHeight;
 
-	_displayBuffer = (byte *)malloc(_screenBytesPerPage);
+	_displayBuffer = new byte[_screenBytesPerPage];	// FIXME: Memory leak!
 
 	return true;
 }
@@ -76,19 +76,6 @@ void LabEngine::waitTOF() {
 	_lastWaitTOFTicks = now;
 }
 
-void LabEngine::applyPalette(byte *buf, uint16 first, uint16 numreg, uint16 slow) {
-	byte tmp[256 * 3];
-
-	for (int i = 0; i < 256 * 3; i++) {
-		tmp[i] = buf[i] * 4;
-	}
-
-	g_system->getPaletteManager()->setPalette(tmp, first, numreg);
-
-	if (slow)
-    	waitTOF();
-}
-
 /*****************************************************************************/
 /* Writes any number of the 256 color registers.                             */
 /* first:    the number of the first color register to write.                */
@@ -101,22 +88,15 @@ void LabEngine::applyPalette(byte *buf, uint16 first, uint16 numreg, uint16 slow
 /*           selected.                                                       */
 /*****************************************************************************/
 void LabEngine::writeColorRegs(byte *buf, uint16 first, uint16 numreg) {
-	applyPalette(buf, first, numreg, 0);
-	memcpy(&(_curvgapal[first * 3]), buf, numreg * 3);
-}
+	byte tmp[256 * 3];
 
-void LabEngine::writeColorRegsSmooth(byte *buf, uint16 first, uint16 numreg) {
-	applyPalette(buf, first, numreg, 1);
-	memcpy(&(_curvgapal[first * 3]), buf, numreg * 3);
-}
+	for (int i = 0; i < 256 * 3; i++) {
+		tmp[i] = buf[i] * 4;
+	}
 
-/*****************************************************************************/
-/* Sets one of the 256 (0..255) color registers.  buf is a char pointer,     */
-/* the first character in the string is the red value, then green, then      */
-/* blue.  Each color value is a 6 bit value.                                 */
-/*****************************************************************************/
-void LabEngine::writeColorReg(byte *buf, uint16 regnum) {
-	writeColorRegs(buf, regnum, 1);
+	g_system->getPaletteManager()->setPalette(tmp, first, numreg);
+
+	memcpy(&(_curvgapal[first * 3]), buf, numreg * 3);
 }
 
 void LabEngine::setPalette(void *cmap, uint16 numcolors) {


Commit: 1913a61f30f4200c044f11268ab6fca40f0af510
    https://github.com/scummvm/scummvm/commit/1913a61f30f4200c044f11268ab6fca40f0af510
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:48+01:00

Commit Message:
LAB: Some renaming and cleanup

Changed paths:
    engines/lab/graphics.cpp
    engines/lab/interface.cpp
    engines/lab/interface.h
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/special.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 6fa29d8..9e65fa9 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -652,7 +652,7 @@ void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 				linesdone = 0;
 			}
 
-			ghoastRect(0, 0, curY, _screenWidth - 1, curY + 1);
+			overlayRect(0, 0, curY, _screenWidth - 1, curY + 1);
 			curY += 4;
 			linesdone++;
 		}
@@ -708,7 +708,7 @@ void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 				imDest._imageData = getCurrentDrawingBuffer();
 
 				imSource.bltBitMap(0, curY, &imDest, 0, curY, _screenWidth, 2);
-				ghoastRect(0, 0, curY, _screenWidth - 1, curY + 1);
+				overlayRect(0, 0, curY, _screenWidth - 1, curY + 1);
 				curY += 4;
 				linesdone++;
 			}
@@ -756,14 +756,13 @@ void LabEngine::doWipe(uint16 wipeType, CloseDataPtr *cPtr, char *filename) {
 		_anim->diffNextFrame();
 }
 
-static byte blackbuffer[256 * 3];
-
 /*****************************************************************************/
 /* Changes the front screen to black.                                        */
 /*****************************************************************************/
 void blackScreen() {
-	memset(blackbuffer, 0, 248 * 3);
-	g_lab->writeColorRegs(blackbuffer, 8, 248);
+	byte pal[256 * 3];
+	memset(pal, 0, 248 * 3);
+	g_lab->writeColorRegs(pal, 8, 248);
 
 	g_system->delayMillis(32);
 }
@@ -772,16 +771,18 @@ void blackScreen() {
 /* Changes the front screen to white.                                        */
 /*****************************************************************************/
 void whiteScreen() {
-	memset(blackbuffer, 255, 248 * 3);
-	g_lab->writeColorRegs(blackbuffer, 8, 248);
+	byte pal[256 * 3];
+	memset(pal, 255, 248 * 3);
+	g_lab->writeColorRegs(pal, 8, 248);
 }
 
 /*****************************************************************************/
 /* Changes the entire screen to black.                                       */
 /*****************************************************************************/
 void blackAllScreen() {
-	memset(blackbuffer, 0, 256 * 3);
-	g_lab->writeColorRegs(blackbuffer, 0, 256);
+	byte pal[256 * 3];
+	memset(pal, 0, 256 * 3);
+	g_lab->writeColorRegs(pal, 0, 256);
 
 	g_system->delayMillis(32);
 }
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 9a51978..7352b61 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -84,7 +84,7 @@ void drawGadgetList(Gadget *gadlist) {
 		gadlist->_image->drawImage(gadlist->x, gadlist->y);
 
 		if (GADGETOFF & gadlist->GadgetFlags)
-			ghoastGadget(gadlist, 1);
+			disableGadget(gadlist, 1);
 
 		gadlist = gadlist->NextGadget;
 	}
@@ -92,19 +92,19 @@ void drawGadgetList(Gadget *gadlist) {
 
 
 /*****************************************************************************/
-/* Ghoasts a gadget, and makes it unavailable for using.                     */
+/* Dims a gadget, and makes it unavailable for using.                        */
 /*****************************************************************************/
-void ghoastGadget(Gadget *curgad, uint16 pencolor) {
-	g_lab->ghoastRect(pencolor, curgad->x, curgad->y, curgad->x + curgad->_image->_width - 1, curgad->y + curgad->_image->_height - 1);
+void disableGadget(Gadget *curgad, uint16 pencolor) {
+	g_lab->overlayRect(pencolor, curgad->x, curgad->y, curgad->x + curgad->_image->_width - 1, curgad->y + curgad->_image->_height - 1);
 	curgad->GadgetFlags |= GADGETOFF;
 }
 
 
 
 /*****************************************************************************/
-/* Unghoasts a gadget, and makes it available again.                         */
+/* Undims a gadget, and makes it available again.                            */
 /*****************************************************************************/
-void unGhoastGadget(Gadget *curgad) {
+void enableGadget(Gadget *curgad) {
 	curgad->_image->drawImage(curgad->x, curgad->y);
 	curgad->GadgetFlags &= !(GADGETOFF);
 }
diff --git a/engines/lab/interface.h b/engines/lab/interface.h
index ceeb4a8..de770f0 100644
--- a/engines/lab/interface.h
+++ b/engines/lab/interface.h
@@ -113,8 +113,8 @@ extern Common::KeyState _keyPressed;
 Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt);
 void freeButtonList(void *gptrlist);
 void drawGadgetList(Gadget *gadlist);
-void ghoastGadget(Gadget *curgad, uint16 pencolor);
-void unGhoastGadget(Gadget *curgad);
+void disableGadget(Gadget *curgad, uint16 pencolor);
+void enableGadget(Gadget *curgad);
 IntuiMessage *getMsg();
 
 } // End of namespace Lab
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 9586a48..f19a1ba 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -147,7 +147,7 @@ public:
 	void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-	void ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void setPalette(void *cmap, uint16 numcolors);
 	void drawHLine(uint16 x, uint16 y1, uint16 y2);
 	void drawVLine(uint16 x1, uint16 y, uint16 x2);
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 9ce9f08..7471b1f 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -491,7 +491,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 	char *sptr;
 
 	uint16 tempfloor;
-	bool noghoast;
+	bool noOverlay;
 
 	_event->mouseHide();
 
@@ -517,20 +517,20 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 		drawRoom(CurRoom, true);
 
 	tempfloor = Floor;
-	getUpFloor(&tempfloor, &noghoast);
+	getUpFloor(&tempfloor, &noOverlay);
 
-	if (noghoast)
-		unGhoastGadget(&upgadget);
+	if (noOverlay)
+		enableGadget(&upgadget);
 	else
-		ghoastGadget(&upgadget, 12);
+		disableGadget(&upgadget, 12);
 
 	tempfloor = Floor;
-	getDownFloor(&tempfloor, &noghoast);
+	getDownFloor(&tempfloor, &noOverlay);
 
-	if (noghoast)
-		unGhoastGadget(&downgadget);
+	if (noOverlay)
+		enableGadget(&downgadget);
 	else
-		ghoastGadget(&downgadget, 12);
+		disableGadget(&downgadget, 12);
 
 	// Labyrinth specific code
 	if (Floor == LOWERFLOOR) {
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 1881056..50cf0fe 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -657,14 +657,14 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 		turnPage((bool)(wipenum == 1));
 
 	if (JPage == 0)
-		ghoastGadget(&BackG, 15);
+		disableGadget(&BackG, 15);
 	else
-		unGhoastGadget(&BackG);
+		enableGadget(&BackG);
 
 	if (lastpage)
-		ghoastGadget(&ForwardG, 15);
+		disableGadget(&ForwardG, 15);
 	else
-		unGhoastGadget(&ForwardG);
+		enableGadget(&ForwardG);
 
 
 	if (needFade)
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 73f80b2..0248bb8 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -270,9 +270,9 @@ void LabEngine::drawHLine(uint16 x1, uint16 y, uint16 x2) {
 }
 
 /*****************************************************************************/
-/* Ghoasts a region on the screen using the desired pen color.               */
+/* Overlays a region on the screen using the desired pen color.              */
 /*****************************************************************************/
-void LabEngine::ghoastRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+void LabEngine::overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	int dx = x1;
 	int dy = y1;
 	int w = x2 - x1 + 1;


Commit: f7fe91c8d23af3628f5df3c553ac4a0f0538d6c2
    https://github.com/scummvm/scummvm/commit/f7fe91c8d23af3628f5df3c553ac4a0f0538d6c2
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:48+01:00

Commit Message:
LAB: Function reordering

Changed paths:
    engines/lab/graphics.cpp



diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 9e65fa9..520828a 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -141,23 +141,6 @@ bool readPict(const char *filename, bool playOnce) {
 }
 
 /*****************************************************************************/
-/* Reads in a music file.  Ignores any graphics.                             */
-/*****************************************************************************/
-bool readMusic(const char *filename, bool waitTillFinished) {
-	Common::File *file = g_lab->_resource->openDataFile(filename, MKTAG('D', 'I', 'F', 'F'));
-	g_lab->_music->updateMusic();
-	if (!g_lab->_music->_doNotFilestopSoundEffect)
-		g_lab->_music->stopSoundEffect();
-	if (!file)
-		return false;
-
-	g_lab->_anim->_doBlack = false;
-	g_lab->_anim->readSound(waitTillFinished, file);
-
-	return true;
-}
-
-/*****************************************************************************/
 /* Reads in a picture into buffer memory.                                    */
 /*****************************************************************************/
 byte *readPictToMem(const char *filename, uint16 x, uint16 y) {
@@ -174,8 +157,8 @@ byte *readPictToMem(const char *filename, uint16 x, uint16 y) {
 		return NULL;
 
 	DispBitMap->_bytesPerRow = x;
-	DispBitMap->_rows        = y;
-	DispBitMap->_flags       = BITMAPF_NONE;
+	DispBitMap->_rows = y;
+	DispBitMap->_flags = BITMAPF_NONE;
 	DispBitMap->_planes[0] = curMem;
 	DispBitMap->_planes[1] = DispBitMap->_planes[0] + 0x10000;
 	DispBitMap->_planes[2] = DispBitMap->_planes[1] + 0x10000;
@@ -187,6 +170,23 @@ byte *readPictToMem(const char *filename, uint16 x, uint16 y) {
 	return mem;
 }
 
+/*****************************************************************************/
+/* Reads in a music file.  Ignores any graphics.                             */
+/*****************************************************************************/
+bool readMusic(const char *filename, bool waitTillFinished) {
+	Common::File *file = g_lab->_resource->openDataFile(filename, MKTAG('D', 'I', 'F', 'F'));
+	g_lab->_music->updateMusic();
+	if (!g_lab->_music->_doNotFilestopSoundEffect)
+		g_lab->_music->stopSoundEffect();
+	if (!file)
+		return false;
+
+	g_lab->_anim->_doBlack = false;
+	g_lab->_anim->readSound(waitTillFinished, file);
+
+	return true;
+}
+
 /*---------------------------------------------------------------------------*/
 /*------------ Does all the text rendering to the message boxes. ------------*/
 /*---------------------------------------------------------------------------*/


Commit: 914bd262955c9da140d89dc6cf3fa03940a13c62
    https://github.com/scummvm/scummvm/commit/914bd262955c9da140d89dc6cf3fa03940a13c62
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:49+01:00

Commit Message:
LAB: Cleanup of roomCords()

Changed paths:
    engines/lab/map.cpp



diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 7471b1f..a2a4ed3 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -252,34 +252,29 @@ void fade(bool fadein, uint16 res) {
 /* Figures out what a room's coordinates should be.                          */
 /*****************************************************************************/
 static void roomCords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16 *y2) {
-	*x1 = mapScaleX(Maps[CurRoom].x);
-	*y1 = mapScaleY(Maps[CurRoom].y);
-	*x2 = *x1;
-	*y2 = *y1;
+	Image *curRoomImg = NULL;
 
 	switch (Maps[CurRoom].SpecialID) {
 	case NORMAL:
 	case UPARROWROOM:
 	case DOWNARROWROOM:
-		(*x2) += Room->_width;
-		(*y2) += Room->_height;
+		curRoomImg = Room;
 		break;
-
 	case BRIDGEROOM:
-		(*x2) += Bridge->_width;
-		(*y2) += Bridge->_height;
+		curRoomImg = Bridge;
 		break;
-
 	case VCORRIDOR:
-		(*x2) += VRoom->_width;
-		(*y2) += VRoom->_height;
+		curRoomImg = VRoom;
 		break;
-
 	case HCORRIDOR:
-		(*x2) += HRoom->_width;
-		(*y2) += HRoom->_height;
+		curRoomImg = HRoom;
 		break;
 	}
+
+	*x1 = mapScaleX(Maps[CurRoom].x);
+	*y1 = mapScaleY(Maps[CurRoom].y);
+	*x2 = *x1 + curRoomImg->_width;
+	*y2 = *y1 + curRoomImg->_height;
 }
 
 /*****************************************************************************/


Commit: 359eda3b9728548b654e16b01df39b1c54b81fdd
    https://github.com/scummvm/scummvm/commit/359eda3b9728548b654e16b01df39b1c54b81fdd
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:49+01:00

Commit Message:
LAB: openDataFile can also be used without checking for a file header

Changed paths:
    engines/lab/resource.cpp
    engines/lab/resource.h



diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index b1507fe..415839d 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -172,7 +172,7 @@ Common::File *Resource::openDataFile(const char *fileName, uint32 fileHeader) {
 	if (!dataFile->isOpen())
 		error("openDataFile couldn't open %s (%s)", translateFileName(fileName), fileName);
 
-	if (dataFile->readUint32BE() != fileHeader) {
+	if (fileHeader > 0 && dataFile->readUint32BE() != fileHeader) {
 		dataFile->close();
 		return nullptr;
 	}
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index b9bdbbb..3516569 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -98,7 +98,7 @@ public:
 	Resource(LabEngine *vm);
 	~Resource() {}
 
-	Common::File *openDataFile(const char * fileName, uint32 fileHeader);
+	Common::File *openDataFile(const char * fileName, uint32 fileHeader = 0);
 	bool readRoomData(const char *fileName);
 	bool readInventory(const char *fileName);
 	bool readViews(uint16 roomNum);


Commit: 8f4d9c9c05e71036e80b47db380eff7922087fd5
    https://github.com/scummvm/scummvm/commit/8f4d9c9c05e71036e80b47db380eff7922087fd5
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:49+01:00

Commit Message:
LAB: Image accepts a Common::File now

Changed paths:
    engines/lab/engine.cpp
    engines/lab/image.cpp
    engines/lab/image.h
    engines/lab/map.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 35672fb..7b14afc 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -181,26 +181,10 @@ bool LabEngine::setUpScreens() {
 	if (!createScreen(_isHiRes))
 		return false;
 
-	/* Loads in the graphics for the movement control panel */
-	Common::File file;
-	file.open(translateFileName("P:Control"));
-	if (!file.isOpen())
-		warning("setUpScreens couldn't open %s", translateFileName("P:Control"));
-
-	if (file.err() || file.size() == 0)
-		return false;
-
-	byte *movePanelBuffer;
-	if (!(movePanelBuffer = (byte *)calloc(file.size(), 1)))
-		return false;
-
-	file.read(movePanelBuffer, file.size());
-	file.close();
-
-	byte *buffer = movePanelBuffer;
-
+	Common::File *controlFile = g_lab->_resource->openDataFile("P:Control");
 	for (uint16 i = 0; i < 20; i++)
-		_moveImages[i] = new Image(&buffer);
+		_moveImages[i] = new Image(controlFile);
+	delete controlFile;
 
 	/* Creates the gadgets for the movement control panel */
 	uint16 y = VGAScaleY(173) - SVGACord(2);
@@ -247,25 +231,11 @@ bool LabEngine::setUpScreens() {
 		curGadget->NextGadget = createButton(289, y, 9, 0, _moveImages[10], _moveImages[11]);
 	}
 
-	file.open(translateFileName("P:Inv"));
-	if (!file.isOpen())
-		warning("setUpScreens couldn't open %s", translateFileName("P:Inv"));
-
-	if (file.err() || file.size() == 0)
-		return false;
-
-	byte *invPanelBuffer;
-	if (!(invPanelBuffer = (byte *)calloc(file.size(), 1)))
-		return false;
-
-	file.read(invPanelBuffer, file.size());
-	file.close();
-
-	buffer = invPanelBuffer;
+	Common::File *invFile = g_lab->_resource->openDataFile("P:Inv");
 
 	if (getPlatform() == Common::kPlatformWindows) {
 		for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++)
-			_invImages[imgIdx] = new Image(&buffer);
+			_invImages[imgIdx] = new Image(invFile);
 
 		_invGadgetList = createButton(24, y, 0, 'm', _invImages[0], _invImages[1]);
 		Gadget *curGadget = _invGadgetList;
@@ -285,7 +255,7 @@ bool LabEngine::setUpScreens() {
 		curGadget = curGadget->NextGadget;
 	} else {
 		for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++)
-			_invImages[imgIdx] = new Image(&buffer);
+			_invImages[imgIdx] = new Image(invFile);
 
 		_invGadgetList = createButton(58, y, 0, 0, _invImages[0], _invImages[1]);
 		Gadget *curGadget = _invGadgetList;
@@ -301,6 +271,8 @@ bool LabEngine::setUpScreens() {
 		curGadget = curGadget->NextGadget;
 	}
 
+	delete invFile;
+
 	return true;
 }
 
diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp
index 0fd7425..3f5801f 100644
--- a/engines/lab/image.cpp
+++ b/engines/lab/image.cpp
@@ -36,21 +36,17 @@ namespace Lab {
 /*****************************************************************************/
 /* Reads in an image from disk.                                              */
 /*****************************************************************************/
-Image::Image(byte **buffer) {
-	uint32 size;
+Image::Image(Common::File *s) {
+	_width = s->readUint16LE();
+	_height = s->readUint16LE();
+	s->skip(4);
 
-	_width = READ_LE_UINT16(*buffer);
-	_height = READ_LE_UINT16(*buffer + 2);
-
-	*buffer += 8; /* sizeof(struct Image); */
-
-	size = _width * _height;
-
-	if (1L & size)
+	uint32 size = _width * _height;
+	if (size & 1)
 		size++;
 
-	_imageData = (byte *)(*buffer);
-	(*buffer) += size;
+	_imageData = new byte[size];	// FIXME: Memory leak!
+	s->read(_imageData, size);
 }
 
 /*****************************************************************************/
diff --git a/engines/lab/image.h b/engines/lab/image.h
index 450c177..8f4d0f8 100644
--- a/engines/lab/image.h
+++ b/engines/lab/image.h
@@ -41,7 +41,7 @@ public:
 
     Image() : _width(0), _height(0), _imageData(0) {}
     Image(int w, int h, byte *d) : _width(w), _height(h), _imageData(d) {}
-    Image(byte **buffer);
+	Image(Common::File *s);
 
     void drawImage(uint16 x, uint16 y);
     void drawMaskImage(uint16 x, uint16 y);
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index a2a4ed3..b331261 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -129,43 +129,37 @@ static uint16 mapScaleY(uint16 y) {
 /* Loads in the map data.                                                    */
 /*****************************************************************************/
 static bool loadMapData() {
-	byte **buffer;
-	uint32 Size;
 	Gadget *gptr;
 	uint16 counter;
 
-	resetBuffer();  /* Make images load into start of buffer */
-	buffer = g_lab->_music->newOpen("P:MapImage", Size);
+	Common::File *mapImages = g_lab->_resource->openDataFile("P:MapImage");
 
-	if (!buffer)
-		return false;
+	Map = new Image(mapImages);
 
-	stealBufMem(Size); /* Now freeze that buffer from further use */
+	Room = new Image(mapImages);
+	UpArrowRoom = new Image(mapImages);
+	DownArrowRoom = new Image(mapImages);
+	HRoom = new Image(mapImages);
+	VRoom = new Image(mapImages);
+	Maze = new Image(mapImages);
+	HugeMaze = new Image(mapImages);
 
-	Map = new Image(buffer);
+	MapNorth = new Image(mapImages);
+	MapEast = new Image(mapImages);
+	MapSouth = new Image(mapImages);
+	MapWest = new Image(mapImages);
 
-	Room = new Image(buffer);
-	UpArrowRoom = new Image(buffer);
-	DownArrowRoom = new Image(buffer);
-	HRoom = new Image(buffer);
-	VRoom = new Image(buffer);
-	Maze = new Image(buffer);
-	HugeMaze = new Image(buffer);
+	Path = new Image(mapImages);
+	Bridge = new Image(mapImages);
 
-	MapNorth = new Image(buffer);
-	MapEast = new Image(buffer);
-	MapSouth = new Image(buffer);
-	MapWest = new Image(buffer);
+	Back = new Image(mapImages);
+	BackAlt = new Image(mapImages);
+	Up = new Image(mapImages);
+	UpAlt = new Image(mapImages);
+	Down = new Image(mapImages);
+	DownAlt = new Image(mapImages);
 
-	Path = new Image(buffer);
-	Bridge = new Image(buffer);
-
-	Back = new Image(buffer);
-	BackAlt = new Image(buffer);
-	Up = new Image(buffer);
-	UpAlt = new Image(buffer);
-	Down = new Image(buffer);
-	DownAlt = new Image(buffer);
+	delete mapImages;
 
 	backgadget._image    = Back;
 	backgadget._altImage = BackAlt;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 50cf0fe..f8b0c20 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -137,8 +137,6 @@ static void doCombination() {
 /* Reads in a backdrop picture.                                              */
 /*****************************************************************************/
 void showCombination(const char *filename) {
-	byte **buffer;
-
 	resetBuffer();
 	g_lab->_anim->_doBlack = true;
 	g_lab->_anim->_noPalChange = true;
@@ -147,10 +145,12 @@ void showCombination(const char *filename) {
 
 	blackScreen();
 
-	buffer = g_lab->_music->newOpen("P:Numbers");
+	Common::File *numFile = g_lab->_resource->openDataFile("P:Numbers");
 
 	for (uint16 CurBit = 0; CurBit < 10; CurBit++)
-		Images[CurBit] = new Image(buffer);
+		Images[CurBit] = new Image(numFile);
+
+	delete numFile;
 
 	allocFile((void **)&g_lab->_tempScrollData, Images[0]->_width * Images[0]->_height * 2L, "tempdata");
 
@@ -279,8 +279,7 @@ static void doTile(bool showsolution) {
 /* Reads in a backdrop picture.                                              */
 /*****************************************************************************/
 void showTile(const char *filename, bool showsolution) {
-	uint16 start;
-	byte **buffer;
+	uint16 start = showsolution ? 0 : 1;
 
 	resetBuffer();
 	g_lab->_anim->_doBlack = true;
@@ -289,19 +288,12 @@ void showTile(const char *filename, bool showsolution) {
 	g_lab->_anim->_noPalChange = false;
 	blackScreen();
 
-	if (showsolution) {
-		start  = 0;
-		buffer = g_lab->_music->newOpen("P:TileSolution");
-	} else {
-		start  = 1;
-		buffer = g_lab->_music->newOpen("P:Tile");
-	}
-
-	if (!buffer)
-		return;
+	Common::File *tileFile = tileFile = g_lab->_resource->openDataFile(showsolution ? "P:TileSolution" : "P:Tile");
 
 	for (uint16 curBit = start; curBit < 16; curBit++)
-		Tiles[curBit] = new Image(buffer);
+		Tiles[curBit] = new Image(tileFile);
+
+	delete tileFile;
 
 	allocFile((void **)&g_lab->_tempScrollData, Tiles[1]->_width * Tiles[1]->_height * 2L, "tempdata");
 
@@ -506,7 +498,6 @@ void doWestPaper() {
 /* Loads in the data for the journal.                                        */
 /*****************************************************************************/
 static bool loadJournalData() {
-	byte **buffer;
 	char filename[20];
 	Gadget *TopGadget = &BackG;
 	bool bridge, dirty, news, clean;
@@ -543,17 +534,16 @@ static bool loadJournalData() {
 	journaltext = g_lab->_resource->getText(filename);
 	journaltexttitle = g_lab->_resource->getText("Lab:Rooms/jt");
 
-	buffer = g_lab->_music->newOpen("P:JImage");
+	Common::File *journalFile = g_lab->_resource->openDataFile("P:JImage");
 
-	if (!buffer)
-		return false;
+	BackG._image = new Image(journalFile);
+	BackG._altImage = new Image(journalFile);
+	ForwardG._image = new Image(journalFile);
+	ForwardG._altImage = new Image(journalFile);
+	CancelG._image = new Image(journalFile);
+	CancelG._altImage = new Image(journalFile);
 
-	BackG._image = new Image(buffer);
-	BackG._altImage = new Image(buffer);
-	ForwardG._image = new Image(buffer);
-	ForwardG._altImage = new Image(buffer);
-	CancelG._image = new Image(buffer);
-	CancelG._altImage = new Image(buffer);
+	delete journalFile;
 
 	BackG.KeyEquiv = VKEY_LTARROW;
 	ForwardG.KeyEquiv = VKEY_RTARROW;
@@ -807,19 +797,9 @@ bool saveRestoreGame() {
 /* Makes sure that the buttons are in memory.                                */
 /*****************************************************************************/
 static void getMonImages() {
-	byte **buffer;
-	uint32 bufferSize;
-
-	resetBuffer();
-
-	buffer = g_lab->_music->newOpen("P:MonImage", bufferSize);
-
-	if (!buffer)
-		return;
-
-	MonButton = new Image(buffer);
-
-	stealBufMem(bufferSize);  /* Trick: protects the memory where the buttons are so they won't be over-written */
+	Common::File *buttonFile = g_lab->_resource->openDataFile("P:MonImage");
+	MonButton = new Image(buttonFile);
+	delete buttonFile;
 }
 
 


Commit: 4d46c1e820f7c33f55fa08d92334c25e6bb123c1
    https://github.com/scummvm/scummvm/commit/4d46c1e820f7c33f55fa08d92334c25e6bb123c1
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:49+01:00

Commit Message:
LAB: Merge getCurMemLabFile() into allocFile()

Changed paths:
    engines/lab/labfile.cpp



diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
index 3a34f80..4fee3ba 100644
--- a/engines/lab/labfile.cpp
+++ b/engines/lab/labfile.cpp
@@ -69,38 +69,6 @@ static void freeFile(uint16 RMarker) {
 	FileMarkers[RMarker].End    = NULL;
 }
 
-
-
-
-
-/*****************************************************************************/
-/* Gets a chunk of memory from the buffer.                                   */
-/*****************************************************************************/
-static void *getCurMemLabFile(uint32 size) {
-	void *ptr = 0;
-
-	if ((((char *) _memPlace) + size - 1) >=
-	        (((char *) buffer) + buffersize))
-		_memPlace = buffer;
-
-	ptr = _memPlace;
-	_memPlace = (char *)_memPlace + size;
-
-	for (int i = 0; i < MAXMARKERS; i++) {
-		if (FileMarkers[i].name[0]) {
-			if ( ((FileMarkers[i].Start >= ptr) && (FileMarkers[i].Start < _memPlace))
-			  || ((FileMarkers[i].End >= ptr) && (FileMarkers[i].End < _memPlace))
-			  || ((ptr >= FileMarkers[i].Start) && (ptr <= FileMarkers[i].End)))
-				freeFile(i);
-		}
-	}
-
-	return ptr;
-}
-
-
-
-
 /*****************************************************************************/
 /* Checks if a file is already buffered.                                     */
 /*****************************************************************************/
@@ -118,9 +86,6 @@ byte **isBuffered(const char *fileName) {
 	return NULL;
 }
 
-
-
-
 /*****************************************************************************/
 /* Grabs a chunk of memory from the room buffer, and manages it for a        */
 /* particular room. If it returns true, then the file is already in memory. */
@@ -148,16 +113,29 @@ bool allocFile(void **Ptr, uint32 Size, const char *fileName) {
 	freeFile(RMarker);
 	strcpy(FileMarkers[RMarker].name, fileName);
 
-	*Ptr = getCurMemLabFile(Size);
-	FileMarkers[RMarker].Start = *Ptr;
-	FileMarkers[RMarker].End   = (void *)(((char *)(*Ptr)) + Size - 1);
+	*Ptr = 0;
 
-	return false;
-}
+	if ((((char *)_memPlace) + Size - 1) >=
+		(((char *)buffer) + buffersize))
+		_memPlace = buffer;
 
+	*Ptr = _memPlace;
+	_memPlace = (char *)_memPlace + Size;
 
+	for (int i = 0; i < MAXMARKERS; i++) {
+		if (FileMarkers[i].name[0]) {
+			if (((FileMarkers[i].Start >= Ptr) && (FileMarkers[i].Start < _memPlace))
+				|| ((FileMarkers[i].End >= Ptr) && (FileMarkers[i].End < _memPlace))
+				|| ((Ptr >= FileMarkers[i].Start) && (Ptr <= FileMarkers[i].End)))
+				freeFile(i);
+		}
+	}
 
+	FileMarkers[RMarker].Start = *Ptr;
+	FileMarkers[RMarker].End   = (void *)(((char *)(*Ptr)) + Size - 1);
 
+	return false;
+}
 
 /*----- Main routines -----*/
 
@@ -215,7 +193,6 @@ void resetBuffer() {
 }
 
 
-
 /*****************************************************************************/
 /* Initializes the buffer.                                                   */
 /*****************************************************************************/
@@ -231,9 +208,6 @@ bool initBuffer(uint32 BufSize, bool IsGraphicsMem) {
 	return (buffer != NULL);
 }
 
-
-
-
 /*****************************************************************************/
 /* Frees the buffer.                                                         */
 /*****************************************************************************/
@@ -244,9 +218,6 @@ void freeBuffer() {
 		free(buffer);
 }
 
-
-
-
 /*------------------------------------------------------------------------*/
 /* The following routines allow stealing of memory from the buffer (which */
 /* later may or may not be given back).                                   */


Commit: ca52b2624ee420b80a79bae2648e3fd5d7e79e76
    https://github.com/scummvm/scummvm/commit/ca52b2624ee420b80a79bae2648e3fd5d7e79e76
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:49+01:00

Commit Message:
LAB: The size parameter of newOpen() is no longer used

Changed paths:
    engines/lab/music.cpp
    engines/lab/music.h



diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 6a7bb4b..e9deb8e 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -320,11 +320,6 @@ void Music::resetMusic() {
 	_tFile = 0;
 }
 
-byte **Music::newOpen(const char *name) {
-	uint32 unused;
-	return newOpen(name, unused);
-}
-
 /*****************************************************************************/
 /* Checks whether or note enough memory in music buffer before loading any   */
 /* files.  Fills it if not.  Does not take into account the current buffer   */
@@ -333,7 +328,7 @@ byte **Music::newOpen(const char *name) {
 /*                                                                           */
 /* Here, the seconds are multipled by 10.                                    */
 /*****************************************************************************/
-byte **Music::newOpen(const char *name, uint32 &size) {
+byte **Music::newOpen(const char *name) {
 	byte **file;
 
 	if (!name || !strcmp(name, "") || !strcmp(name, " "))
@@ -347,7 +342,8 @@ byte **Music::newOpen(const char *name, uint32 &size) {
 	if (!_doNotFilestopSoundEffect)
 		stopSoundEffect();
 
-	file = openFile(name, size);
+	uint32 unused;
+	file = openFile(name, unused);
 	updateMusic();
 	return file;
 }
diff --git a/engines/lab/music.h b/engines/lab/music.h
index 1e2bdc3..45528e5 100644
--- a/engines/lab/music.h
+++ b/engines/lab/music.h
@@ -53,7 +53,6 @@ public:
 	Music(LabEngine *vm);
 
 	byte **newOpen(const char *name);
-	byte **newOpen(const char *name, uint32 &size);
 	bool initMusic();
 	void freeMusic();
 	void updateMusic();


Commit: 58e6627f1989b69a70358ec91ab54a0f180b56c9
    https://github.com/scummvm/scummvm/commit/58e6627f1989b69a70358ec91ab54a0f180b56c9
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:49+01:00

Commit Message:
LAB: Remove superfluous image variables

Changed paths:
    engines/lab/map.cpp



diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index b331261..9b7f3f3 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -72,8 +72,7 @@ extern RoomData *_rooms;
 
 static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge,
 			 *HRoom, *VRoom, *Maze, *HugeMaze, *Path, *MapNorth,
-			 *MapEast, *MapSouth, *MapWest, *XMark, *Back, *BackAlt,
-			 *Down, *DownAlt, *Up, *UpAlt;
+			 *MapEast, *MapSouth, *MapWest, *XMark;
 
 static uint16 MaxRooms;
 static MapData *Maps;
@@ -152,22 +151,15 @@ static bool loadMapData() {
 	Path = new Image(mapImages);
 	Bridge = new Image(mapImages);
 
-	Back = new Image(mapImages);
-	BackAlt = new Image(mapImages);
-	Up = new Image(mapImages);
-	UpAlt = new Image(mapImages);
-	Down = new Image(mapImages);
-	DownAlt = new Image(mapImages);
+	backgadget._image = new Image(mapImages);
+	backgadget._altImage = new Image(mapImages);
+	upgadget._image = new Image(mapImages);
+	upgadget._altImage = new Image(mapImages);
+	downgadget._image = new Image(mapImages);
+	downgadget._altImage = new Image(mapImages);
 
 	delete mapImages;
 
-	backgadget._image    = Back;
-	backgadget._altImage = BackAlt;
-	upgadget._image      = Up;
-	upgadget._altImage   = UpAlt;
-	downgadget._image    = Down;
-	downgadget._altImage = DownAlt;
-
 	counter = 0;
 	gptr = MapGadgetList;
 


Commit: 58e16e2cd745f170749afa1e3a5a358624556f7c
    https://github.com/scummvm/scummvm/commit/58e16e2cd745f170749afa1e3a5a358624556f7c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:49+01:00

Commit Message:
LAB: More renames and C++'ify

Changed paths:
    engines/lab/processroom.cpp



diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 1858aeb..2976c49 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -63,22 +63,19 @@ uint16 getRandom(uint16 max) {
 /*****************************************************************************/
 /* Checks whether all the conditions in a condition list are met.            */
 /*****************************************************************************/
-static bool checkConditions(int16 *Condition) {
-	int16 Counter;
-	bool res;
-
-	if (Condition == NULL)
+static bool checkConditions(int16 *condition) {
+	if (condition == NULL)
 		return true;
 
-	if (Condition[0] == 0)
+	if (condition[0] == 0)
 		return true;
 
-	Counter = 1;
-	res     = g_lab->_conditions->in(Condition[0]);
+	int counter = 1;
+	bool res = g_lab->_conditions->in(condition[0]);
 
-	while (Condition[Counter] && res) {
-		res = g_lab->_conditions->in(Condition[Counter]);
-		Counter++;
+	while (condition[counter] && res) {
+		res = g_lab->_conditions->in(condition[counter]);
+		counter++;
 	}
 
 	return res;
@@ -88,12 +85,10 @@ static bool checkConditions(int16 *Condition) {
 /* Gets the current ViewDataPointer.                                         */
 /*****************************************************************************/
 ViewData *getViewData(uint16 roomNum, uint16 direction) {
-	ViewData *view = NULL;
-
 	if (!_rooms[roomNum]._roomMsg)
 		g_lab->_resource->readViews(roomNum);
 
-	view = _rooms[roomNum]._view[direction];
+	ViewData *view = _rooms[roomNum]._view[direction];
 
 	do {
 		if (checkConditions(view->Condition))
@@ -109,16 +104,11 @@ ViewData *getViewData(uint16 roomNum, uint16 direction) {
 /* Gets an object, if any, from the user's click on the screen.              */
 /*****************************************************************************/
 static CloseData *getObject(uint16 x, uint16 y, CloseDataPtr lcptr) {
-	ViewData *VPtr;
-
 	if (lcptr == NULL) {
-		VPtr = getViewData(g_lab->_roomNum, Direction);
-		lcptr = VPtr->closeUps;
-	}
-
-	else
+		lcptr = getViewData(g_lab->_roomNum, Direction)->closeUps;
+	} else {
 		lcptr = lcptr->SubCloseUps;
-
+	}
 
 	while (lcptr != NULL) {
 		if ((x >= scaleX(lcptr->x1)) && (y >= scaleY(lcptr->y1)) &&
@@ -137,21 +127,21 @@ static CloseData *getObject(uint16 x, uint16 y, CloseDataPtr lcptr) {
 /*      some of the closeups have the same hit boxes, then this returns the  */
 /*      first occurence of the object with the same hit box.                 */
 /*****************************************************************************/
-static CloseDataPtr findCPtrMatch(CloseDataPtr Main, CloseDataPtr List) {
+static CloseDataPtr findCPtrMatch(CloseDataPtr cpmain, CloseDataPtr list) {
 	CloseDataPtr cptr;
 
-	while (List) {
-		if ((Main->x1 == List->x1) && (Main->x2 == List->x2) &&
-		        (Main->y1 == List->y1) && (Main->y2 == List->y2) &&
-		        (Main->depth == List->depth))
-			return List;
+	while (list) {
+		if ((cpmain->x1 == list->x1) && (cpmain->x2 == list->x2) &&
+		        (cpmain->y1 == list->y1) && (cpmain->y2 == list->y2) &&
+		        (cpmain->depth == list->depth))
+			return list;
 
-		cptr = findCPtrMatch(Main, List->SubCloseUps);
+		cptr = findCPtrMatch(cpmain, list->SubCloseUps);
 
 		if (cptr)
 			return cptr;
 		else
-			List = List->NextCloseUp;
+			list = list->NextCloseUp;
 	}
 
 	return NULL;
@@ -161,16 +151,16 @@ static CloseDataPtr findCPtrMatch(CloseDataPtr Main, CloseDataPtr List) {
 /* Returns the current picture name.                                         */
 /*****************************************************************************/
 char *getPictName(CloseDataPtr *lcptr) {
-	ViewData *ViewPtr = getViewData(g_lab->_roomNum, Direction);
+	ViewData *viewPtr = getViewData(g_lab->_roomNum, Direction);
 
 	if (*lcptr != NULL) {
-		*lcptr = findCPtrMatch(*lcptr, ViewPtr->closeUps);
+		*lcptr = findCPtrMatch(*lcptr, viewPtr->closeUps);
 
 		if (*lcptr)
 			return (*lcptr)->GraphicName;
 	}
 
-	return ViewPtr->GraphicName;
+	return viewPtr->GraphicName;
 }
 
 /*****************************************************************************/
@@ -204,10 +194,10 @@ void LabEngine::drawDirection(CloseDataPtr lcptr) {
 /*****************************************************************************/
 /* process a arrow gadget movement.                                          */
 /*****************************************************************************/
-bool processArrow(uint16 *direction, uint16 Arrow) {
-	uint16 room = 1;
+bool processArrow(uint16 *direction, uint16 arrow) {
+	if (arrow == 1) { /* Forward */
+		uint16 room = 1;
 
-	if (Arrow == 1) { /* Forward */
 		if (*direction == NORTH)
 			room = _rooms[g_lab->_roomNum]._northDoor;
 		else if (*direction == SOUTH)
@@ -221,7 +211,7 @@ bool processArrow(uint16 *direction, uint16 Arrow) {
 			return false;
 		else
 			g_lab->_roomNum = room;
-	} else if (Arrow == 0) { /* Left */
+	} else if (arrow == 0) { /* Left */
 		if (*direction == NORTH)
 			*direction = WEST;
 		else if (*direction == WEST)
@@ -230,7 +220,7 @@ bool processArrow(uint16 *direction, uint16 Arrow) {
 			*direction = EAST;
 		else
 			*direction = NORTH;
-	} else if (Arrow == 2) { /* Right */
+	} else if (arrow == 2) { /* Right */
 		if (*direction == NORTH)
 			*direction = EAST;
 		else if (*direction == EAST)
@@ -248,13 +238,11 @@ bool processArrow(uint16 *direction, uint16 Arrow) {
 /* Sets the current close up data.                                           */
 /*****************************************************************************/
 void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords) {
-	ViewData *VPtr;
 	CloseDataPtr lcptr;
 	uint16 x1, y1, x2, y2;
 
 	if (*cptr == NULL) {
-		VPtr = getViewData(g_lab->_roomNum, Direction);
-		lcptr = VPtr->closeUps;
+		lcptr = getViewData(g_lab->_roomNum, Direction)->closeUps;
 	} else
 		lcptr = (*cptr)->SubCloseUps;
 
@@ -284,12 +272,10 @@ void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords)
 /* Takes the currently selected item.                                        */
 /*****************************************************************************/
 bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
-	ViewData *VPtr;
 	CloseDataPtr lcptr;
 
 	if (*cptr == NULL) {
-		VPtr = getViewData(g_lab->_roomNum, Direction);
-		lcptr = VPtr->closeUps;
+		lcptr = getViewData(g_lab->_roomNum, Direction)->closeUps;
 	} else if ((*cptr)->CloseUpType < 0) {
 		g_lab->_conditions->inclElement(abs((*cptr)->CloseUpType));
 		return true;
@@ -315,10 +301,7 @@ bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
 /* Processes the action list.                                                */
 /*****************************************************************************/
 void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
-	CloseDataPtr tlcptr;
 	bool firstLoaded = true;
-	char **str;
-	uint32 startSecs, startMicros, curSecs, curMicros;
 
 	while (aptr) {
 		_music->updateMusic();
@@ -413,11 +396,12 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 
 			break;
 
-		case SHOWMESSAGES:
-			str = (char **)aptr->Data;
-			DoNotDrawMessage = false;
-			drawMessage(str[getRandom(aptr->Param1)]);
-			DoNotDrawMessage = true;
+		case SHOWMESSAGES: {
+				char **str = (char **)aptr->Data;
+				DoNotDrawMessage = false;
+				drawMessage(str[getRandom(aptr->Param1)]);
+				DoNotDrawMessage = true;
+			}
 			break;
 
 		case SETPOSITION:
@@ -437,12 +421,12 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			_anim->_doBlack = true;
 			break;
 
-		case SETCLOSEUP:
-			tlcptr = getObject(scaleX(aptr->Param1), scaleY(aptr->Param2), *lcptr);
-
-			if (tlcptr)
-				*lcptr = tlcptr;
+		case SETCLOSEUP: {
+				CloseDataPtr tlcptr = getObject(scaleX(aptr->Param1), scaleY(aptr->Param2), *lcptr);
 
+				if (tlcptr)
+					*lcptr = tlcptr;
+			}
 			break;
 
 		case MAINVIEW:
@@ -467,21 +451,23 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			DoNotDrawMessage = false;
 			break;
 
-		case WAITSECS:
-			addCurTime(aptr->Param1, 0, &startSecs, &startMicros);
+		case WAITSECS: {
+				uint32 startSecs, startMicros, curSecs, curMicros;
 
-			screenUpdate();
+				addCurTime(aptr->Param1, 0, &startSecs, &startMicros);
 
-			while (1) {
-				_music->updateMusic();
-				_anim->diffNextFrame();
-				getTime(&curSecs, &curMicros);
+				screenUpdate();
 
-				if ((curSecs > startSecs) || ((curSecs == startSecs) &&
-				                              (curMicros >= startMicros)))
-					break;
-			}
+				while (1) {
+					_music->updateMusic();
+					_anim->diffNextFrame();
+					getTime(&curSecs, &curMicros);
 
+					if ((curSecs > startSecs) || ((curSecs == startSecs) &&
+					                              (curMicros >= startMicros)))
+						break;
+				}
+			}
 			break;
 
 		case STOPMUSIC:
@@ -595,7 +581,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 /*****************************************************************************/
 /* Does the work for doActionRule.                                           */
 /*****************************************************************************/
-static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr lcptr, CloseDataPtr *Set, bool AllowDefaults) {
+static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr lcptr, CloseDataPtr *set, bool allowDefaults) {
 	action++;
 
 	if (lcptr) {
@@ -608,13 +594,13 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr lcptr, Clo
 
 		for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 			if (((*rule)->RuleType == ACTION) &&
-				(((*rule)->Param1 == action) || (((*rule)->Param1 == 0) && AllowDefaults))) {
+				(((*rule)->Param1 == action) || (((*rule)->Param1 == 0) && allowDefaults))) {
 				if ((((*rule)->Param2 == lcptr->CloseUpType) ||
-					(((*rule)->Param2 == 0) && AllowDefaults))
+					(((*rule)->Param2 == 0) && allowDefaults))
 				        ||
 						((action == 1) && ((*rule)->Param2 == (-lcptr->CloseUpType)))) {
 					if (checkConditions((*rule)->Condition)) {
-						g_lab->doActions((*rule)->ActionList, Set);
+						g_lab->doActions((*rule)->ActionList, set);
 						return true;
 					}
 				}
@@ -629,14 +615,12 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr lcptr, Clo
 /* Goes through the rules if an action is taken.                             */
 /*****************************************************************************/
 bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *lcptr) {
-	CloseDataPtr tlcptr;
-
 	if (roomNum)
 		g_lab->_newFileName = NOFILE;
 	else
 		g_lab->_newFileName = g_lab->_curFileName;
 
-	tlcptr = getObject(pos.x, pos.y, *lcptr);
+	CloseDataPtr tlcptr = getObject(pos.x, pos.y, *lcptr);
 
 	if (doActionRuleSub(action, roomNum, tlcptr, lcptr, false))
 		return true;
@@ -653,7 +637,7 @@ bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *
 /*****************************************************************************/
 /* Does the work for doActionRule.                                           */
 /*****************************************************************************/
-static bool doOperateRuleSub(int16 ItemNum, int16 roomNum, CloseDataPtr lcptr, CloseDataPtr *Set, bool AllowDefaults) {
+static bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr lcptr, CloseDataPtr *set, bool allowDefaults) {
 	if (lcptr)
 		if (lcptr->CloseUpType > 0) {
 			RuleList *rules = _rooms[roomNum]._rules;
@@ -665,10 +649,10 @@ static bool doOperateRuleSub(int16 ItemNum, int16 roomNum, CloseDataPtr lcptr, C
 
 			for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 				if (((*rule)->RuleType == OPERATE) &&
-				        (((*rule)->Param1 == ItemNum) || (((*rule)->Param1 == 0) && AllowDefaults)) &&
-						(((*rule)->Param2 == lcptr->CloseUpType) || (((*rule)->Param2 == 0) && AllowDefaults))) {
+				        (((*rule)->Param1 == itemNum) || (((*rule)->Param1 == 0) && allowDefaults)) &&
+						(((*rule)->Param2 == lcptr->CloseUpType) || (((*rule)->Param2 == 0) && allowDefaults))) {
 					if (checkConditions((*rule)->Condition)) {
-						g_lab->doActions((*rule)->ActionList, Set);
+						g_lab->doActions((*rule)->ActionList, set);
 						return true;
 					}
 				}


Commit: c320e6d0aea4a70f8fe1df691432f5900a4f6625
    https://github.com/scummvm/scummvm/commit/c320e6d0aea4a70f8fe1df691432f5900a4f6625
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:49+01:00

Commit Message:
LAB: Move inventory to LabEngine class

Changed paths:
    engines/lab/engine.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/labfun.h
    engines/lab/processroom.cpp
    engines/lab/resource.cpp
    engines/lab/resource.h
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 7b14afc..051ccac 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -45,7 +45,6 @@ extern bool stopsound, DoNotDrawMessage;
 /* Global parser data */
 
 extern RoomData *_rooms;
-extern InventoryData *Inventory;
 extern uint16 NumInv, ManyRooms, HighestCondition, Direction;
 
 bool ispal = false, noupdatediff = false, MainDisplay = true, QuitLab = false;
@@ -159,14 +158,14 @@ void LabEngine::drawRoomMessage(uint16 curInv, CloseDataPtr closePtr) {
 	}
 
 	if (_alternate) {
-		if ((curInv <= NumInv) && _conditions->in(curInv) && Inventory[curInv].BInvName) {
+		if ((curInv <= NumInv) && _conditions->in(curInv) && _inventory[curInv].BInvName) {
 			if ((curInv == LAMPNUM) && _conditions->in(LAMPON))  /* LAB: Labyrinth specific */
 				drawStaticMessage(kTextLampOn);
-			else if (Inventory[curInv].Many > 1) {
-				Common::String roomMessage = Common::String(Inventory[curInv].name) + "  (" + Common::String::format("%d", Inventory[curInv].Many) + ")";
+			else if (_inventory[curInv].Many > 1) {
+				Common::String roomMessage = Common::String(_inventory[curInv].name) + "  (" + Common::String::format("%d", _inventory[curInv].Many) + ")";
 				drawMessage(roomMessage.c_str());
 			} else
-				drawMessage(Inventory[curInv].name);
+				drawMessage(_inventory[curInv].name);
 		}
 	} else
 		drawDirection(closePtr);
@@ -390,7 +389,7 @@ bool LabEngine::doCloseUp(CloseDataPtr closePtr) {
 /******************************************************************************/
 const char *LabEngine::getInvName(uint16 CurInv) {
 	if (MainDisplay)
-		return Inventory[CurInv].BInvName;
+		return _inventory[CurInv].BInvName;
 
 	if ((CurInv == LAMPNUM) && _conditions->in(LAMPON))
 		return "P:Mines/120";
@@ -399,20 +398,20 @@ const char *LabEngine::getInvName(uint16 CurInv) {
 		return "P:Future/BeltGlow";
 
 	if (CurInv == WESTPAPERNUM) {
-		g_lab->_curFileName = Inventory[CurInv].BInvName;
+		g_lab->_curFileName = _inventory[CurInv].BInvName;
 		g_lab->_anim->_noPalChange = true;
 		readPict(g_lab->_curFileName, false);
 		g_lab->_anim->_noPalChange = false;
 		doWestPaper();
 	} else if (CurInv == NOTESNUM) {
-		g_lab->_curFileName = Inventory[CurInv].BInvName;
+		g_lab->_curFileName = _inventory[CurInv].BInvName;
 		g_lab->_anim->_noPalChange = true;
 		readPict(g_lab->_curFileName, false);
 		g_lab->_anim->_noPalChange = false;
 		doNotes();
 	}
 
-	return Inventory[CurInv].BInvName;
+	return _inventory[CurInv].BInvName;
 }
 
 /******************************************************************************/
@@ -517,7 +516,7 @@ void LabEngine::decIncInv(uint16 *CurInv, bool dec) {
 		(*CurInv)++;
 
 	while (*CurInv && (*CurInv <= NumInv)) {
-		if (_conditions->in(*CurInv) && Inventory[*CurInv].BInvName) {
+		if (_conditions->in(*CurInv) && _inventory[*CurInv].BInvName) {
 			_nextFileName = getInvName(*CurInv);
 			break;
 		}
@@ -535,7 +534,7 @@ void LabEngine::decIncInv(uint16 *CurInv, bool dec) {
 			*CurInv = 1;
 
 		while (*CurInv && (*CurInv <= NumInv)) {
-			if (_conditions->in(*CurInv) && Inventory[*CurInv].BInvName) {
+			if (_conditions->in(*CurInv) && _inventory[*CurInv].BInvName) {
 				_nextFileName = getInvName(*CurInv);
 				break;
 			}
@@ -565,7 +564,8 @@ void LabEngine::mainGameLoop() {
 	Direction = NORTH;
 
 	_resource->readRoomData("LAB:Doors");
-	_resource->readInventory("LAB:Inventor");
+	if (!(_inventory = _resource->readInventory("LAB:Inventor")))
+		return;
 
 	if (!(_conditions = new LargeSet(HighestCondition + 1, this)))
 		return;
@@ -698,16 +698,16 @@ void LabEngine::mainGameLoop() {
 		_rooms = nullptr;
 	}
 
-	if (Inventory) {
+	if (_inventory) {
 		for (int i = 1; i <= NumInv; i++) {
-			if (Inventory[i].name)
-				free(Inventory[i].name);
+			if (_inventory[i].name)
+				free(_inventory[i].name);
 
-			if (Inventory[i].BInvName)
-				free(Inventory[i].BInvName);
+			if (_inventory[i].BInvName)
+				free(_inventory[i].BInvName);
 		}
 
-		free(Inventory);
+		free(_inventory);
 	}
 }
 
@@ -1041,7 +1041,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			}
 
 			if ((curInv <= NumInv) && _conditions->in(curInv) &&
-			        Inventory[curInv].BInvName)
+			        _inventory[curInv].BInvName)
 				_nextFileName = getInvName(curInv);
 
 			screenUpdate();
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 7bb05c8..90c7131 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -112,6 +112,8 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
     _longWinInFront = false;
     _msgFont = 0;
 
+    _inventory = 0;
+
 	//const Common::FSNode gameDataDir(ConfMan.get("path"));
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game/pict");
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index f19a1ba..d8b75cb 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -125,7 +125,6 @@ public:
 	const char *_newFileName;  /* When ProcessRoom.c decides to change the filename
                                     of the current picture. */
 
-
 private:
 	int _lastWaitTOFTicks;
 	bool _lastMessageLong;
@@ -133,6 +132,7 @@ private:
 	TextFont *_msgFont;
 	bool _longWinInFront;
 	CloseDataPtr _cptr;
+	InventoryData *_inventory;
 
 private:
 	bool createScreen(bool HiRes);
@@ -194,6 +194,8 @@ private:
 	void mayShowCrumbIndicatorOff();
 	const char *getInvName(uint16 curInv);
 
+	bool saveRestoreGame();
+
 public:
 	void doActions(Action *aPtr, CloseDataPtr *lcptr);
 
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index ad84402..987864b 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -193,7 +193,6 @@ void doJournal();
 void doNotes();
 void doWestPaper();
 void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-bool saveRestoreGame();
 
 /*--------------------------*/
 /*----- From saveGame.c ----*/
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 2976c49..954bf00 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -45,7 +45,6 @@ namespace Lab {
 #define NOFILE         "no file"
 
 RoomData *_rooms;
-InventoryData *Inventory;
 uint16 NumInv, ManyRooms, HighestCondition, Direction;
 
 extern bool DoNotDrawMessage, noupdatediff, QuitLab, MusicOn;
@@ -434,16 +433,16 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			break;
 
 		case SUBINV:
-			if (Inventory[aptr->Param1].Many)
-				(Inventory[aptr->Param1].Many)--;
+			if (_inventory[aptr->Param1].Many)
+				(_inventory[aptr->Param1].Many)--;
 
-			if (Inventory[aptr->Param1].Many == 0)
+			if (_inventory[aptr->Param1].Many == 0)
 				_conditions->exclElement(aptr->Param1);
 
 			break;
 
 		case ADDINV:
-			(Inventory[aptr->Param1].Many) += aptr->Param2;
+			(_inventory[aptr->Param1].Many) += aptr->Param2;
 			_conditions->inclElement(aptr->Param1);
 			break;
 
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 415839d..303bae8 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -36,7 +36,6 @@ namespace Lab {
 
 static uint16 allocroom;
 extern RoomData *_rooms;
-extern InventoryData *Inventory;
 extern uint16 NumInv, ManyRooms, HighestCondition;
 
 Resource::Resource(LabEngine *vm) : _vm(vm) {
@@ -127,22 +126,23 @@ bool Resource::readRoomData(const char *fileName) {
 	return true;
 }
 
-bool Resource::readInventory(const char *fileName) {
+InventoryData *Resource::readInventory(const char *fileName) {
 	Common::File *dataFile;
 	if (!(dataFile = openDataFile(fileName, MKTAG('I', 'N', 'V', '1'))))
-		return false;
+		return nullptr;
 
 	NumInv = dataFile->readUint16LE();
-	Inventory = (InventoryData *)malloc((NumInv + 1) * sizeof(InventoryData));
+	InventoryData *inventory = (InventoryData *)malloc((NumInv + 1) * sizeof(InventoryData));
 
 	for (uint16 i = 1; i <= NumInv; i++) {
-		Inventory[i].Many = dataFile->readUint16LE();
-		Inventory[i].name = readString(dataFile);
-		Inventory[i].BInvName = readString(dataFile);
+		inventory[i].Many = dataFile->readUint16LE();
+		inventory[i].name = readString(dataFile);
+		inventory[i].BInvName = readString(dataFile);
 	}
 
 	delete dataFile;
-	return true;
+
+	return inventory;
 }
 
 bool Resource::readViews(uint16 roomNum) {
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index 3516569..2c7f9b7 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -100,7 +100,7 @@ public:
 
 	Common::File *openDataFile(const char * fileName, uint32 fileHeader = 0);
 	bool readRoomData(const char *fileName);
-	bool readInventory(const char *fileName);
+	InventoryData *readInventory(const char *fileName);
 	bool readViews(uint16 roomNum);
 	TextFont *getFont(const char *fileName);
 	char *getText(const char *fileName);
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index f8b0c20..9f36303 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -83,7 +83,6 @@ uint16 CurTile[4][4] = {
 
 extern uint16 *FadePalette;
 extern BitMap *DispBitMap, *DrawBitMap;
-extern InventoryData *Inventory;
 extern uint16 Direction;
 
 #define COMBINATIONUNLOCKED  130
@@ -753,7 +752,7 @@ void LabEngine::doJournal() {
 	freeAllStolenMem();
 }
 
-bool saveRestoreGame() {
+bool LabEngine::saveRestoreGame() {
 	bool isOK = false;
 
 	//g_lab->showMainMenu();
@@ -775,14 +774,14 @@ bool saveRestoreGame() {
 				desc = dialog->createDefaultSaveDescription(slot);
 			}
 
-			isOK = saveGame(Direction, Inventory[QUARTERNUM].Many, slot, desc);
+			isOK = saveGame(Direction, _inventory[QUARTERNUM].Many, slot, desc);
 		}
 	} else {
 		// Restore
 		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
 		int slot = dialog->runModalWithCurrentTarget();
 		if (slot >= 0) {
-			isOK = loadGame(&Direction, &(Inventory[QUARTERNUM].Many), slot);
+			isOK = loadGame(&Direction, &(_inventory[QUARTERNUM].Many), slot);
 			if (isOK)
 				g_lab->_music->resetMusic();
 		}


Commit: c6041a41a3172c23f8c4170fc83a1949e9c832a1
    https://github.com/scummvm/scummvm/commit/c6041a41a3172c23f8c4170fc83a1949e9c832a1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:49+01:00

Commit Message:
LAB: More renames

Changed paths:
    engines/lab/parsefun.h



diff --git a/engines/lab/parsefun.h b/engines/lab/parsefun.h
index 37ff977..ad8f04b 100644
--- a/engines/lab/parsefun.h
+++ b/engines/lab/parsefun.h
@@ -38,7 +38,7 @@ namespace Lab {
 
 /* From Parser.c */
 
-bool parse(const char *InputFile);
+bool parse(const char *inputFile);
 
 
 /* From allocRoom.c */
@@ -48,14 +48,14 @@ void freeRoomBuffer();
 
 /* From ProcessRoom.c */
 
-ViewData *getViewData(uint16 RoomNum, uint16 Direction);
+ViewData *getViewData(uint16 roomNum, uint16 direction);
 char *getPictName(CloseDataPtr *lcptr);
 void drawDirection(CloseDataPtr lcptr);
-bool processArrow(uint16 *Direction, uint16 Arrow);
+bool processArrow(uint16 *direction, uint16 arrow);
 void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords = false);
 bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr);
-bool doActionRule(Common::Point pos, int16 action, int16 RoomNum, CloseDataPtr *lcptr);
-bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *lcptr);
+bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *lcptr);
+bool doOperateRule(int16 x, int16 y, int16 itemNum, CloseDataPtr *lcptr);
 bool doGoForward(CloseDataPtr *lcptr);
 bool doTurn(uint16 from, uint16 to, CloseDataPtr *lcptr);
 bool doMainView(CloseDataPtr *lcptr);


Commit: 021cb4c526b8dbe8b33b3ae03703be36893410da
    https://github.com/scummvm/scummvm/commit/021cb4c526b8dbe8b33b3ae03703be36893410da
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:49+01:00

Commit Message:
LAB: Rename roomCords to roomCoords

Changed paths:
    engines/lab/map.cpp



diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 9b7f3f3..9ca57b0 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -237,7 +237,7 @@ void fade(bool fadein, uint16 res) {
 /*****************************************************************************/
 /* Figures out what a room's coordinates should be.                          */
 /*****************************************************************************/
-static void roomCords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16 *y2) {
+static void roomCoords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16 *y2) {
 	Image *curRoomImg = NULL;
 
 	switch (Maps[CurRoom].SpecialID) {
@@ -699,7 +699,7 @@ void LabEngine::processMap(uint16 CurRoom) {
 					OldMsg = CurMsg;
 
 					for (uint16 i = 1; i <= MaxRooms; i++) {
-						roomCords(i, &x1, &y1, &x2, &y2);
+						roomCoords(i, &x1, &y1, &x2, &y2);
 
 						if ((Maps[i].PageNumber == CurFloor)
 						        && _roomsFound->in(i)
@@ -722,7 +722,7 @@ void LabEngine::processMap(uint16 CurRoom) {
 							if (Maps[OldMsg].PageNumber == CurFloor)
 								drawRoom(OldMsg, (bool)(OldMsg == CurRoom));
 
-							roomCords(CurMsg, &x1, &y1, &x2, &y2);
+							roomCoords(CurMsg, &x1, &y1, &x2, &y2);
 							x1 = (x1 + x2) / 2;
 							y1 = (y1 + y2) / 2;
 


Commit: d50e9f35415240c7f848a12e1a5b35a0bd314fe1
    https://github.com/scummvm/scummvm/commit/d50e9f35415240c7f848a12e1a5b35a0bd314fe1
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:49+01:00

Commit Message:
LAB: Remove dead code

In all cases, dx and dy are always positive

Changed paths:
    engines/lab/image.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp
index 3f5801f..1d8b9d61 100644
--- a/engines/lab/image.cpp
+++ b/engines/lab/image.cpp
@@ -53,32 +53,18 @@ Image::Image(Common::File *s) {
 /* Draws an image to the screen.                                             */
 /*****************************************************************************/
 void Image::drawImage(uint16 x, uint16 y) {
-	int sx = 0, sy = 0;
-	int dx = x, dy = y;
 	int w = _width;
 	int h = _height;
 
-	if (dx < 0) {
-		sx -= dx;
-		w += dx;
-		dx = 0;
-	}
-
-	if (dy < 0) {
-		sy -= dy;
-		w += dy;
-		dy = 0;
-	}
-
-	if (dx + w > g_lab->_screenWidth)
-		w = g_lab->_screenWidth - dx;
+	if (x + w > g_lab->_screenWidth)
+		w = g_lab->_screenWidth - x;
 
-	if (dy + h > g_lab->_screenHeight)
-		h = g_lab->_screenHeight - dy;
+	if (y + h > g_lab->_screenHeight)
+		h = g_lab->_screenHeight - y;
 
 	if ((w > 0) && (h > 0)) {
-		byte *s = _imageData + sy * _width + sx;
-		byte *d = g_lab->getCurrentDrawingBuffer() + dy * g_lab->_screenWidth + dx;
+		byte *s = _imageData;
+		byte *d = g_lab->getCurrentDrawingBuffer() + y * g_lab->_screenWidth + x;
 
 		while (h-- > 0) {
 			memcpy(d, s, w);
@@ -92,32 +78,18 @@ void Image::drawImage(uint16 x, uint16 y) {
 /* Draws an image to the screen.                                             */
 /*****************************************************************************/
 void Image::drawMaskImage(uint16 x, uint16 y) {
-	int sx = 0, sy = 0;
-	int dx = x, dy = y;
 	int w = _width;
 	int h = _height;
 
-	if (dx < 0) {
-		sx -= dx;
-		w += dx;
-		dx = 0;
-	}
-
-	if (dy < 0) {
-		sy -= dy;
-		w += dy;
-		dy = 0;
-	}
-
-	if (dx + w > g_lab->_screenWidth)
-		w = g_lab->_screenWidth - dx;
+	if (x + w > g_lab->_screenWidth)
+		w = g_lab->_screenWidth - x;
 
-	if (dy + h > g_lab->_screenHeight)
-		h = g_lab->_screenHeight - dy;
+	if (y + h > g_lab->_screenHeight)
+		h = g_lab->_screenHeight - y;
 
 	if ((w > 0) && (h > 0)) {
-		byte *s = _imageData + sy * _width + sx;
-		byte *d = g_lab->getCurrentDrawingBuffer() + dy * g_lab->_screenWidth + dx;
+		byte *s = _imageData;
+		byte *d = g_lab->getCurrentDrawingBuffer() + y * g_lab->_screenWidth + x;
 
 		while (h-- > 0) {
 			byte *ss = s;
@@ -141,32 +113,18 @@ void Image::drawMaskImage(uint16 x, uint16 y) {
 /* Reads an image from the screen.                                           */
 /*****************************************************************************/
 void Image::readScreenImage(uint16 x, uint16 y) {
-	int sx = 0, sy = 0;
-	int	dx = x, dy = y;
 	int w = _width;
 	int h = _height;
 
- 	if (dx < 0) {
-		sx -= dx;
-		w += dx;
-		dx = 0;
-	}
-
-	if (dy < 0) {
-		sy -= dy;
-		w += dy;
-		dy = 0;
-	}
-
-	if (dx + w > g_lab->_screenWidth)
-		w = g_lab->_screenWidth - dx;
+	if (x + w > g_lab->_screenWidth)
+		w = g_lab->_screenWidth - x;
 
-	if (dy + h > g_lab->_screenHeight)
-		h = g_lab->_screenHeight - dy;
+	if (y + h > g_lab->_screenHeight)
+		h = g_lab->_screenHeight - y;
 
 	if ((w > 0) && (h > 0)) {
-		byte *s = _imageData + sy * _width + sx;
-		byte *d = g_lab->getCurrentDrawingBuffer() + dy * g_lab->_screenWidth + dx;
+		byte *s = _imageData;
+		byte *d = g_lab->getCurrentDrawingBuffer() + y * g_lab->_screenWidth + x;
 
 		while (h-- > 0) {
 			memcpy(s, d, w);
@@ -184,34 +142,18 @@ void Image::bltBitMap(uint16 xs, uint16 ys, Image *imDest,
 					uint16 xd, uint16 yd, uint16 width, uint16 height) {
 	// I think the old code assumed that the source image data was valid for the given box.
 	// I will proceed on that assumption.
-	int sx = xs;
-	int sy = ys;
-	int dx = xd;
-	int dy = yd;
 	int w = width;
 	int h = height;
 
-	if (dx < 0) {
-		sx -= dx;
-		w += dx;
-		dx = 0;
-	}
-
-	if (dy < 0) {
-		sy -= dy;
-		w += dy;
-		dy = 0;
-	}
-
-	if (dx + w > imDest->_width)
-		w = imDest->_width - dx;
+	if (xd + w > imDest->_width)
+		w = imDest->_width - xd;
 
-	if (dy + h > imDest->_height)
-		h = imDest->_height - dy;
+	if (yd + h > imDest->_height)
+		h = imDest->_height - yd;
 
 	if (w > 0 && h > 0) {
-		byte *s = _imageData + sy * _width + sx;
-		byte *d = imDest->_imageData + dy * imDest->_width + dx;
+		byte *s = _imageData + ys * _width + xs;
+		byte *d = imDest->_imageData + yd * imDest->_width + xd;
 
 		while (h-- > 0) {
 			memcpy(d, s, w);
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 0248bb8..7279140 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -144,25 +144,14 @@ void LabEngine::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16
 		y1 = temp;
 	}
 
-	if (dx > 0) {
-		im._width = x2 - x1 + 1 - dx;
-		im._height = y2 - y1 + 1;
+	im._width = x2 - x1 + 1 - dx;
+	im._height = y2 - y1 + 1;
 
-		im.readScreenImage(x1, y1);
-		im.drawImage(x1 + dx, y1);
+	im.readScreenImage(x1, y1);
+	im.drawImage(x1 + dx, y1);
 
-		setAPen(0);
-		rectFill(x1, y1, x1 + dx - 1, y2);
-	} else if (dx < 0) {
-		im._width = x2 - x1 + 1 + dx;
-		im._height = y2 - y1 + 1;
-
-		im.readScreenImage(x1 - dx, y1);
-		im.drawImage(x1, y1);
-
-		setAPen(0);
-		rectFill(x2 + dx + 1, y1, x2, y2);
-	}
+	setAPen(0);
+	rectFill(x1, y1, x1 + dx - 1, y2);
 }
 
 /*****************************************************************************/
@@ -186,25 +175,14 @@ void LabEngine::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16
 		y1 = temp;
 	}
 
-	if (dy > 0) {
-		im._width = x2 - x1 + 1;
-		im._height = y2 - y1 + 1 - dy;
-
-		im.readScreenImage(x1, y1);
-		im.drawImage(x1, y1 + dy);
+	im._width = x2 - x1 + 1;
+	im._height = y2 - y1 + 1 - dy;
 
-		setAPen(0);
-		rectFill(x1, y1, x2, y1 + dy - 1);
-	} else if (dy < 0) {
-		im._width = x2 - x1 + 1;
-		im._height = y2 - y1 + 1 + dy;
+	im.readScreenImage(x1, y1);
+	im.drawImage(x1, y1 + dy);
 
-		im.readScreenImage(x1, y1 - dy);
-		im.drawImage(x1, y1);
-
-		setAPen(0);
-		rectFill(x1, y2 + dy + 1, x2, y2);
-	}
+	setAPen(0);
+	rectFill(x1, y1, x2, y1 + dy - 1);
 }
 
 /*****************************************************************************/
@@ -218,29 +196,17 @@ void LabEngine::setAPen(byte pennum) {
 /* Fills in a rectangle.                                                     */
 /*****************************************************************************/
 void LabEngine::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	int dx = x1;
-	int dy = y1;
 	int w = x2 - x1 + 1;
 	int h = y2 - y1 + 1;
 
-	if (dx < 0) {
-		w += dx;
-		dx = 0;
-	}
-
-	if (dy < 0) {
-		w += dy;
-		dy = 0;
-	}
-
-	if (dx + w > _screenWidth)
-		w = _screenWidth - dx;
+	if (x1 + w > _screenWidth)
+		w = _screenWidth - x1;
 
-	if (dy + h > _screenHeight)
-		h = _screenHeight - dy;
+	if (y1 + h > _screenHeight)
+		h = _screenHeight - y1;
 
 	if ((w > 0) && (h > 0)) {
-		char *d = (char *)getCurrentDrawingBuffer() + dy * _screenWidth + dx;
+		char *d = (char *)getCurrentDrawingBuffer() + y1 * _screenWidth + x1;
 
 		while (h-- > 0) {
 			char *dd = d;
@@ -273,35 +239,23 @@ void LabEngine::drawHLine(uint16 x1, uint16 y, uint16 x2) {
 /* Overlays a region on the screen using the desired pen color.              */
 /*****************************************************************************/
 void LabEngine::overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	int dx = x1;
-	int dy = y1;
 	int w = x2 - x1 + 1;
 	int h = y2 - y1 + 1;
 
-	if (dx < 0) {
-		w += dx;
-		dx = 0;
-	}
-
-	if (dy < 0) {
-		w += dy;
-		dy = 0;
-	}
-
-	if (dx + w > _screenWidth)
-		w = _screenWidth - dx;
+	if (x1 + w > _screenWidth)
+		w = _screenWidth - x1;
 
-	if (dy + h > _screenHeight)
-		h = _screenHeight - dy;
+	if (y1 + h > _screenHeight)
+		h = _screenHeight - y1;
 
 	if ((w > 0) && (h > 0)) {
-		char *d = (char *)getCurrentDrawingBuffer() + dy * _screenWidth + dx;
+		char *d = (char *)getCurrentDrawingBuffer() + y1 * _screenWidth + x1;
 
 		while (h-- > 0) {
 			char *dd = d;
 			int ww = w;
 
-			if (dy & 1) {
+			if (y1 & 1) {
 				dd++;
 				ww--;
 			}
@@ -313,7 +267,7 @@ void LabEngine::overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, ui
 			}
 
 			d += _screenWidth;
-			dy++;
+			y1++;
 		}
 	}
 }


Commit: b7faa0bccfcefa33e5bb3345b548aa504bd22982
    https://github.com/scummvm/scummvm/commit/b7faa0bccfcefa33e5bb3345b548aa504bd22982
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:50+01:00

Commit Message:
LAB: Fix bug in getText()

Changed paths:
    engines/lab/resource.cpp



diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 303bae8..5be7aed 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -86,7 +86,7 @@ char *Resource::getText(const char *fileName) {
 
 	g_lab->_music->updateMusic();
 
-	byte count = dataFile->size();
+	uint32 count = dataFile->size();
 	byte *buffer = new byte[count];
 	byte *text = buffer;
 	dataFile->read(buffer, count);


Commit: c399536a07b6bf96ff311d4398f51e2d865a2027
    https://github.com/scummvm/scummvm/commit/c399536a07b6bf96ff311d4398f51e2d865a2027
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:50+01:00

Commit Message:
LAB: Small cleanup in from_crumbs()

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 051ccac..d7d9f3b 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -864,17 +864,8 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 				perFlipGadget(actionMode);
 
-				if (gadgetId == 0)
-					drawStaticMessage(kTextTakeWhat);
-				else if (gadgetId == 1)
-					drawStaticMessage(kTextMoveWhat);
-				else if (gadgetId == 2)
-					drawStaticMessage(kTextOpenWhat);
-				else if (gadgetId == 3)
-					drawStaticMessage(kTextCloseWhat);
-				else if (gadgetId == 4)
-					drawStaticMessage(kTextLookWhat);
-
+				if (gadgetId <= 4)
+					drawStaticMessage(kTextTakeWhat + gadgetId);
 				screenUpdate();
 			}
 		} else if (gadgetId == 9) {


Commit: 733fbe4c62911adc478400ba5d0dcf220e1b45ee
    https://github.com/scummvm/scummvm/commit/733fbe4c62911adc478400ba5d0dcf220e1b45ee
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:50+01:00

Commit Message:
LAB: Start working on a separate DisplayMan class

Changed paths:
  A engines/lab/graphics.h
    engines/lab/anim.cpp
    engines/lab/engine.cpp
    engines/lab/eventman.cpp
    engines/lab/graphics.cpp
    engines/lab/interface.cpp
    engines/lab/intro.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/labfun.h
    engines/lab/map.cpp
    engines/lab/processroom.cpp
    engines/lab/savegame.cpp
    engines/lab/special.cpp
    engines/lab/text.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index f4cae84..9402f9c 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -462,7 +462,7 @@ void Anim::diffNextFrame() {
 			_curBit = 0;
 
 			if (DispBitMap->_flags & BITMAPF_VIDEO)
-				_vm->screenUpdate();
+				_vm->_graphics->screenUpdate();
 
 			return; /* done with the next frame. */
 		}
@@ -567,7 +567,7 @@ void Anim::diffNextFrame() {
 				_vm->_event->mouseShow();
 
 				if (!didTOF)
-					_vm->screenUpdate();
+					_vm->_graphics->screenUpdate();
 
 				return;
 			}
@@ -602,7 +602,7 @@ void Anim::playDiff() {
 
 	if (_doBlack) {
 		_doBlack = false;
-		blackScreen();
+		_vm->_graphics->blackScreen();
 	}
 
 	_start = *startoffile;            /* Make a copy of the pointer to the start of the file    */
@@ -683,7 +683,7 @@ void Anim::playDiff() {
 /*****************************************************************************/
 void Anim::stopDiff() {
 	if (_isPlaying && _isAnim)
-		blackScreen();
+		_vm->_graphics->blackScreen();
 }
 
 /*****************************************************************************/
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index d7d9f3b..293c945 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -40,7 +40,7 @@
 
 namespace Lab {
 
-extern bool stopsound, DoNotDrawMessage;
+extern bool DoNotDrawMessage;
 
 /* Global parser data */
 
@@ -96,59 +96,6 @@ static char initcolors[] = { '\x00', '\x00', '\x00', '\x30',
 							 '\x2c', '\x08', '\x08', '\x08'};
 
 /******************************************************************************/
-/* Draws the control panel display.                                           */
-/******************************************************************************/
-void LabEngine::drawPanel() {
-	_event->mouseHide();
-
-	setAPen(3);                 /* Clear Area */
-	rectFill(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319), VGAScaleY(199));
-
-	setAPen(0);                 /* First Line */
-	drawHLine(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319));
-	setAPen(5);                 /* Second Line */
-	drawHLine(0, VGAScaleY(149) + 1 + SVGACord(2), VGAScaleX(319));
-
-	/* Gadget Separators */
-	setAPen(0);
-	drawHLine(0, VGAScaleY(170), VGAScaleX(319));     /* First black line to separate buttons */
-
-	if (!_alternate) {
-		setAPen(4);
-		drawHLine(0, VGAScaleY(170) + 1, VGAScaleX(319)); /* The horizontal lines under the black one */
-		drawGadgetList(_moveGadgetList);
-	} else {
-		if (getPlatform() != Common::kPlatformWindows) {
-			drawVLine(VGAScaleX(124), VGAScaleY(170) + 1, VGAScaleY(199)); /* Vertical Black lines */
-			drawVLine(VGAScaleX(194), VGAScaleY(170) + 1, VGAScaleY(199));
-		} else {
-			drawVLine(VGAScaleX(90), VGAScaleY(170) + 1, VGAScaleY(199));  /* Vertical Black lines */
-			drawVLine(VGAScaleX(160), VGAScaleY(170) + 1, VGAScaleY(199));
-			drawVLine(VGAScaleX(230), VGAScaleY(170) + 1, VGAScaleY(199));
-		}
-
-		setAPen(4);
-		drawHLine(0, VGAScaleY(170) + 1, VGAScaleX(122));   /* The horizontal lines under the black one */
-		drawHLine(VGAScaleX(126), VGAScaleY(170) + 1, VGAScaleX(192));
-		drawHLine(VGAScaleX(196), VGAScaleY(170) + 1, VGAScaleX(319));
-
-		drawVLine(VGAScaleX(1), VGAScaleY(170) + 2, VGAScaleY(198)); /* The vertical high light lines */
-		if (getPlatform() != Common::kPlatformWindows) {
-			drawVLine(VGAScaleX(126), VGAScaleY(170) + 2, VGAScaleY(198));
-			drawVLine(VGAScaleX(196), VGAScaleY(170) + 2, VGAScaleY(198));
-		} else {
-			drawVLine(VGAScaleX(92), VGAScaleY(170) + 2, VGAScaleY(198));
-			drawVLine(VGAScaleX(162), VGAScaleY(170) + 2, VGAScaleY(198));
-			drawVLine(VGAScaleX(232), VGAScaleY(170) + 2, VGAScaleY(198));
-		}
-
-		drawGadgetList(_invGadgetList);
-	}
-
-	_event->mouseShow();
-}
-
-/******************************************************************************/
 /* Draws the message for the room.                                            */
 /******************************************************************************/
 void LabEngine::drawRoomMessage(uint16 curInv, CloseDataPtr closePtr) {
@@ -163,116 +110,14 @@ void LabEngine::drawRoomMessage(uint16 curInv, CloseDataPtr closePtr) {
 				drawStaticMessage(kTextLampOn);
 			else if (_inventory[curInv].Many > 1) {
 				Common::String roomMessage = Common::String(_inventory[curInv].name) + "  (" + Common::String::format("%d", _inventory[curInv].Many) + ")";
-				drawMessage(roomMessage.c_str());
+				_graphics->drawMessage(roomMessage.c_str());
 			} else
-				drawMessage(_inventory[curInv].name);
+				_graphics->drawMessage(_inventory[curInv].name);
 		}
 	} else
 		drawDirection(closePtr);
 
-	_lastTooLong = _lastMessageLong;
-}
-
-/******************************************************************************/
-/* Sets up the Labyrinth screens, and opens up the initial windows.           */
-/******************************************************************************/
-bool LabEngine::setUpScreens() {
-	if (!createScreen(_isHiRes))
-		return false;
-
-	Common::File *controlFile = g_lab->_resource->openDataFile("P:Control");
-	for (uint16 i = 0; i < 20; i++)
-		_moveImages[i] = new Image(controlFile);
-	delete controlFile;
-
-	/* Creates the gadgets for the movement control panel */
-	uint16 y = VGAScaleY(173) - SVGACord(2);
-
-	if (getPlatform() == Common::kPlatformWindows) {
-		_moveGadgetList = createButton(1, y, 0, 't', _moveImages[0], _moveImages[1]);
-		Gadget *curGadget = _moveGadgetList;
-		curGadget->NextGadget = createButton(33, y, 1, 'm', _moveImages[2], _moveImages[3]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(65, y, 2, 'o', _moveImages[4], _moveImages[5]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(97, y, 3, 'c', _moveImages[6], _moveImages[7]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(129, y, 4, 'l', _moveImages[8], _moveImages[9]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(161, y, 5, 'i', _moveImages[12], _moveImages[13]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(193, y, 6, VKEY_LTARROW, _moveImages[14], _moveImages[15]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(225, y, 7, VKEY_UPARROW, _moveImages[16], _moveImages[17]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(257, y, 8, VKEY_RTARROW, _moveImages[18], _moveImages[19]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(289, y, 9, 'p', _moveImages[10], _moveImages[11]);
-	} else {
-		_moveGadgetList = createButton(1, y, 0, 0, _moveImages[0], _moveImages[1]);
-		Gadget *curGadget = _moveGadgetList;
-		curGadget->NextGadget = createButton(33, y, 1, 0, _moveImages[2], _moveImages[3]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(65, y, 2, 0, _moveImages[4], _moveImages[5]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(97, y, 3, 0, _moveImages[6], _moveImages[7]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(129, y, 4, 0, _moveImages[8], _moveImages[9]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(161, y, 5, 0, _moveImages[12], _moveImages[13]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(193, y, 6, 0, _moveImages[14], _moveImages[15]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(225, y, 7, 0, _moveImages[16], _moveImages[17]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(257, y, 8, 0, _moveImages[18], _moveImages[19]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(289, y, 9, 0, _moveImages[10], _moveImages[11]);
-	}
-
-	Common::File *invFile = g_lab->_resource->openDataFile("P:Inv");
-
-	if (getPlatform() == Common::kPlatformWindows) {
-		for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++)
-			_invImages[imgIdx] = new Image(invFile);
-
-		_invGadgetList = createButton(24, y, 0, 'm', _invImages[0], _invImages[1]);
-		Gadget *curGadget = _invGadgetList;
-		curGadget->NextGadget = createButton(56, y, 1, 'g', _invImages[2], _invImages[3]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(94, y, 2, 'u', _invImages[4], _invImages[5]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(126, y, 3, 'l', _moveImages[8], _moveImages[9]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(164, y, 4, VKEY_LTARROW, _moveImages[14], _moveImages[15]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(196, y, 5, VKEY_RTARROW, _moveImages[18], _moveImages[19]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(234, y, 6, 'b', _invImages[6], _invImages[7]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(266, y, 7, 'f', _invImages[8], _invImages[9]);
-		curGadget = curGadget->NextGadget;
-	} else {
-		for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++)
-			_invImages[imgIdx] = new Image(invFile);
-
-		_invGadgetList = createButton(58, y, 0, 0, _invImages[0], _invImages[1]);
-		Gadget *curGadget = _invGadgetList;
-		curGadget->NextGadget = createButton(90, y, 1, 0, _invImages[2], _invImages[3]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(128, y, 2, 0, _invImages[4], _invImages[5]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(160, y, 3, 0, _moveImages[8], _moveImages[9]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(198, y, 4, 0, _moveImages[14], _moveImages[15]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(230, y, 5, 0, _moveImages[18], _moveImages[19]);
-		curGadget = curGadget->NextGadget;
-	}
-
-	delete invFile;
-
-	return true;
+	_lastTooLong = _graphics->_lastMessageLong;
 }
 
 void LabEngine::freeScreens() {
@@ -379,7 +224,7 @@ bool LabEngine::doCloseUp(CloseDataPtr closePtr) {
 	}
 
 	_curFileName = " ";
-	drawPanel();
+	_graphics->drawPanel();
 
 	return true;
 }
@@ -394,20 +239,20 @@ const char *LabEngine::getInvName(uint16 CurInv) {
 	if ((CurInv == LAMPNUM) && _conditions->in(LAMPON))
 		return "P:Mines/120";
 
-	if ((CurInv == BELTNUM) && g_lab->_conditions->in(BELTGLOW))
+	if ((CurInv == BELTNUM) && _conditions->in(BELTGLOW))
 		return "P:Future/BeltGlow";
 
 	if (CurInv == WESTPAPERNUM) {
-		g_lab->_curFileName = _inventory[CurInv].BInvName;
-		g_lab->_anim->_noPalChange = true;
-		readPict(g_lab->_curFileName, false);
-		g_lab->_anim->_noPalChange = false;
+		_curFileName = _inventory[CurInv].BInvName;
+		_anim->_noPalChange = true;
+		_graphics->readPict(_curFileName, false);
+		_anim->_noPalChange = false;
 		doWestPaper();
 	} else if (CurInv == NOTESNUM) {
-		g_lab->_curFileName = _inventory[CurInv].BInvName;
-		g_lab->_anim->_noPalChange = true;
-		readPict(g_lab->_curFileName, false);
-		g_lab->_anim->_noPalChange = false;
+		_curFileName = _inventory[CurInv].BInvName;
+		_anim->_noPalChange = true;
+		_graphics->readPict(_curFileName, false);
+		_anim->_noPalChange = false;
 		doNotes();
 	}
 
@@ -434,7 +279,7 @@ void LabEngine::interfaceOn() {
 		_event->mouseShow();
 	}
 
-	if (_longWinInFront)
+	if (_graphics->_longWinInFront)
 		_event->attachGadgetList(NULL);
 	else if (_alternate)
 		_event->attachGadgetList(_invGadgetList);
@@ -454,8 +299,8 @@ bool LabEngine::doUse(uint16 CurInv) {
 		_cptr = NULL;
 		doMap(_roomNum);
 		setPalette(initcolors, 8);
-		drawMessage(NULL);
-		drawPanel();
+		_graphics->drawMessage(NULL);
+		_graphics->drawPanel();
 	} else if (CurInv == JOURNALNUM) {         /* LAB: Labyrinth specific */
 		drawStaticMessage(kTextUseJournal);
 		interfaceOff();
@@ -463,8 +308,8 @@ bool LabEngine::doUse(uint16 CurInv) {
 		_curFileName = " ";
 		_cptr = NULL;
 		doJournal();
-		drawPanel();
-		drawMessage(NULL);
+		_graphics->drawPanel();
+		_graphics->drawMessage(NULL);
 	} else if (CurInv == LAMPNUM) {            /* LAB: Labyrinth specific */
 		interfaceOff();
 
@@ -478,7 +323,7 @@ bool LabEngine::doUse(uint16 CurInv) {
 
 		_anim->_doBlack = false;
 		_anim->_waitForEffect = true;
-		readPict("Music:Click", true);
+		_graphics->readPict("Music:Click", true);
 		_anim->_waitForEffect = false;
 
 		_anim->_doBlack = false;
@@ -575,8 +420,8 @@ void LabEngine::mainGameLoop() {
 
 	_conditions->readInitialConditions("LAB:Conditio");
 
-	_longWinInFront = false;
-	drawPanel();
+	_graphics->_longWinInFront = false;
+	_graphics->drawPanel();
 
 	perFlipGadget(actionMode);
 
@@ -598,7 +443,7 @@ void LabEngine::mainGameLoop() {
 				_cptr = NULL;
 
 				mayShowCrumbIndicator();
-				screenUpdate();
+				_graphics->screenUpdate();
 			}
 
 			/* Sets the current picture properly on the screen */
@@ -624,15 +469,15 @@ void LabEngine::mainGameLoop() {
 					         MainDisplay) /* LAB: Labyrinth specific code */
 						showTile(_curFileName, (bool)(_cptr->CloseUpType == SPECIALBRICKNOMOUSE));
 					else
-						readPict(_curFileName, false);
+						_graphics->readPict(_curFileName, false);
 				} else
-					readPict(_curFileName, false);
+					_graphics->readPict(_curFileName, false);
 
 				drawRoomMessage(curInv, _cptr);
 				forceDraw = false;
 
 				mayShowCrumbIndicator();
-				screenUpdate();
+				_graphics->screenUpdate();
 
 				if (!_followingCrumbs)
 					eatMessages();
@@ -641,7 +486,7 @@ void LabEngine::mainGameLoop() {
 			if (forceDraw) {
 				drawRoomMessage(curInv, _cptr);
 				forceDraw = false;
-				screenUpdate();
+				_graphics->screenUpdate();
 			}
 		}
 
@@ -669,14 +514,14 @@ void LabEngine::mainGameLoop() {
 
 					GotMessage = true;
 					mayShowCrumbIndicator();
-					screenUpdate();
+					_graphics->screenUpdate();
 					if (!from_crumbs(GADGETUP, code, 0, _event->updateAndGetMousePos(), curInv, curMsg, forceDraw, code, actionMode))
 						break;
 				}
 			}
 
 			mayShowCrumbIndicator();
-			screenUpdate();
+			_graphics->screenUpdate();
 		} else {
 			GotMessage = true;
 
@@ -725,7 +570,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 	_anim->_doBlack = false;
 
-	if ((msgClass == RAWKEY) && (!_longWinInFront)) {
+	if ((msgClass == RAWKEY) && (!_graphics->_longWinInFront)) {
 		if (code == 13) { /* The return key */
 			msgClass     = MOUSEBUTTONS;
 			Qualifier = IEQUALIFIER_LEFTBUTTON;
@@ -736,7 +581,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			_numCrumbs = 0;
 			_droppingCrumbs = true;
 			mayShowCrumbIndicator();
-			screenUpdate();
+			_graphics->screenUpdate();
 		} else if (code == 'f' || code == 'F' ||
 		         code == 'r' || code == 'R') {  /* Follow bread crumbs */
 			if (_droppingCrumbs) {
@@ -755,9 +600,9 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 						MainDisplay = true;
 						interfaceOn(); /* Sets the correct gadget list */
-						drawPanel();
+						_graphics->drawPanel();
 						drawRoomMessage(curInv, _cptr);
-						screenUpdate();
+						_graphics->screenUpdate();
 					}
 				} else {
 					_breadCrumbs[0]._roomNum = 0;
@@ -765,13 +610,13 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 					// Need to hide indicator!!!!
 					mayShowCrumbIndicatorOff();
-					screenUpdate();
+					_graphics->screenUpdate();
 				}
 			}
 		} else if ((code == 315) || (code == 'x') || (code == 'X')
 		         || (code == 'q') || (code == 'Q')) {  /* Quit? */
 			DoNotDrawMessage = false;
-			drawMessage("Do you want to quit? (Y/N)");
+			_graphics->drawMessage("Do you want to quit? (Y/N)");
 			doit = false;
 			eatMessages();
 			interfaceOff();
@@ -813,16 +658,16 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 		eatMessages();
 	}
 
-	if (_longWinInFront) {
+	if (_graphics->_longWinInFront) {
 		if ((msgClass == RAWKEY) ||
 		        ((msgClass == MOUSEBUTTONS) &&
 		         ((IEQUALIFIER_LEFTBUTTON & Qualifier) ||
 		          (IEQUALIFIER_RBUTTON & Qualifier)))) {
-			_longWinInFront = false;
+			_graphics->_longWinInFront = false;
 			DoNotDrawMessage = false;
-			drawPanel();
+			_graphics->drawPanel();
 			drawRoomMessage(curInv, _cptr);
-			screenUpdate();
+			_graphics->screenUpdate();
 		}
 	} else if ((msgClass == GADGETUP) && !_alternate) {
 		if (gadgetId <= 5) {
@@ -833,7 +678,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				hcptr = NULL;
 				_cptr = NULL;
 				mayShowCrumbIndicator();
-				screenUpdate();
+				_graphics->screenUpdate();
 			} else if (gadgetId == 5) {
 				eatMessages();
 
@@ -850,11 +695,11 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				} else
 					decIncInv(&curInv, false);
 
-				drawPanel();
+				_graphics->drawPanel();
 				drawRoomMessage(curInv, _cptr);
 
 				mayShowCrumbIndicator();
-				screenUpdate();
+				_graphics->screenUpdate();
 			} else {
 				Old        = actionMode;
 				actionMode = gadgetId;
@@ -866,13 +711,13 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 				if (gadgetId <= 4)
 					drawStaticMessage(kTextTakeWhat + gadgetId);
-				screenUpdate();
+				_graphics->screenUpdate();
 			}
 		} else if (gadgetId == 9) {
 			doUse(MAPNUM);
 
 			mayShowCrumbIndicator();
-			screenUpdate();
+			_graphics->screenUpdate();
 		} else if (gadgetId >= 6) { /* Arrow Gadgets */
 			_cptr = NULL;
 			hcptr = NULL;
@@ -895,7 +740,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				forceDraw = true;
 
 				mayShowCrumbIndicator();
-				screenUpdate();
+				_graphics->screenUpdate();
 			} else if (gadgetId == 7) {
 				OldRoomNum = _roomNum;
 
@@ -959,7 +804,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				}
 
 				mayShowCrumbIndicator();
-				screenUpdate();
+				_graphics->screenUpdate();
 			}
 		}
 	} else if ((msgClass == GADGETUP) && _alternate) {
@@ -973,10 +818,10 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 			MainDisplay = true;
 			interfaceOn(); /* Sets the correct gadget list */
-			drawPanel();
+			_graphics->drawPanel();
 			drawRoomMessage(curInv, _cptr);
 
-			screenUpdate();
+			_graphics->screenUpdate();
 		}
 
 		gadgetId--;
@@ -996,17 +841,17 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 			_nextFileName = getInvName(curInv);
 
-			drawPanel();
+			_graphics->drawPanel();
 
 			if (doit) {
-				drawMessage("Disk operation failed.");
+				_graphics->drawMessage("Disk operation failed.");
 				setPalette(initcolors, 8);
 
-				screenUpdate();
+				_graphics->screenUpdate();
 
 				g_system->delayMillis(1000);
 			} else {
-				screenUpdate();
+				_graphics->screenUpdate();
 			}
 		} else if (gadgetId == 1) {
 			if (!doUse(curInv)) {
@@ -1019,7 +864,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				drawStaticMessage(kTextUseOnWhat);
 				MainDisplay = true;
 
-				screenUpdate();
+				_graphics->screenUpdate();
 			}
 		} else if (gadgetId == 2) {
 			MainDisplay = !MainDisplay;
@@ -1035,27 +880,27 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			        _inventory[curInv].BInvName)
 				_nextFileName = getInvName(curInv);
 
-			screenUpdate();
+			_graphics->screenUpdate();
 		} else if (gadgetId == 3) { /* Left gadget */
 			decIncInv(&curInv, true);
 			LastInv = curInv;
 			DoNotDrawMessage = false;
 			drawRoomMessage(curInv, _cptr);
 
-			screenUpdate();
+			_graphics->screenUpdate();
 		} else if (gadgetId == 4) { /* Right gadget */
 			decIncInv(&curInv, false);
 			LastInv = curInv;
 			DoNotDrawMessage = false;
 			drawRoomMessage(curInv, _cptr);
 
-			screenUpdate();
+			_graphics->screenUpdate();
 		} else if (gadgetId == 5) { /* bread crumbs */
 			_breadCrumbs[0]._roomNum = 0;
 			_numCrumbs = 0;
 			_droppingCrumbs = true;
 			mayShowCrumbIndicator();
-			screenUpdate();
+			_graphics->screenUpdate();
 		} else if (gadgetId == 6) { /* follow crumbs */
 			if (_droppingCrumbs) {
 				if (_numCrumbs > 0) {
@@ -1072,16 +917,16 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 					MainDisplay = true;
 					interfaceOn(); /* Sets the correct gadget list */
-					drawPanel();
+					_graphics->drawPanel();
 					drawRoomMessage(curInv, _cptr);
-					screenUpdate();
+					_graphics->screenUpdate();
 				} else {
 					_breadCrumbs[0]._roomNum = 0;
 					_droppingCrumbs = false;
 
 					// Need to hide indicator!!!!
 					mayShowCrumbIndicatorOff();
-					screenUpdate();
+					_graphics->screenUpdate();
 				}
 			}
 		}
@@ -1115,7 +960,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 					_curFileName = _newFileName;
 				else if (doActionRule(curPos, TAKE - 1, 0, &_cptr))
 					_curFileName = _newFileName;
-				else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
+				else if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2)))
 					drawStaticMessage(kTextNothing);
 			} else if ((actionMode == 1) /* Manipulate an object */  ||
 			         (actionMode == 2) /* Open up a "door" */      ||
@@ -1123,7 +968,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				if (doActionRule(curPos, actionMode, _roomNum, &_cptr))
 					_curFileName = _newFileName;
 				else if (!doActionRule(curPos, actionMode, 0, &_cptr)) {
-					if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
+					if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2)))
 						drawStaticMessage(kTextNothing);
 				}
 			} else if (actionMode == 4) { /* Look at closeups */
@@ -1131,15 +976,15 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				setCurClose(curPos, &tempcptr);
 
 				if (_cptr == tempcptr) {
-					if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
+					if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2)))
 						drawStaticMessage(kTextNothing);
 				} else if (tempcptr->GraphicName) {
 					if (*(tempcptr->GraphicName)) {
 						_anim->_doBlack = true;
 						_cptr = tempcptr;
-					} else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
+					} else if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2)))
 						drawStaticMessage(kTextNothing);
-				} else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
+				} else if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2)))
 					drawStaticMessage(kTextNothing);
 			} else if ((actionMode == 5)  &&
 			         _conditions->in(curInv)) { /* Use an item on something else */
@@ -1148,13 +993,13 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 					if (!_conditions->in(curInv))
 						decIncInv(&curInv, false);
-				} else if (curPos.y < (VGAScaleY(149) + SVGACord(2)))
+				} else if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2)))
 					drawStaticMessage(kTextNothing);
 			}
 		}
 
 		mayShowCrumbIndicator();
-		screenUpdate();
+		_graphics->screenUpdate();
 	} else if (msgClass == DELTAMOVE) {
 		VPtr = getViewData(_roomNum, Direction);
 		oldcptr = VPtr->closeUps;
@@ -1182,7 +1027,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 		}
 
 		if (hcptr)
-			_event->setMousePos(Common::Point(scaleX((hcptr->x1 + hcptr->x2) / 2), scaleY((hcptr->y1 + hcptr->y2) / 2)));
+			_event->setMousePos(Common::Point(_graphics->scaleX((hcptr->x1 + hcptr->x2) / 2), _graphics->scaleY((hcptr->y1 + hcptr->y2) / 2)));
 	} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) {
 		eatMessages();
 		_alternate = !_alternate;
@@ -1198,11 +1043,11 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				decIncInv(&curInv, false);
 		}
 
-		drawPanel();
+		_graphics->drawPanel();
 		drawRoomMessage(curInv, _cptr);
 
 		mayShowCrumbIndicator();
-		screenUpdate();
+		_graphics->screenUpdate();
 	}
 	return true;
 }
@@ -1220,9 +1065,9 @@ void LabEngine::go() {
 		return;
 	}
 
-	if (!setUpScreens()) {
+	if (!_graphics->setUpScreens()) {
 		_isHiRes = false;
-		mem = mem && setUpScreens();
+		mem = mem && _graphics->setUpScreens();
 	}
 
 	_event->initMouse();
@@ -1250,16 +1095,16 @@ void LabEngine::go() {
 		debug("\n\nNot enough memory to start game.\n\n");
 
 	if (QuitLab) { /* Won the game */
-		blackAllScreen();
-		readPict("P:End/L2In.1", true);
+		_graphics->blackAllScreen();
+		_graphics->readPict("P:End/L2In.1", true);
 
 		for (uint16 i = 0; i < 120; i++) {
 			_music->updateMusic();
 			waitTOF();
 		}
 
-		readPict("P:End/L2In.9", true);
-		readPict("P:End/Lost", true);
+		_graphics->readPict("P:End/L2In.9", true);
+		_graphics->readPict("P:End/Lost", true);
 
 		warning("STUB: waitForPress");
 		while (!1) { // 1 means ignore SDL_ProcessInput calls
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 751f387..6b73de7 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -156,7 +156,7 @@ void EventManager::updateMouse() {
 	}
 
 	if (doUpdateDisplay)
-		_vm->screenUpdate();
+		_vm->_graphics->screenUpdate();
 }
 
 
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 520828a..80888d2 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -36,19 +36,26 @@
 #include "lab/parsefun.h"
 #include "lab/text.h"
 #include "lab/resource.h"
+#include "lab/graphics.h"
 
 namespace Lab {
 
 BitMap bit1, bit2, *DispBitMap = &bit1, *DrawBitMap = &bit1;
 
-extern bool stopsound;
+DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) {
+	_longWinInFront = false;
+	_lastMessageLong = false;
+
+	_screenBytesPerPage = 65536;
+	_curapen = 0;
+}
 
 /*****************************************************************************/
 /* Scales the x co-ordinates to that of the new display.  In the room parser */
 /* file, co-ordinates are set up on a 360x336 display.                       */
 /*****************************************************************************/
-uint16 scaleX(uint16 x) {
-	if (g_lab->_isHiRes)
+uint16 DisplayMan::scaleX(uint16 x) {
+	if (_vm->_isHiRes)
 		return (uint16)((x * 16) / 9);
 	else
 		return (uint16)((x * 8) / 9);
@@ -58,7 +65,7 @@ uint16 scaleX(uint16 x) {
 /* Scales the y co-ordinates to that of the new display.  In the room parser */
 /* file, co-ordinates are set up on a 368x336 display.                       */
 /*****************************************************************************/
-uint16 scaleY(uint16 y) {
+uint16 DisplayMan::scaleY(uint16 y) {
 	if (g_lab->_isHiRes)
 		return (y + (y / 14));
 	else
@@ -68,7 +75,7 @@ uint16 scaleY(uint16 y) {
 /*****************************************************************************/
 /* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
 /*****************************************************************************/
-int16 VGAScaleX(int16 x) {
+int16 DisplayMan::VGAScaleX(int16 x) {
 	if (g_lab->_isHiRes)
 		return (x * 2);
 	else
@@ -78,14 +85,14 @@ int16 VGAScaleX(int16 x) {
 /*****************************************************************************/
 /* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
 /*****************************************************************************/
-int16 VGAScaleY(int16 y) {
+int16 DisplayMan::VGAScaleY(int16 y) {
 	if (g_lab->_isHiRes)
 		return ((y * 12) / 5);
 	else
 		return y;
 }
 
-uint16 SVGACord(uint16 cord) {
+uint16 DisplayMan::SVGACord(uint16 cord) {
 	if (g_lab->_isHiRes)
 		return cord;
 	else
@@ -119,10 +126,10 @@ int VGAUnScaleY(int y) {
 /*****************************************************************************/
 /* Reads in a picture into the dest bitmap.                                  */
 /*****************************************************************************/
-bool readPict(const char *filename, bool playOnce) {
-	g_lab->_anim->stopDiff();
+bool DisplayMan::readPict(const char *filename, bool playOnce) {
+	_vm->_anim->stopDiff();
 
-	byte **file = g_lab->_music->newOpen(filename);
+	byte **file = _vm->_music->newOpen(filename);
 
 	if (file == NULL) {
 		if ((filename[0] == 'p') || (filename[0] == 'P'))
@@ -131,11 +138,11 @@ bool readPict(const char *filename, bool playOnce) {
 		return false;
 	}
 
-	DispBitMap->_bytesPerRow = g_lab->_screenWidth;
-	DispBitMap->_rows        = g_lab->_screenHeight;
+	DispBitMap->_bytesPerRow = _vm->_screenWidth;
+	DispBitMap->_rows        = _vm->_screenHeight;
 	DispBitMap->_flags       = BITMAPF_VIDEO;
 
-	g_lab->_anim->readDiff(playOnce);
+	_vm->_anim->readDiff(playOnce);
 
 	return true;
 }
@@ -143,7 +150,7 @@ bool readPict(const char *filename, bool playOnce) {
 /*****************************************************************************/
 /* Reads in a picture into buffer memory.                                    */
 /*****************************************************************************/
-byte *readPictToMem(const char *filename, uint16 x, uint16 y) {
+byte *DisplayMan::readPictToMem(const char *filename, uint16 x, uint16 y) {
 	byte *mem;
 
 	g_lab->_anim->stopDiff();
@@ -252,7 +259,7 @@ static void getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer, uin
 /* Note: Every individual word MUST be int16 enough to fit on a line, and     */
 /* each line less than 255 characters.                                        */
 /******************************************************************************/
-uint32 flowText(void *font,      /* the TextAttr pointer */
+uint32 DisplayMan::flowText(void *font,      /* the TextAttr pointer */
                 int16 spacing,          /* How much vertical spacing between the lines */
                 byte pencolor,         /* pen number to use for text */
                 byte backpen,          /* the background color */
@@ -269,14 +276,14 @@ uint32 flowText(void *font,      /* the TextAttr pointer */
 	uint16 x, y;
 
 	if (fillback) {
-		g_lab->setAPen(backpen);
-		g_lab->rectFill(x1, y1, x2, y2);
+		setAPen(backpen);
+		rectFill(x1, y1, x2, y2);
 	}
 
 	if (str == NULL)
 		return 0L;
 
-	g_lab->setAPen(pencolor);
+	setAPen(pencolor);
 
 	fontheight = textHeight(_msgFont) + spacing;
 	numlines   = (y2 - y1 + 1) / fontheight;
@@ -319,7 +326,7 @@ uint32 flowText(void *font,      /* the TextAttr pointer */
 /******************************************************************************/
 /* Calls flowText, but flows it to memory.  Same restrictions as flowText.    */
 /******************************************************************************/
-uint32 flowTextToMem(Image *destIm, void *font,     /* the TextAttr pointer */
+uint32 DisplayMan::flowTextToMem(Image *destIm, void *font,     /* the TextAttr pointer */
                      int16 spacing,          /* How much vertical spacing between the lines */
                      byte pencolor,         /* pen number to use for text */
                      byte backpen,          /* the background color */
@@ -329,41 +336,41 @@ uint32 flowTextToMem(Image *destIm, void *font,     /* the TextAttr pointer */
                      bool output,                  /* Whether to output any text */
                      uint16 x1,               /* Cords */
                      uint16 y1, uint16 x2, uint16 y2, const char *str) { /* The text itself */
-	uint32 res, vgabyte = g_lab->_screenBytesPerPage;
-	byte *tmp = g_lab->_currentDisplayBuffer;
+	uint32 res, vgabyte = _screenBytesPerPage;
+	byte *tmp = _vm->_currentDisplayBuffer;
 
-	g_lab->_currentDisplayBuffer = destIm->_imageData;
-	g_lab->_screenBytesPerPage = (uint32)destIm->_width * (int32)destIm->_height;
+	_vm->_currentDisplayBuffer = destIm->_imageData;
+	_screenBytesPerPage = (uint32)destIm->_width * (int32)destIm->_height;
 
-	res = flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str);
+	res = _vm->_graphics->flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str);
 
-	g_lab->_screenBytesPerPage = vgabyte;
-	g_lab->_currentDisplayBuffer = tmp;
+	_screenBytesPerPage = vgabyte;
+	_vm->_currentDisplayBuffer = tmp;
 
 	return res;
 }
 
 /*----- The control panel stuff -----*/
 
-void createBox(uint16 y2) {
-	g_lab->setAPen(7);                 /* Message box area */
-	g_lab->rectFill(VGAScaleX(4), VGAScaleY(154), VGAScaleX(315), VGAScaleY(y2 - 2));
+void DisplayMan::createBox(uint16 y2) {
+	setAPen(7);                 /* Message box area */
+	rectFill(VGAScaleX(4), VGAScaleY(154), VGAScaleX(315), VGAScaleY(y2 - 2));
 
-	g_lab->setAPen(0);                 /* Box around message area */
-	g_lab->drawHLine(VGAScaleX(2), VGAScaleY(152), VGAScaleX(317));
-	g_lab->drawVLine(VGAScaleX(317), VGAScaleY(152), VGAScaleY(y2));
-	g_lab->drawHLine(VGAScaleX(2), VGAScaleY(y2), VGAScaleX(317));
-	g_lab->drawVLine(VGAScaleX(2), VGAScaleY(152), VGAScaleY(y2));
+	setAPen(0);                 /* Box around message area */
+	drawHLine(VGAScaleX(2), VGAScaleY(152), VGAScaleX(317));
+	drawVLine(VGAScaleX(317), VGAScaleY(152), VGAScaleY(y2));
+	drawHLine(VGAScaleX(2), VGAScaleY(y2), VGAScaleX(317));
+	drawVLine(VGAScaleX(2), VGAScaleY(152), VGAScaleY(y2));
 }
 
-int32 LabEngine::longDrawMessage(const char *str) {
+int32 DisplayMan::longDrawMessage(const char *str) {
 	char newText[512];
 
 	if (str == NULL)
 		return 0;
 
-	_event->attachGadgetList(NULL);
-	_event->mouseHide();
+	_vm->_event->attachGadgetList(NULL);
+	_vm->_event->mouseHide();
 	strcpy(newText, str);
 
 	if (!_longWinInFront) {
@@ -373,26 +380,26 @@ int32 LabEngine::longDrawMessage(const char *str) {
 	}
 
 	createBox(198);
-	_event->mouseShow();
+	_vm->_event->mouseShow();
 
-	return flowText(_msgFont, 0, 1, 7, false, true, true, true, VGAScaleX(6), VGAScaleY(155), VGAScaleX(313), VGAScaleY(195), str);
+	return flowText(_vm->_msgFont, 0, 1, 7, false, true, true, true, VGAScaleX(6), VGAScaleY(155), VGAScaleX(313), VGAScaleY(195), str);
 }
 
 void LabEngine::drawStaticMessage(byte index) {
-	drawMessage(_resource->getStaticText((StaticText)index).c_str());
+	_graphics->drawMessage(_resource->getStaticText((StaticText)index).c_str());
 }
 
 /******************************************************************************/
 /* Draws a message to the message box.                                        */
 /******************************************************************************/
-void LabEngine::drawMessage(const char *str) {
+void DisplayMan::drawMessage(const char *str) {
 	if (DoNotDrawMessage) {
 		DoNotDrawMessage = false;
 		return;
 	}
 
 	if (str) {
-		if ((textLength(_msgFont, str, strlen(str)) > VGAScaleX(306))) {
+		if ((textLength(_vm->_msgFont, str, strlen(str)) > VGAScaleX(306))) {
 			longDrawMessage(str);
 			_lastMessageLong = true;
 		} else {
@@ -401,10 +408,10 @@ void LabEngine::drawMessage(const char *str) {
 				drawPanel();
 			}
 
-			_event->mouseHide();
+			_vm->_event->mouseHide();
 			createBox(168);
-			text(_msgFont, VGAScaleX(7), VGAScaleY(155) + SVGACord(2), 1, str, strlen(str));
-			_event->mouseShow();
+			text(_vm->_msgFont, VGAScaleX(7), VGAScaleY(155) + SVGACord(2), 1, str, strlen(str));
+			_vm->_event->mouseShow();
 			_lastMessageLong = false;
 		}
 	}
@@ -425,13 +432,13 @@ void LabEngine::drawMessage(const char *str) {
 /*****************************************************************************/
 /* Scrolls the display to black.                                             */
 /*****************************************************************************/
-void LabEngine::doScrollBlack() {
+void DisplayMan::doScrollBlack() {
 	byte *mem, *tempmem;
 	Image im;
 	uint32 size, copysize;
 	uint32 *baseAddr;
 
-	_event->mouseHide();
+	_vm->_event->mouseHide();
 	uint16 width = VGAScaleX(320);
 	uint16 height = VGAScaleY(149) + SVGACord(2);
 
@@ -440,22 +447,22 @@ void LabEngine::doScrollBlack() {
 	im._width = width;
 	im._height = height;
 	im._imageData = mem;
-	_music->updateMusic();
+	_vm->_music->updateMusic();
 	im.readScreenImage(0, 0);
-	_music->updateMusic();
+	_vm->_music->updateMusic();
 
-	baseAddr = (uint32 *)getCurrentDrawingBuffer();
+	baseAddr = (uint32 *)_vm->getCurrentDrawingBuffer();
 
 	uint16 by      = VGAScaleX(4);
 	uint16 nheight = height;
 
 	while (nheight) {
-		_music->updateMusic();
+		_vm->_music->updateMusic();
 
-		if (!_isHiRes)
-			waitTOF();
+		if (!_vm->_isHiRes)
+			_vm->waitTOF();
 
-		baseAddr = (uint32 *)getCurrentDrawingBuffer();
+		baseAddr = (uint32 *)_vm->getCurrentDrawingBuffer();
 
 		if (by > nheight)
 			by = nheight;
@@ -482,7 +489,7 @@ void LabEngine::doScrollBlack() {
 
 		screenUpdate();
 
-		if (!_isHiRes) {
+		if (!_vm->_isHiRes) {
 			if (nheight <= (height / 8))
 				by = 1;
 			else if (nheight <= (height / 4))
@@ -493,10 +500,10 @@ void LabEngine::doScrollBlack() {
 	}
 
 	freeAllStolenMem();
-	_event->mouseShow();
+	_vm->_event->mouseShow();
 }
 
-static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem) {
+void DisplayMan::copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem) {
 	uint32 size, offSet, copysize;
 	uint16 curPage;
 	uint32 *baseAddr;
@@ -505,12 +512,12 @@ static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startli
 
 	size = (int32)(height - nheight) * (int32)width;
 	mem += startline * width;
-	curPage = ((int32)nheight * (int32)width) / g_lab->_screenBytesPerPage;
-	offSet = ((int32)nheight * (int32)width) - (curPage * g_lab->_screenBytesPerPage);
+	curPage = ((int32)nheight * (int32)width) / g_lab->_graphics->_screenBytesPerPage;
+	offSet = ((int32)nheight * (int32)width) - (curPage * g_lab->_graphics->_screenBytesPerPage);
 
 	while (size) {
-		if (size > (g_lab->_screenBytesPerPage - offSet))
-			copysize = g_lab->_screenBytesPerPage - offSet;
+		if (size > (g_lab->_graphics->_screenBytesPerPage - offSet))
+			copysize = g_lab->_graphics->_screenBytesPerPage - offSet;
 		else
 			copysize = size;
 
@@ -526,35 +533,35 @@ static void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startli
 /*****************************************************************************/
 /* Scrolls the display to a new picture from a black screen.                 */
 /*****************************************************************************/
-void LabEngine::doScrollWipe(char *filename) {
+void DisplayMan::doScrollWipe(char *filename) {
 	uint16 startline = 0, onrow = 0;
 
-	_event->mouseHide();
+	_vm->_event->mouseHide();
 	uint16 width = VGAScaleX(320);
 	uint16 height = VGAScaleY(149) + SVGACord(2);
 
-	while (_music->isSoundEffectActive()) {
-		_music->updateMusic();
-		waitTOF();
+	while (_vm->_music->isSoundEffectActive()) {
+		_vm->_music->updateMusic();
+		_vm->waitTOF();
 	}
 
-	_anim->_isBM = true;
+	_vm->_anim->_isBM = true;
 	readPict(filename, true);
-	setPalette(_anim->_diffPalette, 256);
-	_anim->_isBM = false;
-	byte *mem = _anim->_rawDiffBM._planes[0];
+	_vm->setPalette(_vm->_anim->_diffPalette, 256);
+	_vm->_anim->_isBM = false;
+	byte *mem = _vm->_anim->_rawDiffBM._planes[0];
 
-	_music->updateMusic();
+	_vm->_music->updateMusic();
 	uint16 by = VGAScaleX(3);
 	uint16 nheight = height;
 
-	while (onrow < _anim->_headerdata._height) {
-		_music->updateMusic();
+	while (onrow < _vm->_anim->_headerdata._height) {
+		_vm->_music->updateMusic();
 
 		if ((by > nheight) && nheight)
 			by = nheight;
 
-		if ((startline + by) > (_anim->_headerdata._height - height - 1))
+		if ((startline + by) > (_vm->_anim->_headerdata._height - height - 1))
 			break;
 
 		if (nheight)
@@ -577,19 +584,19 @@ void LabEngine::doScrollWipe(char *filename) {
 			by = VGAScaleX(3);
 	}
 
-	_event->mouseShow();
+	_vm->_event->mouseShow();
 }
 
 /*****************************************************************************/
 /* Does the scroll bounce.  Assumes bitmap already in memory.                */
 /*****************************************************************************/
-void LabEngine::doScrollBounce() {
+void DisplayMan::doScrollBounce() {
 	const uint16 *newby, *newby1;
 
 	const uint16 newbyd[5] = {5, 4, 3, 2, 1}, newby1d[8] = {3, 3, 2, 2, 2, 1, 1, 1};
 	const uint16 newbyw[5] = {10, 8, 6, 4, 2}, newby1w[8] = {6, 6, 4, 4, 4, 2, 2, 2};
 
-	if (getPlatform() != Common::kPlatformWindows) {
+	if (_vm->getPlatform() != Common::kPlatformWindows) {
 		newby = newbyd;
 		newby1 = newby1d;
 	} else {
@@ -597,44 +604,43 @@ void LabEngine::doScrollBounce() {
 		newby1 = newby1w;
 	}
 
-	_event->mouseHide();
+	_vm->_event->mouseHide();
 	int width = VGAScaleX(320);
 	int height = VGAScaleY(149) + SVGACord(2);
-	byte *mem = _anim->_rawDiffBM._planes[0];
+	byte *mem = _vm->_anim->_rawDiffBM._planes[0];
 
-	_music->updateMusic();
-	int startline = _anim->_headerdata._height - height - 1;
+	_vm->_music->updateMusic();
+	int startline = _vm->_anim->_headerdata._height - height - 1;
 
 	for (int i = 0; i < 5; i++) {
-		_music->updateMusic();
+		_vm->_music->updateMusic();
 		startline -= newby[i];
 		copyPage(width, height, 0, startline, mem);
 
 		screenUpdate();
-		waitTOF();
+		_vm->waitTOF();
 	}
 
 	for (int i = 8; i > 0; i--) {
-		_music->updateMusic();
+		_vm->_music->updateMusic();
 		startline += newby1[i - 1];
 		copyPage(width, height, 0, startline, mem);
 
 		screenUpdate();
-		waitTOF();
-
+		_vm->waitTOF();
 	}
 
-	_event->mouseShow();
+	_vm->_event->mouseShow();
 }
 
 /*****************************************************************************/
 /* Does the transporter wipe.                                                */
 /*****************************************************************************/
-void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) {
+void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 	uint16 lastY, curY, linesdone = 0, lineslast;
 	Image imSource, imDest;
 
-	if (_isHiRes) {
+	if (_vm->_isHiRes) {
 		lineslast = 3;
 		lastY = 358;
 	} else {
@@ -647,12 +653,12 @@ void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 
 		while (curY < lastY) {
 			if (linesdone >= lineslast) {
-				_music->updateMusic();
-				waitTOF();
+				_vm->_music->updateMusic();
+				_vm->waitTOF();
 				linesdone = 0;
 			}
 
-			overlayRect(0, 0, curY, _screenWidth - 1, curY + 1);
+			_vm->overlayRect(0, 0, curY, _vm->_screenWidth - 1, curY + 1);
 			curY += 4;
 			linesdone++;
 		}
@@ -665,50 +671,50 @@ void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 
 		while (curY <= lastY) {
 			if (linesdone >= lineslast) {
-				_music->updateMusic();
-				waitTOF();
+				_vm->_music->updateMusic();
+				_vm->waitTOF();
 				linesdone = 0;
 			}
 
-			rectFill(0, curY, _screenWidth - 1, curY + 1);
+			rectFill(0, curY, _vm->_screenWidth - 1, curY + 1);
 			curY += 4;
 			linesdone++;
 		}
 	}
 
 	if (filename == NULL)
-		g_lab->_curFileName = getPictName(cPtr);
+		_vm->_curFileName = getPictName(cPtr);
 	else if (filename[0] > ' ')
-		g_lab->_curFileName = filename;
+		_vm->_curFileName = filename;
 	else
-		g_lab->_curFileName = getPictName(cPtr);
+		_vm->_curFileName = getPictName(cPtr);
 
-	byte *BitMapMem = readPictToMem(g_lab->_curFileName, _screenWidth, lastY + 5);
-	setPalette(_anim->_diffPalette, 256);
+	byte *BitMapMem = readPictToMem(g_lab->_curFileName, _vm->_screenWidth, lastY + 5);
+	_vm->setPalette(_vm->_anim->_diffPalette, 256);
 
 	if (BitMapMem) {
-		imSource._width = _screenWidth;
+		imSource._width = _vm->_screenWidth;
 		imSource._height = lastY;
 		imSource._imageData = BitMapMem;
 
-		imDest._width = _screenWidth;
-		imDest._height = _screenHeight;
-		imDest._imageData = getCurrentDrawingBuffer();
+		imDest._width = _vm->_screenWidth;
+		imDest._height = _vm->_screenHeight;
+		imDest._imageData = _vm->getCurrentDrawingBuffer();
 
 		for (uint16 i = 0; i < 2; i++) {
 			curY = i * 2;
 
 			while (curY < lastY) {
 				if (linesdone >= lineslast) {
-					_music->updateMusic();
-					waitTOF();
+					_vm->_music->updateMusic();
+					_vm->waitTOF();
 					linesdone = 0;
 				}
 
-				imDest._imageData = getCurrentDrawingBuffer();
+				imDest._imageData = _vm->getCurrentDrawingBuffer();
 
-				imSource.bltBitMap(0, curY, &imDest, 0, curY, _screenWidth, 2);
-				overlayRect(0, 0, curY, _screenWidth - 1, curY + 1);
+				imSource.bltBitMap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 2);
+				_vm->overlayRect(0, 0, curY, _vm->_screenWidth - 1, curY + 1);
 				curY += 4;
 				linesdone++;
 			}
@@ -719,17 +725,17 @@ void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 
 			while (curY <= lastY) {
 				if (linesdone >= lineslast) {
-					_music->updateMusic();
-					waitTOF();
+					_vm->_music->updateMusic();
+					_vm->waitTOF();
 					linesdone = 0;
 				}
 
-				imDest._imageData = getCurrentDrawingBuffer();
+				imDest._imageData = _vm->getCurrentDrawingBuffer();
 
 				if (curY == lastY)
-					imSource.bltBitMap(0, curY, &imDest, 0, curY, _screenWidth, 1);
+					imSource.bltBitMap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 1);
 				else
-					imSource.bltBitMap(0, curY, &imDest, 0, curY, _screenWidth, 2);
+					imSource.bltBitMap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 2);
 
 				curY += 4;
 				linesdone++;
@@ -741,7 +747,7 @@ void LabEngine::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 /*****************************************************************************/
 /* Does a certain number of pre-programmed wipes.                            */
 /*****************************************************************************/
-void LabEngine::doWipe(uint16 wipeType, CloseDataPtr *cPtr, char *filename) {
+void DisplayMan::doWipe(uint16 wipeType, CloseDataPtr *cPtr, char *filename) {
 	if ((wipeType == TRANSWIPE) || (wipeType == TRANSPORTER))
 		doTransWipe(cPtr, filename);
 	else if (wipeType == SCROLLWIPE)
@@ -753,16 +759,16 @@ void LabEngine::doWipe(uint16 wipeType, CloseDataPtr *cPtr, char *filename) {
 	else if (wipeType == READFIRSTFRAME)
 		readPict(filename, false);
 	else if (wipeType == READNEXTFRAME)
-		_anim->diffNextFrame();
+		_vm->_anim->diffNextFrame();
 }
 
 /*****************************************************************************/
 /* Changes the front screen to black.                                        */
 /*****************************************************************************/
-void blackScreen() {
+void DisplayMan::blackScreen() {
 	byte pal[256 * 3];
 	memset(pal, 0, 248 * 3);
-	g_lab->writeColorRegs(pal, 8, 248);
+	_vm->writeColorRegs(pal, 8, 248);
 
 	g_system->delayMillis(32);
 }
@@ -770,21 +776,251 @@ void blackScreen() {
 /*****************************************************************************/
 /* Changes the front screen to white.                                        */
 /*****************************************************************************/
-void whiteScreen() {
+void DisplayMan::whiteScreen() {
 	byte pal[256 * 3];
 	memset(pal, 255, 248 * 3);
-	g_lab->writeColorRegs(pal, 8, 248);
+	_vm->writeColorRegs(pal, 8, 248);
 }
 
 /*****************************************************************************/
 /* Changes the entire screen to black.                                       */
 /*****************************************************************************/
-void blackAllScreen() {
+void DisplayMan::blackAllScreen() {
 	byte pal[256 * 3];
 	memset(pal, 0, 256 * 3);
-	g_lab->writeColorRegs(pal, 0, 256);
+	_vm->writeColorRegs(pal, 0, 256);
 
 	g_system->delayMillis(32);
 }
 
+/******************************************************************************/
+/* Draws the control panel display.                                           */
+/******************************************************************************/
+void DisplayMan::drawPanel() {
+	_vm->_event->mouseHide();
+
+	setAPen(3);                 /* Clear Area */
+	rectFill(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319), VGAScaleY(199));
+
+	setAPen(0);                 /* First Line */
+	drawHLine(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319));
+	setAPen(5);                 /* Second Line */
+	drawHLine(0, VGAScaleY(149) + 1 + SVGACord(2), VGAScaleX(319));
+
+	/* Gadget Separators */
+	setAPen(0);
+	drawHLine(0, VGAScaleY(170), VGAScaleX(319));     /* First black line to separate buttons */
+
+	if (!_vm->_alternate) {
+		setAPen(4);
+		drawHLine(0, VGAScaleY(170) + 1, VGAScaleX(319)); /* The horizontal lines under the black one */
+		drawGadgetList(_vm->_moveGadgetList);
+	} else {
+		if (_vm->getPlatform() != Common::kPlatformWindows) {
+			drawVLine(VGAScaleX(124), VGAScaleY(170) + 1, VGAScaleY(199)); /* Vertical Black lines */
+			drawVLine(VGAScaleX(194), VGAScaleY(170) + 1, VGAScaleY(199));
+		} else {
+			drawVLine(VGAScaleX(90), VGAScaleY(170) + 1, VGAScaleY(199));  /* Vertical Black lines */
+			drawVLine(VGAScaleX(160), VGAScaleY(170) + 1, VGAScaleY(199));
+			drawVLine(VGAScaleX(230), VGAScaleY(170) + 1, VGAScaleY(199));
+		}
+
+		setAPen(4);
+		drawHLine(0, VGAScaleY(170) + 1, VGAScaleX(122));   /* The horizontal lines under the black one */
+		drawHLine(VGAScaleX(126), VGAScaleY(170) + 1, VGAScaleX(192));
+		drawHLine(VGAScaleX(196), VGAScaleY(170) + 1, VGAScaleX(319));
+
+		drawVLine(VGAScaleX(1), VGAScaleY(170) + 2, VGAScaleY(198)); /* The vertical high light lines */
+		if (_vm->getPlatform() != Common::kPlatformWindows) {
+			drawVLine(VGAScaleX(126), VGAScaleY(170) + 2, VGAScaleY(198));
+			drawVLine(VGAScaleX(196), VGAScaleY(170) + 2, VGAScaleY(198));
+		} else {
+			drawVLine(VGAScaleX(92), VGAScaleY(170) + 2, VGAScaleY(198));
+			drawVLine(VGAScaleX(162), VGAScaleY(170) + 2, VGAScaleY(198));
+			drawVLine(VGAScaleX(232), VGAScaleY(170) + 2, VGAScaleY(198));
+		}
+
+		drawGadgetList(_vm->_invGadgetList);
+	}
+
+	_vm->_event->mouseShow();
+}
+
+/******************************************************************************/
+/* Sets up the Labyrinth screens, and opens up the initial windows.           */
+/******************************************************************************/
+bool DisplayMan::setUpScreens() {
+	if (!createScreen(_vm->_isHiRes))
+		return false;
+
+	Common::File *controlFile = g_lab->_resource->openDataFile("P:Control");
+	for (uint16 i = 0; i < 20; i++)
+		_vm->_moveImages[i] = new Image(controlFile);
+	delete controlFile;
+
+	/* Creates the gadgets for the movement control panel */
+	uint16 y = VGAScaleY(173) - SVGACord(2);
+
+	if (_vm->getPlatform() == Common::kPlatformWindows) {
+		_vm->_moveGadgetList = createButton(1, y, 0, 't', _vm->_moveImages[0], _vm->_moveImages[1]);
+		Gadget *curGadget = _vm->_moveGadgetList;
+		curGadget->NextGadget = createButton(33, y, 1, 'm', _vm->_moveImages[2], _vm->_moveImages[3]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(65, y, 2, 'o', _vm->_moveImages[4], _vm->_moveImages[5]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(97, y, 3, 'c', _vm->_moveImages[6], _vm->_moveImages[7]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(129, y, 4, 'l', _vm->_moveImages[8], _vm->_moveImages[9]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(161, y, 5, 'i', _vm->_moveImages[12], _vm->_moveImages[13]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(193, y, 6, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(225, y, 7, VKEY_UPARROW, _vm->_moveImages[16], _vm->_moveImages[17]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(257, y, 8, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(289, y, 9, 'p', _vm->_moveImages[10], _vm->_moveImages[11]);
+	} else {
+		_vm->_moveGadgetList = createButton(1, y, 0, 0, _vm->_moveImages[0], _vm->_moveImages[1]);
+		Gadget *curGadget = _vm->_moveGadgetList;
+		curGadget->NextGadget = createButton(33, y, 1, 0, _vm->_moveImages[2], _vm->_moveImages[3]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(65, y, 2, 0, _vm->_moveImages[4], _vm->_moveImages[5]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(97, y, 3, 0, _vm->_moveImages[6], _vm->_moveImages[7]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(129, y, 4, 0, _vm->_moveImages[8], _vm->_moveImages[9]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(161, y, 5, 0, _vm->_moveImages[12], _vm->_moveImages[13]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(193, y, 6, 0, _vm->_moveImages[14], _vm->_moveImages[15]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(225, y, 7, 0, _vm->_moveImages[16], _vm->_moveImages[17]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(257, y, 8, 0, _vm->_moveImages[18], _vm->_moveImages[19]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(289, y, 9, 0, _vm->_moveImages[10], _vm->_moveImages[11]);
+	}
+
+	Common::File *invFile = g_lab->_resource->openDataFile("P:Inv");
+
+	if (_vm->getPlatform() == Common::kPlatformWindows) {
+		for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++)
+			_vm->_invImages[imgIdx] = new Image(invFile);
+
+		_vm->_invGadgetList = createButton(24, y, 0, 'm', _vm->_invImages[0], _vm->_invImages[1]);
+		Gadget *curGadget = _vm->_invGadgetList;
+		curGadget->NextGadget = createButton(56, y, 1, 'g', _vm->_invImages[2], _vm->_invImages[3]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(94, y, 2, 'u', _vm->_invImages[4], _vm->_invImages[5]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(126, y, 3, 'l', _vm->_moveImages[8], _vm->_moveImages[9]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(164, y, 4, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(196, y, 5, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(234, y, 6, 'b', _vm->_invImages[6], _vm->_invImages[7]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(266, y, 7, 'f', _vm->_invImages[8], _vm->_invImages[9]);
+		curGadget = curGadget->NextGadget;
+	} else {
+		for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++)
+			_vm->_invImages[imgIdx] = new Image(invFile);
+
+		_vm->_invGadgetList = createButton(58, y, 0, 0, _vm->_invImages[0], _vm->_invImages[1]);
+		Gadget *curGadget = _vm->_invGadgetList;
+		curGadget->NextGadget = createButton(90, y, 1, 0, _vm->_invImages[2], _vm->_invImages[3]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(128, y, 2, 0, _vm->_invImages[4], _vm->_invImages[5]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(160, y, 3, 0, _vm->_moveImages[8], _vm->_moveImages[9]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(198, y, 4, 0, _vm->_moveImages[14], _vm->_moveImages[15]);
+		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(230, y, 5, 0, _vm->_moveImages[18], _vm->_moveImages[19]);
+		curGadget = curGadget->NextGadget;
+	}
+
+	delete invFile;
+
+	return true;
+}
+
+/*****************************************************************************/
+/* Sets the pen number to use on all the drawing operations.                 */
+/*****************************************************************************/
+void DisplayMan::setAPen(byte pennum) {
+	_curapen = pennum;
+}
+
+/*****************************************************************************/
+/* Fills in a rectangle.                                                     */
+/*****************************************************************************/
+void DisplayMan::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+	int w = x2 - x1 + 1;
+	int h = y2 - y1 + 1;
+
+	if (x1 + w > _vm->_screenWidth)
+		w = _vm->_screenWidth - x1;
+
+	if (y1 + h > _vm->_screenHeight)
+		h = _vm->_screenHeight - y1;
+
+	if ((w > 0) && (h > 0)) {
+		char *d = (char *)_vm->getCurrentDrawingBuffer() + y1 * _vm->_screenWidth + x1;
+
+		while (h-- > 0) {
+			char *dd = d;
+			int ww = w;
+
+			while (ww-- > 0) {
+				*dd++ = _curapen;
+			}
+
+			d += _vm->_screenWidth;
+		}
+	}
+}
+
+/*****************************************************************************/
+/* Draws a horizontal line.                                                  */
+/*****************************************************************************/
+void DisplayMan::drawVLine(uint16 x, uint16 y1, uint16 y2) {
+	rectFill(x, y1, x, y2);
+}
+
+/*****************************************************************************/
+/* Draws a vertical line.                                                    */
+/*****************************************************************************/
+void DisplayMan::drawHLine(uint16 x1, uint16 y, uint16 x2) {
+	rectFill(x1, y, x2, y);
+}
+
+void DisplayMan::screenUpdate() {
+	g_system->copyRectToScreen(_vm->_displayBuffer, _vm->_screenWidth, 0, 0, _vm->_screenWidth, _vm->_screenHeight);
+	g_system->updateScreen();
+
+	_vm->_event->processInput();
+}
+
+/*****************************************************************************/
+/* Sets up either a low-res or a high-res 256 color screen.                  */
+/*****************************************************************************/
+bool DisplayMan::createScreen(bool hiRes) {
+	if (hiRes) {
+		_vm->_screenWidth  = 640;
+		_vm->_screenHeight = 480;
+	} else {
+		_vm->_screenWidth  = 320;
+		_vm->_screenHeight = 200;
+	}
+	_screenBytesPerPage = _vm->_screenWidth * _vm->_screenHeight;
+
+	_vm->_displayBuffer = new byte[_screenBytesPerPage];	// FIXME: Memory leak!
+
+	return true;
+}
+
 } // End of namespace Lab
diff --git a/engines/lab/graphics.h b/engines/lab/graphics.h
new file mode 100644
index 0000000..de2053a
--- /dev/null
+++ b/engines/lab/graphics.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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#ifndef LAB_GRAPHICS_H
+#define LAB_GRAPHICS_H
+
+namespace Lab {
+
+class LabEngine;
+
+class DisplayMan {
+private:
+	LabEngine *_vm;
+
+	byte _curapen;
+
+public:
+	bool _longWinInFront;
+	bool _lastMessageLong;
+	uint32 _screenBytesPerPage;
+
+	DisplayMan(LabEngine *lab);
+
+	uint16 scaleX(uint16 x);
+	uint16 scaleY(uint16 y);
+	int16 VGAScaleX(int16 x);
+	int16 VGAScaleY(int16 y);
+	uint16 SVGACord(uint16 cord);
+	int VGAUnScaleX(int x);
+	int VGAUnScaleY(int y);
+	bool readPict(const char *filename, bool playOnce);
+	byte *readPictToMem(const char *filename, uint16 x, uint16 y);
+	void doScrollBlack();
+	void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem);
+	void doScrollWipe(char *filename);
+	void doScrollBounce();
+	void doTransWipe(CloseDataPtr *cPtr, char *filename);
+	void doWipe(uint16 wipeType, CloseDataPtr *cPtr, char *filename);
+	void blackScreen();
+	void whiteScreen();
+	void blackAllScreen();
+	void createBox(uint16 y2);
+	void drawPanel();
+	bool setUpScreens();
+	int32 longDrawMessage(const char *str);
+	void drawMessage(const char *str);
+	void setAPen(byte pennum);
+	void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	/* Window text stuff */
+	uint32 flowText(void *font,				/* the TextAttr pointer */
+					int16 spacing,			/* How much vertical spacing between the lines */
+					byte pencolor,			/* pen number to use for text */
+					byte backpen,			/* the background color */
+					bool fillback,			/* Whether to fill the background */
+					bool centerh,			/* Whether to center the text horizontally */
+					bool centerv,			/* Whether to center the text vertically */
+					bool output,			/* Whether to output any text */
+					uint16 x1, uint16 y1,	/* Cords */
+					uint16 x2, uint16 y2,
+					const char *text);		/* The text itself */
+
+	uint32 flowTextToMem(Image *destIm,
+					void *font,				/* the TextAttr pointer */
+					int16 spacing,			/* How much vertical spacing between the lines */
+					byte pencolor,			/* pen number to use for text */
+					byte backpen,			/* the background color */
+					bool fillback,			/* Whether to fill the background */
+					bool centerh,			/* Whether to center the text horizontally */
+					bool centerv,			/* Whether to center the text vertically */
+					bool output,			/* Whether to output any text */
+					uint16 x1, uint16 y1,	/* Cords */
+					uint16 x2, uint16 y2,
+					const char *str);		/* The text itself */
+
+	void drawHLine(uint16 x, uint16 y1, uint16 y2);
+	void drawVLine(uint16 x1, uint16 y, uint16 x2);
+	void screenUpdate();
+	bool createScreen(bool HiRes);
+};
+
+} // End of namespace Lab
+
+#endif // LAB_GRAPHICS_H
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 7352b61..30aa547 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -43,7 +43,7 @@ Common::KeyState _keyPressed;
 Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt) {
 	Gadget *gptr;
 
-	x = VGAScaleX(x);
+	x = g_lab->_graphics->VGAScaleX(x);
 
 	if ((gptr = new Gadget())) {
 		gptr->x = x;
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 43cbed6..aab50f4 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -106,13 +106,13 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 				fade(false, 0);
 
 			if (isScreen) {
-				_vm->setAPen(7);
-				_vm->rectFill(VGAScaleX(10), VGAScaleY(10), VGAScaleX(310), VGAScaleY(190));
+				_vm->_graphics->setAPen(7);
+				_vm->_graphics->rectFill(_vm->_graphics->VGAScaleX(10), _vm->_graphics->VGAScaleY(10), _vm->_graphics->VGAScaleX(310), _vm->_graphics->VGAScaleY(190));
 
-				Drawn = flowText(msgFont, (!_vm->_isHiRes) * -1, 5, 7, false, false, true, true, VGAScaleX(14), VGAScaleY(11), VGAScaleX(306), VGAScaleY(189), (char *)curPlace);
+				Drawn = _vm->_graphics->flowText(msgFont, (!_vm->_isHiRes) * -1, 5, 7, false, false, true, true, _vm->_graphics->VGAScaleX(14), _vm->_graphics->VGAScaleY(11), _vm->_graphics->VGAScaleX(306), _vm->_graphics->VGAScaleY(189), (char *)curPlace);
 				fade(true, 0);
 			} else {
-				Drawn = _vm->longDrawMessage((char *)curPlace);
+				Drawn = _vm->_graphics->longDrawMessage((char *)curPlace);
 			}
 
 			curPlace += Drawn;
@@ -227,7 +227,7 @@ void Intro::nReadPict(const char *filename, bool playOnce) {
 
 	_vm->_anim->_doBlack = _introDoBlack;
 	_vm->_anim->stopDiffEnd();
-	readPict(finalFileName.c_str(), playOnce);
+	_vm->_graphics->readPict(finalFileName.c_str(), playOnce);
 }
 
 /*****************************************************************************/
@@ -259,8 +259,7 @@ void Intro::introSequence() {
 		}
 	}
 
-	blackAllScreen();
-
+	_vm->_graphics->blackAllScreen();
 	_vm->_music->initMusic();
 
 	_vm->_anim->_noPalChange = true;
@@ -301,8 +300,7 @@ void Intro::introSequence() {
 	}
 
 	fade(false, 0);
-	blackAllScreen();
-
+	_vm->_graphics->blackAllScreen();
 	_vm->_music->updateMusic();
 
 	nReadPict("Title.A", true);
@@ -328,7 +326,7 @@ void Intro::introSequence() {
 	_vm->_music->newOpen("p:Intro/Intro.1");  /* load the picture into the buffer */
 
 	_vm->_music->updateMusic();
-	blackAllScreen();
+	_vm->_graphics->blackAllScreen();
 	_vm->_music->updateMusic();
 
 	TextFont *msgFont = _vm->_resource->getFont("P:Map.fon");
@@ -349,7 +347,7 @@ void Intro::introSequence() {
 
 	freeAllStolenMem();
 
-	blackAllScreen();
+	_vm->_graphics->blackAllScreen();
 	_vm->_music->updateMusic();
 
 	_introDoBlack = true;
@@ -443,8 +441,8 @@ void Intro::introSequence() {
 	nReadPict("SubX", true);
 
 	if (_quitIntro) {
-		_vm->setAPen(0);
-		_vm->rectFill(0, 0, _vm->_screenWidth - 1, _vm->_screenHeight - 1);
+		_vm->_graphics->setAPen(0);
+		_vm->_graphics->rectFill(0, 0, _vm->_screenWidth - 1, _vm->_screenHeight - 1);
 		_vm->_anim->_doBlack = true;
 	}
 
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 90c7131..efa6752 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -55,16 +55,13 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
  : Engine(syst), _gameDescription(gameDesc), _extraGameFeatures(0) {
 	g_lab = this;
 
-    _screenWidth = 320;
+	_screenWidth = 320;
 	_screenHeight = 200;
-	_screenBytesPerPage = 65536;
 
-    _curapen = 0;
+	_currentDisplayBuffer = 0;
+	_displayBuffer = 0;
 
-    _currentDisplayBuffer = 0;
-    _displayBuffer = 0;
-
-    _lastWaitTOFTicks = 0;
+	_lastWaitTOFTicks = 0;
 
 	_isHiRes = false;
 	_roomNum = -1;
@@ -86,9 +83,9 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_resource = nullptr;
 	_music = nullptr;
 	_anim = nullptr;
+	_graphics = nullptr;
 
-    _lastMessageLong = false;
-    _lastTooLong = false;
+	_lastTooLong = false;
 	_interfaceOff = false;
 	_alternate = false;
 
@@ -104,15 +101,13 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_nextFileName = nullptr;
 	_newFileName = nullptr;
 
-    _moveGadgetList = 0;
-    _invGadgetList = 0;
-
-    _curFileName = " ";
+	_moveGadgetList = 0;
+	_invGadgetList = 0;
 
-    _longWinInFront = false;
-    _msgFont = 0;
+	_curFileName = " ";
+	_msgFont = 0;
 
-    _inventory = 0;
+	_inventory = 0;
 
 	//const Common::FSNode gameDataDir(ConfMan.get("path"));
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
@@ -129,6 +124,7 @@ LabEngine::~LabEngine() {
 	delete _resource;
 	delete _music;
 	delete _anim;
+	delete _graphics;
 }
 
 Common::Error LabEngine::run() {
@@ -141,6 +137,7 @@ Common::Error LabEngine::run() {
 	_resource = new Resource(this);
 	_music = new Music(this);
 	_anim = new Anim(this);
+	_graphics = new DisplayMan(this);
 
 	if (getPlatform() == Common::kPlatformWindows) {
 		// Check if this is the Wyrmkeep trial
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index d8b75cb..9cf28df 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -41,6 +41,7 @@
 #include "lab/music.h"
 #include "lab/resource.h"
 #include "lab/anim.h"
+#include "lab/graphics.h"
 
 struct ADGameDescription;
 
@@ -74,8 +75,6 @@ public:
 
 	int _screenWidth;
 	int _screenHeight;
-	uint32 _screenBytesPerPage;
-
 
 	// timing.cpp
 	void getTime(uint32 *secs, uint32 *micros);
@@ -87,24 +86,19 @@ public:
 private:
 	uint32 _extraGameFeatures;
 	bool _interfaceOff;
-	bool _alternate;
-	Image *_moveImages[20];
-	Image *_invImages[10];
-	Gadget *_moveGadgetList;
-	Gadget *_invGadgetList;
 
 	// timing.cpp
 	void microDelay(uint32 secs, uint32 micros);
 
 	// vga.cpp
 	byte _curvgapal[256 * 3];
-	byte _curapen;
 
 public:
 	EventManager *_event;
 	Resource *_resource;
 	Music *_music;
 	Anim *_anim;
+	DisplayMan *_graphics;
 
 	int _roomNum;
 	byte *_currentDisplayBuffer;
@@ -117,6 +111,7 @@ public:
 	bool _isCrumbTurning;
 	uint32 _crumbSecs, _crumbMicros;
 	bool _isCrumbWaiting;
+	bool _alternate;
 	byte *_tempScrollData;
 	bool _isHiRes;
 	byte *_displayBuffer;
@@ -124,46 +119,34 @@ public:
 	const char *_nextFileName;
 	const char *_newFileName;  /* When ProcessRoom.c decides to change the filename
                                     of the current picture. */
+	TextFont *_msgFont;
+	Gadget *_moveGadgetList;
+	Gadget *_invGadgetList;
+	Image *_moveImages[20];
+	Image *_invImages[10];
 
 private:
 	int _lastWaitTOFTicks;
-	bool _lastMessageLong;
 	bool _lastTooLong;
-	TextFont *_msgFont;
-	bool _longWinInFront;
 	CloseDataPtr _cptr;
 	InventoryData *_inventory;
 
 private:
-	bool createScreen(bool HiRes);
 	bool from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Common::Point tmpPos, uint16 &curInv, IntuiMessage * curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode);
 
 public:
 	void waitTOF();
-	void setAPen(byte pennum);
 	void writeColorRegs(byte *buf, uint16 first, uint16 numreg);
 	byte *getCurrentDrawingBuffer();
-	void screenUpdate();
-	void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void setPalette(void *cmap, uint16 numcolors);
-	void drawHLine(uint16 x, uint16 y1, uint16 y2);
-	void drawVLine(uint16 x1, uint16 y, uint16 x2);
 
-	void drawPanel();
 	void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr);
 	void interfaceOff();
 	void interfaceOn();
 	void decIncInv(uint16 *CurInv, bool dec);
-	int32 longDrawMessage(const char *str);
-	void drawMessage(const char *str);
-	void doScrollBlack();
-	void doScrollWipe(char *filename);
-	void doScrollBounce();
-	void doWipe(uint16 WipeType, CloseDataPtr *cPtr, char *filename);
-	void doTransWipe(CloseDataPtr *cPtr, char *filename);
 	Gadget *checkNumGadgetHit(Gadget *gadlist, uint16 key);
 	IntuiMessage *getMsg();
 	void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein);
@@ -184,7 +167,6 @@ public:
 
 private:
 	// engine.cpp
-	bool setUpScreens();
 	void freeScreens();
 	void perFlipGadget(uint16 gadID);
 	bool doCloseUp(CloseDataPtr cptr);
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 987864b..d81de5c 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -71,41 +71,8 @@ struct SaveGameHeader {
 
 /* Reads in pictures */
 
-bool readPict(const char *filename, bool PlayOnce);
 bool readMusic(const char *filename, bool waitTillFinished);
-byte *readPictToMem(const char *filename, uint16 x, uint16 y);
-
-/* Window text stuff */
-
-uint32 flowText(void *font,  /* the TextAttr pointer */
-                int16 spacing,          /* How much vertical spacing between the lines */
-                byte pencolor,         /* pen number to use for text */
-                byte backpen,          /* the background color */
-                bool fillback,                /* Whether to fill the background */
-                bool centerh,                 /* Whether to center the text horizontally */
-                bool centerv,                 /* Whether to center the text vertically */
-                bool output,                  /* Whether to output any text */
-                uint16 x1,               /* Cords */
-                uint16 y1, uint16 x2, uint16 y2, const char *text); /* The text itself */
-
-uint32 flowTextToMem(Image *DestIm, void *font,     /* the TextAttr pointer */
-                     int16 spacing,          /* How much vertical spacing between the lines */
-                     byte pencolor,         /* pen number to use for text */
-                     byte backpen,          /* the background color */
-                     bool fillback,                /* Whether to fill the background */
-                     bool centerh,                 /* Whether to center the text horizontally */
-                     bool centerv,                 /* Whether to center the text vertically */
-                     bool output,                  /* Whether to output any text */
-                     uint16 x1,               /* Cords */
-                     uint16 y1, uint16 x2, uint16 y2, const char *text); /* The text itself */
-
-void drawMessage(const char *text);
 void drawStaticMessage(byte index);
-int32 longDrawMessage(const char *text);
-
-/* The Wipes */
-
-void doWipe(uint16 WipeType, CloseDataPtr *cptr, char *filename);
 
 /* Double Buffer stuff */
 
@@ -173,11 +140,6 @@ public:
 /*----- From Machine.c ------*/
 /*---------------------------*/
 
-uint16 scaleX(uint16 x);
-uint16 scaleY(uint16 y);
-int16 VGAScaleX(int16 x);
-int16 VGAScaleY(int16 y);
-uint16 SVGACord(uint16 cord);
 int VGAUnScaleX(int x);
 int VGAUnScaleY(int y);
 char *translateFileName(const char *filename);
@@ -211,10 +173,6 @@ void mouseCombination(Common::Point pos);
 void showTile(const char *filename, bool showsolution);
 void mouseTile(Common::Point pos);
 
-void blackScreen();
-void blackAllScreen();
-void whiteScreen();
-
 } // End of namespace Lab
 
 #endif /* LAB_LABFUN_H */
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 9ca57b0..f5746ba 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -164,8 +164,8 @@ static bool loadMapData() {
 	gptr = MapGadgetList;
 
 	while (gptr) {
-		gptr->x = VGAScaleX(MapGadX[counter]);
-		gptr->y = VGAScaleY(MapGadY[counter]);
+		gptr->x = g_lab->_graphics->VGAScaleX(MapGadX[counter]);
+		gptr->y = g_lab->_graphics->VGAScaleY(MapGadY[counter]);
 		gptr = gptr->NextGadget;
 		counter++;
 	}
@@ -479,8 +479,8 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 	if (fadeout)
 		fade(false, 0);
 
-	setAPen(0);
-	rectFill(0, 0, _screenWidth - 1, _screenHeight - 1);
+	_graphics->setAPen(0);
+	_graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1);
 
 	Map->drawImage(0, 0);
 	drawGadgetList(MapGadgetList);
@@ -528,7 +528,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 			HugeMaze->drawImage(mapScaleX(524), mapScaleY(97));
 	} else if (Floor == SURMAZEFLOOR) {
 		sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str();
-		flowText(_msgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr);
+		_graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr);
 	}
 
 	switch (Floor) {
@@ -559,10 +559,10 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 	}
 
 	if (sptr)
-		flowText(_msgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(75), VGAScaleX(134), VGAScaleY(97), sptr);
+		_graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _graphics->VGAScaleX(14), _graphics->VGAScaleY(75), _graphics->VGAScaleX(134), _graphics->VGAScaleY(97), sptr);
 
 	if ((sptr = _rooms[CurMsg]._roomMsg))
-		flowText(_msgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr);
+		_graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _graphics->VGAScaleX(14), _graphics->VGAScaleY(148), _graphics->VGAScaleX(134), _graphics->VGAScaleY(186), sptr);
 
 	if (fadein)
 		fade(true, 0);
@@ -715,9 +715,9 @@ void LabEngine::processMap(uint16 CurRoom) {
 
 						if ((sptr = _rooms[CurMsg]._roomMsg)) {
 							_event->mouseHide();
-							setAPen(3);
-							rectFill(VGAScaleX(13), VGAScaleY(148), VGAScaleX(135), VGAScaleY(186));
-							flowText(_msgFont, 0, 5, 3, true, true, true, true, VGAScaleX(14), VGAScaleY(148), VGAScaleX(134), VGAScaleY(186), sptr);
+							_graphics->setAPen(3);
+							_graphics->rectFill(_graphics->VGAScaleX(13), _graphics->VGAScaleY(148), _graphics->VGAScaleX(135), _graphics->VGAScaleY(186));
+							_graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _graphics->VGAScaleX(14), _graphics->VGAScaleY(148), _graphics->VGAScaleX(134), _graphics->VGAScaleY(186), sptr);
 
 							if (Maps[OldMsg].PageNumber == CurFloor)
 								drawRoom(OldMsg, (bool)(OldMsg == CurRoom));
@@ -727,8 +727,8 @@ void LabEngine::processMap(uint16 CurRoom) {
 							y1 = (y1 + y2) / 2;
 
 							if ((CurMsg != CurRoom) && (Maps[CurMsg].PageNumber == CurFloor)) {
-								setAPen(1);
-								rectFill(x1 - 1, y1, x1, y1);
+								_graphics->setAPen(1);
+								_graphics->rectFill(x1 - 1, y1, x1, y1);
 							}
 
 							_event->mouseShow();
@@ -737,7 +737,7 @@ void LabEngine::processMap(uint16 CurRoom) {
 				}
 			}
 
-			screenUpdate();
+			_graphics->screenUpdate();
 		}
 	}
 }
@@ -751,7 +751,7 @@ void LabEngine::doMap(uint16 CurRoom) {
 
 	_music->updateMusic();
 	loadMapData();
-	blackAllScreen();
+	_graphics->blackAllScreen();
 
 	if (Direction == NORTH)
 		XMark = MapNorth;
@@ -765,18 +765,18 @@ void LabEngine::doMap(uint16 CurRoom) {
 	drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true);
 	_event->mouseShow();
 	_event->attachGadgetList(MapGadgetList);
-	screenUpdate();
+	_graphics->screenUpdate();
 	processMap(CurRoom);
 	_event->attachGadgetList(NULL);
 	fade(false, 0);
-	blackAllScreen();
+	_graphics->blackAllScreen();
 	_event->mouseHide();
-	setAPen(0);
-	rectFill(0, 0, _screenWidth - 1, _screenHeight - 1);
+	_graphics->setAPen(0);
+	_graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1);
 	freeMapData();
-	blackAllScreen();
+	_graphics->blackAllScreen();
 	_event->mouseShow();
-	screenUpdate();
+	_graphics->screenUpdate();
 }
 
 } // End of namespace Lab
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 954bf00..0b81255 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -110,8 +110,8 @@ static CloseData *getObject(uint16 x, uint16 y, CloseDataPtr lcptr) {
 	}
 
 	while (lcptr != NULL) {
-		if ((x >= scaleX(lcptr->x1)) && (y >= scaleY(lcptr->y1)) &&
-		        (x <= scaleX(lcptr->x2)) && (y <= scaleY(lcptr->y2)))
+		if ((x >= g_lab->_graphics->scaleX(lcptr->x1)) && (y >= g_lab->_graphics->scaleY(lcptr->y1)) &&
+		        (x <= g_lab->_graphics->scaleX(lcptr->x2)) && (y <= g_lab->_graphics->scaleY(lcptr->y2)))
 			return lcptr;
 
 		lcptr = lcptr->NextCloseUp;
@@ -167,7 +167,7 @@ char *getPictName(CloseDataPtr *lcptr) {
 /*****************************************************************************/
 void LabEngine::drawDirection(CloseDataPtr lcptr) {
 	if (lcptr != NULL && lcptr->Message) {
-		drawMessage(lcptr->Message);
+		_graphics->drawMessage(lcptr->Message);
 		return;
 	}
 
@@ -187,7 +187,7 @@ void LabEngine::drawDirection(CloseDataPtr lcptr) {
 	else if (Direction == WEST)
 		message += _resource->getStaticText(kTextFacingWest);
 
-	drawMessage(message.c_str());
+	_graphics->drawMessage(message.c_str());
 }
 
 /*****************************************************************************/
@@ -252,10 +252,10 @@ void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords)
 			x2 = lcptr->x2;
 			y2 = lcptr->y2;
 		} else {
-			x1 = scaleX(lcptr->x1);
-			y1 = scaleY(lcptr->y1);
-			x2 = scaleX(lcptr->x2);
-			y2 = scaleY(lcptr->y2);
+			x1 = g_lab->_graphics->scaleX(lcptr->x1);
+			y1 = g_lab->_graphics->scaleY(lcptr->y1);
+			x2 = g_lab->_graphics->scaleX(lcptr->x2);
+			y2 = g_lab->_graphics->scaleY(lcptr->y2);
 		}
 
 		if (pos.x >= x1 && pos.y >= y1 && pos.x <= x2 && pos.y <= y2 && lcptr->GraphicName) {
@@ -283,8 +283,8 @@ bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
 
 
 	while (lcptr != NULL) {
-		if ((x >= scaleX(lcptr->x1)) && (y >= scaleY(lcptr->y1)) &&
-		        (x <= scaleX(lcptr->x2)) && (y <= scaleY(lcptr->y2)) &&
+		if ((x >= g_lab->_graphics->scaleX(lcptr->x1)) && (y >= g_lab->_graphics->scaleY(lcptr->y1)) &&
+		        (x <= g_lab->_graphics->scaleX(lcptr->x2)) && (y <= g_lab->_graphics->scaleY(lcptr->y2)) &&
 		        (lcptr->CloseUpType < 0)) {
 			g_lab->_conditions->inclElement(abs(lcptr->CloseUpType));
 			return true;
@@ -326,11 +326,11 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			break;
 
 		case SHOWDIFF:
-			readPict((char *)aptr->Data, true);
+			_graphics->readPict((char *)aptr->Data, true);
 			break;
 
 		case SHOWDIFFCONT:
-			readPict((char *)aptr->Data, false);
+			_graphics->readPict((char *)aptr->Data, false);
 			break;
 
 		case LOADDIFF:
@@ -345,7 +345,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			break;
 
 		case WIPECMD:
-			doWipe(aptr->Param1, lcptr, (char *)aptr->Data);
+			_graphics->doWipe(aptr->Param1, lcptr, (char *)aptr->Data);
 			break;
 
 		case NOUPDATE:
@@ -362,7 +362,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 
 				if (strcmp(test, _curFileName) != 0) {
 					_curFileName = test;
-					readPict(_curFileName, true);
+					_graphics->readPict(_curFileName, true);
 				}
 			}
 			break;
@@ -378,10 +378,10 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 		case SHOWMESSAGE:
 			DoNotDrawMessage = false;
 
-			if (_longWinInFront)
-				longDrawMessage((char *)aptr->Data);
+			if (_graphics->_longWinInFront)
+				_graphics->longDrawMessage((char *)aptr->Data);
 			else
-				drawMessage((char *)aptr->Data);
+				_graphics->drawMessage((char *)aptr->Data);
 
 			DoNotDrawMessage = true;
 			break;
@@ -389,7 +389,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 		case CSHOWMESSAGE:
 			if (*lcptr == NULL) {
 				DoNotDrawMessage = false;
-				drawMessage((char *)aptr->Data);
+				_graphics->drawMessage((char *)aptr->Data);
 				DoNotDrawMessage = true;
 			}
 
@@ -398,7 +398,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 		case SHOWMESSAGES: {
 				char **str = (char **)aptr->Data;
 				DoNotDrawMessage = false;
-				drawMessage(str[getRandom(aptr->Param1)]);
+				_graphics->drawMessage(str[getRandom(aptr->Param1)]);
 				DoNotDrawMessage = true;
 			}
 			break;
@@ -407,7 +407,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			if (aptr->Param1 & 0x8000) {
 				// This is a Wyrmkeep Windows trial version, thus stop at this
 				// point, since we can't check for game payment status
-				readPict(getPictName(lcptr), true);
+				_graphics->readPict(getPictName(lcptr), true);
 				aptr = NULL;
 				GUI::MessageDialog trialMessage("This is the end of the trial version. You can play the full game using the original interpreter from Wyrmkeep");
 				trialMessage.runModal();
@@ -421,7 +421,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			break;
 
 		case SETCLOSEUP: {
-				CloseDataPtr tlcptr = getObject(scaleX(aptr->Param1), scaleY(aptr->Param2), *lcptr);
+				CloseDataPtr tlcptr = getObject(g_lab->_graphics->scaleX(aptr->Param1), g_lab->_graphics->scaleY(aptr->Param2), *lcptr);
 
 				if (tlcptr)
 					*lcptr = tlcptr;
@@ -455,7 +455,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 
 				addCurTime(aptr->Param1, 0, &startSecs, &startMicros);
 
-				screenUpdate();
+				_graphics->screenUpdate();
 
 				while (1) {
 					_music->updateMusic();
@@ -543,7 +543,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 				waitTOF();
 				waitTOF();
 			} else if (aptr->Param1 == 4) { /* white the palette */
-				whiteScreen();
+				_graphics->whiteScreen();
 				waitTOF();
 				waitTOF();
 			} else if (aptr->Param1 == 6) { /* Restore the palette */
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index bfe089c..7f56c8e 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -138,7 +138,7 @@ bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc)
 
 	// Load scene pic
 	CloseDataPtr cPtr = NULL;
-	readPict(getPictName(&cPtr), true);
+	g_lab->_graphics->readPict(getPictName(&cPtr), true);
 
 	writeSaveGameHeader(file, desc);
 	file->writeUint16LE(g_lab->_roomNum);
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 9f36303..3be558b 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -109,9 +109,9 @@ static byte *loadBackPict(const char *fileName, bool tomem) {
 	g_lab->_anim->_noPalChange = true;
 
 	if (tomem)
-		res = readPictToMem(fileName, g_lab->_screenWidth, g_lab->_screenHeight);
+		res = g_lab->_graphics->readPictToMem(fileName, g_lab->_screenWidth, g_lab->_screenHeight);
 	else
-		readPict(fileName, true);
+		g_lab->_graphics->readPict(fileName, true);
 
 	for (uint16 i = 0; i < 16; i++) {
 		hipal[i] = ((g_lab->_anim->_diffPalette[i * 3] >> 2) << 8) +
@@ -129,7 +129,7 @@ static byte *loadBackPict(const char *fileName, bool tomem) {
 /*****************************************************************************/
 static void doCombination() {
 	for (uint16 i = 0; i <= 5; i++)
-		Images[combination[i]]->drawImage(VGAScaleX(combx[i]), VGAScaleY(65));
+		Images[combination[i]]->drawImage(g_lab->_graphics->VGAScaleX(combx[i]), g_lab->_graphics->VGAScaleY(65));
 }
 
 /*****************************************************************************/
@@ -139,10 +139,10 @@ void showCombination(const char *filename) {
 	resetBuffer();
 	g_lab->_anim->_doBlack = true;
 	g_lab->_anim->_noPalChange = true;
-	readPict(filename, true);
+	g_lab->_graphics->readPict(filename, true);
 	g_lab->_anim->_noPalChange = false;
 
-	blackScreen();
+	g_lab->_graphics->blackScreen();
 
 	Common::File *numFile = g_lab->_resource->openDataFile("P:Numbers");
 
@@ -188,9 +188,9 @@ static void changeCombination(uint16 number) {
 
 		display._imageData = g_lab->getCurrentDrawingBuffer();
 
-		g_lab->scrollDisplayY(2, VGAScaleX(combx[number]), VGAScaleY(65), VGAScaleX(combx[number]) + (Images[combnum])->_width - 1, VGAScaleY(65) + (Images[combnum])->_height);
+		g_lab->scrollDisplayY(2, g_lab->_graphics->VGAScaleX(combx[number]), g_lab->_graphics->VGAScaleY(65), g_lab->_graphics->VGAScaleX(combx[number]) + (Images[combnum])->_width - 1, g_lab->_graphics->VGAScaleY(65) + (Images[combnum])->_height);
 
-		Images[combnum]->bltBitMap(0, (Images[combnum])->_height - (2 * i), &(display), VGAScaleX(combx[number]), VGAScaleY(65), (Images[combnum])->_width, 2);
+		Images[combnum]->bltBitMap(0, (Images[combnum])->_height - (2 * i), &(display), g_lab->_graphics->VGAScaleX(combx[number]), g_lab->_graphics->VGAScaleY(65), (Images[combnum])->_width, 2);
 	}
 
 	for (uint16 i = 0; i < 6; i++)
@@ -240,20 +240,20 @@ static void doTile(bool showsolution) {
 	int16 rows, cols;
 
 	if (showsolution) {
-		rowm = VGAScaleY(23);
-		colm = VGAScaleX(27);
+		rowm = g_lab->_graphics->VGAScaleY(23);
+		colm = g_lab->_graphics->VGAScaleX(27);
 
-		rows = VGAScaleY(31);
-		cols = VGAScaleX(105);
+		rows = g_lab->_graphics->VGAScaleY(31);
+		cols = g_lab->_graphics->VGAScaleX(105);
 	} else {
-		g_lab->setAPen(0);
-		g_lab->rectFill(VGAScaleX(97), VGAScaleY(22), VGAScaleX(220), VGAScaleY(126));
+		g_lab->_graphics->setAPen(0);
+		g_lab->_graphics->rectFill(g_lab->_graphics->VGAScaleX(97), g_lab->_graphics->VGAScaleY(22), g_lab->_graphics->VGAScaleX(220), g_lab->_graphics->VGAScaleY(126));
 
-		rowm = VGAScaleY(25);
-		colm = VGAScaleX(30);
+		rowm = g_lab->_graphics->VGAScaleY(25);
+		colm = g_lab->_graphics->VGAScaleX(30);
 
-		rows = VGAScaleY(25);
-		cols = VGAScaleX(100);
+		rows = g_lab->_graphics->VGAScaleY(25);
+		cols = g_lab->_graphics->VGAScaleX(100);
 	}
 
 	while (row < 4) {
@@ -283,9 +283,9 @@ void showTile(const char *filename, bool showsolution) {
 	resetBuffer();
 	g_lab->_anim->_doBlack = true;
 	g_lab->_anim->_noPalChange = true;
-	readPict(filename, true);
+	g_lab->_graphics->readPict(filename, true);
 	g_lab->_anim->_noPalChange = false;
-	blackScreen();
+	g_lab->_graphics->blackScreen();
 
 	Common::File *tileFile = tileFile = g_lab->_resource->openDataFile(showsolution ? "P:TileSolution" : "P:Tile");
 
@@ -317,33 +317,33 @@ static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 	uint16 last = 0, x1, y1;
 
 	if (scrolltype == LEFTSCROLL) {
-		dX =  VGAScaleX(5);
-		sx =  VGAScaleX(5);
+		dX =  g_lab->_graphics->VGAScaleX(5);
+		sx =  g_lab->_graphics->VGAScaleX(5);
 		last = 6;
 	} else if (scrolltype == RIGHTSCROLL) {
-		dX = VGAScaleX(-5);
-		dx = VGAScaleX(-5);
-		sx =  VGAScaleX(5);
+		dX = g_lab->_graphics->VGAScaleX(-5);
+		dx = g_lab->_graphics->VGAScaleX(-5);
+		sx =  g_lab->_graphics->VGAScaleX(5);
 		last = 6;
 	} else if (scrolltype == UPSCROLL) {
-		dY =  VGAScaleY(5);
-		sy =  VGAScaleY(5);
+		dY =  g_lab->_graphics->VGAScaleY(5);
+		sy =  g_lab->_graphics->VGAScaleY(5);
 		last = 5;
 	} else if (scrolltype == DOWNSCROLL) {
-		dY = VGAScaleY(-5);
-		dy = VGAScaleY(-5);
-		sy =  VGAScaleY(5);
+		dY = g_lab->_graphics->VGAScaleY(-5);
+		dy = g_lab->_graphics->VGAScaleY(-5);
+		sy =  g_lab->_graphics->VGAScaleY(5);
 		last = 5;
 	}
 
-	sx += SVGACord(2);
+	sx += g_lab->_graphics->SVGACord(2);
 
-	x1 = VGAScaleX(100) + (col * VGAScaleX(30)) + dx;
-	y1 = VGAScaleY(25) + (row * VGAScaleY(25)) + dy;
+	x1 = g_lab->_graphics->VGAScaleX(100) + (col * g_lab->_graphics->VGAScaleX(30)) + dx;
+	y1 = g_lab->_graphics->VGAScaleY(25) + (row * g_lab->_graphics->VGAScaleY(25)) + dy;
 
 	for (uint16 i = 0; i < last; i++) {
 		g_lab->waitTOF();
-		scrollRaster(dX, dY, x1, y1, x1 + VGAScaleX(28) + sx, y1 + VGAScaleY(23) + sy);
+		scrollRaster(dX, dY, x1, y1, x1 + g_lab->_graphics->VGAScaleX(28) + sx, y1 + g_lab->_graphics->VGAScaleY(23) + sy);
 		x1 += dX;
 		y1 += dY;
 	}
@@ -413,7 +413,7 @@ static void changeTile(uint16 col, uint16 row) {
 		if (check) {
 			g_lab->_conditions->inclElement(BRICKOPEN);  /* unlocked combination */
 			g_lab->_anim->_doBlack = true;
-			check = readPict("p:Up/BDOpen", true);
+			check = g_lab->_graphics->readPict("p:Up/BDOpen", true);
 		}
 	}
 }
@@ -444,7 +444,7 @@ void doNotes() {
 	TextFont *noteFont = g_lab->_resource->getFont("P:Note.fon");
 	char *ntext = g_lab->_resource->getText("Lab:Rooms/Notes");
 
-	flowText(noteFont, -2 + SVGACord(1), 0, 0, false, false, true, true, VGAScaleX(25) + SVGACord(15), VGAScaleY(50), VGAScaleX(295) - SVGACord(15), VGAScaleY(148), ntext);
+	g_lab->_graphics->flowText(noteFont, -2 + g_lab->_graphics->SVGACord(1), 0, 0, false, false, true, true, g_lab->_graphics->VGAScaleX(25) + g_lab->_graphics->SVGACord(15), g_lab->_graphics->VGAScaleY(50), g_lab->_graphics->VGAScaleX(295) - g_lab->_graphics->SVGACord(15), g_lab->_graphics->VGAScaleY(148), ntext);
 	g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
 
 	closeFont(noteFont);
@@ -464,28 +464,28 @@ void doWestPaper() {
 
 	paperFont = g_lab->_resource->getFont("P:News22.fon");
 	ntext = g_lab->_resource->getText("Lab:Rooms/Date");
-	flowText(paperFont, 0, 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(77) + SVGACord(2), VGAScaleX(262), VGAScaleY(91), ntext);
+	g_lab->_graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, g_lab->_graphics->VGAScaleX(57), g_lab->_graphics->VGAScaleY(77) + g_lab->_graphics->SVGACord(2), g_lab->_graphics->VGAScaleX(262), g_lab->_graphics->VGAScaleY(91), ntext);
 	closeFont(paperFont);
 	delete[] ntext;
 
 	paperFont = g_lab->_resource->getFont("P:News32.fon");
 	ntext = g_lab->_resource->getText("Lab:Rooms/Headline");
 	FileLen = strlen(ntext) - 1;
-	CharsPrinted = flowText(paperFont, -8, 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(86) - SVGACord(2), VGAScaleX(262), VGAScaleY(118), ntext);
+	CharsPrinted = g_lab->_graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, g_lab->_graphics->VGAScaleX(57), g_lab->_graphics->VGAScaleY(86) - g_lab->_graphics->SVGACord(2), g_lab->_graphics->VGAScaleX(262), g_lab->_graphics->VGAScaleY(118), ntext);
 	if (CharsPrinted < FileLen) {
-		y = 130 - SVGACord(5);
-		flowText(paperFont, -8 - SVGACord(1), 0, 0, false, true, false, true, VGAScaleX(57), VGAScaleY(86) - SVGACord(2), VGAScaleX(262), VGAScaleY(132), ntext);
+		y = 130 - g_lab->_graphics->SVGACord(5);
+		g_lab->_graphics->flowText(paperFont, -8 - g_lab->_graphics->SVGACord(1), 0, 0, false, true, false, true, g_lab->_graphics->VGAScaleX(57), g_lab->_graphics->VGAScaleY(86) - g_lab->_graphics->SVGACord(2), g_lab->_graphics->VGAScaleX(262), g_lab->_graphics->VGAScaleY(132), ntext);
 	} else
-		y = 115 - SVGACord(5);
+		y = 115 - g_lab->_graphics->SVGACord(5);
 	closeFont(paperFont);
 	delete[] ntext;
 
 	paperFont = g_lab->_resource->getFont("P:Note.fon");
 	ntext = g_lab->_resource->getText("Lab:Rooms/Col1");
-	CharsPrinted = flowText(paperFont, -4, 0, 0, false, false, false, true, VGAScaleX(45), VGAScaleY(y), VGAScaleX(158), VGAScaleY(148), ntext);
+	CharsPrinted = g_lab->_graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, g_lab->_graphics->VGAScaleX(45), g_lab->_graphics->VGAScaleY(y), g_lab->_graphics->VGAScaleX(158), g_lab->_graphics->VGAScaleY(148), ntext);
 	delete[] ntext;
 	ntext = g_lab->_resource->getText("Lab:Rooms/Col2");
-	CharsPrinted = flowText(paperFont, -4, 0, 0, false, false, false, true, VGAScaleX(162), VGAScaleY(y), VGAScaleX(275), VGAScaleY(148), ntext);
+	CharsPrinted = g_lab->_graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, g_lab->_graphics->VGAScaleX(162), g_lab->_graphics->VGAScaleY(y), g_lab->_graphics->VGAScaleX(275), g_lab->_graphics->VGAScaleY(148), ntext);
 	delete[] ntext;
 	closeFont(paperFont);
 
@@ -550,12 +550,12 @@ static bool loadJournalData() {
 	uint16 counter = 0;
 
 	while (TopGadget) {
-		TopGadget->x = VGAScaleX(JGadX[counter]);
+		TopGadget->x = g_lab->_graphics->VGAScaleX(JGadX[counter]);
 
 		if (counter == 1)
-			TopGadget->y = VGAScaleY(JGadY[counter]) + SVGACord(1);
+			TopGadget->y = g_lab->_graphics->VGAScaleY(JGadY[counter]) + g_lab->_graphics->SVGACord(1);
 		else
-			TopGadget->y = VGAScaleY(JGadY[counter]) - SVGACord(1);
+			TopGadget->y = g_lab->_graphics->VGAScaleY(JGadY[counter]) - g_lab->_graphics->SVGACord(1);
 
 		TopGadget->GadgetID = counter;
 		TopGadget = TopGadget->NextGadget;
@@ -576,7 +576,7 @@ static void drawJournalText() {
 	while (DrawingToPage < JPage) {
 		g_lab->_music->updateMusic();
 		CurText = (char *)(journaltext + CharsDrawn);
-		CharsDrawn += flowText(journalFont, -2, 2, 0, false, false, false, false, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText);
+		CharsDrawn += g_lab->_graphics->flowText(journalFont, -2, 2, 0, false, false, false, false, g_lab->_graphics->VGAScaleX(52), g_lab->_graphics->VGAScaleY(32), g_lab->_graphics->VGAScaleX(152), g_lab->_graphics->VGAScaleY(148), CurText);
 
 		lastpage = (*CurText == 0);
 
@@ -588,16 +588,16 @@ static void drawJournalText() {
 
 	if (JPage <= 1) {
 		CurText = journaltexttitle;
-		flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, true, true, true, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText);
+		g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, true, true, true, g_lab->_graphics->VGAScaleX(52), g_lab->_graphics->VGAScaleY(32), g_lab->_graphics->VGAScaleX(152), g_lab->_graphics->VGAScaleY(148), CurText);
 	} else {
 		CurText = (char *)(journaltext + CharsDrawn);
-		CharsDrawn += flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, VGAScaleX(52), VGAScaleY(32), VGAScaleX(152), VGAScaleY(148), CurText);
+		CharsDrawn += g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_graphics->VGAScaleX(52), g_lab->_graphics->VGAScaleY(32), g_lab->_graphics->VGAScaleX(152), g_lab->_graphics->VGAScaleY(148), CurText);
 	}
 
 	g_lab->_music->updateMusic();
 	CurText = (char *)(journaltext + CharsDrawn);
 	lastpage = (*CurText == 0);
-	flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, VGAScaleX(171), VGAScaleY(32), VGAScaleX(271), VGAScaleY(148), CurText);
+	g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_graphics->VGAScaleX(171), g_lab->_graphics->VGAScaleY(32), g_lab->_graphics->VGAScaleX(271), g_lab->_graphics->VGAScaleY(148), CurText);
 
 	CurText = (char *)(journaltext + CharsDrawn);
 	lastpage = lastpage || (*CurText == 0);
@@ -660,7 +660,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 		fade(true, 0);
 
 	g_lab->_anim->_noPalChange = true;
-	JBackImage._imageData = readPictToMem("P:Journal.pic", _screenWidth, _screenHeight);
+	JBackImage._imageData = _graphics->readPictToMem("P:Journal.pic", _screenWidth, _screenHeight);
 	GotBackImage = true;
 
 	eatMessages();
@@ -716,7 +716,7 @@ void LabEngine::processJournal() {
 /*****************************************************************************/
 void LabEngine::doJournal() {
 	resetBuffer();
-	blackAllScreen();
+	_graphics->blackAllScreen();
 
 	lastpage    = false;
 	GotBackImage = false;
@@ -745,9 +745,9 @@ void LabEngine::doJournal() {
 
 	ScreenImage._imageData = getCurrentDrawingBuffer();
 
-	setAPen(0);
-	rectFill(0, 0, _screenWidth - 1, _screenHeight - 1);
-	blackScreen();
+	_graphics->setAPen(0);
+	_graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1);
+	_graphics->blackScreen();
 
 	freeAllStolenMem();
 }
@@ -783,11 +783,11 @@ bool LabEngine::saveRestoreGame() {
 		if (slot >= 0) {
 			isOK = loadGame(&Direction, &(_inventory[QUARTERNUM].Many), slot);
 			if (isOK)
-				g_lab->_music->resetMusic();
+				_music->resetMusic();
 		}
 	}
 
-	g_lab->screenUpdate();
+	_graphics->screenUpdate();
 
 	return isOK;
 }
@@ -820,31 +820,31 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
 		text += 2;
 
 		fheight = textHeight(monitorFont);
-		x1 = MonButton->_width + VGAScaleX(3);
-		MonGadHeight = MonButton->_height + VGAScaleY(3);
+		x1 = MonButton->_width + _graphics->VGAScaleX(3);
+		MonGadHeight = MonButton->_height + _graphics->VGAScaleY(3);
 
 		if (MonGadHeight > fheight)
 			yspacing = MonGadHeight - fheight;
 		else
 			MonGadHeight = fheight;
 
-		setAPen(0);
-		rectFill(0, 0, _screenWidth - 1, y2);
+		_graphics->setAPen(0);
+		_graphics->rectFill(0, 0, _screenWidth - 1, y2);
 
 		for (uint16 i = 0; i < numlines; i++)
 			MonButton->drawImage(0, i * MonGadHeight);
 	} else if (isinteractive) {
-		setAPen(0);
-		rectFill(0, 0, _screenWidth - 1, y2);
+		_graphics->setAPen(0);
+		_graphics->rectFill(0, 0, _screenWidth - 1, y2);
 	} else {
-		setAPen(0);
-		rectFill(x1, y1, x2, y2);
+		_graphics->setAPen(0);
+		_graphics->rectFill(x1, y1, x2, y2);
 	}
 
 	while (DrawingToPage < monitorPage) {
 		_music->updateMusic();
 		CurText = (char *)(text + CharsDrawn);
-		CharsDrawn += flowText(monitorFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, CurText);
+		CharsDrawn += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, CurText);
 		lastpage = (*CurText == 0);
 
 		if (lastpage)
@@ -855,7 +855,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
 
 	CurText = (char *)(text + CharsDrawn);
 	lastpage = (*CurText == 0);
-	CharsDrawn = flowText(monitorFont, yspacing, 2, 0, false, false, false, true, x1, y1, x2, y2, CurText);
+	CharsDrawn = _graphics->flowText(monitorFont, yspacing, 2, 0, false, false, false, true, x1, y1, x2, y2, CurText);
 	CurText += CharsDrawn;
 	lastpage = lastpage || (*CurText == 0);
 
@@ -914,20 +914,20 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 				return;
 
 			else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) {
-				if ((MouseY >= VGAScaleY(171)) && (MouseY <= VGAScaleY(200))) {
-					if ((MouseX >= VGAScaleX(259)) && (MouseX <= VGAScaleX(289))) {
+				if ((MouseY >= g_lab->_graphics->VGAScaleY(171)) && (MouseY <= g_lab->_graphics->VGAScaleY(200))) {
+					if ((MouseX >= g_lab->_graphics->VGAScaleX(259)) && (MouseX <= g_lab->_graphics->VGAScaleX(289))) {
 						if (!lastpage) {
 							monitorPage += 1;
 							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
 						}
-					} else if ((MouseX >= VGAScaleX(0)) && (MouseX <= VGAScaleX(31))) {
+					} else if ((MouseX >= g_lab->_graphics->VGAScaleX(0)) && (MouseX <= g_lab->_graphics->VGAScaleX(31))) {
 						return;
-					} else if ((MouseX >= VGAScaleX(290)) && (MouseX <= VGAScaleX(320))) {
+					} else if ((MouseX >= g_lab->_graphics->VGAScaleX(290)) && (MouseX <= g_lab->_graphics->VGAScaleX(320))) {
 						if (monitorPage >= 1) {
 							monitorPage -= 1;
 							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
 						}
-					} else if ((MouseX >= VGAScaleX(31)) && (MouseX <= VGAScaleX(59))) {
+					} else if ((MouseX >= g_lab->_graphics->VGAScaleX(31)) && (MouseX <= g_lab->_graphics->VGAScaleX(59))) {
 						if (isinteractive) {
 							monitorPage = 0;
 
@@ -962,20 +962,19 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	char *ntext;
 
-	x1 = VGAScaleX(x1);
-	x2 = VGAScaleX(x2);
-	y1 = VGAScaleY(y1);
-	y2 = VGAScaleY(y2);
+	x1 = _graphics->VGAScaleX(x1);
+	x2 = _graphics->VGAScaleX(x2);
+	y1 = _graphics->VGAScaleY(y1);
+	y2 = _graphics->VGAScaleY(y2);
 
 	TextFileName = textfile;
 
-	blackAllScreen();
-
-	readPict("P:Mon/Monitor.1", true);
-	readPict("P:Mon/NWD1", true);
-	readPict("P:Mon/NWD2", true);
-	readPict("P:Mon/NWD3", true);
-	blackAllScreen();
+	_graphics->blackAllScreen();
+	_graphics->readPict("P:Mon/Monitor.1", true);
+	_graphics->readPict("P:Mon/NWD1", true);
+	_graphics->readPict("P:Mon/NWD2", true);
+	_graphics->readPict("P:Mon/NWD3", true);
+	_graphics->blackAllScreen();
 
 	resetBuffer();
 	monitorPage = 0;
@@ -997,9 +996,9 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 	closeFont(monitorFont);
 	freeAllStolenMem();
 
-	setAPen(0);
-	rectFill(0, 0, _screenWidth - 1, _screenHeight - 1);
-	blackAllScreen();
+	_graphics->setAPen(0);
+	_graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1);
+	_graphics->blackAllScreen();
 }
 
 } // End of namespace Lab
diff --git a/engines/lab/text.cpp b/engines/lab/text.cpp
index 63ec12b..1c1cacd 100644
--- a/engines/lab/text.cpp
+++ b/engines/lab/text.cpp
@@ -82,9 +82,9 @@ void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint
 
 	for (uint16 i = 0; i < numchars; i++) {
 		RealOffset = (g_lab->_screenWidth * y) + x;
-		curpage    = RealOffset / g_lab->_screenBytesPerPage;
-		SegmentOffset = RealOffset - (curpage * g_lab->_screenBytesPerPage);
-		LeftInSegment = g_lab->_screenBytesPerPage - SegmentOffset;
+		curpage    = RealOffset / g_lab->_graphics->_screenBytesPerPage;
+		SegmentOffset = RealOffset - (curpage * g_lab->_graphics->_screenBytesPerPage);
+		LeftInSegment = g_lab->_graphics->_screenBytesPerPage - SegmentOffset;
 		VGACur = VGATop + SegmentOffset;
 
 		if (tf->Widths[(uint)*text]) {
@@ -117,10 +117,10 @@ void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint
 								curpage++;
 								VGATemp = (byte *)(VGATop - templeft);
 								/* Set up VGATempLine for next line */
-								VGATempLine -= g_lab->_screenBytesPerPage;
+								VGATempLine -= g_lab->_graphics->_screenBytesPerPage;
 								/* Set up LeftInSegment for next line */
-								LeftInSegment += g_lab->_screenBytesPerPage + templeft;
-								templeft += g_lab->_screenBytesPerPage;
+								LeftInSegment += g_lab->_graphics->_screenBytesPerPage + templeft;
+								templeft += g_lab->_graphics->_screenBytesPerPage;
 							}
 
 							if (mask & data)
@@ -142,8 +142,8 @@ void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint
 
 				if (LeftInSegment <= 0) {
 					curpage++;
-					VGATempLine -= g_lab->_screenBytesPerPage;
-					LeftInSegment += g_lab->_screenBytesPerPage;
+					VGATempLine -= g_lab->_graphics->_screenBytesPerPage;
+					LeftInSegment += g_lab->_graphics->_screenBytesPerPage;
 				}
 			}
 		}
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 7279140..8ee0d34 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -37,24 +37,6 @@
 namespace Lab {
 
 /*****************************************************************************/
-/* Sets up either a low-res or a high-res 256 color screen.                  */
-/*****************************************************************************/
-bool LabEngine::createScreen(bool hiRes) {
-	if (hiRes) {
-		_screenWidth  = 640;
-		_screenHeight = 480;
-	} else {
-		_screenWidth  = 320;
-		_screenHeight = 200;
-	}
-	_screenBytesPerPage = _screenWidth * _screenHeight;
-
-	_displayBuffer = new byte[_screenBytesPerPage];	// FIXME: Memory leak!
-
-	return true;
-}
-
-/*****************************************************************************/
 /* Sets the current page on the VGA card.                                    */
 /*****************************************************************************/
 void LabEngine::changeVolume(int delta) {
@@ -104,13 +86,6 @@ void LabEngine::setPalette(void *cmap, uint16 numcolors) {
 		writeColorRegs((byte *)cmap, 0, numcolors);
 }
 
-void LabEngine::screenUpdate() {
-	g_system->copyRectToScreen(_displayBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight);
-	g_system->updateScreen();
-
-	_event->processInput();
-}
-
 /*****************************************************************************/
 /* Returns the base address of the current VGA display.                      */
 /*****************************************************************************/
@@ -150,8 +125,8 @@ void LabEngine::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16
 	im.readScreenImage(x1, y1);
 	im.drawImage(x1 + dx, y1);
 
-	setAPen(0);
-	rectFill(x1, y1, x1 + dx - 1, y2);
+	_graphics->setAPen(0);
+	_graphics->rectFill(x1, y1, x1 + dx - 1, y2);
 }
 
 /*****************************************************************************/
@@ -181,58 +156,8 @@ void LabEngine::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16
 	im.readScreenImage(x1, y1);
 	im.drawImage(x1, y1 + dy);
 
-	setAPen(0);
-	rectFill(x1, y1, x2, y1 + dy - 1);
-}
-
-/*****************************************************************************/
-/* Sets the pen number to use on all the drawing operations.                 */
-/*****************************************************************************/
-void LabEngine::setAPen(byte pennum) {
-	_curapen = pennum;
-}
-
-/*****************************************************************************/
-/* Fills in a rectangle.                                                     */
-/*****************************************************************************/
-void LabEngine::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	int w = x2 - x1 + 1;
-	int h = y2 - y1 + 1;
-
-	if (x1 + w > _screenWidth)
-		w = _screenWidth - x1;
-
-	if (y1 + h > _screenHeight)
-		h = _screenHeight - y1;
-
-	if ((w > 0) && (h > 0)) {
-		char *d = (char *)getCurrentDrawingBuffer() + y1 * _screenWidth + x1;
-
-		while (h-- > 0) {
-			char *dd = d;
-			int ww = w;
-
-			while (ww-- > 0) {
-				*dd++ = _curapen;
-			}
-
-			d += _screenWidth;
-		}
-	}
-}
-
-/*****************************************************************************/
-/* Draws a horizontal line.                                                  */
-/*****************************************************************************/
-void LabEngine::drawVLine(uint16 x, uint16 y1, uint16 y2) {
-	rectFill(x, y1, x, y2);
-}
-
-/*****************************************************************************/
-/* Draws a vertical line.                                                    */
-/*****************************************************************************/
-void LabEngine::drawHLine(uint16 x1, uint16 y, uint16 x2) {
-	rectFill(x1, y, x2, y);
+	_graphics->setAPen(0);
+	_graphics->rectFill(x1, y1, x2, y1 + dy - 1);
 }
 
 /*****************************************************************************/


Commit: f7321fa278efd93b0ed97fdaa0e902cd4105bb57
    https://github.com/scummvm/scummvm/commit/f7321fa278efd93b0ed97fdaa0e902cd4105bb57
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:50+01:00

Commit Message:
LAB: Make more functions member of LabEngine class

Changed paths:
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/graphics.h
    engines/lab/interface.h
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/labfun.h
    engines/lab/savegame.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 293c945..f3cda0e 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -121,15 +121,15 @@ void LabEngine::drawRoomMessage(uint16 curInv, CloseDataPtr closePtr) {
 }
 
 void LabEngine::freeScreens() {
-	for (uint16 i = 0; i < 20; i++)
+	for (uint16 i = 0; i < 20; i++) {
 		delete _moveImages[i];
+		_moveImages[i] = nullptr;
+	}
 
-	if (getPlatform() == Common::kPlatformWindows) {
-		for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++)
-			delete _invImages[imgIdx];
-	} else {
-		for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++)
-			delete _invImages[imgIdx];
+	for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++) {
+		delete _invImages[imgIdx];
+		delete Images[imgIdx];
+		_invImages[imgIdx] = Images[imgIdx] = nullptr;
 	}
 }
 
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 80888d2..be71769 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -99,26 +99,6 @@ uint16 DisplayMan::SVGACord(uint16 cord) {
 		return 0;
 }
 
-/*****************************************************************************/
-/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
-/*****************************************************************************/
-int VGAUnScaleX(int x) {
-	if (g_lab->_isHiRes)
-		return (x / 2);
-	else
-		return x;
-}
-
-/*****************************************************************************/
-/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
-/*****************************************************************************/
-int VGAUnScaleY(int y) {
-	if (g_lab->_isHiRes)
-		return ((y * 5) / 12);
-	else
-		return y;
-}
-
 /*---------------------------------------------------------------------------*/
 /*------ From readPict.c.  Reads in pictures and animations from disk. ------*/
 /*---------------------------------------------------------------------------*/
diff --git a/engines/lab/graphics.h b/engines/lab/graphics.h
index de2053a..aac7e58 100644
--- a/engines/lab/graphics.h
+++ b/engines/lab/graphics.h
@@ -53,8 +53,6 @@ public:
 	int16 VGAScaleX(int16 x);
 	int16 VGAScaleY(int16 y);
 	uint16 SVGACord(uint16 cord);
-	int VGAUnScaleX(int x);
-	int VGAUnScaleY(int y);
 	bool readPict(const char *filename, bool playOnce);
 	byte *readPictToMem(const char *filename, uint16 x, uint16 y);
 	void doScrollBlack();
diff --git a/engines/lab/interface.h b/engines/lab/interface.h
index de770f0..42cfb2f 100644
--- a/engines/lab/interface.h
+++ b/engines/lab/interface.h
@@ -29,6 +29,7 @@
  */
 
 #include "common/keyboard.h"
+#include "lab/image.h"
 
 #ifndef LAB_INTEFACE_H
 #define LAB_INTEFACE_H
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index efa6752..33c5078 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -45,12 +45,28 @@
 #include "lab/labfun.h"
 #include "lab/resource.h"
 #include "lab/anim.h"
-
+#include "lab/graphics.h"
 
 namespace Lab {
 
 LabEngine *g_lab;
 
+const uint16 INIT_TILE[4][4] = {
+	{ 1, 5, 9, 13 },
+	{ 2, 6, 10, 14 },
+	{ 3, 7, 11, 15 },
+	{ 4, 8, 12, 0 }
+};
+
+const uint16 SOLUTION[4][4] = {
+	{ 7, 1, 8, 3 },
+	{ 2, 11, 15, 4 },
+	{ 9, 5, 14, 6 },
+	{ 10, 13, 12, 0 }
+};
+
+const int COMBINATION_X[6] = { 45, 83, 129, 166, 211, 248 };
+
 LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
  : Engine(syst), _gameDescription(gameDesc), _extraGameFeatures(0) {
 	g_lab = this;
@@ -92,8 +108,10 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	for (int i = 0; i < 20; i++)
 		_moveImages[i] = nullptr;
 
-	for (int i = 0; i < 10; i++)
+	for (int i = 0; i < 10; i++) {
 		_invImages[i] = nullptr;
+		Images[i] = nullptr;
+	}
 
 	_moveGadgetList = nullptr;
 	_invGadgetList = nullptr;
@@ -109,6 +127,17 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 
 	_inventory = 0;
 
+	for (int i = 0; i < 16; i++)
+		Tiles[i] = nullptr;
+
+	for (int i= 0; i < 4; i++) {
+		for (int j = 0; j < 4; j++)
+			CurTile[i][j] = INIT_TILE[i][j];
+	}
+
+	for (int i = 0; i < 6; i++)
+		combination[i] = 0;
+
 	//const Common::FSNode gameDataDir(ConfMan.get("path"));
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game/pict");
@@ -125,6 +154,9 @@ LabEngine::~LabEngine() {
 	delete _music;
 	delete _anim;
 	delete _graphics;
+
+	for (int i = 0; i < 16; i++)
+		delete Tiles[i];
 }
 
 Common::Error LabEngine::run() {
@@ -182,8 +214,333 @@ Common::String LabEngine::generateSaveFileName(uint slot) {
 	return Common::String::format("%s.%03u", _targetName.c_str(), slot);
 }
 
-/*void LabEngine::showMainMenu() {
+/*****************************************************************************/
+/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
+/*****************************************************************************/
+int LabEngine::VGAUnScaleX(int x) {
+	if (_isHiRes)
+		return (x / 2);
+	else
+		return x;
+}
+
+/*****************************************************************************/
+/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
+/*****************************************************************************/
+int LabEngine::VGAUnScaleY(int y) {
+	if (_isHiRes)
+		return ((y * 5) / 12);
+	else
+		return y;
+}
+
+/*****************************************************************************/
+/* Processes mouse clicks and changes the combination.                       */
+/*****************************************************************************/
+void LabEngine::mouseTile(Common::Point pos) {
+	int x = VGAUnScaleX(pos.x);
+	int y = VGAUnScaleY(pos.y);
+
+	if ((x < 101) || (y < 26))
+		return;
+
+	x = (x - 101) / 30;
+	y = (y -  26) / 25;
+
+	if ((x < 4) && (y < 4))
+		changeTile(x, y);
+}
+
+/*****************************************************************************/
+/* Changes the combination number of one of the slots                        */
+/*****************************************************************************/
+void LabEngine::changeTile(uint16 col, uint16 row) {
+	int16 scrolltype = -1;
+
+	if (row > 0) {
+		if (CurTile[col] [row - 1] == 0) {
+			CurTile[col] [row - 1] = CurTile[col] [row];
+			CurTile[col] [row] = 0;
+			scrolltype = DOWNSCROLL;
+		}
+	}
+
+	if (col > 0) {
+		if (CurTile[col - 1] [row] == 0) {
+			CurTile[col - 1] [row] = CurTile[col] [row];
+			CurTile[col] [row] = 0;
+			scrolltype = RIGHTSCROLL;
+		}
+	}
+
+	if (row < 3) {
+		if (CurTile[col] [row + 1] == 0) {
+			CurTile[col] [row + 1] = CurTile[col] [row];
+			CurTile[col] [row] = 0;
+			scrolltype = UPSCROLL;
+		}
+	}
+
+	if (col < 3) {
+		if (CurTile[col + 1] [row] == 0) {
+			CurTile[col + 1] [row] = CurTile[col] [row];
+			CurTile[col] [row] = 0;
+			scrolltype = LEFTSCROLL;
+		}
+	}
+
+	if (scrolltype != -1) {
+		doTileScroll(col, row, scrolltype);
+
+		if (getFeatures() & GF_WINDOWS_TRIAL) {
+			GUI::MessageDialog trialMessage("This puzzle is not available in the trial version of the game");
+			trialMessage.runModal();
+			return;
+		}
+
+		bool check = true;
+		row   = 0;
+		col   = 0;
+
+		while (row < 4) {
+			while (col < 4) {
+				check = check && (CurTile[row] [col] == SOLUTION[row] [col]);
+				col++;
+			}
+
+			row++;
+			col = 0;
+		}
+
+		if (check) {
+			_conditions->inclElement(BRICKOPEN);  /* unlocked combination */
+			_anim->_doBlack = true;
+			check = _graphics->readPict("p:Up/BDOpen", true);
+		}
+	}
+}
+
+/*****************************************************************************/
+/* Processes mouse clicks and changes the combination.                       */
+/*****************************************************************************/
+void LabEngine::mouseCombination(Common::Point pos) {
+	uint16 number;
+
+	int x = VGAUnScaleX(pos.x);
+	int y = VGAUnScaleY(pos.y);
+
+	if ((y >= 63) && (y <= 99)) {
+		if ((x >= 44) && (x < 83))
+			number = 0;
+		else if (x < 127)
+			number = 1;
+		else if (x < 165)
+			number = 2;
+		else if (x < 210)
+			number = 3;
+		else if (x < 245)
+			number = 4;
+		else if (x < 286)
+			number = 5;
+		else
+			return;
+
+		changeCombination(number);
+	}
+}
+
+/*****************************************************************************/
+/* Draws the images of the combination lock to the display bitmap.           */
+/*****************************************************************************/
+void LabEngine::doTile(bool showsolution) {
+	uint16 row = 0, col = 0, rowm, colm, num;
+	int16 rows, cols;
+
+	if (showsolution) {
+		rowm = _graphics->VGAScaleY(23);
+		colm = _graphics->VGAScaleX(27);
 
-}*/
+		rows = _graphics->VGAScaleY(31);
+		cols = _graphics->VGAScaleX(105);
+	} else {
+		_graphics->setAPen(0);
+		_graphics->rectFill(_graphics->VGAScaleX(97), _graphics->VGAScaleY(22), _graphics->VGAScaleX(220), _graphics->VGAScaleY(126));
+
+		rowm = _graphics->VGAScaleY(25);
+		colm = _graphics->VGAScaleX(30);
+
+		rows = _graphics->VGAScaleY(25);
+		cols = _graphics->VGAScaleX(100);
+	}
+
+	while (row < 4) {
+		while (col < 4) {
+			if (showsolution)
+				num = SOLUTION[col] [row];
+			else
+				num = CurTile[col] [row];
+
+			if (showsolution || num)
+				Tiles[num]->drawImage(cols + (col * colm), rows + (row * rowm));
+
+			col++;
+		}
+
+		row++;
+		col = 0;
+	}
+}
+
+/*****************************************************************************/
+/* Reads in a backdrop picture.                                              */
+/*****************************************************************************/
+void LabEngine::showTile(const char *filename, bool showsolution) {
+	uint16 start = showsolution ? 0 : 1;
+
+	resetBuffer();
+	g_lab->_anim->_doBlack = true;
+	g_lab->_anim->_noPalChange = true;
+	g_lab->_graphics->readPict(filename, true);
+	g_lab->_anim->_noPalChange = false;
+	g_lab->_graphics->blackScreen();
+
+	Common::File *tileFile = tileFile = g_lab->_resource->openDataFile(showsolution ? "P:TileSolution" : "P:Tile");
+
+	for (uint16 curBit = start; curBit < 16; curBit++)
+		Tiles[curBit] = new Image(tileFile);
+
+	delete tileFile;
+
+	allocFile((void **)&g_lab->_tempScrollData, Tiles[1]->_width * Tiles[1]->_height * 2L, "tempdata");
+
+	g_lab->doTile(showsolution);
+	g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
+}
+
+/*****************************************************************************/
+/* Does the scrolling for the tiles on the tile puzzle.                      */
+/*****************************************************************************/
+void LabEngine::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
+	int16 dX = 0, dY = 0, dx = 0, dy = 0, sx = 0, sy = 0;
+	uint16 last = 0, x1, y1;
+
+	if (scrolltype == LEFTSCROLL) {
+		dX =  g_lab->_graphics->VGAScaleX(5);
+		sx =  g_lab->_graphics->VGAScaleX(5);
+		last = 6;
+	} else if (scrolltype == RIGHTSCROLL) {
+		dX = g_lab->_graphics->VGAScaleX(-5);
+		dx = g_lab->_graphics->VGAScaleX(-5);
+		sx =  g_lab->_graphics->VGAScaleX(5);
+		last = 6;
+	} else if (scrolltype == UPSCROLL) {
+		dY =  g_lab->_graphics->VGAScaleY(5);
+		sy =  g_lab->_graphics->VGAScaleY(5);
+		last = 5;
+	} else if (scrolltype == DOWNSCROLL) {
+		dY = g_lab->_graphics->VGAScaleY(-5);
+		dy = g_lab->_graphics->VGAScaleY(-5);
+		sy =  g_lab->_graphics->VGAScaleY(5);
+		last = 5;
+	}
+
+	sx += g_lab->_graphics->SVGACord(2);
+
+	x1 = g_lab->_graphics->VGAScaleX(100) + (col * g_lab->_graphics->VGAScaleX(30)) + dx;
+	y1 = g_lab->_graphics->VGAScaleY(25) + (row * g_lab->_graphics->VGAScaleY(25)) + dy;
+
+	for (uint16 i = 0; i < last; i++) {
+		g_lab->waitTOF();
+		scrollRaster(dX, dY, x1, y1, x1 + g_lab->_graphics->VGAScaleX(28) + sx, y1 + g_lab->_graphics->VGAScaleY(23) + sy);
+		x1 += dX;
+		y1 += dY;
+	}
+}
+
+/*****************************************************************************/
+/* Changes the combination number of one of the slots                        */
+/*****************************************************************************/
+void LabEngine::changeCombination(uint16 number) {
+	static const int solution[6] = { 0, 4, 0, 8, 7, 2 };
+
+	Image display;
+	uint16 combnum;
+	bool unlocked = true;
+
+	if (combination[number] < 9)
+		(combination[number])++;
+	else
+		combination[number] = 0;
+
+	combnum = combination[number];
+
+	display._imageData = g_lab->getCurrentDrawingBuffer();
+	display._width     = g_lab->_screenWidth;
+	display._height    = g_lab->_screenHeight;
+
+	for (uint16 i = 1; i <= (Images[combnum]->_height / 2); i++) {
+		if (g_lab->_isHiRes) {
+			if (i & 1)
+				g_lab->waitTOF();
+		} else
+			g_lab->waitTOF();
+
+		display._imageData = g_lab->getCurrentDrawingBuffer();
+
+		g_lab->scrollDisplayY(2, g_lab->_graphics->VGAScaleX(COMBINATION_X[number]), g_lab->_graphics->VGAScaleY(65), g_lab->_graphics->VGAScaleX(COMBINATION_X[number]) + (Images[combnum])->_width - 1, g_lab->_graphics->VGAScaleY(65) + (Images[combnum])->_height);
+
+		Images[combnum]->bltBitMap(0, (Images[combnum])->_height - (2 * i), &(display), g_lab->_graphics->VGAScaleX(COMBINATION_X[number]), g_lab->_graphics->VGAScaleY(65), (Images[combnum])->_width, 2);
+	}
+
+	for (uint16 i = 0; i < 6; i++)
+		unlocked = (combination[i] == solution[i]) && unlocked;
+
+	if (unlocked)
+		_conditions->inclElement(COMBINATIONUNLOCKED);
+	else
+		_conditions->exclElement(COMBINATIONUNLOCKED);
+}
+
+void LabEngine::scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+	if (dx)
+		scrollDisplayX(dx, x1, y1, x2, y2);
+
+	if (dy)
+		scrollDisplayY(dy, x1, y1, x2, y2);
+}
+
+/*****************************************************************************/
+/* Draws the images of the combination lock to the display bitmap.           */
+/*****************************************************************************/
+void LabEngine::doCombination() {
+	for (uint16 i = 0; i <= 5; i++)
+		Images[combination[i]]->drawImage(_graphics->VGAScaleX(COMBINATION_X[i]), _graphics->VGAScaleY(65));
+}
+
+/*****************************************************************************/
+/* Reads in a backdrop picture.                                              */
+/*****************************************************************************/
+void LabEngine::showCombination(const char *filename) {
+	resetBuffer();
+	g_lab->_anim->_doBlack = true;
+	g_lab->_anim->_noPalChange = true;
+	g_lab->_graphics->readPict(filename, true);
+	g_lab->_anim->_noPalChange = false;
+
+	g_lab->_graphics->blackScreen();
+
+	Common::File *numFile = g_lab->_resource->openDataFile("P:Numbers");
+
+	for (uint16 CurBit = 0; CurBit < 10; CurBit++)
+		Images[CurBit] = new Image(numFile);
+
+	delete numFile;
+
+	allocFile((void **)&g_lab->_tempScrollData, Images[0]->_width * Images[0]->_height * 2L, "tempdata");
+
+	doCombination();
+
+	g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
+}
 
 } // End of namespace Lab
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 9cf28df..b109ac6 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -52,7 +52,13 @@ enum GameFeatures {
 	GF_WINDOWS_TRIAL = 1 << 1
 };
 
-#define ONESECOND 1000
+#define ONESECOND      1000
+#define BRICKOPEN      115
+#define COMBINATIONUNLOCKED  130
+#define LEFTSCROLL     1
+#define RIGHTSCROLL    2
+#define UPSCROLL       3
+#define DOWNSCROLL     4
 
 class LabEngine : public Engine {
 public:
@@ -124,12 +130,16 @@ public:
 	Gadget *_invGadgetList;
 	Image *_moveImages[20];
 	Image *_invImages[10];
+	Image *Images[10];
+	uint16 CurTile[4][4];
+	byte combination[6];
 
 private:
 	int _lastWaitTOFTicks;
 	bool _lastTooLong;
 	CloseDataPtr _cptr;
 	InventoryData *_inventory;
+	Image *Tiles[16];
 
 private:
 	bool from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Common::Point tmpPos, uint16 &curInv, IntuiMessage * curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode);
@@ -175,6 +185,18 @@ private:
 	void mayShowCrumbIndicator();
 	void mayShowCrumbIndicatorOff();
 	const char *getInvName(uint16 curInv);
+	int VGAUnScaleX(int x);
+	int VGAUnScaleY(int y);
+	void mouseTile(Common::Point pos);
+	void changeTile(uint16 col, uint16 row);
+	void mouseCombination(Common::Point pos);
+	void doTile(bool showsolution);
+	void showTile(const char *filename, bool showsolution);
+	void doTileScroll(uint16 col, uint16 row, uint16 scrolltype);
+	void changeCombination(uint16 number);
+	void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void doCombination();
+	void showCombination(const char *filename);
 
 	bool saveRestoreGame();
 
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index d81de5c..558abe1 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -54,7 +54,6 @@ class LabEngine;
 #define EAST    2
 #define WEST    3
 
-class Image;
 struct TextFont;
 struct Gadget;
 
@@ -140,8 +139,6 @@ public:
 /*----- From Machine.c ------*/
 /*---------------------------*/
 
-int VGAUnScaleX(int x);
-int VGAUnScaleY(int y);
 char *translateFileName(const char *filename);
 
 /*---------------------------*/
@@ -169,9 +166,6 @@ bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header);
 /*--------------------------*/
 
 void showCombination(const char *filename);
-void mouseCombination(Common::Point pos);
-void showTile(const char *filename, bool showsolution);
-void mouseTile(Common::Point pos);
 
 } // End of namespace Lab
 
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 7f56c8e..d97a036 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -51,8 +51,6 @@ namespace Lab {
 
 
 /* Lab: Labyrinth specific */
-extern byte combination[6];
-extern uint16 CurTile[4] [4];
 extern char *getPictName(CloseDataPtr *lcptr);
 
 void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName) {
@@ -155,12 +153,12 @@ bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc)
 
 	// Combination lock and tile stuff
 	for (i = 0; i < 6; i++)
-		file->writeByte(combination[i]);
+		file->writeByte(g_lab->combination[i]);
 
 	// Tiles
 	for (i = 0; i < 4; i++)
 		for (j = 0; j < 4; j++)
-			file->writeUint16LE(CurTile[i][j]);
+			file->writeUint16LE(g_lab->CurTile[i][j]);
 
 	// Breadcrumbs
 	for (i = 0; i < sizeof(g_lab->_breadCrumbs); i++) {
@@ -205,12 +203,12 @@ bool loadGame(uint16 *Direction, uint16 *Quarters, int slot) {
 
 	// Combination lock and tile stuff
 	for (i = 0; i < 6; i++)
-		combination[i] = file->readByte();
+		g_lab->combination[i] = file->readByte();
 
 	// Tiles
 	for (i = 0; i < 4; i++)
 		for (j = 0; j < 4; j++)
-			CurTile[i][j] = file->readUint16LE();
+			g_lab->CurTile[i][j] = file->readUint16LE();
 
 	// Breadcrumbs
 	for (i = 0; i < 128; i++) {
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 3be558b..3f26fbc 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -48,11 +48,6 @@ namespace Lab {
 static uint16 MonGadHeight = 1;
 static uint16 hipal[20];
 
-// Combination lock rules
-static Image *Images[10];
-byte combination[6] = { 0, 0, 0, 0, 0, 0 }, solution[] = { 0, 4, 0, 8, 7, 2 };
-static uint16 combx[] = { 45, 83, 129, 166, 211, 248 };
-
 static TextFont *journalFont;
 static char *journaltext, *journaltexttitle;
 static uint16 JPage = 0;
@@ -67,33 +62,13 @@ static const char *TextFileName;
 Image *MonButton, *AltMonButton, *MonQuit, *AltMonQuit, *MonBack, *AltMonBack,
 *MonDown, *AltMonDown, *MonUp, *AltMonUp;
 
-// Tile puzzle rules
-Image *Tiles[16];
-uint16 CurTile[4][4] = {
-	{ 1, 5, 9, 13 },
-	{ 2, 6, 10, 14 },
-	{ 3, 7, 11, 15 },
-	{ 4, 8, 12, 0 }
-}, TileSolution[4][4] = {
-	{ 7, 1, 8, 3 },
-	{ 2, 11, 15, 4 },
-	{ 9, 5, 14, 6 },
-	{ 10, 13, 12, 0 }
-};
-
 extern uint16 *FadePalette;
 extern BitMap *DispBitMap, *DrawBitMap;
 extern uint16 Direction;
 
-#define COMBINATIONUNLOCKED  130
-#define BRICKOPEN            115
 #define INCL(BITSET,BIT) ((BITSET) |= (BIT))
 #define SETBIT(BITSET,BITNUM)   INCL(BITSET, (1 << (BITNUM)))
 #define INBIT(BITSET,BITNUM)    ( ((1 << (BITNUM)) & (BITSET)) > 0 )
-#define LEFTSCROLL     1
-#define RIGHTSCROLL    2
-#define UPSCROLL       3
-#define DOWNSCROLL     4
 #define BRIDGE0   148
 #define BRIDGE1   104
 #define DIRTY     175
@@ -125,319 +100,6 @@ static byte *loadBackPict(const char *fileName, bool tomem) {
 }
 
 /*****************************************************************************/
-/* Draws the images of the combination lock to the display bitmap.           */
-/*****************************************************************************/
-static void doCombination() {
-	for (uint16 i = 0; i <= 5; i++)
-		Images[combination[i]]->drawImage(g_lab->_graphics->VGAScaleX(combx[i]), g_lab->_graphics->VGAScaleY(65));
-}
-
-/*****************************************************************************/
-/* Reads in a backdrop picture.                                              */
-/*****************************************************************************/
-void showCombination(const char *filename) {
-	resetBuffer();
-	g_lab->_anim->_doBlack = true;
-	g_lab->_anim->_noPalChange = true;
-	g_lab->_graphics->readPict(filename, true);
-	g_lab->_anim->_noPalChange = false;
-
-	g_lab->_graphics->blackScreen();
-
-	Common::File *numFile = g_lab->_resource->openDataFile("P:Numbers");
-
-	for (uint16 CurBit = 0; CurBit < 10; CurBit++)
-		Images[CurBit] = new Image(numFile);
-
-	delete numFile;
-
-	allocFile((void **)&g_lab->_tempScrollData, Images[0]->_width * Images[0]->_height * 2L, "tempdata");
-
-	doCombination();
-
-	g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
-}
-
-
-
-/*****************************************************************************/
-/* Changes the combination number of one of the slots                        */
-/*****************************************************************************/
-static void changeCombination(uint16 number) {
-	Image display;
-	uint16 combnum;
-	bool unlocked = true;
-
-	if (combination[number] < 9)
-		(combination[number])++;
-	else
-		combination[number] = 0;
-
-	combnum = combination[number];
-
-	display._imageData = g_lab->getCurrentDrawingBuffer();
-	display._width     = g_lab->_screenWidth;
-	display._height    = g_lab->_screenHeight;
-
-	for (uint16 i = 1; i <= (Images[combnum]->_height / 2); i++) {
-		if (g_lab->_isHiRes) {
-			if (i & 1)
-				g_lab->waitTOF();
-		} else
-			g_lab->waitTOF();
-
-		display._imageData = g_lab->getCurrentDrawingBuffer();
-
-		g_lab->scrollDisplayY(2, g_lab->_graphics->VGAScaleX(combx[number]), g_lab->_graphics->VGAScaleY(65), g_lab->_graphics->VGAScaleX(combx[number]) + (Images[combnum])->_width - 1, g_lab->_graphics->VGAScaleY(65) + (Images[combnum])->_height);
-
-		Images[combnum]->bltBitMap(0, (Images[combnum])->_height - (2 * i), &(display), g_lab->_graphics->VGAScaleX(combx[number]), g_lab->_graphics->VGAScaleY(65), (Images[combnum])->_width, 2);
-	}
-
-	for (uint16 i = 0; i < 6; i++)
-		unlocked = (combination[i] == solution[i]) && unlocked;
-
-	if (unlocked)
-		g_lab->_conditions->inclElement(COMBINATIONUNLOCKED);
-	else
-		g_lab->_conditions->exclElement(COMBINATIONUNLOCKED);
-}
-
-
-/*****************************************************************************/
-/* Processes mouse clicks and changes the combination.                       */
-/*****************************************************************************/
-void mouseCombination(Common::Point pos) {
-	uint16 number;
-
-	int x = VGAUnScaleX(pos.x);
-	int y = VGAUnScaleY(pos.y);
-
-	if ((y >= 63) && (y <= 99)) {
-		if ((x >= 44) && (x < 83))
-			number = 0;
-		else if (x < 127)
-			number = 1;
-		else if (x < 165)
-			number = 2;
-		else if (x < 210)
-			number = 3;
-		else if (x < 245)
-			number = 4;
-		else if (x < 286)
-			number = 5;
-		else
-			return;
-
-		changeCombination(number);
-	}
-}
-
-/*****************************************************************************/
-/* Draws the images of the combination lock to the display bitmap.           */
-/*****************************************************************************/
-static void doTile(bool showsolution) {
-	uint16 row = 0, col = 0, rowm, colm, num;
-	int16 rows, cols;
-
-	if (showsolution) {
-		rowm = g_lab->_graphics->VGAScaleY(23);
-		colm = g_lab->_graphics->VGAScaleX(27);
-
-		rows = g_lab->_graphics->VGAScaleY(31);
-		cols = g_lab->_graphics->VGAScaleX(105);
-	} else {
-		g_lab->_graphics->setAPen(0);
-		g_lab->_graphics->rectFill(g_lab->_graphics->VGAScaleX(97), g_lab->_graphics->VGAScaleY(22), g_lab->_graphics->VGAScaleX(220), g_lab->_graphics->VGAScaleY(126));
-
-		rowm = g_lab->_graphics->VGAScaleY(25);
-		colm = g_lab->_graphics->VGAScaleX(30);
-
-		rows = g_lab->_graphics->VGAScaleY(25);
-		cols = g_lab->_graphics->VGAScaleX(100);
-	}
-
-	while (row < 4) {
-		while (col < 4) {
-			if (showsolution)
-				num = TileSolution[col] [row];
-			else
-				num = CurTile[col] [row];
-
-			if (showsolution || num)
-				Tiles[num]->drawImage(cols + (col * colm), rows + (row * rowm));
-
-			col++;
-		}
-
-		row++;
-		col = 0;
-	}
-}
-
-/*****************************************************************************/
-/* Reads in a backdrop picture.                                              */
-/*****************************************************************************/
-void showTile(const char *filename, bool showsolution) {
-	uint16 start = showsolution ? 0 : 1;
-
-	resetBuffer();
-	g_lab->_anim->_doBlack = true;
-	g_lab->_anim->_noPalChange = true;
-	g_lab->_graphics->readPict(filename, true);
-	g_lab->_anim->_noPalChange = false;
-	g_lab->_graphics->blackScreen();
-
-	Common::File *tileFile = tileFile = g_lab->_resource->openDataFile(showsolution ? "P:TileSolution" : "P:Tile");
-
-	for (uint16 curBit = start; curBit < 16; curBit++)
-		Tiles[curBit] = new Image(tileFile);
-
-	delete tileFile;
-
-	allocFile((void **)&g_lab->_tempScrollData, Tiles[1]->_width * Tiles[1]->_height * 2L, "tempdata");
-
-	doTile(showsolution);
-
-	g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
-}
-
-static void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	if (dx)
-		g_lab->scrollDisplayX(dx, x1, y1, x2, y2);
-
-	if (dy)
-		g_lab->scrollDisplayY(dy, x1, y1, x2, y2);
-}
-
-/*****************************************************************************/
-/* Does the scrolling for the tiles on the tile puzzle.                      */
-/*****************************************************************************/
-static void doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
-	int16 dX = 0, dY = 0, dx = 0, dy = 0, sx = 0, sy = 0;
-	uint16 last = 0, x1, y1;
-
-	if (scrolltype == LEFTSCROLL) {
-		dX =  g_lab->_graphics->VGAScaleX(5);
-		sx =  g_lab->_graphics->VGAScaleX(5);
-		last = 6;
-	} else if (scrolltype == RIGHTSCROLL) {
-		dX = g_lab->_graphics->VGAScaleX(-5);
-		dx = g_lab->_graphics->VGAScaleX(-5);
-		sx =  g_lab->_graphics->VGAScaleX(5);
-		last = 6;
-	} else if (scrolltype == UPSCROLL) {
-		dY =  g_lab->_graphics->VGAScaleY(5);
-		sy =  g_lab->_graphics->VGAScaleY(5);
-		last = 5;
-	} else if (scrolltype == DOWNSCROLL) {
-		dY = g_lab->_graphics->VGAScaleY(-5);
-		dy = g_lab->_graphics->VGAScaleY(-5);
-		sy =  g_lab->_graphics->VGAScaleY(5);
-		last = 5;
-	}
-
-	sx += g_lab->_graphics->SVGACord(2);
-
-	x1 = g_lab->_graphics->VGAScaleX(100) + (col * g_lab->_graphics->VGAScaleX(30)) + dx;
-	y1 = g_lab->_graphics->VGAScaleY(25) + (row * g_lab->_graphics->VGAScaleY(25)) + dy;
-
-	for (uint16 i = 0; i < last; i++) {
-		g_lab->waitTOF();
-		scrollRaster(dX, dY, x1, y1, x1 + g_lab->_graphics->VGAScaleX(28) + sx, y1 + g_lab->_graphics->VGAScaleY(23) + sy);
-		x1 += dX;
-		y1 += dY;
-	}
-}
-
-/*****************************************************************************/
-/* Changes the combination number of one of the slots                        */
-/*****************************************************************************/
-static void changeTile(uint16 col, uint16 row) {
-	int16 scrolltype = -1;
-
-	if (row > 0) {
-		if (CurTile[col] [row - 1] == 0) {
-			CurTile[col] [row - 1] = CurTile[col] [row];
-			CurTile[col] [row] = 0;
-			scrolltype = DOWNSCROLL;
-		}
-	}
-
-	if (col > 0) {
-		if (CurTile[col - 1] [row] == 0) {
-			CurTile[col - 1] [row] = CurTile[col] [row];
-			CurTile[col] [row] = 0;
-			scrolltype = RIGHTSCROLL;
-		}
-	}
-
-	if (row < 3) {
-		if (CurTile[col] [row + 1] == 0) {
-			CurTile[col] [row + 1] = CurTile[col] [row];
-			CurTile[col] [row] = 0;
-			scrolltype = UPSCROLL;
-		}
-	}
-
-	if (col < 3) {
-		if (CurTile[col + 1] [row] == 0) {
-			CurTile[col + 1] [row] = CurTile[col] [row];
-			CurTile[col] [row] = 0;
-			scrolltype = LEFTSCROLL;
-		}
-	}
-
-	if (scrolltype != -1) {
-		doTileScroll(col, row, scrolltype);
-
-		if (g_lab->getFeatures() & GF_WINDOWS_TRIAL) {
-			GUI::MessageDialog trialMessage("This puzzle is not available in the trial version of the game");
-			trialMessage.runModal();
-			return;
-		}
-
-		bool check = true;
-		row   = 0;
-		col   = 0;
-
-		while (row < 4) {
-			while (col < 4) {
-				check = check && (CurTile[row] [col] == TileSolution[row] [col]);
-				col++;
-			}
-
-			row++;
-			col = 0;
-		}
-
-		if (check) {
-			g_lab->_conditions->inclElement(BRICKOPEN);  /* unlocked combination */
-			g_lab->_anim->_doBlack = true;
-			check = g_lab->_graphics->readPict("p:Up/BDOpen", true);
-		}
-	}
-}
-
-
-/*****************************************************************************/
-/* Processes mouse clicks and changes the combination.                       */
-/*****************************************************************************/
-void mouseTile(Common::Point pos) {
-	int x = VGAUnScaleX(pos.x);
-	int y = VGAUnScaleY(pos.y);
-
-	if ((x < 101) || (y < 26))
-		return;
-
-	x = (x - 101) / 30;
-	y = (y -  26) / 25;
-
-	if ((x < 4) && (y < 4))
-		changeTile(x, y);
-}
-
-
-/*****************************************************************************/
 /* Does the things to properly set up the detective notes.                   */
 /*****************************************************************************/
 void doNotes() {


Commit: d376fd8dd0b8676dbf1d27d400d78e5a292f05db
    https://github.com/scummvm/scummvm/commit/d376fd8dd0b8676dbf1d27d400d78e5a292f05db
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:50+01:00

Commit Message:
LAB: Get rid of g_lab in several LabEngine and DisplayMan functions

Changed paths:
    engines/lab/graphics.cpp
    engines/lab/lab.cpp



diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index be71769..73ec5cc 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -66,7 +66,7 @@ uint16 DisplayMan::scaleX(uint16 x) {
 /* file, co-ordinates are set up on a 368x336 display.                       */
 /*****************************************************************************/
 uint16 DisplayMan::scaleY(uint16 y) {
-	if (g_lab->_isHiRes)
+	if (_vm->_isHiRes)
 		return (y + (y / 14));
 	else
 		return ((y * 10) / 24);
@@ -76,7 +76,7 @@ uint16 DisplayMan::scaleY(uint16 y) {
 /* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
 /*****************************************************************************/
 int16 DisplayMan::VGAScaleX(int16 x) {
-	if (g_lab->_isHiRes)
+	if (_vm->_isHiRes)
 		return (x * 2);
 	else
 		return x;
@@ -86,14 +86,14 @@ int16 DisplayMan::VGAScaleX(int16 x) {
 /* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
 /*****************************************************************************/
 int16 DisplayMan::VGAScaleY(int16 y) {
-	if (g_lab->_isHiRes)
+	if (_vm->_isHiRes)
 		return ((y * 12) / 5);
 	else
 		return y;
 }
 
 uint16 DisplayMan::SVGACord(uint16 cord) {
-	if (g_lab->_isHiRes)
+	if (_vm->_isHiRes)
 		return cord;
 	else
 		return 0;
@@ -133,12 +133,12 @@ bool DisplayMan::readPict(const char *filename, bool playOnce) {
 byte *DisplayMan::readPictToMem(const char *filename, uint16 x, uint16 y) {
 	byte *mem;
 
-	g_lab->_anim->stopDiff();
+	_vm->_anim->stopDiff();
 
 	allocFile((void **)&mem, (int32)x * (int32)y, "Bitmap");
 	byte *curMem = mem;
 
-	byte **file = g_lab->_music->newOpen(filename);
+	byte **file = _vm->_music->newOpen(filename);
 
 	if (file == NULL)
 		return NULL;
@@ -152,7 +152,7 @@ byte *DisplayMan::readPictToMem(const char *filename, uint16 x, uint16 y) {
 	DispBitMap->_planes[3] = DispBitMap->_planes[2] + 0x10000;
 	DispBitMap->_planes[4] = DispBitMap->_planes[3] + 0x10000;
 
-	g_lab->_anim->readDiff(true);
+	_vm->_anim->readDiff(true);
 
 	return mem;
 }
@@ -488,16 +488,16 @@ void DisplayMan::copyPage(uint16 width, uint16 height, uint16 nheight, uint16 st
 	uint16 curPage;
 	uint32 *baseAddr;
 
-	baseAddr = (uint32 *)g_lab->getCurrentDrawingBuffer();
+	baseAddr = (uint32 *)_vm->getCurrentDrawingBuffer();
 
 	size = (int32)(height - nheight) * (int32)width;
 	mem += startline * width;
-	curPage = ((int32)nheight * (int32)width) / g_lab->_graphics->_screenBytesPerPage;
-	offSet = ((int32)nheight * (int32)width) - (curPage * g_lab->_graphics->_screenBytesPerPage);
+	curPage = ((int32)nheight * (int32)width) / _vm->_graphics->_screenBytesPerPage;
+	offSet = ((int32)nheight * (int32)width) - (curPage * _vm->_graphics->_screenBytesPerPage);
 
 	while (size) {
-		if (size > (g_lab->_graphics->_screenBytesPerPage - offSet))
-			copysize = g_lab->_graphics->_screenBytesPerPage - offSet;
+		if (size > (_vm->_graphics->_screenBytesPerPage - offSet))
+			copysize = _vm->_graphics->_screenBytesPerPage - offSet;
 		else
 			copysize = size;
 
@@ -669,7 +669,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 	else
 		_vm->_curFileName = getPictName(cPtr);
 
-	byte *BitMapMem = readPictToMem(g_lab->_curFileName, _vm->_screenWidth, lastY + 5);
+	byte *BitMapMem = readPictToMem(_vm->_curFileName, _vm->_screenWidth, lastY + 5);
 	_vm->setPalette(_vm->_anim->_diffPalette, 256);
 
 	if (BitMapMem) {
@@ -833,7 +833,7 @@ bool DisplayMan::setUpScreens() {
 	if (!createScreen(_vm->_isHiRes))
 		return false;
 
-	Common::File *controlFile = g_lab->_resource->openDataFile("P:Control");
+	Common::File *controlFile = _vm->_resource->openDataFile("P:Control");
 	for (uint16 i = 0; i < 20; i++)
 		_vm->_moveImages[i] = new Image(controlFile);
 	delete controlFile;
@@ -883,7 +883,7 @@ bool DisplayMan::setUpScreens() {
 		curGadget->NextGadget = createButton(289, y, 9, 0, _vm->_moveImages[10], _vm->_moveImages[11]);
 	}
 
-	Common::File *invFile = g_lab->_resource->openDataFile("P:Inv");
+	Common::File *invFile = _vm->_resource->openDataFile("P:Inv");
 
 	if (_vm->getPlatform() == Common::kPlatformWindows) {
 		for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++)
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 33c5078..a8baec2 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -299,8 +299,8 @@ void LabEngine::changeTile(uint16 col, uint16 row) {
 		}
 
 		bool check = true;
-		row   = 0;
-		col   = 0;
+		row = 0;
+		col = 0;
 
 		while (row < 4) {
 			while (col < 4) {
@@ -398,23 +398,23 @@ void LabEngine::showTile(const char *filename, bool showsolution) {
 	uint16 start = showsolution ? 0 : 1;
 
 	resetBuffer();
-	g_lab->_anim->_doBlack = true;
-	g_lab->_anim->_noPalChange = true;
-	g_lab->_graphics->readPict(filename, true);
-	g_lab->_anim->_noPalChange = false;
-	g_lab->_graphics->blackScreen();
+	_anim->_doBlack = true;
+	_anim->_noPalChange = true;
+	_graphics->readPict(filename, true);
+	_anim->_noPalChange = false;
+	_graphics->blackScreen();
 
-	Common::File *tileFile = tileFile = g_lab->_resource->openDataFile(showsolution ? "P:TileSolution" : "P:Tile");
+	Common::File *tileFile = tileFile = _resource->openDataFile(showsolution ? "P:TileSolution" : "P:Tile");
 
 	for (uint16 curBit = start; curBit < 16; curBit++)
 		Tiles[curBit] = new Image(tileFile);
 
 	delete tileFile;
 
-	allocFile((void **)&g_lab->_tempScrollData, Tiles[1]->_width * Tiles[1]->_height * 2L, "tempdata");
+	allocFile((void **)&_tempScrollData, Tiles[1]->_width * Tiles[1]->_height * 2L, "tempdata");
 
-	g_lab->doTile(showsolution);
-	g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
+	doTile(showsolution);
+	setPalette(_anim->_diffPalette, 256);
 }
 
 /*****************************************************************************/
@@ -425,33 +425,33 @@ void LabEngine::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 	uint16 last = 0, x1, y1;
 
 	if (scrolltype == LEFTSCROLL) {
-		dX =  g_lab->_graphics->VGAScaleX(5);
-		sx =  g_lab->_graphics->VGAScaleX(5);
+		dX = _graphics->VGAScaleX(5);
+		sx = _graphics->VGAScaleX(5);
 		last = 6;
 	} else if (scrolltype == RIGHTSCROLL) {
-		dX = g_lab->_graphics->VGAScaleX(-5);
-		dx = g_lab->_graphics->VGAScaleX(-5);
-		sx =  g_lab->_graphics->VGAScaleX(5);
+		dX = _graphics->VGAScaleX(-5);
+		dx = _graphics->VGAScaleX(-5);
+		sx = _graphics->VGAScaleX(5);
 		last = 6;
 	} else if (scrolltype == UPSCROLL) {
-		dY =  g_lab->_graphics->VGAScaleY(5);
-		sy =  g_lab->_graphics->VGAScaleY(5);
+		dY = _graphics->VGAScaleY(5);
+		sy = _graphics->VGAScaleY(5);
 		last = 5;
 	} else if (scrolltype == DOWNSCROLL) {
-		dY = g_lab->_graphics->VGAScaleY(-5);
-		dy = g_lab->_graphics->VGAScaleY(-5);
-		sy =  g_lab->_graphics->VGAScaleY(5);
+		dY = _graphics->VGAScaleY(-5);
+		dy = _graphics->VGAScaleY(-5);
+		sy = _graphics->VGAScaleY(5);
 		last = 5;
 	}
 
-	sx += g_lab->_graphics->SVGACord(2);
+	sx += _graphics->SVGACord(2);
 
-	x1 = g_lab->_graphics->VGAScaleX(100) + (col * g_lab->_graphics->VGAScaleX(30)) + dx;
-	y1 = g_lab->_graphics->VGAScaleY(25) + (row * g_lab->_graphics->VGAScaleY(25)) + dy;
+	x1 = _graphics->VGAScaleX(100) + (col * _graphics->VGAScaleX(30)) + dx;
+	y1 = _graphics->VGAScaleY(25) + (row * _graphics->VGAScaleY(25)) + dy;
 
 	for (uint16 i = 0; i < last; i++) {
-		g_lab->waitTOF();
-		scrollRaster(dX, dY, x1, y1, x1 + g_lab->_graphics->VGAScaleX(28) + sx, y1 + g_lab->_graphics->VGAScaleY(23) + sy);
+		waitTOF();
+		scrollRaster(dX, dY, x1, y1, x1 + _graphics->VGAScaleX(28) + sx, y1 + _graphics->VGAScaleY(23) + sy);
 		x1 += dX;
 		y1 += dY;
 	}
@@ -474,22 +474,22 @@ void LabEngine::changeCombination(uint16 number) {
 
 	combnum = combination[number];
 
-	display._imageData = g_lab->getCurrentDrawingBuffer();
-	display._width     = g_lab->_screenWidth;
-	display._height    = g_lab->_screenHeight;
+	display._imageData = getCurrentDrawingBuffer();
+	display._width     = _screenWidth;
+	display._height    = _screenHeight;
 
 	for (uint16 i = 1; i <= (Images[combnum]->_height / 2); i++) {
-		if (g_lab->_isHiRes) {
+		if (_isHiRes) {
 			if (i & 1)
-				g_lab->waitTOF();
+				waitTOF();
 		} else
-			g_lab->waitTOF();
+			waitTOF();
 
-		display._imageData = g_lab->getCurrentDrawingBuffer();
+		display._imageData = getCurrentDrawingBuffer();
 
-		g_lab->scrollDisplayY(2, g_lab->_graphics->VGAScaleX(COMBINATION_X[number]), g_lab->_graphics->VGAScaleY(65), g_lab->_graphics->VGAScaleX(COMBINATION_X[number]) + (Images[combnum])->_width - 1, g_lab->_graphics->VGAScaleY(65) + (Images[combnum])->_height);
+		scrollDisplayY(2, _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), _graphics->VGAScaleX(COMBINATION_X[number]) + (Images[combnum])->_width - 1, _graphics->VGAScaleY(65) + (Images[combnum])->_height);
 
-		Images[combnum]->bltBitMap(0, (Images[combnum])->_height - (2 * i), &(display), g_lab->_graphics->VGAScaleX(COMBINATION_X[number]), g_lab->_graphics->VGAScaleY(65), (Images[combnum])->_width, 2);
+		Images[combnum]->bltBitMap(0, (Images[combnum])->_height - (2 * i), &(display), _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), (Images[combnum])->_width, 2);
 	}
 
 	for (uint16 i = 0; i < 6; i++)
@@ -522,25 +522,25 @@ void LabEngine::doCombination() {
 /*****************************************************************************/
 void LabEngine::showCombination(const char *filename) {
 	resetBuffer();
-	g_lab->_anim->_doBlack = true;
-	g_lab->_anim->_noPalChange = true;
-	g_lab->_graphics->readPict(filename, true);
-	g_lab->_anim->_noPalChange = false;
+	_anim->_doBlack = true;
+	_anim->_noPalChange = true;
+	_graphics->readPict(filename, true);
+	_anim->_noPalChange = false;
 
-	g_lab->_graphics->blackScreen();
+	_graphics->blackScreen();
 
-	Common::File *numFile = g_lab->_resource->openDataFile("P:Numbers");
+	Common::File *numFile = _resource->openDataFile("P:Numbers");
 
 	for (uint16 CurBit = 0; CurBit < 10; CurBit++)
 		Images[CurBit] = new Image(numFile);
 
 	delete numFile;
 
-	allocFile((void **)&g_lab->_tempScrollData, Images[0]->_width * Images[0]->_height * 2L, "tempdata");
+	allocFile((void **)&_tempScrollData, Images[0]->_width * Images[0]->_height * 2L, "tempdata");
 
 	doCombination();
 
-	g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
+	setPalette(_anim->_diffPalette, 256);
 }
 
 } // End of namespace Lab


Commit: a182a6af1a71a3140c7cb40d2df3595ea3ad0a90
    https://github.com/scummvm/scummvm/commit/a182a6af1a71a3140c7cb40d2df3595ea3ad0a90
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:50+01:00

Commit Message:
LAB: Rewrite picture handling and get rid of the memory manager

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/graphics.h
    engines/lab/intro.cpp
    engines/lab/lab.cpp
    engines/lab/labfile.cpp
    engines/lab/labfun.h
    engines/lab/music.cpp
    engines/lab/music.h
    engines/lab/processroom.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 9402f9c..5ecfa72 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -586,7 +586,7 @@ void Anim::diffNextFrame() {
 /*****************************************************************************/
 /* A separate task launched by readDiff.  Plays the DIFF.                    */
 /*****************************************************************************/
-void Anim::playDiff() {
+void Anim::playDiff(byte *buffer) {
 	_waitSec   = 0L;
 	_waitMicros = 0L;
 	_delayMicros = 0L;
@@ -605,7 +605,7 @@ void Anim::playDiff() {
 		_vm->_graphics->blackScreen();
 	}
 
-	_start = *startoffile;            /* Make a copy of the pointer to the start of the file    */
+	_start = buffer;				   /* Make a copy of the pointer to the start of the file    */
 	*_diffFile = _start;               /* Now can modify the file without modifying the original */
 
 	if (_start == NULL) {
@@ -709,9 +709,9 @@ void Anim::stopSound() {
 /*****************************************************************************/
 /* Reads in a DIFF file.                                                     */
 /*****************************************************************************/
-bool Anim::readDiff(bool playOnce) {
+bool Anim::readDiff(byte *buffer, bool playOnce) {
 	_playOnce = playOnce;
-	playDiff();
+	playDiff(buffer);
 	return true;
 }
 
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 3fed57d..170e84d 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -114,14 +114,13 @@ public:
 	bool VUnDIFFMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySize, uint16 bytesPerRow);
 	void runLengthDecode(byte *dest, byte *source);
 	void VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow);
-	bool readDiff(bool playOnce);
+	bool readDiff(byte *buffer, bool playOnce);
+	void playDiff(byte *buffer);
 	void diffNextFrame();
 	void readSound(bool waitTillFinished, Common::File *file);
 	void stopDiff();
 	void stopDiffEnd();
 	void stopSound();
-	void playDiff();
-
 };
 
 } // End of namespace Lab
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index f3cda0e..fa12324 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -1057,22 +1057,14 @@ void LabEngine::go() {
 
 	_isHiRes = ((getFeatures() & GF_LOWRES) == 0);
 
-	bool mem = false;
-	if (initBuffer(BUFFERSIZE, true)) {
-		mem = true;
-	} else {
-		warning("initBuffer() failed");
-		return;
-	}
-
 	if (!_graphics->setUpScreens()) {
 		_isHiRes = false;
-		mem = mem && _graphics->setUpScreens();
+		_graphics->setUpScreens();
 	}
 
 	_event->initMouse();
 
-	mem = mem && initRoomBuffer();
+	initRoomBuffer();
 
 	if (!doIntro)
 		_music->initMusic();
@@ -1081,18 +1073,15 @@ void LabEngine::go() {
 
 	_event->mouseHide();
 
-	if (doIntro && mem) {
+	if (doIntro) {
 		Intro *intro = new Intro(this);
 		intro->introSequence();
 		delete intro;
 	} else
 		_anim->_doBlack = true;
 
-	if (mem) {
-		_event->mouseShow();
-		mainGameLoop();
-	} else
-		debug("\n\nNot enough memory to start game.\n\n");
+	_event->mouseShow();
+	mainGameLoop();
 
 	if (QuitLab) { /* Won the game */
 		_graphics->blackAllScreen();
@@ -1117,7 +1106,7 @@ void LabEngine::go() {
 	closeFont(_msgFont);
 
 	freeRoomBuffer();
-	freeBuffer();
+	_graphics->freePict();
 
 	freeScreens();
 
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 73ec5cc..614b744 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -48,6 +48,11 @@ DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) {
 
 	_screenBytesPerPage = 65536;
 	_curapen = 0;
+	_curBitmap = NULL;
+}
+
+DisplayMan::~DisplayMan() {
+	freePict();
 }
 
 /*****************************************************************************/
@@ -103,26 +108,32 @@ uint16 DisplayMan::SVGACord(uint16 cord) {
 /*------ From readPict.c.  Reads in pictures and animations from disk. ------*/
 /*---------------------------------------------------------------------------*/
 
+void DisplayMan::loadPict(const char *filename) {
+	Common::File *bitmapFile = _vm->_resource->openDataFile(filename);
+	freePict();
+	_curBitmap = new byte[bitmapFile->size()];
+	bitmapFile->read(_curBitmap, bitmapFile->size());
+	delete bitmapFile;
+}
+
 /*****************************************************************************/
 /* Reads in a picture into the dest bitmap.                                  */
 /*****************************************************************************/
 bool DisplayMan::readPict(const char *filename, bool playOnce) {
 	_vm->_anim->stopDiff();
 
-	byte **file = _vm->_music->newOpen(filename);
+	loadPict(filename);
 
-	if (file == NULL) {
-		if ((filename[0] == 'p') || (filename[0] == 'P'))
-			blackScreen();
+	_vm->_music->updateMusic();
 
-		return false;
-	}
+	if (!_vm->_music->_doNotFilestopSoundEffect)
+		_vm->_music->stopSoundEffect();
 
 	DispBitMap->_bytesPerRow = _vm->_screenWidth;
 	DispBitMap->_rows        = _vm->_screenHeight;
 	DispBitMap->_flags       = BITMAPF_VIDEO;
 
-	_vm->_anim->readDiff(playOnce);
+	_vm->_anim->readDiff(_curBitmap, playOnce);
 
 	return true;
 }
@@ -131,30 +142,32 @@ bool DisplayMan::readPict(const char *filename, bool playOnce) {
 /* Reads in a picture into buffer memory.                                    */
 /*****************************************************************************/
 byte *DisplayMan::readPictToMem(const char *filename, uint16 x, uint16 y) {
-	byte *mem;
-
 	_vm->_anim->stopDiff();
 
-	allocFile((void **)&mem, (int32)x * (int32)y, "Bitmap");
-	byte *curMem = mem;
+	loadPict(filename);
 
-	byte **file = _vm->_music->newOpen(filename);
+	_vm->_music->updateMusic();
 
-	if (file == NULL)
-		return NULL;
+	if (!_vm->_music->_doNotFilestopSoundEffect)
+		_vm->_music->stopSoundEffect();
 
 	DispBitMap->_bytesPerRow = x;
 	DispBitMap->_rows = y;
 	DispBitMap->_flags = BITMAPF_NONE;
-	DispBitMap->_planes[0] = curMem;
+	DispBitMap->_planes[0] = _curBitmap;
 	DispBitMap->_planes[1] = DispBitMap->_planes[0] + 0x10000;
 	DispBitMap->_planes[2] = DispBitMap->_planes[1] + 0x10000;
 	DispBitMap->_planes[3] = DispBitMap->_planes[2] + 0x10000;
 	DispBitMap->_planes[4] = DispBitMap->_planes[3] + 0x10000;
 
-	_vm->_anim->readDiff(true);
+	_vm->_anim->readDiff(_curBitmap, true);
+
+	return _curBitmap;
+}
 
-	return mem;
+void DisplayMan::freePict() {
+	delete _curBitmap;
+	_curBitmap = NULL;
 }
 
 /*****************************************************************************/
@@ -413,16 +426,15 @@ void DisplayMan::drawMessage(const char *str) {
 /* Scrolls the display to black.                                             */
 /*****************************************************************************/
 void DisplayMan::doScrollBlack() {
-	byte *mem, *tempmem;
+	byte *tempmem;
 	Image im;
 	uint32 size, copysize;
 	uint32 *baseAddr;
-
-	_vm->_event->mouseHide();
 	uint16 width = VGAScaleX(320);
 	uint16 height = VGAScaleY(149) + SVGACord(2);
+	byte *mem = new byte[width * height];
 
-	allocFile((void **)&mem, (int32)width * (int32)height, "Temp Mem");
+	_vm->_event->mouseHide();
 
 	im._width = width;
 	im._height = height;
@@ -479,7 +491,8 @@ void DisplayMan::doScrollBlack() {
 		}
 	}
 
-	freeAllStolenMem();
+	delete[] mem;
+	freePict();
 	_vm->_event->mouseShow();
 }
 
diff --git a/engines/lab/graphics.h b/engines/lab/graphics.h
index aac7e58..63523cb 100644
--- a/engines/lab/graphics.h
+++ b/engines/lab/graphics.h
@@ -40,20 +40,20 @@ private:
 	LabEngine *_vm;
 
 	byte _curapen;
+	byte *_curBitmap;
 
 public:
-	bool _longWinInFront;
-	bool _lastMessageLong;
-	uint32 _screenBytesPerPage;
-
 	DisplayMan(LabEngine *lab);
+	virtual ~DisplayMan();
 
 	uint16 scaleX(uint16 x);
 	uint16 scaleY(uint16 y);
 	int16 VGAScaleX(int16 x);
 	int16 VGAScaleY(int16 y);
 	uint16 SVGACord(uint16 cord);
+	void loadPict(const char *filename);
 	bool readPict(const char *filename, bool playOnce);
+	void freePict();
 	byte *readPictToMem(const char *filename, uint16 x, uint16 y);
 	void doScrollBlack();
 	void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem);
@@ -101,6 +101,10 @@ public:
 	void drawVLine(uint16 x1, uint16 y, uint16 x2);
 	void screenUpdate();
 	bool createScreen(bool HiRes);
+
+	bool _longWinInFront;
+	bool _lastMessageLong;
+	uint32 _screenBytesPerPage;
 };
 
 } // End of namespace Lab
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index aab50f4..52a46eb 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -85,39 +85,37 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 
 	uint32 lastSecs = 0L, lastMicros = 0L, secs = 0L, micros = 0L;
 	IntuiMessage *msg;
-	byte *curPlace, **tFile;
 	bool drawNextText = true, end = false, begin = true;
 
 	int32 cls, code, Drawn;
 	int16 qualifier;
 
+	Common::File *textFile = g_lab->_resource->openDataFile(path);
+	byte *textBuffer = new byte[textFile->size()];
+	textFile->read(textBuffer, textFile->size());
+	delete textFile;
+	byte *curText = textBuffer;
+
 	while (1) {
 		if (drawNextText) {
-			if (begin) {
+			if (begin)
 				begin = false;
-
-				tFile = _vm->_music->newOpen(path);
-
-				if (!tFile)
-					return;
-
-				curPlace = *tFile;
-			} else if (isScreen)
+			else if (isScreen)
 				fade(false, 0);
 
 			if (isScreen) {
 				_vm->_graphics->setAPen(7);
 				_vm->_graphics->rectFill(_vm->_graphics->VGAScaleX(10), _vm->_graphics->VGAScaleY(10), _vm->_graphics->VGAScaleX(310), _vm->_graphics->VGAScaleY(190));
 
-				Drawn = _vm->_graphics->flowText(msgFont, (!_vm->_isHiRes) * -1, 5, 7, false, false, true, true, _vm->_graphics->VGAScaleX(14), _vm->_graphics->VGAScaleY(11), _vm->_graphics->VGAScaleX(306), _vm->_graphics->VGAScaleY(189), (char *)curPlace);
+				Drawn = _vm->_graphics->flowText(msgFont, (!_vm->_isHiRes) * -1, 5, 7, false, false, true, true, _vm->_graphics->VGAScaleX(14), _vm->_graphics->VGAScaleY(11), _vm->_graphics->VGAScaleX(306), _vm->_graphics->VGAScaleY(189), (char *)curText);
 				fade(true, 0);
 			} else {
-				Drawn = _vm->_graphics->longDrawMessage((char *)curPlace);
+				Drawn = _vm->_graphics->longDrawMessage((char *)curText);
 			}
 
-			curPlace += Drawn;
+			curText += Drawn;
 
-			end = (*curPlace == 0);
+			end = (*curText == 0);
 
 			drawNextText = false;
 			introEatMessages();
@@ -126,6 +124,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 				if (isScreen)
 					fade(false, 0);
 
+				delete[] textBuffer;
 				return;
 			}
 
@@ -145,6 +144,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 					if (isScreen)
 						fade(false, 0);
 
+					delete[] textBuffer;
 					return;
 				} else {
 					drawNextText = true;
@@ -164,6 +164,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 				if (isScreen)
 					fade(false, 0);
 
+				delete[] textBuffer;
 				return;
 			}
 
@@ -173,6 +174,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 						if (isScreen)
 							fade(false, 0);
 
+						delete[] textBuffer;
 						return;
 					} else
 						drawNextText = true;
@@ -184,6 +186,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 					if (isScreen)
 						fade(false, 0);
 
+					delete[] textBuffer;
 					return;
 				}
 			}
@@ -192,11 +195,12 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 				if (isScreen)
 					fade(false, 0);
 
+				delete[] textBuffer;
 				return;
 			} else
 				drawNextText = true;
 		}
-	}
+	}	// while(1)
 }
 
 /*****************************************************************************/
@@ -323,8 +327,6 @@ void Intro::introSequence() {
 	nReadPict("DA", true);
 	musicDelay();
 
-	_vm->_music->newOpen("p:Intro/Intro.1");  /* load the picture into the buffer */
-
 	_vm->_music->updateMusic();
 	_vm->_graphics->blackAllScreen();
 	_vm->_music->updateMusic();
@@ -345,8 +347,6 @@ void Intro::introSequence() {
 	doPictText("i.2A", msgFont, true);
 	doPictText("i.2B", msgFont, true);
 
-	freeAllStolenMem();
-
 	_vm->_graphics->blackAllScreen();
 	_vm->_music->updateMusic();
 
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index a8baec2..ef75544 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -397,7 +397,6 @@ void LabEngine::doTile(bool showsolution) {
 void LabEngine::showTile(const char *filename, bool showsolution) {
 	uint16 start = showsolution ? 0 : 1;
 
-	resetBuffer();
 	_anim->_doBlack = true;
 	_anim->_noPalChange = true;
 	_graphics->readPict(filename, true);
@@ -411,8 +410,6 @@ void LabEngine::showTile(const char *filename, bool showsolution) {
 
 	delete tileFile;
 
-	allocFile((void **)&_tempScrollData, Tiles[1]->_width * Tiles[1]->_height * 2L, "tempdata");
-
 	doTile(showsolution);
 	setPalette(_anim->_diffPalette, 256);
 }
@@ -521,7 +518,6 @@ void LabEngine::doCombination() {
 /* Reads in a backdrop picture.                                              */
 /*****************************************************************************/
 void LabEngine::showCombination(const char *filename) {
-	resetBuffer();
 	_anim->_doBlack = true;
 	_anim->_noPalChange = true;
 	_graphics->readPict(filename, true);
@@ -536,8 +532,6 @@ void LabEngine::showCombination(const char *filename) {
 
 	delete numFile;
 
-	allocFile((void **)&_tempScrollData, Images[0]->_width * Images[0]->_height * 2L, "tempdata");
-
 	doCombination();
 
 	setPalette(_anim->_diffPalette, 256);
diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
index 4fee3ba..579316c 100644
--- a/engines/lab/labfile.cpp
+++ b/engines/lab/labfile.cpp
@@ -35,139 +35,6 @@
 namespace Lab {
 
 
-static byte *buffer = NULL, *realbufferstart = NULL, *startoffilestorage = NULL;
-
-byte **startoffile = &startoffilestorage;
-static uint32 buffersize, realbuffersize;
-
-/*-------------------- Routines that buffer a whole file --------------------*/
-
-#define MAXMARKERS        15
-
-
-struct FileMarker {
-	char name[32];
-	void *Start, *End;
-};
-
-
-
-static FileMarker FileMarkers[MAXMARKERS];
-static uint16 _curMarker  = 0;
-static void *_memPlace   = NULL;
-
-
-
-
-
-/*****************************************************************************/
-/* Frees a File's resources.                                                 */
-/*****************************************************************************/
-static void freeFile(uint16 RMarker) {
-	FileMarkers[RMarker].name[0] = 0;
-	FileMarkers[RMarker].Start  = NULL;
-	FileMarkers[RMarker].End    = NULL;
-}
-
-/*****************************************************************************/
-/* Checks if a file is already buffered.                                     */
-/*****************************************************************************/
-byte **isBuffered(const char *fileName) {
-	if (fileName == NULL)
-		return NULL;
-
-	for (int i = 0; i < MAXMARKERS; i++) {
-		if (strcmp(FileMarkers[i].name, fileName) == 0) {
-			*startoffile = (byte *)FileMarkers[i].Start;
-			return startoffile;
-		}
-	}
-
-	return NULL;
-}
-
-/*****************************************************************************/
-/* Grabs a chunk of memory from the room buffer, and manages it for a        */
-/* particular room. If it returns true, then the file is already in memory. */
-/*****************************************************************************/
-bool allocFile(void **Ptr, uint32 Size, const char *fileName) {
-	uint16 RMarker;
-	byte **temp;
-
-	if (1 & Size)  /* Memory is required to be even aligned */
-		Size++;
-
-	temp = isBuffered(fileName);
-
-	if (temp) {
-		*Ptr = *temp;
-		return true;
-	}
-
-	RMarker = _curMarker;
-	_curMarker++;
-
-	if (_curMarker >= MAXMARKERS)
-		_curMarker = 0;
-
-	freeFile(RMarker);
-	strcpy(FileMarkers[RMarker].name, fileName);
-
-	*Ptr = 0;
-
-	if ((((char *)_memPlace) + Size - 1) >=
-		(((char *)buffer) + buffersize))
-		_memPlace = buffer;
-
-	*Ptr = _memPlace;
-	_memPlace = (char *)_memPlace + Size;
-
-	for (int i = 0; i < MAXMARKERS; i++) {
-		if (FileMarkers[i].name[0]) {
-			if (((FileMarkers[i].Start >= Ptr) && (FileMarkers[i].Start < _memPlace))
-				|| ((FileMarkers[i].End >= Ptr) && (FileMarkers[i].End < _memPlace))
-				|| ((Ptr >= FileMarkers[i].Start) && (Ptr <= FileMarkers[i].End)))
-				freeFile(i);
-		}
-	}
-
-	FileMarkers[RMarker].Start = *Ptr;
-	FileMarkers[RMarker].End   = (void *)(((char *)(*Ptr)) + Size - 1);
-
-	return false;
-}
-
-/*----- Main routines -----*/
-
-
-/*****************************************************************************/
-/* Reads a file into memory.                                                 */
-/*****************************************************************************/
-byte **openFile(const char *name, uint32 &size) {
-	byte *buf;
-	Common::File file;
-
-	file.open(translateFileName(name));
-	if (!file.isOpen()) {
-		warning("Cannot open file %s", translateFileName(name));
-
-		return NULL;
-	}
-
-	size = file.size();
-
-	buf = (byte *)malloc(size);
-	if (!buf)
-		error("Unable to allocate %d bytes file file %s", size, name);
-
-	*startoffile = buf;
-
-	file.read(buf, size);
-
-	return startoffile;
-}
-
-
 /*****************************************************************************/
 /* Reads a block of memory.                                                  */
 /*****************************************************************************/
@@ -176,110 +43,6 @@ void readBlock(void *Buffer, uint32 Size, byte **File) {
 	(*File) += Size;
 }
 
-/*****************************************************************************/
-/* Resets the internal buffers to empty.                                     */
-/*****************************************************************************/
-void resetBuffer() {
-	uint16 RMarker;
-
-	_curMarker = 0;
-	RMarker   = 0;
-	_memPlace  = buffer;
-
-	while (RMarker < MAXMARKERS) {
-		freeFile(RMarker);
-		RMarker++;
-	}
-}
-
-
-/*****************************************************************************/
-/* Initializes the buffer.                                                   */
-/*****************************************************************************/
-bool initBuffer(uint32 BufSize, bool IsGraphicsMem) {
-	buffer = (byte *)calloc(BufSize, 1);
-
-	buffersize = BufSize;
-	realbuffersize = buffersize;
-	realbufferstart = buffer;
-
-	resetBuffer();
-
-	return (buffer != NULL);
-}
-
-/*****************************************************************************/
-/* Frees the buffer.                                                         */
-/*****************************************************************************/
-void freeBuffer() {
-	freeAllStolenMem();
-
-	if (buffer)
-		free(buffer);
-}
-
-/*------------------------------------------------------------------------*/
-/* The following routines allow stealing of memory from the buffer (which */
-/* later may or may not be given back).                                   */
-/*------------------------------------------------------------------------*/
-
-
-
-
-/*****************************************************************************/
-/* Clears all the buffers.                                                   */
-/*****************************************************************************/
-static void flushBuffers() {
-	for (int i = 0; i < MAXMARKERS; i++)
-		freeFile(i);
-}
-
-
-
-/*****************************************************************************/
-/* Steal some memory from the buffer                                         */
-/*****************************************************************************/
-void *stealBufMem(int32 Size) {
-	void *Mem;
-
-	flushBuffers();
-	Mem = buffer;
-
-	buffer += Size;
-	buffersize -= Size;
-	_memPlace = buffer;
-
-	return Mem;
-}
-
-
-Common::File *openPartial(const char *name) {
-	Common::File *f;
-
-	f = new Common::File();
-	f->open(translateFileName(name));
-
-	if (!f->isOpen()) {
-		warning("openPartial skipped %s", translateFileName(name));
-		delete f;
-		return 0;
-	}
-
-	return f;
-}
-
-
-/*****************************************************************************/
-/* Frees all the memory stolen from the buffer.                              */
-/*****************************************************************************/
-void freeAllStolenMem() {
-	flushBuffers();
-
-	buffer = realbufferstart;
-	buffersize = realbuffersize;
-	_memPlace = buffer;
-}
-
 static char NewFileName[255];
 
 /*****************************************************************************/
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 558abe1..8d7c609 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -92,27 +92,7 @@ void gadgetsOnOff(void *gptr, void *win, int32 num, bool on);
 void eatMessages();
 bool quitPlaying();
 
-/*---------------------------*/
-/*------ From LabFile.c -----*/
-/*---------------------------*/
-
-/* Buffer a whole file */
-byte **isBuffered(const char *fileName);
-byte **openFile(const char *name, uint32 &size);
 void readBlock(void *Buffer, uint32 Size, byte **File);
-void resetBuffer();
-bool initBuffer(uint32 BufSize, bool IsGraphicsMem);
-void freeBuffer();
-
-/* Functions that borrow memory from the buffer */
-bool allocFile(void **Ptr, uint32 Size, const char *fileName);
-void *stealBufMem(int32 Size);
-void freeAllStolenMem();
-
-
-/* Read chunks of a file */
-Common::File *openPartial(const char *name);
-void closePartial(int32 File);
 
 /*---------------------------*/
 /*----- From LabSets.c ------*/
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index e9deb8e..b6b00cb 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -175,7 +175,7 @@ bool Music::initMusic() {
 	else
 		filename = "Music:BackGrou";
 
-	_file = openPartial(filename);
+	_file = g_lab->_resource->openDataFile(filename);
 
 	if (_file) {
 		startMusic(true);
@@ -277,7 +277,7 @@ void Music::changeMusic(const char *newmusic) {
 			_tLeftInFile = _leftinfile;
 	}
 
-	_file = openPartial(newmusic);
+	_file = g_lab->_resource->openDataFile(newmusic);
 
 	if (_file) {
 		_musicOn = true;   /* turn it off */
@@ -320,32 +320,4 @@ void Music::resetMusic() {
 	_tFile = 0;
 }
 
-/*****************************************************************************/
-/* Checks whether or note enough memory in music buffer before loading any   */
-/* files.  Fills it if not.  Does not take into account the current buffer   */
-/* playing; a built in fudge factor.  We've also got another FUDGEFACTOR     */
-/* defined above in case things go wrong.                                    */
-/*                                                                           */
-/* Here, the seconds are multipled by 10.                                    */
-/*****************************************************************************/
-byte **Music::newOpen(const char *name) {
-	byte **file;
-
-	if (!name || !strcmp(name, "") || !strcmp(name, " "))
-		return NULL;
-
-	if ((file = isBuffered(name)))
-		return file;
-
-	updateMusic();
-
-	if (!_doNotFilestopSoundEffect)
-		stopSoundEffect();
-
-	uint32 unused;
-	file = openFile(name, unused);
-	updateMusic();
-	return file;
-}
-
 } // End of namespace Lab
diff --git a/engines/lab/music.h b/engines/lab/music.h
index 45528e5..a94fae5 100644
--- a/engines/lab/music.h
+++ b/engines/lab/music.h
@@ -52,7 +52,6 @@ class Music {
 public:
 	Music(LabEngine *vm);
 
-	byte **newOpen(const char *name);
 	bool initMusic();
 	void freeMusic();
 	void updateMusic();
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 0b81255..bc7fa2e 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -300,8 +300,6 @@ bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
 /* Processes the action list.                                                */
 /*****************************************************************************/
 void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
-	bool firstLoaded = true;
-
 	while (aptr) {
 		_music->updateMusic();
 
@@ -334,13 +332,8 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			break;
 
 		case LOADDIFF:
-			if (firstLoaded) {
-				resetBuffer();
-				firstLoaded = false;
-			}
-
 			if (aptr->Data)
-				_music->newOpen((char *)aptr->Data);          /* Puts a file into memory */
+				_graphics->loadPict((char *)aptr->Data);          /* Puts a file into memory */
 
 			break;
 
@@ -524,7 +517,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			break;
 
 		case RESETBUFFER:
-			resetBuffer();
+			g_lab->_graphics->freePict();
 			break;
 
 		case SPECIALCMD:
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 3f26fbc..855093e 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -152,7 +152,6 @@ void doWestPaper() {
 	closeFont(paperFont);
 
 	g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
-	freeAllStolenMem();
 }
 
 /*****************************************************************************/
@@ -377,7 +376,6 @@ void LabEngine::processJournal() {
 /* Does the journal processing.                                              */
 /*****************************************************************************/
 void LabEngine::doJournal() {
-	resetBuffer();
 	_graphics->blackAllScreen();
 
 	lastpage    = false;
@@ -410,8 +408,6 @@ void LabEngine::doJournal() {
 	_graphics->setAPen(0);
 	_graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1);
 	_graphics->blackScreen();
-
-	freeAllStolenMem();
 }
 
 bool LabEngine::saveRestoreGame() {
@@ -638,7 +634,6 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 	_graphics->readPict("P:Mon/NWD3", true);
 	_graphics->blackAllScreen();
 
-	resetBuffer();
 	monitorPage = 0;
 	lastpage = false;
 	FadePalette = hipal;
@@ -656,11 +651,11 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 	_event->mouseHide();
 	delete[] ntext;
 	closeFont(monitorFont);
-	freeAllStolenMem();
 
 	_graphics->setAPen(0);
 	_graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1);
 	_graphics->blackAllScreen();
+	_graphics->freePict();
 }
 
 } // End of namespace Lab


Commit: eb0a52e7fb68fae75d5f8ab2ce435f0589537722
    https://github.com/scummvm/scummvm/commit/eb0a52e7fb68fae75d5f8ab2ce435f0589537722
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:50+01:00

Commit Message:
LAB: Remove some superfluous initialization code

Changed paths:
    engines/lab/lab.cpp



diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index ef75544..4a14ba6 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -119,12 +119,8 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_nextFileName = nullptr;
 	_newFileName = nullptr;
 
-	_moveGadgetList = 0;
-	_invGadgetList = 0;
-
 	_curFileName = " ";
 	_msgFont = 0;
-
 	_inventory = 0;
 
 	for (int i = 0; i < 16; i++)


Commit: 9ba30835a290c0e6fb10472149477d19e94e00b3
    https://github.com/scummvm/scummvm/commit/9ba30835a290c0e6fb10472149477d19e94e00b3
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:50+01:00

Commit Message:
LAB: Refactor the remaining functions in labfile.cpp

Changed paths:
  R engines/lab/labfile.cpp
    engines/lab/anim.cpp
    engines/lab/anim.h
    engines/lab/labfun.h
    engines/lab/module.mk
    engines/lab/resource.cpp
    engines/lab/resource.h



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 5ecfa72..f7770ad 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -414,6 +414,11 @@ void Anim::unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesPerRow
 		unDIFFMemory(newBuf, diffData, 1, bufType + 1);
 }
 
+void Anim::readBlock(void *Buffer, uint32 Size, byte **File) {
+	memcpy(Buffer, *File, (size_t)Size);
+	(*File) += Size;
+}
+
 void Anim::diffNextFrame() {
 	if (_header == 65535)  /* Already done. */
 		return;
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 170e84d..6c4c8be 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -93,6 +93,7 @@ private:
 	void VUnDIFFByteByte(byte *Dest, byte *diff, uint16 bytesperrow);
 	void VUnDIFFByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow);
 	void VUnDIFFByteLong(uint32 *Dest, uint32 *diff, uint16 bytesperrow);
+	void readBlock(void *Buffer, uint32 Size, byte **File);
 
 public:
 	Anim(LabEngine *vm);
diff --git a/engines/lab/labfile.cpp b/engines/lab/labfile.cpp
deleted file mode 100644
index 579316c..0000000
--- a/engines/lab/labfile.cpp
+++ /dev/null
@@ -1,88 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "lab/lab.h"
-#include "lab/labfun.h"
-#include "common/file.h"
-
-namespace Lab {
-
-
-/*****************************************************************************/
-/* Reads a block of memory.                                                  */
-/*****************************************************************************/
-void readBlock(void *Buffer, uint32 Size, byte **File) {
-	memcpy(Buffer, *File, (size_t) Size);
-	(*File) += Size;
-}
-
-static char NewFileName[255];
-
-/*****************************************************************************/
-/* Modifies the filename so that paths and stuff are correct.  Should mostly  */
-/* deal with assigns and the '/' instead of '\' on IBM systems.              */
-/*                                                                           */
-/* NOTE: Make a *copy* of the string, and modify that.  It would be a real   */
-/* *bad* idea to modify the original.  Since Labyrinth only focuses its      */
-/* attention to one file at a time, it would be fine to have one variable    */
-/* not on the stack which is used to store the new filename.                 */
-/*****************************************************************************/
-char *translateFileName(const char *filename) {
-	Common::String fileNameStr = filename;
-	fileNameStr.toUppercase();
-	Common::String fileNameStrFinal;
-
-	if (fileNameStr.hasPrefix("P:")) {
-		if (g_lab->_isHiRes)
-			fileNameStrFinal = "GAME/SPICT/";
-		else
-			fileNameStrFinal = "GAME/PICT/";
-	} else if (fileNameStr.hasPrefix("LAB:"))
-		fileNameStrFinal = "GAME/";
-	else if (fileNameStr.hasPrefix("MUSIC:"))
-		fileNameStrFinal = "GAME/MUSIC/";
-
-	if (fileNameStr.contains(':')) {
-		while (fileNameStr[0] != ':') {
-			fileNameStr.deleteChar(0);
-		}
-
-		fileNameStr.deleteChar(0);
-	}
-
-	fileNameStrFinal += fileNameStr;
-
-	strcpy(NewFileName, fileNameStrFinal.c_str());
-
-	return NewFileName;
-}
-
-
-} // End of namespace Lab
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 8d7c609..67200a8 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -116,12 +116,6 @@ public:
 };
 
 /*---------------------------*/
-/*----- From Machine.c ------*/
-/*---------------------------*/
-
-char *translateFileName(const char *filename);
-
-/*---------------------------*/
 /*-------- From Map.c -------*/
 /*---------------------------*/
 
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index 18bb7e6..5b8ac1a 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -10,7 +10,6 @@ MODULE_OBJS := \
 	interface.o \
 	intro.o \
 	lab.o \
-	labfile.o \
 	labsets.o \
 	map.o \
 	music.o \
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 5be7aed..5b4c0c1 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -43,21 +43,16 @@ Resource::Resource(LabEngine *vm) : _vm(vm) {
 }
 
 void Resource::readStaticText() {
-	Common::File labTextFile;
-	labTextFile.open(translateFileName("Lab:Rooms/LabText"));
-	if (!labTextFile.isOpen())
-		error("Unable to open file %s (Lab:Rooms/LabText)", translateFileName("Lab:Rooms/LabText"));
+	Common::File *labTextFile = openDataFile("Lab:Rooms/LabText");
 
 	for (int i = 0; i < 48; i++)
-		_staticText[i] = labTextFile.readLine();
+		_staticText[i] = labTextFile->readLine();
 
-	labTextFile.close();
+	delete labTextFile;
 }
 
 TextFont *Resource::getFont(const char *fileName) {
-	Common::File *dataFile;
-	if (!(dataFile = openDataFile(fileName, MKTAG('V', 'G', 'A', 'F'))))
-		error("getFont: couldn't open %s (%s)", translateFileName(fileName), fileName);
+	Common::File *dataFile = openDataFile(fileName, MKTAG('V', 'G', 'A', 'F'));
 
 	uint32 headerSize = 4L + 2L + 256 * 3 + 4L;
 	uint32 fileSize = dataFile->size();
@@ -79,10 +74,7 @@ TextFont *Resource::getFont(const char *fileName) {
 }
 
 char *Resource::getText(const char *fileName) {
-	Common::File *dataFile = new Common::File();
-	dataFile->open(translateFileName(fileName));
-	if (!dataFile->isOpen())
-		error("getText: couldn't open %s (%s)", translateFileName(fileName), fileName);
+	Common::File *dataFile = openDataFile(fileName);
 
 	g_lab->_music->updateMusic();
 
@@ -94,6 +86,7 @@ char *Resource::getText(const char *fileName) {
 	while (text && *text != '\0')
 		*text++ -= (byte)95;
 
+	delete dataFile;
 	return (char *)buffer;
 }
 
@@ -166,6 +159,34 @@ bool Resource::readViews(uint16 roomNum) {
 	return true;
 }
 
+Common::String Resource::translateFileName(Common::String filename) {
+	filename.toUppercase();
+	Common::String fileNameStrFinal;
+
+	if (filename.hasPrefix("P:")) {
+		if (g_lab->_isHiRes)
+			fileNameStrFinal = "GAME/SPICT/";
+		else
+			fileNameStrFinal = "GAME/PICT/";
+	}
+	else if (filename.hasPrefix("LAB:"))
+		fileNameStrFinal = "GAME/";
+	else if (filename.hasPrefix("MUSIC:"))
+		fileNameStrFinal = "GAME/MUSIC/";
+
+	if (filename.contains(':')) {
+		while (filename[0] != ':') {
+			filename.deleteChar(0);
+		}
+
+		filename.deleteChar(0);
+	}
+
+	fileNameStrFinal += filename;
+
+	return fileNameStrFinal;
+}
+
 Common::File *Resource::openDataFile(const char *fileName, uint32 fileHeader) {
 	Common::File *dataFile = new Common::File();
 	dataFile->open(translateFileName(fileName));
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index 2c7f9b7..99996a1 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -115,6 +115,7 @@ private:
 	CloseData *readCloseUps(uint16 depth, Common::File *file);
 	ViewData *readView(Common::File *file);
 	void readStaticText();
+	Common::String translateFileName(Common::String filename);
 
 	Common::String _staticText[48];
 };


Commit: 3ac02c1196875ff28e4aa9d2804bef811f8decb6
    https://github.com/scummvm/scummvm/commit/3ac02c1196875ff28e4aa9d2804bef811f8decb6
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:50+01:00

Commit Message:
LAB: Simplify file handling code

Changed paths:
    engines/lab/labsets.cpp
    engines/lab/map.cpp
    engines/lab/music.cpp
    engines/lab/resource.cpp



diff --git a/engines/lab/labsets.cpp b/engines/lab/labsets.cpp
index 21c495d..2598587 100644
--- a/engines/lab/labsets.cpp
+++ b/engines/lab/labsets.cpp
@@ -58,19 +58,15 @@ void LargeSet::exclElement(uint16 element) {
 }
 
 bool LargeSet::readInitialConditions(const char *fileName) {
-	Common::File *file;
+	Common::File *file = _vm->_resource->openDataFile(fileName, MKTAG('C', 'O', 'N', '0'));
 
-	if ((file = _vm->_resource->openDataFile(fileName, MKTAG('C', 'O', 'N', '0')))) {
-		uint16 conditions = file->readUint16LE();
-		for (int i = 0; i < conditions; i++) {
-			inclElement(file->readUint16LE());
-		}
-
-		delete file;
-		return true;
+	uint16 conditions = file->readUint16LE();
+	for (int i = 0; i < conditions; i++) {
+		inclElement(file->readUint16LE());
 	}
 
-	return false;
+	delete file;
+	return true;
 }
 
 
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index f5746ba..36591d7 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -171,8 +171,6 @@ static bool loadMapData() {
 	}
 
 	Common::File *mapFile = g_lab->_resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0'));
-	if (!mapFile)
-		error("Corrupt map file");
 	g_lab->_music->updateMusic();
 	if (!g_lab->_music->_doNotFilestopSoundEffect)
 		g_lab->_music->stopSoundEffect();
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index b6b00cb..0f42064 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -176,14 +176,8 @@ bool Music::initMusic() {
 		filename = "Music:BackGrou";
 
 	_file = g_lab->_resource->openDataFile(filename);
-
-	if (_file) {
-		startMusic(true);
-		return true;
-	}
-
-	_musicOn = false;
-	return false;
+	startMusic(true);
+	return true;
 }
 
 /*****************************************************************************/
@@ -278,16 +272,10 @@ void Music::changeMusic(const char *newmusic) {
 	}
 
 	_file = g_lab->_resource->openDataFile(newmusic);
-
-	if (_file) {
-		_musicOn = true;   /* turn it off */
-		setMusic(false);
-		_musicOn = false;  /* turn it back on */
-		setMusic(true);
-	} else {
-		_file  = _tFile;
-		_tFile = 0;
-	}
+	_musicOn = true;   /* turn it off */
+	setMusic(false);
+	_musicOn = false;  /* turn it back on */
+	setMusic(true);
 }
 
 /*****************************************************************************/
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 5b4c0c1..aaac1cd 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -34,7 +34,6 @@
 
 namespace Lab {
 
-static uint16 allocroom;
 extern RoomData *_rooms;
 extern uint16 NumInv, ManyRooms, HighestCondition;
 
@@ -91,9 +90,7 @@ char *Resource::getText(const char *fileName) {
 }
 
 bool Resource::readRoomData(const char *fileName) {
-	Common::File *dataFile;
-	if (!(dataFile = openDataFile(fileName, MKTAG('D', 'O', 'R', '1'))))
-		return false;
+	Common::File *dataFile = openDataFile(fileName, MKTAG('D', 'O', 'R', '1'));
 
 	ManyRooms = dataFile->readUint16LE();
 	HighestCondition = dataFile->readUint16LE();
@@ -120,9 +117,7 @@ bool Resource::readRoomData(const char *fileName) {
 }
 
 InventoryData *Resource::readInventory(const char *fileName) {
-	Common::File *dataFile;
-	if (!(dataFile = openDataFile(fileName, MKTAG('I', 'N', 'V', '1'))))
-		return nullptr;
+	Common::File *dataFile = openDataFile(fileName, MKTAG('I', 'N', 'V', '1'));
 
 	NumInv = dataFile->readUint16LE();
 	InventoryData *inventory = (InventoryData *)malloc((NumInv + 1) * sizeof(InventoryData));
@@ -140,11 +135,7 @@ InventoryData *Resource::readInventory(const char *fileName) {
 
 bool Resource::readViews(uint16 roomNum) {
 	Common::String fileName = "LAB:Rooms/" + Common::String::format("%d", roomNum);
-	Common::File *dataFile;
-	if (!(dataFile = openDataFile(fileName.c_str(), MKTAG('R', 'O', 'M', '4'))))
-		return false;
-
-	allocroom = roomNum;
+	Common::File *dataFile = openDataFile(fileName.c_str(), MKTAG('R', 'O', 'M', '4'));
 
 	_rooms[roomNum]._roomMsg = readString(dataFile);
 	_rooms[roomNum]._view[NORTH] = readView(dataFile);
@@ -191,11 +182,14 @@ Common::File *Resource::openDataFile(const char *fileName, uint32 fileHeader) {
 	Common::File *dataFile = new Common::File();
 	dataFile->open(translateFileName(fileName));
 	if (!dataFile->isOpen())
-		error("openDataFile couldn't open %s (%s)", translateFileName(fileName), fileName);
+		error("openDataFile: Couldn't open %s (%s)", translateFileName(fileName), fileName);
 
-	if (fileHeader > 0 && dataFile->readUint32BE() != fileHeader) {
-		dataFile->close();
-		return nullptr;
+	if (fileHeader > 0) {
+		uint32 headerTag = dataFile->readUint32BE();
+		if (headerTag != fileHeader) {
+			dataFile->close();
+			error("openDataFile: Unexpected header in %s (%s) - expected: %d, got: %d", translateFileName(fileName), fileName, fileHeader, headerTag);
+		}
 	}
 
 	return dataFile;


Commit: 6eb9c084bed4108b729568d0cdbac66d2a5d9172
    https://github.com/scummvm/scummvm/commit/6eb9c084bed4108b729568d0cdbac66d2a5d9172
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:50+01:00

Commit Message:
LAB: Remove dead code

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index fa12324..b4b20e7 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -1053,8 +1053,6 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 }
 
 void LabEngine::go() {
-	bool doIntro = true;
-
 	_isHiRes = ((getFeatures() & GF_LOWRES) == 0);
 
 	if (!_graphics->setUpScreens()) {
@@ -1066,19 +1064,13 @@ void LabEngine::go() {
 
 	initRoomBuffer();
 
-	if (!doIntro)
-		_music->initMusic();
-
 	_msgFont = _resource->getFont("P:AvanteG.12");
 
 	_event->mouseHide();
 
-	if (doIntro) {
-		Intro *intro = new Intro(this);
-		intro->introSequence();
-		delete intro;
-	} else
-		_anim->_doBlack = true;
+	Intro *intro = new Intro(this);
+	intro->introSequence();
+	delete intro;
 
 	_event->mouseShow();
 	mainGameLoop();


Commit: dddd07cc8754117811c296d9b0c384306e70baa0
    https://github.com/scummvm/scummvm/commit/dddd07cc8754117811c296d9b0c384306e70baa0
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:50+01:00

Commit Message:
LAB: Remove unused code

Changed paths:
    engines/lab/engine.cpp
    engines/lab/parsefun.h



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index b4b20e7..b6e6f72 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -49,8 +49,6 @@ extern uint16 NumInv, ManyRooms, HighestCondition, Direction;
 
 bool ispal = false, noupdatediff = false, MainDisplay = true, QuitLab = false;
 
-#define BUFFERSIZE 850000L
-
 /* LAB: Labyrinth specific code for the special puzzles */
 #define SPECIALLOCK         100
 #define SPECIALBRICK        101
@@ -1062,8 +1060,6 @@ void LabEngine::go() {
 
 	_event->initMouse();
 
-	initRoomBuffer();
-
 	_msgFont = _resource->getFont("P:AvanteG.12");
 
 	_event->mouseHide();
@@ -1097,7 +1093,6 @@ void LabEngine::go() {
 
 	closeFont(_msgFont);
 
-	freeRoomBuffer();
 	_graphics->freePict();
 
 	freeScreens();
@@ -1200,36 +1195,4 @@ void LabEngine::mayShowCrumbIndicatorOff() {
 	}
 }
 
-/* Have to make sure that ROOMBUFFERSIZE is bigger than the biggest piece of memory
-   that we need */
-#define ROOMBUFFERSIZE (2 * 20480L)
-
-static void *_roomBuffer = nullptr;
-static uint16 _curMarker  = 0;
-static void *_memPlace = nullptr;
-
-/*****************************************************************************/
-/* Allocates the memory for the room buffers.                                */
-/*****************************************************************************/
-bool initRoomBuffer() {
-	_curMarker = 0;
-
-	if ((_roomBuffer = calloc(ROOMBUFFERSIZE, 1))) {
-		_memPlace = _roomBuffer;
-
-		return true;
-	} else
-		return false;
-}
-
-/*****************************************************************************/
-/* Frees the memory for the room buffers.                                    */
-/*****************************************************************************/
-void freeRoomBuffer() {
-	if (_roomBuffer) {
-		free(_roomBuffer);
-		_roomBuffer = nullptr;
-	}
-}
-
 } // End of namespace Lab
diff --git a/engines/lab/parsefun.h b/engines/lab/parsefun.h
index ad8f04b..7f88951 100644
--- a/engines/lab/parsefun.h
+++ b/engines/lab/parsefun.h
@@ -40,12 +40,6 @@ namespace Lab {
 
 bool parse(const char *inputFile);
 
-
-/* From allocRoom.c */
-
-bool initRoomBuffer();
-void freeRoomBuffer();
-
 /* From ProcessRoom.c */
 
 ViewData *getViewData(uint16 roomNum, uint16 direction);


Commit: 6f3644f377cb298cb82d7a9235b9aec4cfa875ea
    https://github.com/scummvm/scummvm/commit/6f3644f377cb298cb82d7a9235b9aec4cfa875ea
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:51+01:00

Commit Message:
LAB: Fix a regression in roomCoords()

Changed paths:
    engines/lab/map.cpp



diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 36591d7..4df01ea 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -253,12 +253,20 @@ static void roomCoords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint1
 	case HCORRIDOR:
 		curRoomImg = HRoom;
 		break;
+	default:
+		// Some rooms (like the map) do not have an image
+		break;
 	}
 
 	*x1 = mapScaleX(Maps[CurRoom].x);
 	*y1 = mapScaleY(Maps[CurRoom].y);
-	*x2 = *x1 + curRoomImg->_width;
-	*y2 = *y1 + curRoomImg->_height;
+	*x2 = *x1;
+	*y2 = *y1;
+
+	if (curRoomImg) {
+		*x2 += curRoomImg->_width;
+		*y2 += curRoomImg->_height;
+	}
 }
 
 /*****************************************************************************/


Commit: ea6d4579e284e10778c1703ff6a1638505697cea
    https://github.com/scummvm/scummvm/commit/ea6d4579e284e10778c1703ff6a1638505697cea
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:51+01:00

Commit Message:
LAB: Merge all of the different image drawing functions

Changed paths:
    engines/lab/graphics.cpp
    engines/lab/image.cpp
    engines/lab/image.h
    engines/lab/lab.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 614b744..88b53ce 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -706,7 +706,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 
 				imDest._imageData = _vm->getCurrentDrawingBuffer();
 
-				imSource.bltBitMap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 2);
+				imSource.blitBitmap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 2, false);
 				_vm->overlayRect(0, 0, curY, _vm->_screenWidth - 1, curY + 1);
 				curY += 4;
 				linesdone++;
@@ -726,9 +726,9 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 				imDest._imageData = _vm->getCurrentDrawingBuffer();
 
 				if (curY == lastY)
-					imSource.bltBitMap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 1);
+					imSource.blitBitmap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 1, false);
 				else
-					imSource.bltBitMap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 2);
+					imSource.blitBitmap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 2, false);
 
 				curY += 4;
 				linesdone++;
diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp
index 1d8b9d61..45377ac 100644
--- a/engines/lab/image.cpp
+++ b/engines/lab/image.cpp
@@ -50,26 +50,48 @@ Image::Image(Common::File *s) {
 }
 
 /*****************************************************************************/
-/* Draws an image to the screen.                                             */
+/* Blits a piece of one image to another.                                    */
 /*****************************************************************************/
-void Image::drawImage(uint16 x, uint16 y) {
-	int w = _width;
-	int h = _height;
+void Image::blitBitmap(uint16 xs, uint16 ys, Image *imDest,
+	uint16 xd, uint16 yd, uint16 width, uint16 height, byte masked) {
+	int w = width;
+	int h = height;
+	int destWidth = (imDest) ? imDest->_width : g_lab->_screenWidth;
+	int destHeight = (imDest) ? imDest->_height : g_lab->_screenHeight;
+	byte *destBuffer = (imDest) ? imDest->_imageData : g_lab->getCurrentDrawingBuffer();
 
-	if (x + w > g_lab->_screenWidth)
-		w = g_lab->_screenWidth - x;
+	if (xd + w > destWidth)
+		w = destWidth - xd;
 
-	if (y + h > g_lab->_screenHeight)
-		h = g_lab->_screenHeight - y;
+	if (yd + h > destHeight)
+		h = destHeight - yd;
 
-	if ((w > 0) && (h > 0)) {
-		byte *s = _imageData;
-		byte *d = g_lab->getCurrentDrawingBuffer() + y * g_lab->_screenWidth + x;
+	if (w > 0 && h > 0) {
+		byte *s = _imageData + ys * _width + xs;
+		byte *d = destBuffer + yd * destWidth + xd;
 
-		while (h-- > 0) {
-			memcpy(d, s, w);
-			s += _width;
-			d += g_lab->_screenWidth;
+		if (!masked) {
+			while (h-- > 0) {
+				memcpy(d, s, w);
+				s += _width;
+				d += destWidth;
+			}
+		} else {
+			while (h-- > 0) {
+				byte *ss = s;
+				byte *dd = d;
+				int ww = w;
+
+				while (ww-- > 0) {
+					byte c = *ss++;
+
+					if (c) *dd++ = c - 1;
+					else dd++;
+				}
+
+				s += _width;
+				d += destWidth;
+			}
 		}
 	}
 }
@@ -77,36 +99,15 @@ void Image::drawImage(uint16 x, uint16 y) {
 /*****************************************************************************/
 /* Draws an image to the screen.                                             */
 /*****************************************************************************/
-void Image::drawMaskImage(uint16 x, uint16 y) {
-	int w = _width;
-	int h = _height;
-
-	if (x + w > g_lab->_screenWidth)
-		w = g_lab->_screenWidth - x;
-
-	if (y + h > g_lab->_screenHeight)
-		h = g_lab->_screenHeight - y;
-
-	if ((w > 0) && (h > 0)) {
-		byte *s = _imageData;
-		byte *d = g_lab->getCurrentDrawingBuffer() + y * g_lab->_screenWidth + x;
-
-		while (h-- > 0) {
-			byte *ss = s;
-			byte *dd = d;
-			int ww = w;
-
-			while (ww-- > 0) {
-				byte c = *ss++;
-
-				if (c) *dd++ = c - 1;
-				else dd++;
-			}
+void Image::drawImage(uint16 x, uint16 y) {
+	blitBitmap(0, 0, NULL, x, y, _width, _height, false);
+}
 
-			s += _width;
-			d += g_lab->_screenWidth;
-		}
-	}
+/*****************************************************************************/
+/* Draws an image to the screen with transparency.                           */
+/*****************************************************************************/
+void Image::drawMaskImage(uint16 x, uint16 y) {
+	blitBitmap(0, 0, NULL, x, y, _width, _height, true);
 }
 
 /*****************************************************************************/
@@ -134,33 +135,4 @@ void Image::readScreenImage(uint16 x, uint16 y) {
 	}
 }
 
-/*****************************************************************************/
-/* Blits a piece of one image to another.                                    */
-/* NOTE: for our purposes, assumes that ImDest is to be in VGA memory.       */
-/*****************************************************************************/
-void Image::bltBitMap(uint16 xs, uint16 ys, Image *imDest,
-					uint16 xd, uint16 yd, uint16 width, uint16 height) {
-	// I think the old code assumed that the source image data was valid for the given box.
-	// I will proceed on that assumption.
-	int w = width;
-	int h = height;
-
-	if (xd + w > imDest->_width)
-		w = imDest->_width - xd;
-
-	if (yd + h > imDest->_height)
-		h = imDest->_height - yd;
-
-	if (w > 0 && h > 0) {
-		byte *s = _imageData + ys * _width + xs;
-		byte *d = imDest->_imageData + yd * imDest->_width + xd;
-
-		while (h-- > 0) {
-			memcpy(d, s, w);
-			s += _width;
-			d += imDest->_width;
-		}
-	}
-}
-
 } // End of namespace Lab
diff --git a/engines/lab/image.h b/engines/lab/image.h
index 8f4d0f8..f443f4c 100644
--- a/engines/lab/image.h
+++ b/engines/lab/image.h
@@ -46,7 +46,7 @@ public:
     void drawImage(uint16 x, uint16 y);
     void drawMaskImage(uint16 x, uint16 y);
     void readScreenImage(uint16 x, uint16 y);
-	void bltBitMap(uint16 xs, uint16 ys, Image *ImDest, uint16 xd, uint16 yd, uint16 width, uint16 height);
+	void blitBitmap(uint16 xs, uint16 ys, Image *ImDest, uint16 xd, uint16 yd, uint16 width, uint16 height, byte masked);
 };
 
 
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 4a14ba6..2cd237c 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -482,7 +482,7 @@ void LabEngine::changeCombination(uint16 number) {
 
 		scrollDisplayY(2, _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), _graphics->VGAScaleX(COMBINATION_X[number]) + (Images[combnum])->_width - 1, _graphics->VGAScaleY(65) + (Images[combnum])->_height);
 
-		Images[combnum]->bltBitMap(0, (Images[combnum])->_height - (2 * i), &(display), _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), (Images[combnum])->_width, 2);
+		Images[combnum]->blitBitmap(0, (Images[combnum])->_height - (2 * i), &(display), _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), (Images[combnum])->_width, 2, false);
 	}
 
 	for (uint16 i = 0; i < 6; i++)
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 855093e..69a8aae 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -273,14 +273,14 @@ static void turnPage(bool FromLeft) {
 			g_lab->_music->updateMusic();
 			g_lab->waitTOF();
 			ScreenImage._imageData = g_lab->getCurrentDrawingBuffer();
-			JBackImage.bltBitMap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight);
+			JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight, false);
 		}
 	} else {
 		for (int i = (g_lab->_screenWidth - 8); i > 0; i -= 8) {
 			g_lab->_music->updateMusic();
 			g_lab->waitTOF();
 			ScreenImage._imageData = g_lab->getCurrentDrawingBuffer();
-			JBackImage.bltBitMap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight);
+			JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight, false);
 		}
 	}
 }
@@ -302,7 +302,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 	ScreenImage._imageData = getCurrentDrawingBuffer();
 
 	if (wipenum == 0)
-		JBackImage.bltBitMap(0, 0, &ScreenImage, 0, 0, _screenWidth, _screenHeight);
+		JBackImage.blitBitmap(0, 0, &ScreenImage, 0, 0, _screenWidth, _screenHeight, false);
 	else
 		turnPage((bool)(wipenum == 1));
 


Commit: c42973604cbfa3a1c27c624a0b7caae8e70ec3c2
    https://github.com/scummvm/scummvm/commit/c42973604cbfa3a1c27c624a0b7caae8e70ec3c2
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:51+01:00

Commit Message:
LAB: Split the tile puzzle related functions into a separate file

Changed paths:
  A engines/lab/tilepuzzle.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/module.mk



diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 2cd237c..acd1ea9 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -51,22 +51,6 @@ namespace Lab {
 
 LabEngine *g_lab;
 
-const uint16 INIT_TILE[4][4] = {
-	{ 1, 5, 9, 13 },
-	{ 2, 6, 10, 14 },
-	{ 3, 7, 11, 15 },
-	{ 4, 8, 12, 0 }
-};
-
-const uint16 SOLUTION[4][4] = {
-	{ 7, 1, 8, 3 },
-	{ 2, 11, 15, 4 },
-	{ 9, 5, 14, 6 },
-	{ 10, 13, 12, 0 }
-};
-
-const int COMBINATION_X[6] = { 45, 83, 129, 166, 211, 248 };
-
 LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
  : Engine(syst), _gameDescription(gameDesc), _extraGameFeatures(0) {
 	g_lab = this;
@@ -123,16 +107,7 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_msgFont = 0;
 	_inventory = 0;
 
-	for (int i = 0; i < 16; i++)
-		Tiles[i] = nullptr;
-
-	for (int i= 0; i < 4; i++) {
-		for (int j = 0; j < 4; j++)
-			CurTile[i][j] = INIT_TILE[i][j];
-	}
-
-	for (int i = 0; i < 6; i++)
-		combination[i] = 0;
+	initTilePuzzle();
 
 	//const Common::FSNode gameDataDir(ConfMan.get("path"));
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
@@ -210,327 +185,4 @@ Common::String LabEngine::generateSaveFileName(uint slot) {
 	return Common::String::format("%s.%03u", _targetName.c_str(), slot);
 }
 
-/*****************************************************************************/
-/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
-/*****************************************************************************/
-int LabEngine::VGAUnScaleX(int x) {
-	if (_isHiRes)
-		return (x / 2);
-	else
-		return x;
-}
-
-/*****************************************************************************/
-/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
-/*****************************************************************************/
-int LabEngine::VGAUnScaleY(int y) {
-	if (_isHiRes)
-		return ((y * 5) / 12);
-	else
-		return y;
-}
-
-/*****************************************************************************/
-/* Processes mouse clicks and changes the combination.                       */
-/*****************************************************************************/
-void LabEngine::mouseTile(Common::Point pos) {
-	int x = VGAUnScaleX(pos.x);
-	int y = VGAUnScaleY(pos.y);
-
-	if ((x < 101) || (y < 26))
-		return;
-
-	x = (x - 101) / 30;
-	y = (y -  26) / 25;
-
-	if ((x < 4) && (y < 4))
-		changeTile(x, y);
-}
-
-/*****************************************************************************/
-/* Changes the combination number of one of the slots                        */
-/*****************************************************************************/
-void LabEngine::changeTile(uint16 col, uint16 row) {
-	int16 scrolltype = -1;
-
-	if (row > 0) {
-		if (CurTile[col] [row - 1] == 0) {
-			CurTile[col] [row - 1] = CurTile[col] [row];
-			CurTile[col] [row] = 0;
-			scrolltype = DOWNSCROLL;
-		}
-	}
-
-	if (col > 0) {
-		if (CurTile[col - 1] [row] == 0) {
-			CurTile[col - 1] [row] = CurTile[col] [row];
-			CurTile[col] [row] = 0;
-			scrolltype = RIGHTSCROLL;
-		}
-	}
-
-	if (row < 3) {
-		if (CurTile[col] [row + 1] == 0) {
-			CurTile[col] [row + 1] = CurTile[col] [row];
-			CurTile[col] [row] = 0;
-			scrolltype = UPSCROLL;
-		}
-	}
-
-	if (col < 3) {
-		if (CurTile[col + 1] [row] == 0) {
-			CurTile[col + 1] [row] = CurTile[col] [row];
-			CurTile[col] [row] = 0;
-			scrolltype = LEFTSCROLL;
-		}
-	}
-
-	if (scrolltype != -1) {
-		doTileScroll(col, row, scrolltype);
-
-		if (getFeatures() & GF_WINDOWS_TRIAL) {
-			GUI::MessageDialog trialMessage("This puzzle is not available in the trial version of the game");
-			trialMessage.runModal();
-			return;
-		}
-
-		bool check = true;
-		row = 0;
-		col = 0;
-
-		while (row < 4) {
-			while (col < 4) {
-				check = check && (CurTile[row] [col] == SOLUTION[row] [col]);
-				col++;
-			}
-
-			row++;
-			col = 0;
-		}
-
-		if (check) {
-			_conditions->inclElement(BRICKOPEN);  /* unlocked combination */
-			_anim->_doBlack = true;
-			check = _graphics->readPict("p:Up/BDOpen", true);
-		}
-	}
-}
-
-/*****************************************************************************/
-/* Processes mouse clicks and changes the combination.                       */
-/*****************************************************************************/
-void LabEngine::mouseCombination(Common::Point pos) {
-	uint16 number;
-
-	int x = VGAUnScaleX(pos.x);
-	int y = VGAUnScaleY(pos.y);
-
-	if ((y >= 63) && (y <= 99)) {
-		if ((x >= 44) && (x < 83))
-			number = 0;
-		else if (x < 127)
-			number = 1;
-		else if (x < 165)
-			number = 2;
-		else if (x < 210)
-			number = 3;
-		else if (x < 245)
-			number = 4;
-		else if (x < 286)
-			number = 5;
-		else
-			return;
-
-		changeCombination(number);
-	}
-}
-
-/*****************************************************************************/
-/* Draws the images of the combination lock to the display bitmap.           */
-/*****************************************************************************/
-void LabEngine::doTile(bool showsolution) {
-	uint16 row = 0, col = 0, rowm, colm, num;
-	int16 rows, cols;
-
-	if (showsolution) {
-		rowm = _graphics->VGAScaleY(23);
-		colm = _graphics->VGAScaleX(27);
-
-		rows = _graphics->VGAScaleY(31);
-		cols = _graphics->VGAScaleX(105);
-	} else {
-		_graphics->setAPen(0);
-		_graphics->rectFill(_graphics->VGAScaleX(97), _graphics->VGAScaleY(22), _graphics->VGAScaleX(220), _graphics->VGAScaleY(126));
-
-		rowm = _graphics->VGAScaleY(25);
-		colm = _graphics->VGAScaleX(30);
-
-		rows = _graphics->VGAScaleY(25);
-		cols = _graphics->VGAScaleX(100);
-	}
-
-	while (row < 4) {
-		while (col < 4) {
-			if (showsolution)
-				num = SOLUTION[col] [row];
-			else
-				num = CurTile[col] [row];
-
-			if (showsolution || num)
-				Tiles[num]->drawImage(cols + (col * colm), rows + (row * rowm));
-
-			col++;
-		}
-
-		row++;
-		col = 0;
-	}
-}
-
-/*****************************************************************************/
-/* Reads in a backdrop picture.                                              */
-/*****************************************************************************/
-void LabEngine::showTile(const char *filename, bool showsolution) {
-	uint16 start = showsolution ? 0 : 1;
-
-	_anim->_doBlack = true;
-	_anim->_noPalChange = true;
-	_graphics->readPict(filename, true);
-	_anim->_noPalChange = false;
-	_graphics->blackScreen();
-
-	Common::File *tileFile = tileFile = _resource->openDataFile(showsolution ? "P:TileSolution" : "P:Tile");
-
-	for (uint16 curBit = start; curBit < 16; curBit++)
-		Tiles[curBit] = new Image(tileFile);
-
-	delete tileFile;
-
-	doTile(showsolution);
-	setPalette(_anim->_diffPalette, 256);
-}
-
-/*****************************************************************************/
-/* Does the scrolling for the tiles on the tile puzzle.                      */
-/*****************************************************************************/
-void LabEngine::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
-	int16 dX = 0, dY = 0, dx = 0, dy = 0, sx = 0, sy = 0;
-	uint16 last = 0, x1, y1;
-
-	if (scrolltype == LEFTSCROLL) {
-		dX = _graphics->VGAScaleX(5);
-		sx = _graphics->VGAScaleX(5);
-		last = 6;
-	} else if (scrolltype == RIGHTSCROLL) {
-		dX = _graphics->VGAScaleX(-5);
-		dx = _graphics->VGAScaleX(-5);
-		sx = _graphics->VGAScaleX(5);
-		last = 6;
-	} else if (scrolltype == UPSCROLL) {
-		dY = _graphics->VGAScaleY(5);
-		sy = _graphics->VGAScaleY(5);
-		last = 5;
-	} else if (scrolltype == DOWNSCROLL) {
-		dY = _graphics->VGAScaleY(-5);
-		dy = _graphics->VGAScaleY(-5);
-		sy = _graphics->VGAScaleY(5);
-		last = 5;
-	}
-
-	sx += _graphics->SVGACord(2);
-
-	x1 = _graphics->VGAScaleX(100) + (col * _graphics->VGAScaleX(30)) + dx;
-	y1 = _graphics->VGAScaleY(25) + (row * _graphics->VGAScaleY(25)) + dy;
-
-	for (uint16 i = 0; i < last; i++) {
-		waitTOF();
-		scrollRaster(dX, dY, x1, y1, x1 + _graphics->VGAScaleX(28) + sx, y1 + _graphics->VGAScaleY(23) + sy);
-		x1 += dX;
-		y1 += dY;
-	}
-}
-
-/*****************************************************************************/
-/* Changes the combination number of one of the slots                        */
-/*****************************************************************************/
-void LabEngine::changeCombination(uint16 number) {
-	static const int solution[6] = { 0, 4, 0, 8, 7, 2 };
-
-	Image display;
-	uint16 combnum;
-	bool unlocked = true;
-
-	if (combination[number] < 9)
-		(combination[number])++;
-	else
-		combination[number] = 0;
-
-	combnum = combination[number];
-
-	display._imageData = getCurrentDrawingBuffer();
-	display._width     = _screenWidth;
-	display._height    = _screenHeight;
-
-	for (uint16 i = 1; i <= (Images[combnum]->_height / 2); i++) {
-		if (_isHiRes) {
-			if (i & 1)
-				waitTOF();
-		} else
-			waitTOF();
-
-		display._imageData = getCurrentDrawingBuffer();
-
-		scrollDisplayY(2, _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), _graphics->VGAScaleX(COMBINATION_X[number]) + (Images[combnum])->_width - 1, _graphics->VGAScaleY(65) + (Images[combnum])->_height);
-
-		Images[combnum]->blitBitmap(0, (Images[combnum])->_height - (2 * i), &(display), _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), (Images[combnum])->_width, 2, false);
-	}
-
-	for (uint16 i = 0; i < 6; i++)
-		unlocked = (combination[i] == solution[i]) && unlocked;
-
-	if (unlocked)
-		_conditions->inclElement(COMBINATIONUNLOCKED);
-	else
-		_conditions->exclElement(COMBINATIONUNLOCKED);
-}
-
-void LabEngine::scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	if (dx)
-		scrollDisplayX(dx, x1, y1, x2, y2);
-
-	if (dy)
-		scrollDisplayY(dy, x1, y1, x2, y2);
-}
-
-/*****************************************************************************/
-/* Draws the images of the combination lock to the display bitmap.           */
-/*****************************************************************************/
-void LabEngine::doCombination() {
-	for (uint16 i = 0; i <= 5; i++)
-		Images[combination[i]]->drawImage(_graphics->VGAScaleX(COMBINATION_X[i]), _graphics->VGAScaleY(65));
-}
-
-/*****************************************************************************/
-/* Reads in a backdrop picture.                                              */
-/*****************************************************************************/
-void LabEngine::showCombination(const char *filename) {
-	_anim->_doBlack = true;
-	_anim->_noPalChange = true;
-	_graphics->readPict(filename, true);
-	_anim->_noPalChange = false;
-
-	_graphics->blackScreen();
-
-	Common::File *numFile = _resource->openDataFile("P:Numbers");
-
-	for (uint16 CurBit = 0; CurBit < 10; CurBit++)
-		Images[CurBit] = new Image(numFile);
-
-	delete numFile;
-
-	doCombination();
-
-	setPalette(_anim->_diffPalette, 256);
-}
-
 } // End of namespace Lab
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index b109ac6..01dcaa0 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -197,6 +197,7 @@ private:
 	void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void doCombination();
 	void showCombination(const char *filename);
+	void initTilePuzzle();
 
 	bool saveRestoreGame();
 
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index 5b8ac1a..434ba7d 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -18,6 +18,7 @@ MODULE_OBJS := \
 	savegame.o \
 	special.o \
 	text.o \
+	tilepuzzle.o \
 	timing.o \
 	vga.o
 
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
new file mode 100644
index 0000000..a473b0e
--- /dev/null
+++ b/engines/lab/tilepuzzle.cpp
@@ -0,0 +1,388 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+ /*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/lab.h"
+#include "gui/message.h"
+
+namespace Lab {
+
+const uint16 INIT_TILE[4][4] = {
+	{ 1, 5, 9, 13 },
+	{ 2, 6, 10, 14 },
+	{ 3, 7, 11, 15 },
+	{ 4, 8, 12, 0 }
+};
+
+const uint16 SOLUTION[4][4] = {
+	{ 7, 1, 8, 3 },
+	{ 2, 11, 15, 4 },
+	{ 9, 5, 14, 6 },
+	{ 10, 13, 12, 0 }
+};
+
+const int COMBINATION_X[6] = { 45, 83, 129, 166, 211, 248 };
+
+void LabEngine::initTilePuzzle() {
+	for (int i = 0; i < 16; i++)
+		Tiles[i] = nullptr;
+
+	for (int i = 0; i < 4; i++) {
+		for (int j = 0; j < 4; j++)
+			CurTile[i][j] = INIT_TILE[i][j];
+	}
+
+	for (int i = 0; i < 6; i++)
+		combination[i] = 0;
+}
+
+/*****************************************************************************/
+/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
+/*****************************************************************************/
+int LabEngine::VGAUnScaleX(int x) {
+	if (_isHiRes)
+		return (x / 2);
+	else
+		return x;
+}
+
+/*****************************************************************************/
+/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
+/*****************************************************************************/
+int LabEngine::VGAUnScaleY(int y) {
+	if (_isHiRes)
+		return ((y * 5) / 12);
+	else
+		return y;
+}
+
+/*****************************************************************************/
+/* Processes mouse clicks and changes the combination.                       */
+/*****************************************************************************/
+void LabEngine::mouseTile(Common::Point pos) {
+	int x = VGAUnScaleX(pos.x);
+	int y = VGAUnScaleY(pos.y);
+
+	if ((x < 101) || (y < 26))
+		return;
+
+	x = (x - 101) / 30;
+	y = (y -  26) / 25;
+
+	if ((x < 4) && (y < 4))
+		changeTile(x, y);
+}
+
+/*****************************************************************************/
+/* Changes the combination number of one of the slots                        */
+/*****************************************************************************/
+void LabEngine::changeTile(uint16 col, uint16 row) {
+	int16 scrolltype = -1;
+
+	if (row > 0) {
+		if (CurTile[col] [row - 1] == 0) {
+			CurTile[col] [row - 1] = CurTile[col] [row];
+			CurTile[col] [row] = 0;
+			scrolltype = DOWNSCROLL;
+		}
+	}
+
+	if (col > 0) {
+		if (CurTile[col - 1] [row] == 0) {
+			CurTile[col - 1] [row] = CurTile[col] [row];
+			CurTile[col] [row] = 0;
+			scrolltype = RIGHTSCROLL;
+		}
+	}
+
+	if (row < 3) {
+		if (CurTile[col] [row + 1] == 0) {
+			CurTile[col] [row + 1] = CurTile[col] [row];
+			CurTile[col] [row] = 0;
+			scrolltype = UPSCROLL;
+		}
+	}
+
+	if (col < 3) {
+		if (CurTile[col + 1] [row] == 0) {
+			CurTile[col + 1] [row] = CurTile[col] [row];
+			CurTile[col] [row] = 0;
+			scrolltype = LEFTSCROLL;
+		}
+	}
+
+	if (scrolltype != -1) {
+		doTileScroll(col, row, scrolltype);
+
+		if (getFeatures() & GF_WINDOWS_TRIAL) {
+			GUI::MessageDialog trialMessage("This puzzle is not available in the trial version of the game");
+			trialMessage.runModal();
+			return;
+		}
+
+		bool check = true;
+		row = 0;
+		col = 0;
+
+		while (row < 4) {
+			while (col < 4) {
+				check = check && (CurTile[row] [col] == SOLUTION[row] [col]);
+				col++;
+			}
+
+			row++;
+			col = 0;
+		}
+
+		if (check) {
+			_conditions->inclElement(BRICKOPEN);  /* unlocked combination */
+			_anim->_doBlack = true;
+			check = _graphics->readPict("p:Up/BDOpen", true);
+		}
+	}
+}
+
+/*****************************************************************************/
+/* Processes mouse clicks and changes the combination.                       */
+/*****************************************************************************/
+void LabEngine::mouseCombination(Common::Point pos) {
+	uint16 number;
+
+	int x = VGAUnScaleX(pos.x);
+	int y = VGAUnScaleY(pos.y);
+
+	if ((y >= 63) && (y <= 99)) {
+		if ((x >= 44) && (x < 83))
+			number = 0;
+		else if (x < 127)
+			number = 1;
+		else if (x < 165)
+			number = 2;
+		else if (x < 210)
+			number = 3;
+		else if (x < 245)
+			number = 4;
+		else if (x < 286)
+			number = 5;
+		else
+			return;
+
+		changeCombination(number);
+	}
+}
+
+/*****************************************************************************/
+/* Draws the images of the combination lock to the display bitmap.           */
+/*****************************************************************************/
+void LabEngine::doTile(bool showsolution) {
+	uint16 row = 0, col = 0, rowm, colm, num;
+	int16 rows, cols;
+
+	if (showsolution) {
+		rowm = _graphics->VGAScaleY(23);
+		colm = _graphics->VGAScaleX(27);
+
+		rows = _graphics->VGAScaleY(31);
+		cols = _graphics->VGAScaleX(105);
+	} else {
+		_graphics->setAPen(0);
+		_graphics->rectFill(_graphics->VGAScaleX(97), _graphics->VGAScaleY(22), _graphics->VGAScaleX(220), _graphics->VGAScaleY(126));
+
+		rowm = _graphics->VGAScaleY(25);
+		colm = _graphics->VGAScaleX(30);
+
+		rows = _graphics->VGAScaleY(25);
+		cols = _graphics->VGAScaleX(100);
+	}
+
+	while (row < 4) {
+		while (col < 4) {
+			if (showsolution)
+				num = SOLUTION[col] [row];
+			else
+				num = CurTile[col] [row];
+
+			if (showsolution || num)
+				Tiles[num]->drawImage(cols + (col * colm), rows + (row * rowm));
+
+			col++;
+		}
+
+		row++;
+		col = 0;
+	}
+}
+
+/*****************************************************************************/
+/* Reads in a backdrop picture.                                              */
+/*****************************************************************************/
+void LabEngine::showTile(const char *filename, bool showsolution) {
+	uint16 start = showsolution ? 0 : 1;
+
+	_anim->_doBlack = true;
+	_anim->_noPalChange = true;
+	_graphics->readPict(filename, true);
+	_anim->_noPalChange = false;
+	_graphics->blackScreen();
+
+	Common::File *tileFile = tileFile = _resource->openDataFile(showsolution ? "P:TileSolution" : "P:Tile");
+
+	for (uint16 curBit = start; curBit < 16; curBit++)
+		Tiles[curBit] = new Image(tileFile);
+
+	delete tileFile;
+
+	doTile(showsolution);
+	setPalette(_anim->_diffPalette, 256);
+}
+
+/*****************************************************************************/
+/* Does the scrolling for the tiles on the tile puzzle.                      */
+/*****************************************************************************/
+void LabEngine::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
+	int16 dX = 0, dY = 0, dx = 0, dy = 0, sx = 0, sy = 0;
+	uint16 last = 0, x1, y1;
+
+	if (scrolltype == LEFTSCROLL) {
+		dX = _graphics->VGAScaleX(5);
+		sx = _graphics->VGAScaleX(5);
+		last = 6;
+	} else if (scrolltype == RIGHTSCROLL) {
+		dX = _graphics->VGAScaleX(-5);
+		dx = _graphics->VGAScaleX(-5);
+		sx = _graphics->VGAScaleX(5);
+		last = 6;
+	} else if (scrolltype == UPSCROLL) {
+		dY = _graphics->VGAScaleY(5);
+		sy = _graphics->VGAScaleY(5);
+		last = 5;
+	} else if (scrolltype == DOWNSCROLL) {
+		dY = _graphics->VGAScaleY(-5);
+		dy = _graphics->VGAScaleY(-5);
+		sy = _graphics->VGAScaleY(5);
+		last = 5;
+	}
+
+	sx += _graphics->SVGACord(2);
+
+	x1 = _graphics->VGAScaleX(100) + (col * _graphics->VGAScaleX(30)) + dx;
+	y1 = _graphics->VGAScaleY(25) + (row * _graphics->VGAScaleY(25)) + dy;
+
+	for (uint16 i = 0; i < last; i++) {
+		waitTOF();
+		scrollRaster(dX, dY, x1, y1, x1 + _graphics->VGAScaleX(28) + sx, y1 + _graphics->VGAScaleY(23) + sy);
+		x1 += dX;
+		y1 += dY;
+	}
+}
+
+/*****************************************************************************/
+/* Changes the combination number of one of the slots                        */
+/*****************************************************************************/
+void LabEngine::changeCombination(uint16 number) {
+	static const int solution[6] = { 0, 4, 0, 8, 7, 2 };
+
+	Image display;
+	uint16 combnum;
+	bool unlocked = true;
+
+	if (combination[number] < 9)
+		(combination[number])++;
+	else
+		combination[number] = 0;
+
+	combnum = combination[number];
+
+	display._imageData = getCurrentDrawingBuffer();
+	display._width     = _screenWidth;
+	display._height    = _screenHeight;
+
+	for (uint16 i = 1; i <= (Images[combnum]->_height / 2); i++) {
+		if (_isHiRes) {
+			if (i & 1)
+				waitTOF();
+		} else
+			waitTOF();
+
+		display._imageData = getCurrentDrawingBuffer();
+
+		scrollDisplayY(2, _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), _graphics->VGAScaleX(COMBINATION_X[number]) + (Images[combnum])->_width - 1, _graphics->VGAScaleY(65) + (Images[combnum])->_height);
+
+		Images[combnum]->blitBitmap(0, (Images[combnum])->_height - (2 * i), &(display), _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), (Images[combnum])->_width, 2, false);
+	}
+
+	for (uint16 i = 0; i < 6; i++)
+		unlocked = (combination[i] == solution[i]) && unlocked;
+
+	if (unlocked)
+		_conditions->inclElement(COMBINATIONUNLOCKED);
+	else
+		_conditions->exclElement(COMBINATIONUNLOCKED);
+}
+
+void LabEngine::scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+	if (dx)
+		scrollDisplayX(dx, x1, y1, x2, y2);
+
+	if (dy)
+		scrollDisplayY(dy, x1, y1, x2, y2);
+}
+
+/*****************************************************************************/
+/* Draws the images of the combination lock to the display bitmap.           */
+/*****************************************************************************/
+void LabEngine::doCombination() {
+	for (uint16 i = 0; i <= 5; i++)
+		Images[combination[i]]->drawImage(_graphics->VGAScaleX(COMBINATION_X[i]), _graphics->VGAScaleY(65));
+}
+
+/*****************************************************************************/
+/* Reads in a backdrop picture.                                              */
+/*****************************************************************************/
+void LabEngine::showCombination(const char *filename) {
+	_anim->_doBlack = true;
+	_anim->_noPalChange = true;
+	_graphics->readPict(filename, true);
+	_anim->_noPalChange = false;
+
+	_graphics->blackScreen();
+
+	Common::File *numFile = _resource->openDataFile("P:Numbers");
+
+	for (uint16 CurBit = 0; CurBit < 10; CurBit++)
+		Images[CurBit] = new Image(numFile);
+
+	delete numFile;
+
+	doCombination();
+
+	setPalette(_anim->_diffPalette, 256);
+}
+
+} // End of namespace Lab


Commit: ab1d9771d28cd70659505b900a07574e70113735
    https://github.com/scummvm/scummvm/commit/ab1d9771d28cd70659505b900a07574e70113735
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:51+01:00

Commit Message:
LAB: Some cleanup of the monitor code

Changed paths:
    engines/lab/special.cpp



diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 69a8aae..6c96d18 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -59,8 +59,7 @@ static bool GotBackImage = false;
 static uint16 monitorPage;
 static const char *TextFileName;
 
-Image *MonButton, *AltMonButton, *MonQuit, *AltMonQuit, *MonBack, *AltMonBack,
-*MonDown, *AltMonDown, *MonUp, *AltMonUp;
+Image *MonButton;
 
 extern uint16 *FadePalette;
 extern BitMap *DispBitMap, *DrawBitMap;
@@ -451,16 +450,6 @@ bool LabEngine::saveRestoreGame() {
 }
 
 /*****************************************************************************/
-/* Makes sure that the buttons are in memory.                                */
-/*****************************************************************************/
-static void getMonImages() {
-	Common::File *buttonFile = g_lab->_resource->openDataFile("P:MonImage");
-	MonButton = new Image(buttonFile);
-	delete buttonFile;
-}
-
-
-/*****************************************************************************/
 /* Draws the text for the monitor.                                           */
 /*****************************************************************************/
 void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) {
@@ -639,7 +628,9 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 	FadePalette = hipal;
 
 	TextFont *monitorFont = _resource->getFont("P:Map.fon");
-	getMonImages();
+	Common::File *buttonFile = g_lab->_resource->openDataFile("P:MonImage");
+	MonButton = new Image(buttonFile);
+	delete buttonFile;
 
 	ntext = _resource->getText(textfile);
 	loadBackPict(background, false);


Commit: 525db01913605f899107bc115fcde418023e700f
    https://github.com/scummvm/scummvm/commit/525db01913605f899107bc115fcde418023e700f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:51+01:00

Commit Message:
LAB: Simplify several calls to flowText() and rectFill()

Changed paths:
    engines/lab/graphics.cpp
    engines/lab/graphics.h
    engines/lab/intro.cpp
    engines/lab/map.cpp
    engines/lab/special.cpp
    engines/lab/tilepuzzle.cpp



diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 88b53ce..8aa5950 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -316,6 +316,19 @@ uint32 DisplayMan::flowText(void *font,      /* the TextAttr pointer */
 	return (str - temp);
 }
 
+uint32 DisplayMan::flowTextScaled(void *font,      /* the TextAttr pointer */
+	int16 spacing,          /* How much vertical spacing between the lines */
+	byte pencolor,         /* pen number to use for text */
+	byte backpen,          /* the background color */
+	bool fillback,                /* Whether to fill the background */
+	bool centerh,                 /* Whether to center the text horizontally */
+	bool centerv,                 /* Whether to center the text vertically */
+	bool output,                  /* Whether to output any text */
+	uint16 x1,               /* Cords */
+	uint16 y1, uint16 x2, uint16 y2, const char *str) {
+	return flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, VGAScaleX(x1), VGAScaleY(y1), VGAScaleX(x2), VGAScaleY(y2), str);
+}
+
 /******************************************************************************/
 /* Calls flowText, but flows it to memory.  Same restrictions as flowText.    */
 /******************************************************************************/
@@ -347,7 +360,7 @@ uint32 DisplayMan::flowTextToMem(Image *destIm, void *font,     /* the TextAttr
 
 void DisplayMan::createBox(uint16 y2) {
 	setAPen(7);                 /* Message box area */
-	rectFill(VGAScaleX(4), VGAScaleY(154), VGAScaleX(315), VGAScaleY(y2 - 2));
+	rectFillScaled(4, 154, 315, y2 - 2);
 
 	setAPen(0);                 /* Box around message area */
 	drawHLine(VGAScaleX(2), VGAScaleY(152), VGAScaleX(317));
@@ -375,7 +388,7 @@ int32 DisplayMan::longDrawMessage(const char *str) {
 	createBox(198);
 	_vm->_event->mouseShow();
 
-	return flowText(_vm->_msgFont, 0, 1, 7, false, true, true, true, VGAScaleX(6), VGAScaleY(155), VGAScaleX(313), VGAScaleY(195), str);
+	return flowTextScaled(_vm->_msgFont, 0, 1, 7, false, true, true, true, 6, 155, 313, 195, str);
 }
 
 void LabEngine::drawStaticMessage(byte index) {
@@ -977,6 +990,10 @@ void DisplayMan::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	}
 }
 
+void DisplayMan::rectFillScaled(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+	rectFill(VGAScaleX(x1), VGAScaleY(y1), VGAScaleX(x2), VGAScaleY(y2));
+}
+
 /*****************************************************************************/
 /* Draws a horizontal line.                                                  */
 /*****************************************************************************/
diff --git a/engines/lab/graphics.h b/engines/lab/graphics.h
index 63523cb..ba3e34c 100644
--- a/engines/lab/graphics.h
+++ b/engines/lab/graphics.h
@@ -71,6 +71,7 @@ public:
 	void drawMessage(const char *str);
 	void setAPen(byte pennum);
 	void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void rectFillScaled(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	/* Window text stuff */
 	uint32 flowText(void *font,				/* the TextAttr pointer */
 					int16 spacing,			/* How much vertical spacing between the lines */
@@ -84,6 +85,18 @@ public:
 					uint16 x2, uint16 y2,
 					const char *text);		/* The text itself */
 
+	uint32 flowTextScaled(void *font,		/* the TextAttr pointer */
+		int16 spacing,			/* How much vertical spacing between the lines */
+		byte pencolor,			/* pen number to use for text */
+		byte backpen,			/* the background color */
+		bool fillback,			/* Whether to fill the background */
+		bool centerh,			/* Whether to center the text horizontally */
+		bool centerv,			/* Whether to center the text vertically */
+		bool output,			/* Whether to output any text */
+		uint16 x1, uint16 y1,	/* Cords */
+		uint16 x2, uint16 y2,
+		const char *text);		/* The text itself */
+
 	uint32 flowTextToMem(Image *destIm,
 					void *font,				/* the TextAttr pointer */
 					int16 spacing,			/* How much vertical spacing between the lines */
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 52a46eb..47897a7 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -105,9 +105,9 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 
 			if (isScreen) {
 				_vm->_graphics->setAPen(7);
-				_vm->_graphics->rectFill(_vm->_graphics->VGAScaleX(10), _vm->_graphics->VGAScaleY(10), _vm->_graphics->VGAScaleX(310), _vm->_graphics->VGAScaleY(190));
+				_vm->_graphics->rectFillScaled(10, 10, 310, 190);
 
-				Drawn = _vm->_graphics->flowText(msgFont, (!_vm->_isHiRes) * -1, 5, 7, false, false, true, true, _vm->_graphics->VGAScaleX(14), _vm->_graphics->VGAScaleY(11), _vm->_graphics->VGAScaleX(306), _vm->_graphics->VGAScaleY(189), (char *)curText);
+				Drawn = _vm->_graphics->flowTextScaled(msgFont, (!_vm->_isHiRes) * -1, 5, 7, false, false, true, true, 14, 11, 306, 189, (char *)curText);
 				fade(true, 0);
 			} else {
 				Drawn = _vm->_graphics->longDrawMessage((char *)curText);
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 4df01ea..51295a8 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -565,10 +565,10 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 	}
 
 	if (sptr)
-		_graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _graphics->VGAScaleX(14), _graphics->VGAScaleY(75), _graphics->VGAScaleX(134), _graphics->VGAScaleY(97), sptr);
+		_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 75, 134, 97, sptr);
 
 	if ((sptr = _rooms[CurMsg]._roomMsg))
-		_graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _graphics->VGAScaleX(14), _graphics->VGAScaleY(148), _graphics->VGAScaleX(134), _graphics->VGAScaleY(186), sptr);
+		_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr);
 
 	if (fadein)
 		fade(true, 0);
@@ -722,8 +722,8 @@ void LabEngine::processMap(uint16 CurRoom) {
 						if ((sptr = _rooms[CurMsg]._roomMsg)) {
 							_event->mouseHide();
 							_graphics->setAPen(3);
-							_graphics->rectFill(_graphics->VGAScaleX(13), _graphics->VGAScaleY(148), _graphics->VGAScaleX(135), _graphics->VGAScaleY(186));
-							_graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _graphics->VGAScaleX(14), _graphics->VGAScaleY(148), _graphics->VGAScaleX(134), _graphics->VGAScaleY(186), sptr);
+							_graphics->rectFillScaled(13, 148, 135, 186);
+							_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr);
 
 							if (Maps[OldMsg].PageNumber == CurFloor)
 								drawRoom(OldMsg, (bool)(OldMsg == CurRoom));
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 6c96d18..76f9c15 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -143,10 +143,10 @@ void doWestPaper() {
 
 	paperFont = g_lab->_resource->getFont("P:Note.fon");
 	ntext = g_lab->_resource->getText("Lab:Rooms/Col1");
-	CharsPrinted = g_lab->_graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, g_lab->_graphics->VGAScaleX(45), g_lab->_graphics->VGAScaleY(y), g_lab->_graphics->VGAScaleX(158), g_lab->_graphics->VGAScaleY(148), ntext);
+	CharsPrinted = g_lab->_graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 45, y, 158, 148, ntext);
 	delete[] ntext;
 	ntext = g_lab->_resource->getText("Lab:Rooms/Col2");
-	CharsPrinted = g_lab->_graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, g_lab->_graphics->VGAScaleX(162), g_lab->_graphics->VGAScaleY(y), g_lab->_graphics->VGAScaleX(275), g_lab->_graphics->VGAScaleY(148), ntext);
+	CharsPrinted = g_lab->_graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 162, y, 275, 148, ntext);
 	delete[] ntext;
 	closeFont(paperFont);
 
@@ -236,7 +236,7 @@ static void drawJournalText() {
 	while (DrawingToPage < JPage) {
 		g_lab->_music->updateMusic();
 		CurText = (char *)(journaltext + CharsDrawn);
-		CharsDrawn += g_lab->_graphics->flowText(journalFont, -2, 2, 0, false, false, false, false, g_lab->_graphics->VGAScaleX(52), g_lab->_graphics->VGAScaleY(32), g_lab->_graphics->VGAScaleX(152), g_lab->_graphics->VGAScaleY(148), CurText);
+		CharsDrawn += g_lab->_graphics->flowTextScaled(journalFont, -2, 2, 0, false, false, false, false, 52, 32, 152, 148, CurText);
 
 		lastpage = (*CurText == 0);
 
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index a473b0e..137038f 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -212,7 +212,7 @@ void LabEngine::doTile(bool showsolution) {
 		cols = _graphics->VGAScaleX(105);
 	} else {
 		_graphics->setAPen(0);
-		_graphics->rectFill(_graphics->VGAScaleX(97), _graphics->VGAScaleY(22), _graphics->VGAScaleX(220), _graphics->VGAScaleY(126));
+		_graphics->rectFillScaled(97, 22, 220, 126);
 
 		rowm = _graphics->VGAScaleY(25);
 		colm = _graphics->VGAScaleX(30);


Commit: 61d89cb7448f747473cf6a0c474da1b322233fbe
    https://github.com/scummvm/scummvm/commit/61d89cb7448f747473cf6a0c474da1b322233fbe
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:51+01:00

Commit Message:
LAB: Small cleanup in drawMap()

Changed paths:
    engines/lab/map.cpp



diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 51295a8..bef3dd1 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -537,35 +537,10 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 		_graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr);
 	}
 
-	switch (Floor) {
-	case LOWERFLOOR:
-		sptr = (char *)_resource->getStaticText(kTextLowerFloor).c_str();
-		break;
-	case MIDDLEFLOOR:
-		sptr = (char *)_resource->getStaticText(kTextMiddleFloor).c_str();
-		break;
-	case UPPERFLOOR:
-		sptr = (char *)_resource->getStaticText(kTextUpperFloor).c_str();
-		break;
-	case MEDMAZEFLOOR:
-		sptr = (char *)_resource->getStaticText(kTextMedMazeFloor).c_str();
-		break;
-	case HEDGEMAZEFLOOR:
-		sptr = (char *)_resource->getStaticText(kTextHedgeMazeFloor).c_str();
-		break;
-	case SURMAZEFLOOR:
-		sptr = (char *)_resource->getStaticText(kTextSurMazeFloor).c_str();
-		break;
-	case CARNIVAL:
-		sptr = (char *)_resource->getStaticText(kTextCarnivalFloor).c_str();
-		break;
-	default:
-		sptr = NULL;
-		break;
-	}
-
-	if (sptr)
+	if (Floor >= LOWERFLOOR && Floor <= CARNIVAL) {
+		sptr = (char *)_resource->getStaticText(Floor - 1).c_str();
 		_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 75, 134, 97, sptr);
+	}
 
 	if ((sptr = _rooms[CurMsg]._roomMsg))
 		_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr);


Commit: d9d2383d93760da2267170e786987ba91da1fa08
    https://github.com/scummvm/scummvm/commit/d9d2383d93760da2267170e786987ba91da1fa08
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:51+01:00

Commit Message:
LAB: Use the windows keyboard mapping for the other versions

Changed paths:
    engines/lab/graphics.cpp



diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 8aa5950..3ed28d0 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -867,86 +867,56 @@ bool DisplayMan::setUpScreens() {
 	/* Creates the gadgets for the movement control panel */
 	uint16 y = VGAScaleY(173) - SVGACord(2);
 
-	if (_vm->getPlatform() == Common::kPlatformWindows) {
-		_vm->_moveGadgetList = createButton(1, y, 0, 't', _vm->_moveImages[0], _vm->_moveImages[1]);
-		Gadget *curGadget = _vm->_moveGadgetList;
-		curGadget->NextGadget = createButton(33, y, 1, 'm', _vm->_moveImages[2], _vm->_moveImages[3]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(65, y, 2, 'o', _vm->_moveImages[4], _vm->_moveImages[5]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(97, y, 3, 'c', _vm->_moveImages[6], _vm->_moveImages[7]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(129, y, 4, 'l', _vm->_moveImages[8], _vm->_moveImages[9]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(161, y, 5, 'i', _vm->_moveImages[12], _vm->_moveImages[13]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(193, y, 6, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(225, y, 7, VKEY_UPARROW, _vm->_moveImages[16], _vm->_moveImages[17]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(257, y, 8, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(289, y, 9, 'p', _vm->_moveImages[10], _vm->_moveImages[11]);
-	} else {
-		_vm->_moveGadgetList = createButton(1, y, 0, 0, _vm->_moveImages[0], _vm->_moveImages[1]);
-		Gadget *curGadget = _vm->_moveGadgetList;
-		curGadget->NextGadget = createButton(33, y, 1, 0, _vm->_moveImages[2], _vm->_moveImages[3]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(65, y, 2, 0, _vm->_moveImages[4], _vm->_moveImages[5]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(97, y, 3, 0, _vm->_moveImages[6], _vm->_moveImages[7]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(129, y, 4, 0, _vm->_moveImages[8], _vm->_moveImages[9]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(161, y, 5, 0, _vm->_moveImages[12], _vm->_moveImages[13]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(193, y, 6, 0, _vm->_moveImages[14], _vm->_moveImages[15]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(225, y, 7, 0, _vm->_moveImages[16], _vm->_moveImages[17]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(257, y, 8, 0, _vm->_moveImages[18], _vm->_moveImages[19]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(289, y, 9, 0, _vm->_moveImages[10], _vm->_moveImages[11]);
-	}
+	// The key mapping was only set for the Windows version.
+	// It's very convenient to have those shortcut, so I added them
+	// for all versions. (Strangerke)
+	_vm->_moveGadgetList = createButton(1, y, 0, 't', _vm->_moveImages[0], _vm->_moveImages[1]);
+	Gadget *curGadget = _vm->_moveGadgetList;
+	curGadget->NextGadget = createButton(33, y, 1, 'm', _vm->_moveImages[2], _vm->_moveImages[3]);
+	curGadget = curGadget->NextGadget;
+	curGadget->NextGadget = createButton(65, y, 2, 'o', _vm->_moveImages[4], _vm->_moveImages[5]);
+	curGadget = curGadget->NextGadget;
+	curGadget->NextGadget = createButton(97, y, 3, 'c', _vm->_moveImages[6], _vm->_moveImages[7]);
+	curGadget = curGadget->NextGadget;
+	curGadget->NextGadget = createButton(129, y, 4, 'l', _vm->_moveImages[8], _vm->_moveImages[9]);
+	curGadget = curGadget->NextGadget;
+	curGadget->NextGadget = createButton(161, y, 5, 'i', _vm->_moveImages[12], _vm->_moveImages[13]);
+	curGadget = curGadget->NextGadget;
+	curGadget->NextGadget = createButton(193, y, 6, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]);
+	curGadget = curGadget->NextGadget;
+	curGadget->NextGadget = createButton(225, y, 7, VKEY_UPARROW, _vm->_moveImages[16], _vm->_moveImages[17]);
+	curGadget = curGadget->NextGadget;
+	curGadget->NextGadget = createButton(257, y, 8, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]);
+	curGadget = curGadget->NextGadget;
+	curGadget->NextGadget = createButton(289, y, 9, 'p', _vm->_moveImages[10], _vm->_moveImages[11]);
 
 	Common::File *invFile = _vm->_resource->openDataFile("P:Inv");
-
 	if (_vm->getPlatform() == Common::kPlatformWindows) {
 		for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++)
 			_vm->_invImages[imgIdx] = new Image(invFile);
-
-		_vm->_invGadgetList = createButton(24, y, 0, 'm', _vm->_invImages[0], _vm->_invImages[1]);
-		Gadget *curGadget = _vm->_invGadgetList;
-		curGadget->NextGadget = createButton(56, y, 1, 'g', _vm->_invImages[2], _vm->_invImages[3]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(94, y, 2, 'u', _vm->_invImages[4], _vm->_invImages[5]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(126, y, 3, 'l', _vm->_moveImages[8], _vm->_moveImages[9]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(164, y, 4, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(196, y, 5, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(234, y, 6, 'b', _vm->_invImages[6], _vm->_invImages[7]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(266, y, 7, 'f', _vm->_invImages[8], _vm->_invImages[9]);
-		curGadget = curGadget->NextGadget;
 	} else {
 		for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++)
 			_vm->_invImages[imgIdx] = new Image(invFile);
-
-		_vm->_invGadgetList = createButton(58, y, 0, 0, _vm->_invImages[0], _vm->_invImages[1]);
-		Gadget *curGadget = _vm->_invGadgetList;
-		curGadget->NextGadget = createButton(90, y, 1, 0, _vm->_invImages[2], _vm->_invImages[3]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(128, y, 2, 0, _vm->_invImages[4], _vm->_invImages[5]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(160, y, 3, 0, _vm->_moveImages[8], _vm->_moveImages[9]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(198, y, 4, 0, _vm->_moveImages[14], _vm->_moveImages[15]);
+	}
+	_vm->_invGadgetList = createButton(24, y, 0, 'm', _vm->_invImages[0], _vm->_invImages[1]);
+	curGadget = _vm->_invGadgetList;
+	curGadget->NextGadget = createButton(56, y, 1, 'g', _vm->_invImages[2], _vm->_invImages[3]);
+	curGadget = curGadget->NextGadget;
+	curGadget->NextGadget = createButton(94, y, 2, 'u', _vm->_invImages[4], _vm->_invImages[5]);
+	curGadget = curGadget->NextGadget;
+	curGadget->NextGadget = createButton(126, y, 3, 'l', _vm->_moveImages[8], _vm->_moveImages[9]);
+	curGadget = curGadget->NextGadget;
+	curGadget->NextGadget = createButton(164, y, 4, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]);
+	curGadget = curGadget->NextGadget;
+	curGadget->NextGadget = createButton(196, y, 5, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]);
+
+	// The windows version has 2 extra gadgets for breadcrumb trail
+	// TODO: the game is really hard to play without those, maybe we could add something to enable that.
+	if (_vm->getPlatform() == Common::kPlatformWindows) {
 		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(230, y, 5, 0, _vm->_moveImages[18], _vm->_moveImages[19]);
+		curGadget->NextGadget = createButton(234, y, 6, 'b', _vm->_invImages[6], _vm->_invImages[7]);
 		curGadget = curGadget->NextGadget;
+		curGadget->NextGadget = createButton(266, y, 7, 'f', _vm->_invImages[8], _vm->_invImages[9]);
 	}
 
 	delete invFile;


Commit: ef99d82d13fdbfcaedd8e5fdea243ba3740c5185
    https://github.com/scummvm/scummvm/commit/ef99d82d13fdbfcaedd8e5fdea243ba3740c5185
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:51+01:00

Commit Message:
LAB: Move more functions to DisplayMan

Changed paths:
    engines/lab/anim.cpp
    engines/lab/engine.cpp
    engines/lab/eventman.cpp
    engines/lab/graphics.cpp
    engines/lab/graphics.h
    engines/lab/image.cpp
    engines/lab/interface.cpp
    engines/lab/intro.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/labfun.h
    engines/lab/map.cpp
    engines/lab/processroom.cpp
    engines/lab/special.cpp
    engines/lab/text.cpp
    engines/lab/tilepuzzle.cpp
    engines/lab/vga.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index f7770ad..edf677b 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -424,7 +424,7 @@ void Anim::diffNextFrame() {
 		return;
 
 	if (DispBitMap->_flags & BITMAPF_VIDEO) {
-		DispBitMap->_planes[0] = _vm->getCurrentDrawingBuffer();
+		DispBitMap->_planes[0] = _vm->_graphics->getCurrentDrawingBuffer();
 		DispBitMap->_planes[1] = DispBitMap->_planes[0] + 0x10000;
 		DispBitMap->_planes[2] = DispBitMap->_planes[1] + 0x10000;
 		DispBitMap->_planes[3] = DispBitMap->_planes[2] + 0x10000;
@@ -444,7 +444,7 @@ void Anim::diffNextFrame() {
 				}
 
 				if (_isPal && !_noPalChange) {
-					_vm->setPalette(_diffPalette, 256);
+					_vm->_graphics->setPalette(_diffPalette, 256);
 					_isPal = false;
 				}
 
@@ -452,7 +452,7 @@ void Anim::diffNextFrame() {
 			}
 
 			if (_isPal && !_noPalChange && !_isBM && !_donePal) {
-				_vm->setPalette(_diffPalette, 256);
+				_vm->_graphics->setPalette(_diffPalette, 256);
 				_isPal = false;
 			}
 
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index b6e6f72..a986807 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -296,7 +296,7 @@ bool LabEngine::doUse(uint16 CurInv) {
 		_curFileName = " ";
 		_cptr = NULL;
 		doMap(_roomNum);
-		setPalette(initcolors, 8);
+		_graphics->setPalette(initcolors, 8);
 		_graphics->drawMessage(NULL);
 		_graphics->drawPanel();
 	} else if (CurInv == JOURNALNUM) {         /* LAB: Labyrinth specific */
@@ -400,7 +400,7 @@ void LabEngine::mainGameLoop() {
 
 	bool forceDraw = false, GotMessage = true;
 
-	setPalette(initcolors, 8);
+	_graphics->setPalette(initcolors, 8);
 
 	_cptr    = NULL;
 	_roomNum = 1;
@@ -843,14 +843,10 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 			if (doit) {
 				_graphics->drawMessage("Disk operation failed.");
-				setPalette(initcolors, 8);
-
-				_graphics->screenUpdate();
-
+				_graphics->setPalette(initcolors, 8);
 				g_system->delayMillis(1000);
-			} else {
-				_graphics->screenUpdate();
 			}
+			_graphics->screenUpdate();
 		} else if (gadgetId == 1) {
 			if (!doUse(curInv)) {
 				Old        = actionMode;
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 6b73de7..0b3f71e 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -299,8 +299,9 @@ void EventManager::processInput(bool can_delay) {
 					_mousePos.x = 0;
 					_mouseAtEdge = true;
 				}
-				if (_mousePos.x > _vm->_screenWidth - 1) {
-					_mousePos.x = _vm->_screenWidth;
+
+				if (_mousePos.x >= _vm->_graphics->_screenWidth) {
+					_mousePos.x = _vm->_graphics->_screenWidth;
 					_mouseAtEdge = true;
 				}
 
@@ -309,8 +310,9 @@ void EventManager::processInput(bool can_delay) {
 					_mousePos.y = 0;
 					_mouseAtEdge = true;
 				}
-				if (_mousePos.y > _vm->_screenHeight - 1) {
-					_mousePos.y = _vm->_screenHeight;
+
+				if (_mousePos.y >= _vm->_graphics->_screenHeight) {
+					_mousePos.y = _vm->_graphics->_screenHeight;
 					_mouseAtEdge = true;
 				}
 
@@ -350,7 +352,7 @@ void EventManager::processInput(bool can_delay) {
 				break;
 			}
 
-			g_system->copyRectToScreen(_vm->_displayBuffer, _vm->_screenWidth, 0, 0, _vm->_screenWidth, _vm->_screenHeight);
+			g_system->copyRectToScreen(_vm->_graphics->_displayBuffer, _vm->_graphics->_screenWidth, 0, 0, _vm->_graphics->_screenWidth, _vm->_graphics->_screenHeight);
 			g_system->updateScreen();
 		}
 	}
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 3ed28d0..a10512d 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -48,7 +48,16 @@ DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) {
 
 	_screenBytesPerPage = 65536;
 	_curapen = 0;
-	_curBitmap = NULL;
+	_curBitmap = nullptr;
+	_displayBuffer = nullptr;
+	_currentDisplayBuffer = nullptr;
+	_tempScrollData = nullptr;
+
+	_screenWidth = 0;
+	_screenHeight = 0;
+
+	for (int i = 0; i < 256 * 3; i++)
+		_curvgapal[i] = 0;
 }
 
 DisplayMan::~DisplayMan() {
@@ -129,8 +138,8 @@ bool DisplayMan::readPict(const char *filename, bool playOnce) {
 	if (!_vm->_music->_doNotFilestopSoundEffect)
 		_vm->_music->stopSoundEffect();
 
-	DispBitMap->_bytesPerRow = _vm->_screenWidth;
-	DispBitMap->_rows        = _vm->_screenHeight;
+	DispBitMap->_bytesPerRow = _screenWidth;
+	DispBitMap->_rows        = _screenHeight;
 	DispBitMap->_flags       = BITMAPF_VIDEO;
 
 	_vm->_anim->readDiff(_curBitmap, playOnce);
@@ -343,15 +352,15 @@ uint32 DisplayMan::flowTextToMem(Image *destIm, void *font,     /* the TextAttr
                      uint16 x1,               /* Cords */
                      uint16 y1, uint16 x2, uint16 y2, const char *str) { /* The text itself */
 	uint32 res, vgabyte = _screenBytesPerPage;
-	byte *tmp = _vm->_currentDisplayBuffer;
+	byte *tmp = _currentDisplayBuffer;
 
-	_vm->_currentDisplayBuffer = destIm->_imageData;
+	_currentDisplayBuffer = destIm->_imageData;
 	_screenBytesPerPage = (uint32)destIm->_width * (int32)destIm->_height;
 
-	res = _vm->_graphics->flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str);
+	res = flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str);
 
 	_screenBytesPerPage = vgabyte;
-	_vm->_currentDisplayBuffer = tmp;
+	_currentDisplayBuffer = tmp;
 
 	return res;
 }
@@ -391,10 +400,6 @@ int32 DisplayMan::longDrawMessage(const char *str) {
 	return flowTextScaled(_vm->_msgFont, 0, 1, 7, false, true, true, true, 6, 155, 313, 195, str);
 }
 
-void LabEngine::drawStaticMessage(byte index) {
-	_graphics->drawMessage(_resource->getStaticText((StaticText)index).c_str());
-}
-
 /******************************************************************************/
 /* Draws a message to the message box.                                        */
 /******************************************************************************/
@@ -442,7 +447,7 @@ void DisplayMan::doScrollBlack() {
 	byte *tempmem;
 	Image im;
 	uint32 size, copysize;
-	uint32 *baseAddr;
+	byte *baseAddr;
 	uint16 width = VGAScaleX(320);
 	uint16 height = VGAScaleY(149) + SVGACord(2);
 	byte *mem = new byte[width * height];
@@ -456,7 +461,7 @@ void DisplayMan::doScrollBlack() {
 	im.readScreenImage(0, 0);
 	_vm->_music->updateMusic();
 
-	baseAddr = (uint32 *)_vm->getCurrentDrawingBuffer();
+	baseAddr = getCurrentDrawingBuffer();
 
 	uint16 by      = VGAScaleX(4);
 	uint16 nheight = height;
@@ -467,7 +472,7 @@ void DisplayMan::doScrollBlack() {
 		if (!_vm->_isHiRes)
 			_vm->waitTOF();
 
-		baseAddr = (uint32 *)_vm->getCurrentDrawingBuffer();
+		baseAddr = getCurrentDrawingBuffer();
 
 		if (by > nheight)
 			by = nheight;
@@ -510,20 +515,17 @@ void DisplayMan::doScrollBlack() {
 }
 
 void DisplayMan::copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem) {
-	uint32 size, offSet, copysize;
-	uint16 curPage;
-	uint32 *baseAddr;
+	byte *baseAddr = getCurrentDrawingBuffer();
 
-	baseAddr = (uint32 *)_vm->getCurrentDrawingBuffer();
-
-	size = (int32)(height - nheight) * (int32)width;
+	uint32 size = (int32)(height - nheight) * (int32)width;
 	mem += startline * width;
-	curPage = ((int32)nheight * (int32)width) / _vm->_graphics->_screenBytesPerPage;
-	offSet = ((int32)nheight * (int32)width) - (curPage * _vm->_graphics->_screenBytesPerPage);
+	uint16 curPage = ((int32)nheight * (int32)width) / _screenBytesPerPage;
+	uint32 offSet = ((int32)nheight * (int32)width) - (curPage * _screenBytesPerPage);
 
 	while (size) {
-		if (size > (_vm->_graphics->_screenBytesPerPage - offSet))
-			copysize = _vm->_graphics->_screenBytesPerPage - offSet;
+		uint32 copysize;
+		if (size > (_screenBytesPerPage - offSet))
+			copysize = _screenBytesPerPage - offSet;
 		else
 			copysize = size;
 
@@ -553,7 +555,7 @@ void DisplayMan::doScrollWipe(char *filename) {
 
 	_vm->_anim->_isBM = true;
 	readPict(filename, true);
-	_vm->setPalette(_vm->_anim->_diffPalette, 256);
+	setPalette(_vm->_anim->_diffPalette, 256);
 	_vm->_anim->_isBM = false;
 	byte *mem = _vm->_anim->_rawDiffBM._planes[0];
 
@@ -664,7 +666,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 				linesdone = 0;
 			}
 
-			_vm->overlayRect(0, 0, curY, _vm->_screenWidth - 1, curY + 1);
+			overlayRect(0, 0, curY, _screenWidth - 1, curY + 1);
 			curY += 4;
 			linesdone++;
 		}
@@ -682,7 +684,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 				linesdone = 0;
 			}
 
-			rectFill(0, curY, _vm->_screenWidth - 1, curY + 1);
+			rectFill(0, curY, _screenWidth - 1, curY + 1);
 			curY += 4;
 			linesdone++;
 		}
@@ -695,17 +697,17 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 	else
 		_vm->_curFileName = getPictName(cPtr);
 
-	byte *BitMapMem = readPictToMem(_vm->_curFileName, _vm->_screenWidth, lastY + 5);
-	_vm->setPalette(_vm->_anim->_diffPalette, 256);
+	byte *BitMapMem = readPictToMem(_vm->_curFileName, _screenWidth, lastY + 5);
+	setPalette(_vm->_anim->_diffPalette, 256);
 
 	if (BitMapMem) {
-		imSource._width = _vm->_screenWidth;
+		imSource._width = _screenWidth;
 		imSource._height = lastY;
 		imSource._imageData = BitMapMem;
 
-		imDest._width = _vm->_screenWidth;
-		imDest._height = _vm->_screenHeight;
-		imDest._imageData = _vm->getCurrentDrawingBuffer();
+		imDest._width = _screenWidth;
+		imDest._height = _screenHeight;
+		imDest._imageData = getCurrentDrawingBuffer();
 
 		for (uint16 i = 0; i < 2; i++) {
 			curY = i * 2;
@@ -717,10 +719,10 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 					linesdone = 0;
 				}
 
-				imDest._imageData = _vm->getCurrentDrawingBuffer();
+				imDest._imageData = getCurrentDrawingBuffer();
 
-				imSource.blitBitmap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 2, false);
-				_vm->overlayRect(0, 0, curY, _vm->_screenWidth - 1, curY + 1);
+				imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, 2, false);
+				overlayRect(0, 0, curY, _screenWidth - 1, curY + 1);
 				curY += 4;
 				linesdone++;
 			}
@@ -736,12 +738,12 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 					linesdone = 0;
 				}
 
-				imDest._imageData = _vm->getCurrentDrawingBuffer();
+				imDest._imageData = getCurrentDrawingBuffer();
 
 				if (curY == lastY)
-					imSource.blitBitmap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 1, false);
+					imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, 1, false);
 				else
-					imSource.blitBitmap(0, curY, &imDest, 0, curY, _vm->_screenWidth, 2, false);
+					imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, 2, false);
 
 				curY += 4;
 				linesdone++;
@@ -774,7 +776,7 @@ void DisplayMan::doWipe(uint16 wipeType, CloseDataPtr *cPtr, char *filename) {
 void DisplayMan::blackScreen() {
 	byte pal[256 * 3];
 	memset(pal, 0, 248 * 3);
-	_vm->writeColorRegs(pal, 8, 248);
+	writeColorRegs(pal, 8, 248);
 
 	g_system->delayMillis(32);
 }
@@ -785,7 +787,7 @@ void DisplayMan::blackScreen() {
 void DisplayMan::whiteScreen() {
 	byte pal[256 * 3];
 	memset(pal, 255, 248 * 3);
-	_vm->writeColorRegs(pal, 8, 248);
+	writeColorRegs(pal, 8, 248);
 }
 
 /*****************************************************************************/
@@ -794,7 +796,7 @@ void DisplayMan::whiteScreen() {
 void DisplayMan::blackAllScreen() {
 	byte pal[256 * 3];
 	memset(pal, 0, 256 * 3);
-	_vm->writeColorRegs(pal, 0, 256);
+	writeColorRegs(pal, 0, 256);
 
 	g_system->delayMillis(32);
 }
@@ -938,14 +940,14 @@ void DisplayMan::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	int w = x2 - x1 + 1;
 	int h = y2 - y1 + 1;
 
-	if (x1 + w > _vm->_screenWidth)
-		w = _vm->_screenWidth - x1;
+	if (x1 + w > _screenWidth)
+		w = _screenWidth - x1;
 
-	if (y1 + h > _vm->_screenHeight)
-		h = _vm->_screenHeight - y1;
+	if (y1 + h > _screenHeight)
+		h = _screenHeight - y1;
 
 	if ((w > 0) && (h > 0)) {
-		char *d = (char *)_vm->getCurrentDrawingBuffer() + y1 * _vm->_screenWidth + x1;
+		char *d = (char *)getCurrentDrawingBuffer() + y1 * _screenWidth + x1;
 
 		while (h-- > 0) {
 			char *dd = d;
@@ -955,7 +957,7 @@ void DisplayMan::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 				*dd++ = _curapen;
 			}
 
-			d += _vm->_screenWidth;
+			d += _screenWidth;
 		}
 	}
 }
@@ -979,7 +981,7 @@ void DisplayMan::drawHLine(uint16 x1, uint16 y, uint16 x2) {
 }
 
 void DisplayMan::screenUpdate() {
-	g_system->copyRectToScreen(_vm->_displayBuffer, _vm->_screenWidth, 0, 0, _vm->_screenWidth, _vm->_screenHeight);
+	g_system->copyRectToScreen(_displayBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight);
 	g_system->updateScreen();
 
 	_vm->_event->processInput();
@@ -990,17 +992,176 @@ void DisplayMan::screenUpdate() {
 /*****************************************************************************/
 bool DisplayMan::createScreen(bool hiRes) {
 	if (hiRes) {
-		_vm->_screenWidth  = 640;
-		_vm->_screenHeight = 480;
+		_screenWidth  = 640;
+		_screenHeight = 480;
 	} else {
-		_vm->_screenWidth  = 320;
-		_vm->_screenHeight = 200;
+		_screenWidth  = 320;
+		_screenHeight = 200;
 	}
-	_screenBytesPerPage = _vm->_screenWidth * _vm->_screenHeight;
-
-	_vm->_displayBuffer = new byte[_screenBytesPerPage];	// FIXME: Memory leak!
+	_screenBytesPerPage = _screenWidth * _screenHeight;
+	_displayBuffer = new byte[_screenBytesPerPage];	// FIXME: Memory leak!
 
 	return true;
 }
 
+/*****************************************************************************/
+/* Converts an Amiga palette (up to 16 colors) to a VGA palette, then sets   */
+/* the VGA palette.                                                          */
+/*****************************************************************************/
+void DisplayMan::setAmigaPal(uint16 *pal, uint16 numColors) {
+	byte vgaPal[16 * 3];
+	uint16 vgaIdx = 0;
+
+	if (numColors > 16)
+		numColors = 16;
+
+	for (uint16 i = 0; i < numColors; i++) {
+		vgaPal[vgaIdx++] = (byte)(((pal[i] & 0xf00) >> 8) << 2);
+		vgaPal[vgaIdx++] = (byte)(((pal[i] & 0x0f0) >> 4) << 2);
+		vgaPal[vgaIdx++] = (byte)(((pal[i] & 0x00f)) << 2);
+	}
+
+	writeColorRegs(vgaPal, 0, 16);
+	_vm->waitTOF();
+}
+
+/*****************************************************************************/
+/* Writes any number of the 256 color registers.                             */
+/* first:    the number of the first color register to write.                */
+/* numreg:   the number of registers to write                                */
+/* buf:      a char pointer which contains the selected color registers.     */
+/*           Each value representing a color register occupies 3 bytes in    */
+/*           the array.  The order is red, green then blue.  The first byte  */
+/*           in the array is the red component of the first element selected.*/
+/*           The length of the buffer is 3 times the number of registers     */
+/*           selected.                                                       */
+/*****************************************************************************/
+void DisplayMan::writeColorRegs(byte *buf, uint16 first, uint16 numreg) {
+	byte tmp[256 * 3];
+
+	for (int i = 0; i < 256 * 3; i++) {
+		tmp[i] = buf[i] * 4;
+	}
+
+	g_system->getPaletteManager()->setPalette(tmp, first, numreg);
+
+	memcpy(&(_curvgapal[first * 3]), buf, numreg * 3);
+}
+
+void DisplayMan::setPalette(void *cmap, uint16 numcolors) {
+	if (memcmp(cmap, _curvgapal, numcolors * 3) != 0)
+		writeColorRegs((byte *)cmap, 0, numcolors);
+}
+
+/*****************************************************************************/
+/* Returns the base address of the current VGA display.                      */
+/*****************************************************************************/
+byte *DisplayMan::getCurrentDrawingBuffer() {
+	if (_currentDisplayBuffer)
+		return _currentDisplayBuffer;
+
+	return _displayBuffer;
+}
+
+/*****************************************************************************/
+/* Overlays a region on the screen using the desired pen color.              */
+/*****************************************************************************/
+void DisplayMan::overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+	int w = x2 - x1 + 1;
+	int h = y2 - y1 + 1;
+
+	if (x1 + w > _screenWidth)
+		w = _screenWidth - x1;
+
+	if (y1 + h > _screenHeight)
+		h = _screenHeight - y1;
+
+	if ((w > 0) && (h > 0)) {
+		char *d = (char *)getCurrentDrawingBuffer() + y1 * _screenWidth + x1;
+
+		while (h-- > 0) {
+			char *dd = d;
+			int ww = w;
+
+			if (y1 & 1) {
+				dd++;
+				ww--;
+			}
+
+			while (ww > 0) {
+				*dd = pencolor;
+				dd += 2;
+				ww -= 2;
+			}
+
+			d += _screenWidth;
+			y1++;
+		}
+	}
+}
+
+/*****************************************************************************/
+/* Scrolls the display in the x direction by blitting.                       */
+/* The _tempScrollData variable must be initialized to some memory, or this   */
+/* function will fail.                                                       */
+/*****************************************************************************/
+void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+	Image im;
+	uint16 temp;
+
+	im._imageData = _tempScrollData;
+
+	if (x1 > x2) {
+		temp = x2;
+		x2 = x1;
+		x1 = temp;
+	}
+
+	if (y1 > y2) {
+		temp = y2;
+		y2 = y1;
+		y1 = temp;
+	}
+
+	im._width = x2 - x1 + 1 - dx;
+	im._height = y2 - y1 + 1;
+
+	im.readScreenImage(x1, y1);
+	im.drawImage(x1 + dx, y1);
+
+	setAPen(0);
+	rectFill(x1, y1, x1 + dx - 1, y2);
+}
+
+/*****************************************************************************/
+/* Scrolls the display in the y direction by blitting.                       */
+/*****************************************************************************/
+void DisplayMan::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+	Image im;
+	uint16 temp;
+
+	im._imageData = _tempScrollData;
+
+	if (x1 > x2) {
+		temp = x2;
+		x2 = x1;
+		x1 = temp;
+	}
+
+	if (y1 > y2) {
+		temp = y2;
+		y2 = y1;
+		y1 = temp;
+	}
+
+	im._width = x2 - x1 + 1;
+	im._height = y2 - y1 + 1 - dy;
+
+	im.readScreenImage(x1, y1);
+	im.drawImage(x1, y1 + dy);
+
+	setAPen(0);
+	rectFill(x1, y1, x2, y1 + dy - 1);
+}
+
 } // End of namespace Lab
diff --git a/engines/lab/graphics.h b/engines/lab/graphics.h
index ba3e34c..4a69a59 100644
--- a/engines/lab/graphics.h
+++ b/engines/lab/graphics.h
@@ -31,6 +31,8 @@
 #ifndef LAB_GRAPHICS_H
 #define LAB_GRAPHICS_H
 
+#include "graphics/palette.h"
+
 namespace Lab {
 
 class LabEngine;
@@ -41,6 +43,8 @@ private:
 
 	byte _curapen;
 	byte *_curBitmap;
+	byte _curvgapal[256 * 3];
+	byte *_tempScrollData;
 
 public:
 	DisplayMan(LabEngine *lab);
@@ -114,10 +118,21 @@ public:
 	void drawVLine(uint16 x1, uint16 y, uint16 x2);
 	void screenUpdate();
 	bool createScreen(bool HiRes);
+	void setAmigaPal(uint16 *pal, uint16 numColors);
+	void writeColorRegs(byte *buf, uint16 first, uint16 numreg);
+	void setPalette(void *cmap, uint16 numcolors);
+	void overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	byte *getCurrentDrawingBuffer();
+	void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 
 	bool _longWinInFront;
 	bool _lastMessageLong;
 	uint32 _screenBytesPerPage;
+	int _screenWidth;
+	int _screenHeight;
+	byte *_displayBuffer;
+	byte *_currentDisplayBuffer;
 };
 
 } // End of namespace Lab
diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp
index 45377ac..ab63e96 100644
--- a/engines/lab/image.cpp
+++ b/engines/lab/image.cpp
@@ -56,9 +56,9 @@ void Image::blitBitmap(uint16 xs, uint16 ys, Image *imDest,
 	uint16 xd, uint16 yd, uint16 width, uint16 height, byte masked) {
 	int w = width;
 	int h = height;
-	int destWidth = (imDest) ? imDest->_width : g_lab->_screenWidth;
-	int destHeight = (imDest) ? imDest->_height : g_lab->_screenHeight;
-	byte *destBuffer = (imDest) ? imDest->_imageData : g_lab->getCurrentDrawingBuffer();
+	int destWidth = (imDest) ? imDest->_width : g_lab->_graphics->_screenWidth;
+	int destHeight = (imDest) ? imDest->_height : g_lab->_graphics->_screenHeight;
+	byte *destBuffer = (imDest) ? imDest->_imageData : g_lab->_graphics->getCurrentDrawingBuffer();
 
 	if (xd + w > destWidth)
 		w = destWidth - xd;
@@ -117,20 +117,20 @@ void Image::readScreenImage(uint16 x, uint16 y) {
 	int w = _width;
 	int h = _height;
 
-	if (x + w > g_lab->_screenWidth)
-		w = g_lab->_screenWidth - x;
+	if (x + w > g_lab->_graphics->_screenWidth)
+		w = g_lab->_graphics->_screenWidth - x;
 
-	if (y + h > g_lab->_screenHeight)
-		h = g_lab->_screenHeight - y;
+	if (y + h > g_lab->_graphics->_screenHeight)
+		h = g_lab->_graphics->_screenHeight - y;
 
 	if ((w > 0) && (h > 0)) {
 		byte *s = _imageData;
-		byte *d = g_lab->getCurrentDrawingBuffer() + y * g_lab->_screenWidth + x;
+		byte *d = g_lab->_graphics->getCurrentDrawingBuffer() + y * g_lab->_graphics->_screenWidth + x;
 
 		while (h-- > 0) {
 			memcpy(s, d, w);
 			s += _width;
-			d += g_lab->_screenWidth;
+			d += g_lab->_graphics->_screenWidth;
 		}
 	}
 }
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 30aa547..61cfc6c 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -95,7 +95,7 @@ void drawGadgetList(Gadget *gadlist) {
 /* Dims a gadget, and makes it unavailable for using.                        */
 /*****************************************************************************/
 void disableGadget(Gadget *curgad, uint16 pencolor) {
-	g_lab->overlayRect(pencolor, curgad->x, curgad->y, curgad->x + curgad->_image->_width - 1, curgad->y + curgad->_image->_height - 1);
+	g_lab->_graphics->overlayRect(pencolor, curgad->x, curgad->y, curgad->x + curgad->_image->_width - 1, curgad->y + curgad->_image->_height - 1);
 	curgad->GadgetFlags |= GADGETOFF;
 }
 
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 47897a7..0313733 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -299,7 +299,7 @@ void Intro::introSequence() {
 
 		palette[15] = temp;
 
-		setAmigaPal(palette, 16);
+		_vm->_graphics->setAmigaPal(palette, 16);
 		_vm->waitTOF();
 	}
 
@@ -382,7 +382,7 @@ void Intro::introSequence() {
 
 			_vm->_music->updateMusic();
 			_vm->waitTOF();
-			_vm->setPalette(_vm->_anim->_diffPalette, 256);
+			_vm->_graphics->setPalette(_vm->_anim->_diffPalette, 256);
 			_vm->waitTOF();
 			_vm->waitTOF();
 		}
@@ -442,7 +442,7 @@ void Intro::introSequence() {
 
 	if (_quitIntro) {
 		_vm->_graphics->setAPen(0);
-		_vm->_graphics->rectFill(0, 0, _vm->_screenWidth - 1, _vm->_screenHeight - 1);
+		_vm->_graphics->rectFill(0, 0, _vm->_graphics->_screenWidth - 1, _vm->_graphics->_screenHeight - 1);
 		_vm->_anim->_doBlack = true;
 	}
 
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index acd1ea9..1e15845 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -55,12 +55,6 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
  : Engine(syst), _gameDescription(gameDesc), _extraGameFeatures(0) {
 	g_lab = this;
 
-	_screenWidth = 320;
-	_screenHeight = 200;
-
-	_currentDisplayBuffer = 0;
-	_displayBuffer = 0;
-
 	_lastWaitTOFTicks = 0;
 
 	_isHiRes = false;
@@ -185,4 +179,8 @@ Common::String LabEngine::generateSaveFileName(uint slot) {
 	return Common::String::format("%s.%03u", _targetName.c_str(), slot);
 }
 
+void LabEngine::drawStaticMessage(byte index) {
+	_graphics->drawMessage(_resource->getStaticText((StaticText)index).c_str());
+}
+
 } // End of namespace Lab
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 01dcaa0..b917da7 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -75,13 +75,8 @@ public:
 	bool hasFeature(EngineFeature f) const;
 	Common::String generateSaveFileName(uint slot);
 
-	//void showMainMenu();
-
 	LargeSet *_conditions, *_roomsFound;
 
-	int _screenWidth;
-	int _screenHeight;
-
 	// timing.cpp
 	void getTime(uint32 *secs, uint32 *micros);
 	void addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *timeMicros);
@@ -96,9 +91,6 @@ private:
 	// timing.cpp
 	void microDelay(uint32 secs, uint32 micros);
 
-	// vga.cpp
-	byte _curvgapal[256 * 3];
-
 public:
 	EventManager *_event;
 	Resource *_resource;
@@ -107,8 +99,6 @@ public:
 	DisplayMan *_graphics;
 
 	int _roomNum;
-	byte *_currentDisplayBuffer;
-
 	CrumbData _breadCrumbs[MAX_CRUMBS];
 	uint16 _numCrumbs;
 	bool _droppingCrumbs;
@@ -118,9 +108,7 @@ public:
 	uint32 _crumbSecs, _crumbMicros;
 	bool _isCrumbWaiting;
 	bool _alternate;
-	byte *_tempScrollData;
 	bool _isHiRes;
-	byte *_displayBuffer;
 	const char *_curFileName;
 	const char *_nextFileName;
 	const char *_newFileName;  /* When ProcessRoom.c decides to change the filename
@@ -146,13 +134,6 @@ private:
 
 public:
 	void waitTOF();
-	void writeColorRegs(byte *buf, uint16 first, uint16 numreg);
-	byte *getCurrentDrawingBuffer();
-	void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-	void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-	void overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-	void setPalette(void *cmap, uint16 numcolors);
-
 	void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr);
 	void interfaceOff();
 	void interfaceOn();
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 67200a8..20785f4 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -120,7 +120,6 @@ public:
 /*---------------------------*/
 
 void fade(bool fadein, uint16 res);
-void setAmigaPal(uint16 *pal, uint16 numcolors);
 void doMap(uint16 CurRoom);
 void doJournal();
 void doNotes();
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index bef3dd1..3f20fea 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -43,27 +43,6 @@ namespace Lab {
 
 extern uint16 Direction;
 
-/*****************************************************************************/
-/* Converts an Amiga palette (up to 16 colors) to a VGA palette, then sets   */
-/* the VGA palette.                                                          */
-/*****************************************************************************/
-void setAmigaPal(uint16 *pal, uint16 numcolors) {
-	byte vgapal[16 * 3];
-	uint16 vgacount = 0;
-
-	if (numcolors > 16)
-		numcolors = 16;
-
-	for (uint16 i = 0; i < numcolors; i++) {
-		vgapal[vgacount++] = (byte)(((pal[i] & 0xf00) >> 8) << 2);
-		vgapal[vgacount++] = (byte)(((pal[i] & 0x0f0) >> 4) << 2);
-		vgapal[vgacount++] = (byte)(((pal[i] & 0x00f)) << 2);
-	}
-
-	g_lab->writeColorRegs(vgapal, 0, 16);
-	g_lab->waitTOF();
-}
-
 /*---------------------------------------------------------------------------*/
 /*------------------------------ The Map stuff ------------------------------*/
 /*---------------------------------------------------------------------------*/
@@ -226,7 +205,7 @@ void fade(bool fadein, uint16 res) {
 				                 (0xF00 & fadeNumOut(0xF00 & FadePalette[palIdx], 0xF00 & res, i));
 		}
 
-		setAmigaPal(newpal, 16);
+		g_lab->_graphics->setAmigaPal(newpal, 16);
 		g_lab->waitTOF();
 		g_lab->_music->updateMusic();
 	}
@@ -486,7 +465,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 		fade(false, 0);
 
 	_graphics->setAPen(0);
-	_graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1);
+	_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);
 
 	Map->drawImage(0, 0);
 	drawGadgetList(MapGadgetList);
@@ -583,7 +562,7 @@ void LabEngine::processMap(uint16 CurRoom) {
 			}
 
 			waitTOF();
-			writeColorRegs(newcolor, 1, 1);
+			_graphics->writeColorRegs(newcolor, 1, 1);
 			_event->updateMouse();
 			waitTOF();
 			_event->updateMouse();
@@ -753,7 +732,7 @@ void LabEngine::doMap(uint16 CurRoom) {
 	_graphics->blackAllScreen();
 	_event->mouseHide();
 	_graphics->setAPen(0);
-	_graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1);
+	_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);
 	freeMapData();
 	_graphics->blackAllScreen();
 	_event->mouseShow();
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index bc7fa2e..45d5584 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -532,7 +532,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 					_anim->_diffPalette[idx] = 255 - _anim->_diffPalette[idx];
 
 				waitTOF();
-				setPalette(_anim->_diffPalette, 256);
+				_graphics->setPalette(_anim->_diffPalette, 256);
 				waitTOF();
 				waitTOF();
 			} else if (aptr->Param1 == 4) { /* white the palette */
@@ -541,7 +541,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 				waitTOF();
 			} else if (aptr->Param1 == 6) { /* Restore the palette */
 				waitTOF();
-				setPalette(_anim->_diffPalette, 256);
+				_graphics->setPalette(_anim->_diffPalette, 256);
 				waitTOF();
 				waitTOF();
 			} else if (aptr->Param1 == 7) { /* Quick pause */
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 76f9c15..4143ad6 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -77,13 +77,13 @@ extern uint16 Direction;
 
 
 static byte *loadBackPict(const char *fileName, bool tomem) {
-	byte *res = NULL;
+	byte *res = nullptr;
 
 	FadePalette = hipal;
 	g_lab->_anim->_noPalChange = true;
 
 	if (tomem)
-		res = g_lab->_graphics->readPictToMem(fileName, g_lab->_screenWidth, g_lab->_screenHeight);
+		res = g_lab->_graphics->readPictToMem(fileName, g_lab->_graphics->_screenWidth, g_lab->_graphics->_screenHeight);
 	else
 		g_lab->_graphics->readPict(fileName, true);
 
@@ -106,7 +106,7 @@ void doNotes() {
 	char *ntext = g_lab->_resource->getText("Lab:Rooms/Notes");
 
 	g_lab->_graphics->flowText(noteFont, -2 + g_lab->_graphics->SVGACord(1), 0, 0, false, false, true, true, g_lab->_graphics->VGAScaleX(25) + g_lab->_graphics->SVGACord(15), g_lab->_graphics->VGAScaleY(50), g_lab->_graphics->VGAScaleX(295) - g_lab->_graphics->SVGACord(15), g_lab->_graphics->VGAScaleY(148), ntext);
-	g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
+	g_lab->_graphics->setPalette(g_lab->_anim->_diffPalette, 256);
 
 	closeFont(noteFont);
 	delete[] ntext;
@@ -150,7 +150,7 @@ void doWestPaper() {
 	delete[] ntext;
 	closeFont(paperFont);
 
-	g_lab->setPalette(g_lab->_anim->_diffPalette, 256);
+	g_lab->_graphics->setPalette(g_lab->_anim->_diffPalette, 256);
 }
 
 /*****************************************************************************/
@@ -268,18 +268,18 @@ static void drawJournalText() {
 /*****************************************************************************/
 static void turnPage(bool FromLeft) {
 	if (FromLeft) {
-		for (int i = 0; i < g_lab->_screenWidth; i += 8) {
+		for (int i = 0; i < g_lab->_graphics->_screenWidth; i += 8) {
 			g_lab->_music->updateMusic();
 			g_lab->waitTOF();
-			ScreenImage._imageData = g_lab->getCurrentDrawingBuffer();
-			JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight, false);
+			ScreenImage._imageData = g_lab->_graphics->getCurrentDrawingBuffer();
+			JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_graphics->_screenHeight, false);
 		}
 	} else {
-		for (int i = (g_lab->_screenWidth - 8); i > 0; i -= 8) {
+		for (int i = (g_lab->_graphics->_screenWidth - 8); i > 0; i -= 8) {
 			g_lab->_music->updateMusic();
 			g_lab->waitTOF();
-			ScreenImage._imageData = g_lab->getCurrentDrawingBuffer();
-			JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_screenHeight, false);
+			ScreenImage._imageData = g_lab->_graphics->getCurrentDrawingBuffer();
+			JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_graphics->_screenHeight, false);
 		}
 	}
 }
@@ -298,10 +298,10 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 
 	drawJournalText();
 
-	ScreenImage._imageData = getCurrentDrawingBuffer();
+	ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
 
 	if (wipenum == 0)
-		JBackImage.blitBitmap(0, 0, &ScreenImage, 0, 0, _screenWidth, _screenHeight, false);
+		JBackImage.blitBitmap(0, 0, &ScreenImage, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false);
 	else
 		turnPage((bool)(wipenum == 1));
 
@@ -320,7 +320,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 		fade(true, 0);
 
 	g_lab->_anim->_noPalChange = true;
-	JBackImage._imageData = _graphics->readPictToMem("P:Journal.pic", _screenWidth, _screenHeight);
+	JBackImage._imageData = _graphics->readPictToMem("P:Journal.pic", _graphics->_screenWidth, _graphics->_screenHeight);
 	GotBackImage = true;
 
 	eatMessages();
@@ -380,15 +380,15 @@ void LabEngine::doJournal() {
 	lastpage    = false;
 	GotBackImage = false;
 
-	JBackImage._width = _screenWidth;
-	JBackImage._height = _screenHeight;
+	JBackImage._width = _graphics->_screenWidth;
+	JBackImage._height = _graphics->_screenHeight;
 	JBackImage._imageData   = NULL;
 
 	BackG.NextGadget = &CancelG;
 	CancelG.NextGadget = &ForwardG;
 
 	ScreenImage = JBackImage;
-	ScreenImage._imageData = getCurrentDrawingBuffer();
+	ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
 
 	_music->updateMusic();
 	loadJournalData();
@@ -402,10 +402,10 @@ void LabEngine::doJournal() {
 	fade(false, 0);
 	_event->mouseHide();
 
-	ScreenImage._imageData = getCurrentDrawingBuffer();
+	ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
 
 	_graphics->setAPen(0);
-	_graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1);
+	_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);
 	_graphics->blackScreen();
 }
 
@@ -476,13 +476,13 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
 			MonGadHeight = fheight;
 
 		_graphics->setAPen(0);
-		_graphics->rectFill(0, 0, _screenWidth - 1, y2);
+		_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2);
 
 		for (uint16 i = 0; i < numlines; i++)
 			MonButton->drawImage(0, i * MonGadHeight);
 	} else if (isinteractive) {
 		_graphics->setAPen(0);
-		_graphics->rectFill(0, 0, _screenWidth - 1, y2);
+		_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2);
 	} else {
 		_graphics->setAPen(0);
 		_graphics->rectFill(x1, y1, x2, y2);
@@ -644,7 +644,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 	closeFont(monitorFont);
 
 	_graphics->setAPen(0);
-	_graphics->rectFill(0, 0, _screenWidth - 1, _screenHeight - 1);
+	_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);
 	_graphics->blackAllScreen();
 	_graphics->freePict();
 }
diff --git a/engines/lab/text.cpp b/engines/lab/text.cpp
index 1c1cacd..f784c21 100644
--- a/engines/lab/text.cpp
+++ b/engines/lab/text.cpp
@@ -78,10 +78,10 @@ void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint
 	int32 templeft, LeftInSegment;
 	uint16 bwidth, mask, curpage, data;
 
-	VGATop = g_lab->getCurrentDrawingBuffer();
+	VGATop = g_lab->_graphics->getCurrentDrawingBuffer();
 
 	for (uint16 i = 0; i < numchars; i++) {
-		RealOffset = (g_lab->_screenWidth * y) + x;
+		RealOffset = (g_lab->_graphics->_screenWidth * y) + x;
 		curpage    = RealOffset / g_lab->_graphics->_screenBytesPerPage;
 		SegmentOffset = RealOffset - (curpage * g_lab->_graphics->_screenBytesPerPage);
 		LeftInSegment = g_lab->_graphics->_screenBytesPerPage - SegmentOffset;
@@ -137,8 +137,8 @@ void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint
 					}
 				}
 
-				VGATempLine += g_lab->_screenWidth;
-				LeftInSegment -= g_lab->_screenWidth;
+				VGATempLine += g_lab->_graphics->_screenWidth;
+				LeftInSegment -= g_lab->_graphics->_screenWidth;
 
 				if (LeftInSegment <= 0) {
 					curpage++;
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index 137038f..1cee9d3 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -259,7 +259,7 @@ void LabEngine::showTile(const char *filename, bool showsolution) {
 	delete tileFile;
 
 	doTile(showsolution);
-	setPalette(_anim->_diffPalette, 256);
+	_graphics->setPalette(_anim->_diffPalette, 256);
 }
 
 /*****************************************************************************/
@@ -319,9 +319,9 @@ void LabEngine::changeCombination(uint16 number) {
 
 	combnum = combination[number];
 
-	display._imageData = getCurrentDrawingBuffer();
-	display._width     = _screenWidth;
-	display._height    = _screenHeight;
+	display._imageData = _graphics->getCurrentDrawingBuffer();
+	display._width     = _graphics->_screenWidth;
+	display._height    = _graphics->_screenHeight;
 
 	for (uint16 i = 1; i <= (Images[combnum]->_height / 2); i++) {
 		if (_isHiRes) {
@@ -330,10 +330,8 @@ void LabEngine::changeCombination(uint16 number) {
 		} else
 			waitTOF();
 
-		display._imageData = getCurrentDrawingBuffer();
-
-		scrollDisplayY(2, _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), _graphics->VGAScaleX(COMBINATION_X[number]) + (Images[combnum])->_width - 1, _graphics->VGAScaleY(65) + (Images[combnum])->_height);
-
+		display._imageData = _graphics->getCurrentDrawingBuffer();
+		_graphics->scrollDisplayY(2, _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), _graphics->VGAScaleX(COMBINATION_X[number]) + (Images[combnum])->_width - 1, _graphics->VGAScaleY(65) + (Images[combnum])->_height);
 		Images[combnum]->blitBitmap(0, (Images[combnum])->_height - (2 * i), &(display), _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), (Images[combnum])->_width, 2, false);
 	}
 
@@ -348,10 +346,10 @@ void LabEngine::changeCombination(uint16 number) {
 
 void LabEngine::scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	if (dx)
-		scrollDisplayX(dx, x1, y1, x2, y2);
+		_graphics->scrollDisplayX(dx, x1, y1, x2, y2);
 
 	if (dy)
-		scrollDisplayY(dy, x1, y1, x2, y2);
+		_graphics->scrollDisplayY(dy, x1, y1, x2, y2);
 }
 
 /*****************************************************************************/
@@ -382,7 +380,7 @@ void LabEngine::showCombination(const char *filename) {
 
 	doCombination();
 
-	setPalette(_anim->_diffPalette, 256);
+	_graphics->setPalette(_anim->_diffPalette, 256);
 }
 
 } // End of namespace Lab
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 8ee0d34..95099dc 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -45,7 +45,7 @@ void LabEngine::changeVolume(int delta) {
 
 
 void LabEngine::waitTOF() {
-	g_system->copyRectToScreen(_displayBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight);
+	g_system->copyRectToScreen(_graphics->_displayBuffer, _graphics->_screenWidth, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight);
 	g_system->updateScreen();
 
   	_event->processInput();
@@ -58,143 +58,4 @@ void LabEngine::waitTOF() {
 	_lastWaitTOFTicks = now;
 }
 
-/*****************************************************************************/
-/* Writes any number of the 256 color registers.                             */
-/* first:    the number of the first color register to write.                */
-/* numreg:   the number of registers to write                                */
-/* buf:      a char pointer which contains the selected color registers.     */
-/*           Each value representing a color register occupies 3 bytes in    */
-/*           the array.  The order is red, green then blue.  The first byte  */
-/*           in the array is the red component of the first element selected.*/
-/*           The length of the buffer is 3 times the number of registers     */
-/*           selected.                                                       */
-/*****************************************************************************/
-void LabEngine::writeColorRegs(byte *buf, uint16 first, uint16 numreg) {
-	byte tmp[256 * 3];
-
-	for (int i = 0; i < 256 * 3; i++) {
-		tmp[i] = buf[i] * 4;
-	}
-
-	g_system->getPaletteManager()->setPalette(tmp, first, numreg);
-
-	memcpy(&(_curvgapal[first * 3]), buf, numreg * 3);
-}
-
-void LabEngine::setPalette(void *cmap, uint16 numcolors) {
-	if (memcmp(cmap, _curvgapal, numcolors * 3) != 0)
-		writeColorRegs((byte *)cmap, 0, numcolors);
-}
-
-/*****************************************************************************/
-/* Returns the base address of the current VGA display.                      */
-/*****************************************************************************/
-byte *LabEngine::getCurrentDrawingBuffer() {
-	if (_currentDisplayBuffer)
-		return _currentDisplayBuffer;
-
-	return _displayBuffer;
-}
-
-/*****************************************************************************/
-/* Scrolls the display in the x direction by blitting.                       */
-/* The _tempScrollData variable must be initialized to some memory, or this   */
-/* function will fail.                                                       */
-/*****************************************************************************/
-void LabEngine::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	Image im;
-	uint16 temp;
-
-	im._imageData = _tempScrollData;
-
-	if (x1 > x2) {
-		temp = x2;
-		x2 = x1;
-		x1 = temp;
-	}
-
-	if (y1 > y2) {
-		temp = y2;
-		y2 = y1;
-		y1 = temp;
-	}
-
-	im._width = x2 - x1 + 1 - dx;
-	im._height = y2 - y1 + 1;
-
-	im.readScreenImage(x1, y1);
-	im.drawImage(x1 + dx, y1);
-
-	_graphics->setAPen(0);
-	_graphics->rectFill(x1, y1, x1 + dx - 1, y2);
-}
-
-/*****************************************************************************/
-/* Scrolls the display in the y direction by blitting.                       */
-/*****************************************************************************/
-void LabEngine::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	Image im;
-	uint16 temp;
-
-	im._imageData = _tempScrollData;
-
-	if (x1 > x2) {
-		temp = x2;
-		x2 = x1;
-		x1 = temp;
-	}
-
-	if (y1 > y2) {
-		temp = y2;
-		y2 = y1;
-		y1 = temp;
-	}
-
-	im._width = x2 - x1 + 1;
-	im._height = y2 - y1 + 1 - dy;
-
-	im.readScreenImage(x1, y1);
-	im.drawImage(x1, y1 + dy);
-
-	_graphics->setAPen(0);
-	_graphics->rectFill(x1, y1, x2, y1 + dy - 1);
-}
-
-/*****************************************************************************/
-/* Overlays a region on the screen using the desired pen color.              */
-/*****************************************************************************/
-void LabEngine::overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	int w = x2 - x1 + 1;
-	int h = y2 - y1 + 1;
-
-	if (x1 + w > _screenWidth)
-		w = _screenWidth - x1;
-
-	if (y1 + h > _screenHeight)
-		h = _screenHeight - y1;
-
-	if ((w > 0) && (h > 0)) {
-		char *d = (char *)getCurrentDrawingBuffer() + y1 * _screenWidth + x1;
-
-		while (h-- > 0) {
-			char *dd = d;
-			int ww = w;
-
-			if (y1 & 1) {
-				dd++;
-				ww--;
-			}
-
-			while (ww > 0) {
-				*dd = pencolor;
-				dd += 2;
-				ww -= 2;
-			}
-
-			d += _screenWidth;
-			y1++;
-		}
-	}
-}
-
 } // End of namespace Lab


Commit: fa966938c8bf7fc5c933050fb74332d8ac0506a1
    https://github.com/scummvm/scummvm/commit/fa966938c8bf7fc5c933050fb74332d8ac0506a1
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:51+01:00

Commit Message:
LAB: Remove vga.cpp

Changed paths:
    engines/lab/lab.cpp
    engines/lab/module.mk
    engines/lab/vga.cpp



diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 1e15845..6781a8a 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -183,4 +183,21 @@ void LabEngine::drawStaticMessage(byte index) {
 	_graphics->drawMessage(_resource->getStaticText((StaticText)index).c_str());
 }
 
+void LabEngine::changeVolume(int delta) {
+	warning("STUB: changeVolume()");
+}
+
+void LabEngine::waitTOF() {
+	g_system->copyRectToScreen(_graphics->_displayBuffer, _graphics->_screenWidth, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight);
+	g_system->updateScreen();
+
+	_event->processInput();
+
+	uint32 now;
+
+	for (now = g_system->getMillis(); now - _lastWaitTOFTicks <= 0xF; now = g_system->getMillis() )
+		g_system->delayMillis(_lastWaitTOFTicks - now + 17);
+
+	_lastWaitTOFTicks = now;
+}
 } // End of namespace Lab
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index 434ba7d..3985b14 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -19,9 +19,7 @@ MODULE_OBJS := \
 	special.o \
 	text.o \
 	tilepuzzle.o \
-	timing.o \
-	vga.o
-
+	timing.o
 
 # This module can be built as a plugin
 ifeq ($(ENABLE_LAB), DYNAMIC_PLUGIN)
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
index 95099dc..b80f338 100644
--- a/engines/lab/vga.cpp
+++ b/engines/lab/vga.cpp
@@ -28,34 +28,6 @@
  *
  */
 
-#include "graphics/palette.h"
-#include "common/events.h"
-
-#include "lab/lab.h"
-#include "lab/image.h"
-
 namespace Lab {
 
-/*****************************************************************************/
-/* Sets the current page on the VGA card.                                    */
-/*****************************************************************************/
-void LabEngine::changeVolume(int delta) {
-	warning("STUB: changeVolume()");
-}
-
-
-void LabEngine::waitTOF() {
-	g_system->copyRectToScreen(_graphics->_displayBuffer, _graphics->_screenWidth, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight);
-	g_system->updateScreen();
-
-  	_event->processInput();
-
-  	uint32 now;
-
-	for (now = g_system->getMillis(); now - _lastWaitTOFTicks <= 0xF; now = g_system->getMillis() )
-		g_system->delayMillis(_lastWaitTOFTicks - now + 17);
-
-	_lastWaitTOFTicks = now;
-}
-
 } // End of namespace Lab


Commit: f48cf343c2761b7918924cc4af923f9503de102c
    https://github.com/scummvm/scummvm/commit/f48cf343c2761b7918924cc4af923f9503de102c
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:51+01:00

Commit Message:
LAB: Move doNotes and doWestPaper to LabEngine, remove some useless defines

Changed paths:
  A engines/lab/labsets.h
    engines/lab/engine.cpp
    engines/lab/lab.h
    engines/lab/labfun.h
    engines/lab/savegame.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index a986807..ed4908b 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -565,7 +565,6 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 	bool doit;
 	uint16 NewDir;
 
-
 	_anim->_doBlack = false;
 
 	if ((msgClass == RAWKEY) && (!_graphics->_longWinInFront)) {
@@ -1055,9 +1054,7 @@ void LabEngine::go() {
 	}
 
 	_event->initMouse();
-
 	_msgFont = _resource->getFont("P:AvanteG.12");
-
 	_event->mouseHide();
 
 	Intro *intro = new Intro(this);
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index b917da7..06e4b74 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -42,6 +42,7 @@
 #include "lab/resource.h"
 #include "lab/anim.h"
 #include "lab/graphics.h"
+#include "lab/labsets.h"
 
 struct ADGameDescription;
 
@@ -149,6 +150,8 @@ public:
 	void drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive);
 	void processMonitor(char *ntext, TextFont *monitorFont, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void doNotes();
+	void doWestPaper();
 	void eatMessages();
 	void drawStaticMessage(byte index);
 	void drawDirection(CloseDataPtr lcPtr);
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 20785f4..d58b27e 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -68,63 +68,13 @@ struct SaveGameHeader {
 /*----- From graphics.c ------*/
 /*----------------------------*/
 
-/* Reads in pictures */
-
 bool readMusic(const char *filename, bool waitTillFinished);
-void drawStaticMessage(byte index);
-
-/* Double Buffer stuff */
-
-void newFlipViews(void *scrPtr, uint16 *newpal, uint16 numcolors);
-void flipViews(void *scrPtr);
-
-/*----------------------------*/
-/*----- From Interface.c -----*/
-/*----------------------------*/
-
-Gadget *addGadButton(uint16 x, uint16 y, void *UpImage, void *DownImage, uint16 id);
-void gadgetsOnOff(void *gptr, void *win, int32 num, bool on);
-
-/*----------------------*/
-/*----- From Lab.c -----*/
-/*----------------------*/
-
-void eatMessages();
-bool quitPlaying();
-
-void readBlock(void *Buffer, uint32 Size, byte **File);
-
-/*---------------------------*/
-/*----- From LabSets.c ------*/
-/*---------------------------*/
-
-class LargeSet {
-public:
-    LargeSet(uint16 last, LabEngine *vm);
-    ~LargeSet();
-    bool in(uint16 element);
-    void inclElement(uint16 element);
-    void exclElement(uint16 element);
-    bool readInitialConditions(const char *fileName);
-
-private:
-	LabEngine *_vm;
-
-public:
-    uint16 _lastElement;
-    uint16 *_array;
-};
 
 /*---------------------------*/
 /*-------- From Map.c -------*/
 /*---------------------------*/
 
 void fade(bool fadein, uint16 res);
-void doMap(uint16 CurRoom);
-void doJournal();
-void doNotes();
-void doWestPaper();
-void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 
 /*--------------------------*/
 /*----- From saveGame.c ----*/
@@ -134,12 +84,6 @@ bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc);
 bool loadGame(uint16 *Direction, uint16 *Quarters, int slot);
 bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header);
 
-/*--------------------------*/
-/*----- From Special.c -----*/
-/*--------------------------*/
-
-void showCombination(const char *filename);
-
 } // End of namespace Lab
 
 #endif /* LAB_LABFUN_H */
diff --git a/engines/lab/labsets.h b/engines/lab/labsets.h
new file mode 100644
index 0000000..3251ee1
--- /dev/null
+++ b/engines/lab/labsets.h
@@ -0,0 +1,61 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+ /*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#ifndef LAB_LABSETS_H
+#define LAB_LABSETS_H
+
+namespace Lab {
+
+/*---------------------------*/
+/*----- From LabSets.c ------*/
+/*---------------------------*/
+
+class LabEngine;
+
+class LargeSet {
+public:
+    LargeSet(uint16 last, LabEngine *vm);
+    ~LargeSet();
+    bool in(uint16 element);
+    void inclElement(uint16 element);
+    void exclElement(uint16 element);
+    bool readInitialConditions(const char *fileName);
+
+private:
+	LabEngine *_vm;
+
+public:
+    uint16 _lastElement;
+    uint16 *_array;
+};
+
+} // End of namespace Lab
+
+#endif // LAB_LABSETS_H
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index d97a036..cfb636f 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -42,14 +42,7 @@ namespace Lab {
 #define SAVEGAME_ID       MKTAG('L', 'O', 'T', 'S')
 #define SAVEGAME_VERSION  1
 
-#define BOOKMARK  0
-#define CARDMARK  1
-#define FLOPPY    2
-
-
 /*----- The machine independent section of saveGame.c -----*/
-
-
 /* Lab: Labyrinth specific */
 extern char *getPictName(CloseDataPtr *lcptr);
 
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 4143ad6..7c7dcb1 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -101,7 +101,7 @@ static byte *loadBackPict(const char *fileName, bool tomem) {
 /*****************************************************************************/
 /* Does the things to properly set up the detective notes.                   */
 /*****************************************************************************/
-void doNotes() {
+void LabEngine::doNotes() {
 	TextFont *noteFont = g_lab->_resource->getFont("P:Note.fon");
 	char *ntext = g_lab->_resource->getText("Lab:Rooms/Notes");
 
@@ -117,7 +117,7 @@ void doNotes() {
 /* Does the things to properly set up the old west newspaper.  Assumes that  */
 /* OpenHiRes already called.                                                 */
 /*****************************************************************************/
-void doWestPaper() {
+void LabEngine::doWestPaper() {
 	char *ntext;
 	TextFont *paperFont;
 	int32 FileLen, CharsPrinted;


Commit: 438e7a24f5f362c383269cca41ced901a98f284e
    https://github.com/scummvm/scummvm/commit/438e7a24f5f362c383269cca41ced901a98f284e
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:51+01:00

Commit Message:
LAB: Get rid of some global variables

Changed paths:
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/graphics.h
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/processroom.cpp
    engines/lab/resource.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index ed4908b..158286f 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -40,14 +40,10 @@
 
 namespace Lab {
 
-extern bool DoNotDrawMessage;
-
 /* Global parser data */
-
 extern RoomData *_rooms;
-extern uint16 NumInv, ManyRooms, HighestCondition, Direction;
 
-bool ispal = false, noupdatediff = false, MainDisplay = true, QuitLab = false;
+bool ispal = false, MainDisplay = true;
 
 /* LAB: Labyrinth specific code for the special puzzles */
 #define SPECIALLOCK         100
@@ -103,7 +99,7 @@ void LabEngine::drawRoomMessage(uint16 curInv, CloseDataPtr closePtr) {
 	}
 
 	if (_alternate) {
-		if ((curInv <= NumInv) && _conditions->in(curInv) && _inventory[curInv].BInvName) {
+		if ((curInv <= _numInv) && _conditions->in(curInv) && _inventory[curInv].BInvName) {
 			if ((curInv == LAMPNUM) && _conditions->in(LAMPON))  /* LAB: Labyrinth specific */
 				drawStaticMessage(kTextLampOn);
 			else if (_inventory[curInv].Many > 1) {
@@ -358,7 +354,7 @@ void LabEngine::decIncInv(uint16 *CurInv, bool dec) {
 	else
 		(*CurInv)++;
 
-	while (*CurInv && (*CurInv <= NumInv)) {
+	while (*CurInv && (*CurInv <= _numInv)) {
 		if (_conditions->in(*CurInv) && _inventory[*CurInv].BInvName) {
 			_nextFileName = getInvName(*CurInv);
 			break;
@@ -370,13 +366,13 @@ void LabEngine::decIncInv(uint16 *CurInv, bool dec) {
 			(*CurInv)++;
 	}
 
-	if ((*CurInv == 0) || (*CurInv > NumInv)) {
+	if ((*CurInv == 0) || (*CurInv > _numInv)) {
 		if (dec)
-			*CurInv = NumInv;
+			*CurInv = _numInv;
 		else
 			*CurInv = 1;
 
-		while (*CurInv && (*CurInv <= NumInv)) {
+		while (*CurInv && (*CurInv <= _numInv)) {
 			if (_conditions->in(*CurInv) && _inventory[*CurInv].BInvName) {
 				_nextFileName = getInvName(*CurInv);
 				break;
@@ -404,16 +400,16 @@ void LabEngine::mainGameLoop() {
 
 	_cptr    = NULL;
 	_roomNum = 1;
-	Direction = NORTH;
+	_direction = NORTH;
 
 	_resource->readRoomData("LAB:Doors");
 	if (!(_inventory = _resource->readInventory("LAB:Inventor")))
 		return;
 
-	if (!(_conditions = new LargeSet(HighestCondition + 1, this)))
+	if (!(_conditions = new LargeSet(_highestCondition + 1, this)))
 		return;
 
-	if (!(_roomsFound = new LargeSet(ManyRooms + 1, this)))
+	if (!(_roomsFound = new LargeSet(_manyRooms + 1, this)))
 		return;
 
 	_conditions->readInitialConditions("LAB:Conditio");
@@ -429,7 +425,7 @@ void LabEngine::mainGameLoop() {
 		_event->processInput(true);
 
 		if (GotMessage) {
-			if (QuitLab || g_engine->shouldQuit()) {
+			if (_quitLab || g_engine->shouldQuit()) {
 				_anim->stopDiff();
 				break;
 			}
@@ -448,11 +444,11 @@ void LabEngine::mainGameLoop() {
 			if (MainDisplay)
 				_nextFileName = getPictName(&_cptr);
 
-			if (noupdatediff) {
+			if (_noUpdateDiff) {
 				_roomsFound->inclElement(_roomNum); /* Potentially entered another room */
 				forceDraw |= (strcmp(_nextFileName, _curFileName) != 0);
 
-				noupdatediff = false;
+				_noUpdateDiff = false;
 				_curFileName = _nextFileName;
 			} else if (strcmp(_nextFileName, _curFileName) != 0) {
 				interfaceOff();
@@ -542,7 +538,7 @@ void LabEngine::mainGameLoop() {
 	}
 
 	if (_inventory) {
-		for (int i = 1; i <= NumInv; i++) {
+		for (int i = 1; i <= _numInv; i++) {
 			if (_inventory[i].name)
 				free(_inventory[i].name);
 
@@ -558,8 +554,8 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 	uint32 msgClass = tmpClass;
 	Common::Point curPos = tmpPos;
 
-	uint16 OldRoomNum, OldDirection = 0;
-	uint16 LastInv = MAPNUM, Old;
+	uint16 oldDirection = 0;
+	uint16 lastInv = MAPNUM;
 	CloseDataPtr oldcptr, tempcptr, hcptr = NULL;
 	ViewData *VPtr;
 	bool doit;
@@ -593,7 +589,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 						eatMessages();
 						_alternate = false;
 						_anim->_doBlack = true;
-						DoNotDrawMessage = false;
+						_graphics->_doNotDrawMessage = false;
 
 						MainDisplay = true;
 						interfaceOn(); /* Sets the correct gadget list */
@@ -612,7 +608,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			}
 		} else if ((code == 315) || (code == 'x') || (code == 'X')
 		         || (code == 'q') || (code == 'Q')) {  /* Quit? */
-			DoNotDrawMessage = false;
+			_graphics->_doNotDrawMessage = false;
 			_graphics->drawMessage("Do you want to quit? (Y/N)");
 			doit = false;
 			eatMessages();
@@ -661,7 +657,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 		         ((IEQUALIFIER_LEFTBUTTON & Qualifier) ||
 		          (IEQUALIFIER_RBUTTON & Qualifier)))) {
 			_graphics->_longWinInFront = false;
-			DoNotDrawMessage = false;
+			_graphics->_doNotDrawMessage = false;
 			_graphics->drawPanel();
 			drawRoomMessage(curInv, _cptr);
 			_graphics->screenUpdate();
@@ -681,13 +677,13 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 				_alternate = true;
 				_anim->_doBlack = true;
-				DoNotDrawMessage = false;
+				_graphics->_doNotDrawMessage = false;
 				interfaceOn(); /* Sets the correct gadget list */
 
 				MainDisplay = false;
 
-				if (LastInv && _conditions->in(LastInv)) {
-					curInv = LastInv;
+				if (lastInv && _conditions->in(lastInv)) {
+					curInv = lastInv;
 					_nextFileName = getInvName(curInv);
 				} else
 					decIncInv(&curInv, false);
@@ -698,11 +694,11 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				mayShowCrumbIndicator();
 				_graphics->screenUpdate();
 			} else {
-				Old        = actionMode;
+				uint16 oldActionMode = actionMode;
 				actionMode = gadgetId;
 
-				if (Old < 5)
-					perFlipGadget(Old);
+				if (oldActionMode < 5)
+					perFlipGadget(oldActionMode);
 
 				perFlipGadget(actionMode);
 
@@ -727,28 +723,28 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 				_curFileName = " ";
 
-				OldDirection = Direction;
+				oldDirection = _direction;
 
-				NewDir = Direction;
+				NewDir = _direction;
 				processArrow(&NewDir, gadgetId - 6);
-				doTurn(Direction, NewDir, &_cptr);
+				doTurn(_direction, NewDir, &_cptr);
 				_anim->_doBlack = true;
-				Direction = NewDir;
+				_direction = NewDir;
 				forceDraw = true;
 
 				mayShowCrumbIndicator();
 				_graphics->screenUpdate();
 			} else if (gadgetId == 7) {
-				OldRoomNum = _roomNum;
+				uint16 oldRoomNum = _roomNum;
 
 				if (doGoForward(&_cptr)) {
-					if (OldRoomNum == _roomNum)
+					if (oldRoomNum == _roomNum)
 						_anim->_doBlack = true;
 				} else {
 					_anim->_doBlack = true;
-					processArrow(&Direction, gadgetId - 6);
+					processArrow(&_direction, gadgetId - 6);
 
-					if (OldRoomNum != _roomNum) {
+					if (oldRoomNum != _roomNum) {
 						drawStaticMessage(kTextGoForward);
 						_roomsFound->inclElement(_roomNum); /* Potentially entered a new room */
 						_curFileName = " ";
@@ -761,15 +757,15 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 				if (_followingCrumbs) {
 					if (_isCrumbTurning) {
-						if (Direction == OldDirection) {
+						if (_direction == oldDirection) {
 							_followingCrumbs = false;
 						}
 					} else {
-						if (_roomNum == OldRoomNum) { // didn't get there?
+						if (_roomNum == oldRoomNum) { // didn't get there?
 							_followingCrumbs = false;
 						}
 					}
-				} else if (_droppingCrumbs && OldRoomNum != _roomNum) {
+				} else if (_droppingCrumbs && oldRoomNum != _roomNum) {
 					// If in surreal maze, turn off DroppingCrumbs.
 					// Note: These numbers were generated by parsing the
 					// "Maps" file, which is why they are hard-coded. Bleh!
@@ -795,7 +791,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 							}
 
 							_breadCrumbs[_numCrumbs]._roomNum = _roomNum;
-							_breadCrumbs[_numCrumbs++]._direction = Direction;
+							_breadCrumbs[_numCrumbs++]._direction = _direction;
 						}
 					}
 				}
@@ -811,7 +807,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			eatMessages();
 			_alternate = false;
 			_anim->_doBlack = true;
-			DoNotDrawMessage = false;
+			_graphics->_doNotDrawMessage = false;
 
 			MainDisplay = true;
 			interfaceOn(); /* Sets the correct gadget list */
@@ -834,7 +830,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			MainDisplay = true;
 
 			curInv = MAPNUM;
-			LastInv = MAPNUM;
+			lastInv = MAPNUM;
 
 			_nextFileName = getInvName(curInv);
 
@@ -848,11 +844,11 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			_graphics->screenUpdate();
 		} else if (gadgetId == 1) {
 			if (!doUse(curInv)) {
-				Old        = actionMode;
+				uint16 oldActionMode = actionMode;
 				actionMode = 5;  /* Use button */
 
-				if (Old < 5)
-					perFlipGadget(Old);
+				if (oldActionMode < 5)
+					perFlipGadget(oldActionMode);
 
 				drawStaticMessage(kTextUseOnWhat);
 				MainDisplay = true;
@@ -862,29 +858,29 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 		} else if (gadgetId == 2) {
 			MainDisplay = !MainDisplay;
 
-			if ((curInv == 0) || (curInv > NumInv)) {
+			if ((curInv == 0) || (curInv > _numInv)) {
 				curInv = 1;
 
-				while ((curInv <= NumInv) && (!_conditions->in(curInv)))
+				while ((curInv <= _numInv) && (!_conditions->in(curInv)))
 					curInv++;
 			}
 
-			if ((curInv <= NumInv) && _conditions->in(curInv) &&
+			if ((curInv <= _numInv) && _conditions->in(curInv) &&
 			        _inventory[curInv].BInvName)
 				_nextFileName = getInvName(curInv);
 
 			_graphics->screenUpdate();
 		} else if (gadgetId == 3) { /* Left gadget */
 			decIncInv(&curInv, true);
-			LastInv = curInv;
-			DoNotDrawMessage = false;
+			lastInv = curInv;
+			_graphics->_doNotDrawMessage = false;
 			drawRoomMessage(curInv, _cptr);
 
 			_graphics->screenUpdate();
 		} else if (gadgetId == 4) { /* Right gadget */
 			decIncInv(&curInv, false);
-			LastInv = curInv;
-			DoNotDrawMessage = false;
+			lastInv = curInv;
+			_graphics->_doNotDrawMessage = false;
 			drawRoomMessage(curInv, _cptr);
 
 			_graphics->screenUpdate();
@@ -906,7 +902,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 					eatMessages();
 					_alternate = false;
 					_anim->_doBlack = true;
-					DoNotDrawMessage = false;
+					_graphics->_doNotDrawMessage = false;
 
 					MainDisplay = true;
 					interfaceOn(); /* Sets the correct gadget list */
@@ -994,7 +990,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 		mayShowCrumbIndicator();
 		_graphics->screenUpdate();
 	} else if (msgClass == DELTAMOVE) {
-		VPtr = getViewData(_roomNum, Direction);
+		VPtr = getViewData(_roomNum, _direction);
 		oldcptr = VPtr->closeUps;
 
 		if (hcptr == NULL) {
@@ -1025,13 +1021,13 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 		eatMessages();
 		_alternate = !_alternate;
 		_anim->_doBlack = true;
-		DoNotDrawMessage = false;
+		_graphics->_doNotDrawMessage = false;
 		MainDisplay = true;
 		interfaceOn(); /* Sets the correct gadget list */
 
 		if (_alternate) {
-			if (LastInv && _conditions->in(LastInv))
-				curInv = LastInv;
+			if (lastInv && _conditions->in(lastInv))
+				curInv = lastInv;
 			else
 				decIncInv(&curInv, false);
 		}
@@ -1064,7 +1060,7 @@ void LabEngine::go() {
 	_event->mouseShow();
 	mainGameLoop();
 
-	if (QuitLab) { /* Won the game */
+	if (_quitLab) { /* Won the game */
 		_graphics->blackAllScreen();
 		_graphics->readPict("P:End/L2In.1", true);
 
@@ -1141,7 +1137,7 @@ int LabEngine::followCrumbs() {
 	else
 		exitDir = NORTH;
 
-	int moveDir = movement[Direction][exitDir];
+	int moveDir = movement[_direction][exitDir];
 
 	if (_numCrumbs == 0) {
 		_isCrumbTurning = false;
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index a10512d..babc550 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -45,6 +45,7 @@ BitMap bit1, bit2, *DispBitMap = &bit1, *DrawBitMap = &bit1;
 DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) {
 	_longWinInFront = false;
 	_lastMessageLong = false;
+	_doNotDrawMessage = false;
 
 	_screenBytesPerPage = 65536;
 	_curapen = 0;
@@ -199,7 +200,6 @@ bool readMusic(const char *filename, bool waitTillFinished) {
 /*---------------------------------------------------------------------------*/
 /*------------ Does all the text rendering to the message boxes. ------------*/
 /*---------------------------------------------------------------------------*/
-bool DoNotDrawMessage = false;
 
 /*----- The flowText routines -----*/
 
@@ -404,8 +404,8 @@ int32 DisplayMan::longDrawMessage(const char *str) {
 /* Draws a message to the message box.                                        */
 /******************************************************************************/
 void DisplayMan::drawMessage(const char *str) {
-	if (DoNotDrawMessage) {
-		DoNotDrawMessage = false;
+	if (_doNotDrawMessage) {
+		_doNotDrawMessage = false;
 		return;
 	}
 
diff --git a/engines/lab/graphics.h b/engines/lab/graphics.h
index 4a69a59..979d73f 100644
--- a/engines/lab/graphics.h
+++ b/engines/lab/graphics.h
@@ -133,6 +133,7 @@ public:
 	int _screenHeight;
 	byte *_displayBuffer;
 	byte *_currentDisplayBuffer;
+	bool _doNotDrawMessage;
 };
 
 } // End of namespace Lab
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 6781a8a..f9de51b 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -70,6 +70,13 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_followCrumbsFast = false;
 	_isCrumbTurning = false;
 	_isCrumbWaiting = false;
+	_noUpdateDiff = false;
+	_quitLab = false;
+	_numInv = 0;
+	_manyRooms = 0;
+	_direction = 0;
+	_highestCondition = 0;
+
 	_crumbSecs = 0;
 	_crumbMicros = 0;
 
@@ -98,8 +105,8 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_newFileName = nullptr;
 
 	_curFileName = " ";
-	_msgFont = 0;
-	_inventory = 0;
+	_msgFont = nullptr;
+	_inventory = nullptr;
 
 	initTilePuzzle();
 
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 06e4b74..5675a0c 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -88,6 +88,8 @@ public:
 private:
 	uint32 _extraGameFeatures;
 	bool _interfaceOff;
+	bool _noUpdateDiff;
+	bool _quitLab;
 
 	// timing.cpp
 	void microDelay(uint32 secs, uint32 micros);
@@ -110,6 +112,11 @@ public:
 	bool _isCrumbWaiting;
 	bool _alternate;
 	bool _isHiRes;
+	uint16 _numInv;
+	uint16 _manyRooms;
+	uint16 _direction;
+	uint16 _highestCondition;
+
 	const char *_curFileName;
 	const char *_nextFileName;
 	const char *_newFileName;  /* When ProcessRoom.c decides to change the filename
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 3f20fea..8281a49 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -41,8 +41,6 @@
 
 namespace Lab {
 
-extern uint16 Direction;
-
 /*---------------------------------------------------------------------------*/
 /*------------------------------ The Map stuff ------------------------------*/
 /*---------------------------------------------------------------------------*/
@@ -713,13 +711,13 @@ void LabEngine::doMap(uint16 CurRoom) {
 	loadMapData();
 	_graphics->blackAllScreen();
 
-	if (Direction == NORTH)
+	if (_direction == NORTH)
 		XMark = MapNorth;
-	else if (Direction == SOUTH)
+	else if (_direction == SOUTH)
 		XMark = MapSouth;
-	else if (Direction == EAST)
+	else if (_direction == EAST)
 		XMark = MapEast;
-	else if (Direction == WEST)
+	else if (_direction == WEST)
 		XMark = MapWest;
 
 	drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true);
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 45d5584..a4d3da2 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -45,9 +45,6 @@ namespace Lab {
 #define NOFILE         "no file"
 
 RoomData *_rooms;
-uint16 NumInv, ManyRooms, HighestCondition, Direction;
-
-extern bool DoNotDrawMessage, noupdatediff, QuitLab, MusicOn;
 
 /*****************************************************************************/
 /* Generates a random number.                                                */
@@ -104,7 +101,7 @@ ViewData *getViewData(uint16 roomNum, uint16 direction) {
 /*****************************************************************************/
 static CloseData *getObject(uint16 x, uint16 y, CloseDataPtr lcptr) {
 	if (lcptr == NULL) {
-		lcptr = getViewData(g_lab->_roomNum, Direction)->closeUps;
+		lcptr = getViewData(g_lab->_roomNum, g_lab->_direction)->closeUps;
 	} else {
 		lcptr = lcptr->SubCloseUps;
 	}
@@ -150,7 +147,7 @@ static CloseDataPtr findCPtrMatch(CloseDataPtr cpmain, CloseDataPtr list) {
 /* Returns the current picture name.                                         */
 /*****************************************************************************/
 char *getPictName(CloseDataPtr *lcptr) {
-	ViewData *viewPtr = getViewData(g_lab->_roomNum, Direction);
+	ViewData *viewPtr = getViewData(g_lab->_roomNum, g_lab->_direction);
 
 	if (*lcptr != NULL) {
 		*lcptr = findCPtrMatch(*lcptr, viewPtr->closeUps);
@@ -178,13 +175,13 @@ void LabEngine::drawDirection(CloseDataPtr lcptr) {
 		message += ", ";
 	}
 
-	if (Direction == NORTH)
+	if (_direction == NORTH)
 		message += _resource->getStaticText(kTextFacingNorth);
-	else if (Direction == EAST)
+	else if (_direction == EAST)
 		message += _resource->getStaticText(kTextFacingEast);
-	else if (Direction == SOUTH)
+	else if (_direction == SOUTH)
 		message += _resource->getStaticText(kTextFacingSouth);
-	else if (Direction == WEST)
+	else if (_direction == WEST)
 		message += _resource->getStaticText(kTextFacingWest);
 
 	_graphics->drawMessage(message.c_str());
@@ -241,7 +238,7 @@ void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords)
 	uint16 x1, y1, x2, y2;
 
 	if (*cptr == NULL) {
-		lcptr = getViewData(g_lab->_roomNum, Direction)->closeUps;
+		lcptr = getViewData(g_lab->_roomNum, g_lab->_direction)->closeUps;
 	} else
 		lcptr = (*cptr)->SubCloseUps;
 
@@ -274,7 +271,7 @@ bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
 	CloseDataPtr lcptr;
 
 	if (*cptr == NULL) {
-		lcptr = getViewData(g_lab->_roomNum, Direction)->closeUps;
+		lcptr = getViewData(g_lab->_roomNum, g_lab->_direction)->closeUps;
 	} else if ((*cptr)->CloseUpType < 0) {
 		g_lab->_conditions->inclElement(abs((*cptr)->CloseUpType));
 		return true;
@@ -342,7 +339,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			break;
 
 		case NOUPDATE:
-			noupdatediff = true;
+			_noUpdateDiff = true;
 			_anim->_doBlack = false;
 			break;
 
@@ -369,30 +366,30 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			break;
 
 		case SHOWMESSAGE:
-			DoNotDrawMessage = false;
+			_graphics->_doNotDrawMessage = false;
 
 			if (_graphics->_longWinInFront)
 				_graphics->longDrawMessage((char *)aptr->Data);
 			else
 				_graphics->drawMessage((char *)aptr->Data);
 
-			DoNotDrawMessage = true;
+			_graphics->_doNotDrawMessage = true;
 			break;
 
 		case CSHOWMESSAGE:
 			if (*lcptr == NULL) {
-				DoNotDrawMessage = false;
+				_graphics->_doNotDrawMessage = false;
 				_graphics->drawMessage((char *)aptr->Data);
-				DoNotDrawMessage = true;
+				_graphics->_doNotDrawMessage = true;
 			}
 
 			break;
 
 		case SHOWMESSAGES: {
 				char **str = (char **)aptr->Data;
-				DoNotDrawMessage = false;
+				_graphics->_doNotDrawMessage = false;
 				_graphics->drawMessage(str[getRandom(aptr->Param1)]);
-				DoNotDrawMessage = true;
+				_graphics->_doNotDrawMessage = true;
 			}
 			break;
 
@@ -408,7 +405,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			}
 
 			_roomNum   = aptr->Param1;
-			Direction = aptr->Param2 - 1;
+			_direction = aptr->Param2 - 1;
 			*lcptr      = NULL;
 			_anim->_doBlack = true;
 			break;
@@ -440,7 +437,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			break;
 
 		case SHOWDIR:
-			DoNotDrawMessage = false;
+			_graphics->_doNotDrawMessage = false;
 			break;
 
 		case WAITSECS: {
@@ -509,11 +506,11 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			break;
 
 		case WINGAME:
-			QuitLab = true;
+			_quitLab = true;
 			break;
 
 		case LOSTGAME:
-			QuitLab = true;
+			_quitLab = true;
 			break;
 
 		case RESETBUFFER:
@@ -695,7 +692,7 @@ bool doGoForward(CloseDataPtr *lcptr) {
 	RuleList *rules = _rooms[g_lab->_roomNum]._rules;
 
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
-		if (((*rule)->RuleType == GOFORWARD) && ((*rule)->Param1 == (Direction + 1))) {
+		if (((*rule)->RuleType == GOFORWARD) && ((*rule)->Param1 == (g_lab->_direction + 1))) {
 			if (checkConditions((*rule)->Condition)) {
 				g_lab->doActions((*rule)->ActionList, lcptr);
 				return true;
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index aaac1cd..654ce97 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -35,7 +35,6 @@
 namespace Lab {
 
 extern RoomData *_rooms;
-extern uint16 NumInv, ManyRooms, HighestCondition;
 
 Resource::Resource(LabEngine *vm) : _vm(vm) {
 	readStaticText();
@@ -92,12 +91,12 @@ char *Resource::getText(const char *fileName) {
 bool Resource::readRoomData(const char *fileName) {
 	Common::File *dataFile = openDataFile(fileName, MKTAG('D', 'O', 'R', '1'));
 
-	ManyRooms = dataFile->readUint16LE();
-	HighestCondition = dataFile->readUint16LE();
-	_rooms = (RoomData *)malloc((ManyRooms + 1) * sizeof(RoomData));
-	memset(_rooms, 0, (ManyRooms + 1) * sizeof(RoomData));
+	_vm->_manyRooms = dataFile->readUint16LE();
+	_vm->_highestCondition = dataFile->readUint16LE();
+	_rooms = (RoomData *)malloc((_vm->_manyRooms + 1) * sizeof(RoomData));
+	memset(_rooms, 0, (_vm->_manyRooms + 1) * sizeof(RoomData));
 
-	for (uint16 i = 1; i <= ManyRooms; i++) {
+	for (uint16 i = 1; i <= _vm->_manyRooms; i++) {
 		_rooms[i]._northDoor = dataFile->readUint16LE();
 		_rooms[i]._southDoor = dataFile->readUint16LE();
 		_rooms[i]._eastDoor = dataFile->readUint16LE();
@@ -119,10 +118,10 @@ bool Resource::readRoomData(const char *fileName) {
 InventoryData *Resource::readInventory(const char *fileName) {
 	Common::File *dataFile = openDataFile(fileName, MKTAG('I', 'N', 'V', '1'));
 
-	NumInv = dataFile->readUint16LE();
-	InventoryData *inventory = (InventoryData *)malloc((NumInv + 1) * sizeof(InventoryData));
+	_vm->_numInv = dataFile->readUint16LE();
+	InventoryData *inventory = (InventoryData *)malloc((_vm->_numInv + 1) * sizeof(InventoryData));
 
-	for (uint16 i = 1; i <= NumInv; i++) {
+	for (uint16 i = 1; i <= _vm->_numInv; i++) {
 		inventory[i].Many = dataFile->readUint16LE();
 		inventory[i].name = readString(dataFile);
 		inventory[i].BInvName = readString(dataFile);
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 7c7dcb1..01b114f 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -63,7 +63,6 @@ Image *MonButton;
 
 extern uint16 *FadePalette;
 extern BitMap *DispBitMap, *DrawBitMap;
-extern uint16 Direction;
 
 #define INCL(BITSET,BIT) ((BITSET) |= (BIT))
 #define SETBIT(BITSET,BITNUM)   INCL(BITSET, (1 << (BITNUM)))
@@ -431,14 +430,14 @@ bool LabEngine::saveRestoreGame() {
 				desc = dialog->createDefaultSaveDescription(slot);
 			}
 
-			isOK = saveGame(Direction, _inventory[QUARTERNUM].Many, slot, desc);
+			isOK = saveGame(_direction, _inventory[QUARTERNUM].Many, slot, desc);
 		}
 	} else {
 		// Restore
 		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
 		int slot = dialog->runModalWithCurrentTarget();
 		if (slot >= 0) {
-			isOK = loadGame(&Direction, &(_inventory[QUARTERNUM].Many), slot);
+			isOK = loadGame(&_direction, &(_inventory[QUARTERNUM].Many), slot);
 			if (isOK)
 				_music->resetMusic();
 		}


Commit: 785772e86f2f1a15a0f5154e25203b5b94e5087a
    https://github.com/scummvm/scummvm/commit/785772e86f2f1a15a0f5154e25203b5b94e5087a
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:52+01:00

Commit Message:
LAB: Move fade functions to DisplayMan, some renaming

Changed paths:
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/graphics.h
    engines/lab/intro.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/labfun.h
    engines/lab/map.cpp
    engines/lab/savegame.cpp
    engines/lab/special.cpp
    engines/lab/tilepuzzle.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 158286f..8af38d8 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -122,8 +122,8 @@ void LabEngine::freeScreens() {
 
 	for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++) {
 		delete _invImages[imgIdx];
-		delete Images[imgIdx];
-		_invImages[imgIdx] = Images[imgIdx] = nullptr;
+		delete _numberImages[imgIdx];
+		_invImages[imgIdx] = _numberImages[imgIdx] = nullptr;
 	}
 }
 
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index babc550..52f92e5 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -53,6 +53,7 @@ DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) {
 	_displayBuffer = nullptr;
 	_currentDisplayBuffer = nullptr;
 	_tempScrollData = nullptr;
+	FadePalette = nullptr;
 
 	_screenWidth = 0;
 	_screenHeight = 0;
@@ -1164,4 +1165,36 @@ void DisplayMan::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint1
 	rectFill(x1, y1, x2, y1 + dy - 1);
 }
 
+/*****************************************************************************/
+/* Does the fading of the Palette on the screen.                             */
+/*****************************************************************************/
+uint16 DisplayMan::fadeNumIn(uint16 num, uint16 res, uint16 counter) {
+	return (num - ((((int32)(15 - counter)) * ((int32)(num - res))) / 15));
+}
+
+
+uint16 DisplayMan::fadeNumOut(uint16 num, uint16 res, uint16 counter) {
+	return (num - ((((int32) counter) * ((int32)(num - res))) / 15));
+}
+
+void DisplayMan::fade(bool fadein, uint16 res) {
+	uint16 newpal[16];
+
+	for (uint16 i = 0; i < 16; i++) {
+		for (uint16 palIdx = 0; palIdx < 16; palIdx++) {
+			if (fadein)
+				newpal[palIdx] = (0x00F & fadeNumIn(0x00F & FadePalette[palIdx], 0x00F & res, i)) +
+				(0x0F0 & fadeNumIn(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) +
+				(0xF00 & fadeNumIn(0xF00 & FadePalette[palIdx], 0xF00 & res, i));
+			else
+				newpal[palIdx] = (0x00F & fadeNumOut(0x00F & FadePalette[palIdx], 0x00F & res, i)) +
+				(0x0F0 & fadeNumOut(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) +
+				(0xF00 & fadeNumOut(0xF00 & FadePalette[palIdx], 0xF00 & res, i));
+		}
+
+		g_lab->_graphics->setAmigaPal(newpal, 16);
+		g_lab->waitTOF();
+		g_lab->_music->updateMusic();
+	}
+}
 } // End of namespace Lab
diff --git a/engines/lab/graphics.h b/engines/lab/graphics.h
index 979d73f..564f041 100644
--- a/engines/lab/graphics.h
+++ b/engines/lab/graphics.h
@@ -41,6 +41,9 @@ class DisplayMan {
 private:
 	LabEngine *_vm;
 
+	uint16 fadeNumIn(uint16 num, uint16 res, uint16 counter);
+	uint16 fadeNumOut(uint16 num, uint16 res, uint16 counter);
+
 	byte _curapen;
 	byte *_curBitmap;
 	byte _curvgapal[256 * 3];
@@ -125,6 +128,7 @@ public:
 	byte *getCurrentDrawingBuffer();
 	void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void fade(bool fadein, uint16 res);
 
 	bool _longWinInFront;
 	bool _lastMessageLong;
@@ -134,6 +138,7 @@ public:
 	byte *_displayBuffer;
 	byte *_currentDisplayBuffer;
 	bool _doNotDrawMessage;
+	uint16 *FadePalette;
 };
 
 } // End of namespace Lab
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 0313733..070b03f 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -33,8 +33,6 @@
 #include "lab/anim.h"
 
 namespace Lab {
-extern uint16 *FadePalette;
-
 Intro::Intro(LabEngine *vm) : _vm(vm) {
 	_quitIntro = false;
 }
@@ -101,14 +99,14 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 			if (begin)
 				begin = false;
 			else if (isScreen)
-				fade(false, 0);
+				_vm->_graphics->fade(false, 0);
 
 			if (isScreen) {
 				_vm->_graphics->setAPen(7);
 				_vm->_graphics->rectFillScaled(10, 10, 310, 190);
 
 				Drawn = _vm->_graphics->flowTextScaled(msgFont, (!_vm->_isHiRes) * -1, 5, 7, false, false, true, true, 14, 11, 306, 189, (char *)curText);
-				fade(true, 0);
+				_vm->_graphics->fade(true, 0);
 			} else {
 				Drawn = _vm->_graphics->longDrawMessage((char *)curText);
 			}
@@ -122,7 +120,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 
 			if (_quitIntro) {
 				if (isScreen)
-					fade(false, 0);
+					_vm->_graphics->fade(false, 0);
 
 				delete[] textBuffer;
 				return;
@@ -142,7 +140,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 			if (secs > timeDelay) {
 				if (end) {
 					if (isScreen)
-						fade(false, 0);
+						_vm->_graphics->fade(false, 0);
 
 					delete[] textBuffer;
 					return;
@@ -162,7 +160,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 				_quitIntro = true;
 
 				if (isScreen)
-					fade(false, 0);
+					_vm->_graphics->fade(false, 0);
 
 				delete[] textBuffer;
 				return;
@@ -172,7 +170,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 				if (IEQUALIFIER_LEFTBUTTON & qualifier) {
 					if (end) {
 						if (isScreen)
-							fade(false, 0);
+							_vm->_graphics->fade(false, 0);
 
 						delete[] textBuffer;
 						return;
@@ -184,7 +182,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 
 				if (_quitIntro) {
 					if (isScreen)
-						fade(false, 0);
+						_vm->_graphics->fade(false, 0);
 
 					delete[] textBuffer;
 					return;
@@ -193,7 +191,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 
 			if (end) {
 				if (isScreen)
-					fade(false, 0);
+					_vm->_graphics->fade(false, 0);
 
 				delete[] textBuffer;
 				return;
@@ -273,7 +271,7 @@ void Intro::introSequence() {
 		nReadPict("TNDcycle2.pic", true);
 	_vm->_anim->_noPalChange = false;
 
-	FadePalette = palette;
+	_vm->_graphics->FadePalette = palette;
 
 	for (uint16 i = 0; i < 16; i++) {
 		if (_quitIntro)
@@ -285,7 +283,7 @@ void Intro::introSequence() {
 	}
 
 	_vm->_music->updateMusic();
-	fade(true, 0);
+	_vm->_graphics->fade(true, 0);
 
 	for (int times = 0; times < 150; times++) {
 		if (_quitIntro)
@@ -303,7 +301,7 @@ void Intro::introSequence() {
 		_vm->waitTOF();
 	}
 
-	fade(false, 0);
+	_vm->_graphics->fade(false, 0);
 	_vm->_graphics->blackAllScreen();
 	_vm->_music->updateMusic();
 
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index f9de51b..5f2a4d5 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -95,9 +95,12 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 
 	for (int i = 0; i < 10; i++) {
 		_invImages[i] = nullptr;
-		Images[i] = nullptr;
+		_numberImages[i] = nullptr;
 	}
 
+	for (int i = 0; i < 16; i++)
+		_tiles[i] = nullptr;
+
 	_moveGadgetList = nullptr;
 	_invGadgetList = nullptr;
 	_curFileName = nullptr;
@@ -128,7 +131,7 @@ LabEngine::~LabEngine() {
 	delete _graphics;
 
 	for (int i = 0; i < 16; i++)
-		delete Tiles[i];
+		delete _tiles[i];
 }
 
 Common::Error LabEngine::run() {
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 5675a0c..384b559 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -126,16 +126,16 @@ public:
 	Gadget *_invGadgetList;
 	Image *_moveImages[20];
 	Image *_invImages[10];
-	Image *Images[10];
-	uint16 CurTile[4][4];
-	byte combination[6];
+	Image *_numberImages[10];
+	uint16 _curTile[4][4];
+	byte _combination[6];
 
 private:
 	int _lastWaitTOFTicks;
 	bool _lastTooLong;
 	CloseDataPtr _cptr;
 	InventoryData *_inventory;
-	Image *Tiles[16];
+	Image *_tiles[16];
 
 private:
 	bool from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Common::Point tmpPos, uint16 &curInv, IntuiMessage * curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode);
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index d58b27e..c56dbcd 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -70,12 +70,6 @@ struct SaveGameHeader {
 
 bool readMusic(const char *filename, bool waitTillFinished);
 
-/*---------------------------*/
-/*-------- From Map.c -------*/
-/*---------------------------*/
-
-void fade(bool fadein, uint16 res);
-
 /*--------------------------*/
 /*----- From saveGame.c ----*/
 /*--------------------------*/
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 8281a49..218aae4 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -56,8 +56,6 @@ static MapData *Maps;
 
 extern char *LOWERFLOORS, *MIDDLEFLOORS, *UPPERFLOORS, *MEDMAZEFLOORS, *HEDGEMAZEFLOORS, *SURMAZEFLOORS, *CARNIVALFLOOR, *SURMAZEMSG;
 
-uint16 *FadePalette;
-
 static uint16 MapGadX[3] = {101, 55, 8}, MapGadY[3] = {105, 105, 105};
 
 static Gadget downgadget = { 101, 105, 2, VKEY_DNARROW, 0L, NULL, NULL, NULL },
@@ -66,14 +64,6 @@ static Gadget downgadget = { 101, 105, 2, VKEY_DNARROW, 0L, NULL, NULL, NULL },
 
 static Gadget *MapGadgetList = &backgadget;
 
-static uint16 AmigaMapPalette[] = {
-	0x0BA8, 0x0C11, 0x0A74, 0x0076,
-	0x0A96, 0x0DCB, 0x0CCA, 0x0222,
-	0x0444, 0x0555, 0x0777, 0x0999,
-	0x0AAA, 0x0ED0, 0x0EEE, 0x0694
-};
-
-
 #define LOWERFLOOR     1
 #define MIDDLEFLOOR    2
 #define UPPERFLOOR     3
@@ -167,48 +157,11 @@ static bool loadMapData() {
 	return true;
 }
 
-
 static void freeMapData() {
 	delete[] Maps;
 	Maps = NULL;
 }
 
-
-static uint16 fadeNumIn(uint16 num, uint16 res, uint16 counter) {
-	return (num - ((((int32)(15 - counter)) * ((int32)(num - res))) / 15));
-}
-
-
-static uint16 fadeNumOut(uint16 num, uint16 res, uint16 counter) {
-	return (num - ((((int32) counter) * ((int32)(num - res))) / 15));
-}
-
-
-
-/*****************************************************************************/
-/* Does the fading of the Palette on the screen.                             */
-/*****************************************************************************/
-void fade(bool fadein, uint16 res) {
-	uint16 newpal[16];
-
-	for (uint16 i = 0; i < 16; i++) {
-		for (uint16 palIdx = 0; palIdx < 16; palIdx++) {
-			if (fadein)
-				newpal[palIdx] = (0x00F & fadeNumIn(0x00F & FadePalette[palIdx], 0x00F & res, i)) +
-				                 (0x0F0 & fadeNumIn(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) +
-				                 (0xF00 & fadeNumIn(0xF00 & FadePalette[palIdx], 0xF00 & res, i));
-			else
-				newpal[palIdx] = (0x00F & fadeNumOut(0x00F & FadePalette[palIdx], 0x00F & res, i)) +
-				                 (0x0F0 & fadeNumOut(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) +
-				                 (0xF00 & fadeNumOut(0xF00 & FadePalette[palIdx], 0xF00 & res, i));
-		}
-
-		g_lab->_graphics->setAmigaPal(newpal, 16);
-		g_lab->waitTOF();
-		g_lab->_music->updateMusic();
-	}
-}
-
 /*****************************************************************************/
 /* Figures out what a room's coordinates should be.                          */
 /*****************************************************************************/
@@ -460,7 +413,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 	_event->mouseHide();
 
 	if (fadeout)
-		fade(false, 0);
+		_graphics->fade(false, 0);
 
 	_graphics->setAPen(0);
 	_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);
@@ -523,7 +476,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 		_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr);
 
 	if (fadein)
-		fade(true, 0);
+		_graphics->fade(true, 0);
 
 	_event->mouseShow();
 }
@@ -594,9 +547,9 @@ void LabEngine::processMap(uint16 CurRoom) {
 					getUpFloor(&CurFloor, &drawmap);
 
 					if (drawmap) {
-						fade(false, 0);
+						_graphics->fade(false, 0);
 						drawMap(CurRoom, CurMsg, CurFloor, false, false);
-						fade(true, 0);
+						_graphics->fade(true, 0);
 					} else
 						CurFloor = OldFloor;
 				} else if (GadgetID == 2) { /* Down arrow */
@@ -604,9 +557,9 @@ void LabEngine::processMap(uint16 CurRoom) {
 					getDownFloor(&CurFloor, &drawmap);
 
 					if (drawmap) {
-						fade(false, 0);
+						_graphics->fade(false, 0);
 						drawMap(CurRoom, CurMsg, CurFloor, false, false);
-						fade(true, 0);
+						_graphics->fade(true, 0);
 					} else
 						CurFloor = OldFloor;
 				}
@@ -618,9 +571,9 @@ void LabEngine::processMap(uint16 CurRoom) {
 				        && onFloor(SURMAZEFLOOR)) {
 					CurFloor = SURMAZEFLOOR;
 
-					fade(false, 0);
+					_graphics->fade(false, 0);
 					drawMap(CurRoom, CurMsg, CurFloor, false, false);
-					fade(true, 0);
+					_graphics->fade(true, 0);
 				}
 
 				else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(358)) && (MouseY >= mapScaleY(71))
@@ -628,9 +581,9 @@ void LabEngine::processMap(uint16 CurRoom) {
 				         && onFloor(CARNIVAL)) {
 					CurFloor = CARNIVAL;
 
-					fade(false, 0);
+					_graphics->fade(false, 0);
 					drawMap(CurRoom, CurMsg, CurFloor, false, false);
-					fade(true, 0);
+					_graphics->fade(true, 0);
 				}
 
 				else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(557)) && (MouseY >= mapScaleY(325))
@@ -638,9 +591,9 @@ void LabEngine::processMap(uint16 CurRoom) {
 				         && onFloor(MEDMAZEFLOOR)) {
 					CurFloor = MEDMAZEFLOOR;
 
-					fade(false, 0);
+					_graphics->fade(false, 0);
 					drawMap(CurRoom, CurMsg, CurFloor, false, false);
-					fade(true, 0);
+					_graphics->fade(true, 0);
 				}
 
 				else if ((CurFloor == UPPERFLOOR) && (MouseX >= mapScaleX(524)) && (MouseY >=  mapScaleY(97))
@@ -648,9 +601,9 @@ void LabEngine::processMap(uint16 CurRoom) {
 				         && onFloor(HEDGEMAZEFLOOR)) {
 					CurFloor = HEDGEMAZEFLOOR;
 
-					fade(false, 0);
+					_graphics->fade(false, 0);
 					drawMap(CurRoom, CurMsg, CurFloor, false, false);
-					fade(true, 0);
+					_graphics->fade(true, 0);
 				}
 
 				else if (MouseX > mapScaleX(314)) {
@@ -705,7 +658,14 @@ void LabEngine::processMap(uint16 CurRoom) {
 /* Does the map processing.                                                  */
 /*****************************************************************************/
 void LabEngine::doMap(uint16 CurRoom) {
-	FadePalette = AmigaMapPalette;
+	static uint16 AmigaMapPalette[] = {
+		0x0BA8, 0x0C11, 0x0A74, 0x0076,
+		0x0A96, 0x0DCB, 0x0CCA, 0x0222,
+		0x0444, 0x0555, 0x0777, 0x0999,
+		0x0AAA, 0x0ED0, 0x0EEE, 0x0694
+	};
+
+	_graphics->FadePalette = AmigaMapPalette;
 
 	_music->updateMusic();
 	loadMapData();
@@ -726,7 +686,7 @@ void LabEngine::doMap(uint16 CurRoom) {
 	_graphics->screenUpdate();
 	processMap(CurRoom);
 	_event->attachGadgetList(NULL);
-	fade(false, 0);
+	_graphics->fade(false, 0);
 	_graphics->blackAllScreen();
 	_event->mouseHide();
 	_graphics->setAPen(0);
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index cfb636f..133e4b1 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -146,12 +146,12 @@ bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc)
 
 	// Combination lock and tile stuff
 	for (i = 0; i < 6; i++)
-		file->writeByte(g_lab->combination[i]);
+		file->writeByte(g_lab->_combination[i]);
 
 	// Tiles
 	for (i = 0; i < 4; i++)
 		for (j = 0; j < 4; j++)
-			file->writeUint16LE(g_lab->CurTile[i][j]);
+			file->writeUint16LE(g_lab->_curTile[i][j]);
 
 	// Breadcrumbs
 	for (i = 0; i < sizeof(g_lab->_breadCrumbs); i++) {
@@ -196,12 +196,12 @@ bool loadGame(uint16 *Direction, uint16 *Quarters, int slot) {
 
 	// Combination lock and tile stuff
 	for (i = 0; i < 6; i++)
-		g_lab->combination[i] = file->readByte();
+		g_lab->_combination[i] = file->readByte();
 
 	// Tiles
 	for (i = 0; i < 4; i++)
 		for (j = 0; j < 4; j++)
-			g_lab->CurTile[i][j] = file->readUint16LE();
+			g_lab->_curTile[i][j] = file->readUint16LE();
 
 	// Breadcrumbs
 	for (i = 0; i < 128; i++) {
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 01b114f..c4751ce 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -60,8 +60,6 @@ static uint16 monitorPage;
 static const char *TextFileName;
 
 Image *MonButton;
-
-extern uint16 *FadePalette;
 extern BitMap *DispBitMap, *DrawBitMap;
 
 #define INCL(BITSET,BIT) ((BITSET) |= (BIT))
@@ -78,7 +76,7 @@ extern BitMap *DispBitMap, *DrawBitMap;
 static byte *loadBackPict(const char *fileName, bool tomem) {
 	byte *res = nullptr;
 
-	FadePalette = hipal;
+	g_lab->_graphics->FadePalette = hipal;
 	g_lab->_anim->_noPalChange = true;
 
 	if (tomem)
@@ -316,7 +314,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 
 
 	if (needFade)
-		fade(true, 0);
+		_graphics->fade(true, 0);
 
 	g_lab->_anim->_noPalChange = true;
 	JBackImage._imageData = _graphics->readPictToMem("P:Journal.pic", _graphics->_screenWidth, _graphics->_screenHeight);
@@ -398,7 +396,7 @@ void LabEngine::doJournal() {
 	_event->mouseShow();
 	processJournal();
 	_event->attachGadgetList(NULL);
-	fade(false, 0);
+	_graphics->fade(false, 0);
 	_event->mouseHide();
 
 	ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
@@ -536,9 +534,9 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 				TextFileName = Test;
 
 				ntext = g_lab->_resource->getText(TextFileName);
-				fade(false, 0);
+				_graphics->fade(false, 0);
 				drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
-				fade(true, 0);
+				_graphics->fade(true, 0);
 				delete[] ntext;
 			}
 		}
@@ -624,7 +622,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 
 	monitorPage = 0;
 	lastpage = false;
-	FadePalette = hipal;
+	_graphics->FadePalette = hipal;
 
 	TextFont *monitorFont = _resource->getFont("P:Map.fon");
 	Common::File *buttonFile = g_lab->_resource->openDataFile("P:MonImage");
@@ -635,9 +633,9 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 	loadBackPict(background, false);
 	drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
 	_event->mouseShow();
-	fade(true, 0);
+	_graphics->fade(true, 0);
 	processMonitor(ntext, monitorFont, isinteractive, x1, y1, x2, y2);
-	fade(false, 0);
+	_graphics->fade(false, 0);
 	_event->mouseHide();
 	delete[] ntext;
 	closeFont(monitorFont);
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index 1cee9d3..5ab0454 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -51,15 +51,15 @@ const int COMBINATION_X[6] = { 45, 83, 129, 166, 211, 248 };
 
 void LabEngine::initTilePuzzle() {
 	for (int i = 0; i < 16; i++)
-		Tiles[i] = nullptr;
+		_tiles[i] = nullptr;
 
 	for (int i = 0; i < 4; i++) {
 		for (int j = 0; j < 4; j++)
-			CurTile[i][j] = INIT_TILE[i][j];
+			_curTile[i][j] = INIT_TILE[i][j];
 	}
 
 	for (int i = 0; i < 6; i++)
-		combination[i] = 0;
+		_combination[i] = 0;
 }
 
 /*****************************************************************************/
@@ -106,33 +106,33 @@ void LabEngine::changeTile(uint16 col, uint16 row) {
 	int16 scrolltype = -1;
 
 	if (row > 0) {
-		if (CurTile[col] [row - 1] == 0) {
-			CurTile[col] [row - 1] = CurTile[col] [row];
-			CurTile[col] [row] = 0;
+		if (_curTile[col] [row - 1] == 0) {
+			_curTile[col] [row - 1] = _curTile[col] [row];
+			_curTile[col] [row] = 0;
 			scrolltype = DOWNSCROLL;
 		}
 	}
 
 	if (col > 0) {
-		if (CurTile[col - 1] [row] == 0) {
-			CurTile[col - 1] [row] = CurTile[col] [row];
-			CurTile[col] [row] = 0;
+		if (_curTile[col - 1] [row] == 0) {
+			_curTile[col - 1] [row] = _curTile[col] [row];
+			_curTile[col] [row] = 0;
 			scrolltype = RIGHTSCROLL;
 		}
 	}
 
 	if (row < 3) {
-		if (CurTile[col] [row + 1] == 0) {
-			CurTile[col] [row + 1] = CurTile[col] [row];
-			CurTile[col] [row] = 0;
+		if (_curTile[col] [row + 1] == 0) {
+			_curTile[col] [row + 1] = _curTile[col] [row];
+			_curTile[col] [row] = 0;
 			scrolltype = UPSCROLL;
 		}
 	}
 
 	if (col < 3) {
-		if (CurTile[col + 1] [row] == 0) {
-			CurTile[col + 1] [row] = CurTile[col] [row];
-			CurTile[col] [row] = 0;
+		if (_curTile[col + 1] [row] == 0) {
+			_curTile[col + 1] [row] = _curTile[col] [row];
+			_curTile[col] [row] = 0;
 			scrolltype = LEFTSCROLL;
 		}
 	}
@@ -152,7 +152,7 @@ void LabEngine::changeTile(uint16 col, uint16 row) {
 
 		while (row < 4) {
 			while (col < 4) {
-				check = check && (CurTile[row] [col] == SOLUTION[row] [col]);
+				check = check && (_curTile[row] [col] == SOLUTION[row] [col]);
 				col++;
 			}
 
@@ -226,10 +226,10 @@ void LabEngine::doTile(bool showsolution) {
 			if (showsolution)
 				num = SOLUTION[col] [row];
 			else
-				num = CurTile[col] [row];
+				num = _curTile[col] [row];
 
 			if (showsolution || num)
-				Tiles[num]->drawImage(cols + (col * colm), rows + (row * rowm));
+				_tiles[num]->drawImage(cols + (col * colm), rows + (row * rowm));
 
 			col++;
 		}
@@ -254,7 +254,7 @@ void LabEngine::showTile(const char *filename, bool showsolution) {
 	Common::File *tileFile = tileFile = _resource->openDataFile(showsolution ? "P:TileSolution" : "P:Tile");
 
 	for (uint16 curBit = start; curBit < 16; curBit++)
-		Tiles[curBit] = new Image(tileFile);
+		_tiles[curBit] = new Image(tileFile);
 
 	delete tileFile;
 
@@ -312,18 +312,18 @@ void LabEngine::changeCombination(uint16 number) {
 	uint16 combnum;
 	bool unlocked = true;
 
-	if (combination[number] < 9)
-		(combination[number])++;
+	if (_combination[number] < 9)
+		(_combination[number])++;
 	else
-		combination[number] = 0;
+		_combination[number] = 0;
 
-	combnum = combination[number];
+	combnum = _combination[number];
 
 	display._imageData = _graphics->getCurrentDrawingBuffer();
 	display._width     = _graphics->_screenWidth;
 	display._height    = _graphics->_screenHeight;
 
-	for (uint16 i = 1; i <= (Images[combnum]->_height / 2); i++) {
+	for (uint16 i = 1; i <= (_numberImages[combnum]->_height / 2); i++) {
 		if (_isHiRes) {
 			if (i & 1)
 				waitTOF();
@@ -331,12 +331,12 @@ void LabEngine::changeCombination(uint16 number) {
 			waitTOF();
 
 		display._imageData = _graphics->getCurrentDrawingBuffer();
-		_graphics->scrollDisplayY(2, _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), _graphics->VGAScaleX(COMBINATION_X[number]) + (Images[combnum])->_width - 1, _graphics->VGAScaleY(65) + (Images[combnum])->_height);
-		Images[combnum]->blitBitmap(0, (Images[combnum])->_height - (2 * i), &(display), _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), (Images[combnum])->_width, 2, false);
+		_graphics->scrollDisplayY(2, _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), _graphics->VGAScaleX(COMBINATION_X[number]) + (_numberImages[combnum])->_width - 1, _graphics->VGAScaleY(65) + (_numberImages[combnum])->_height);
+		_numberImages[combnum]->blitBitmap(0, (_numberImages[combnum])->_height - (2 * i), &(display), _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), (_numberImages[combnum])->_width, 2, false);
 	}
 
 	for (uint16 i = 0; i < 6; i++)
-		unlocked = (combination[i] == solution[i]) && unlocked;
+		unlocked = (_combination[i] == solution[i]) && unlocked;
 
 	if (unlocked)
 		_conditions->inclElement(COMBINATIONUNLOCKED);
@@ -357,7 +357,7 @@ void LabEngine::scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2
 /*****************************************************************************/
 void LabEngine::doCombination() {
 	for (uint16 i = 0; i <= 5; i++)
-		Images[combination[i]]->drawImage(_graphics->VGAScaleX(COMBINATION_X[i]), _graphics->VGAScaleY(65));
+		_numberImages[_combination[i]]->drawImage(_graphics->VGAScaleX(COMBINATION_X[i]), _graphics->VGAScaleY(65));
 }
 
 /*****************************************************************************/
@@ -374,7 +374,7 @@ void LabEngine::showCombination(const char *filename) {
 	Common::File *numFile = _resource->openDataFile("P:Numbers");
 
 	for (uint16 CurBit = 0; CurBit < 10; CurBit++)
-		Images[CurBit] = new Image(numFile);
+		_numberImages[CurBit] = new Image(numFile);
 
 	delete numFile;
 


Commit: a9dc3a930241e0d6bb878d70dd98a5511572cc1c
    https://github.com/scummvm/scummvm/commit/a9dc3a930241e0d6bb878d70dd98a5511572cc1c
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:52+01:00

Commit Message:
LAB: Remove some useless uses of g_lab

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 8af38d8..e371858 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -1105,7 +1105,7 @@ int LabEngine::followCrumbs() {
 		uint32 Secs;
 		uint32 Micros;
 
-		g_lab->timeDiff(_crumbSecs, _crumbMicros, &Secs, &Micros);
+		timeDiff(_crumbSecs, _crumbMicros, &Secs, &Micros);
 
 		if (Secs != 0 || Micros != 0)
 			return 0;
@@ -1117,7 +1117,7 @@ int LabEngine::followCrumbs() {
 		_breadCrumbs[_numCrumbs--]._roomNum = 0;
 
 	// Is the current crumb this room? If not, logic error.
-	if (g_lab->_roomNum != _breadCrumbs[_numCrumbs]._roomNum) {
+	if (_roomNum != _breadCrumbs[_numCrumbs]._roomNum) {
 		_numCrumbs = 0;
 		_breadCrumbs[0]._roomNum = 0;
 		_droppingCrumbs = false;
@@ -1150,7 +1150,7 @@ int LabEngine::followCrumbs() {
 		_isCrumbTurning = (moveDir != VKEY_UPARROW);
 		_isCrumbWaiting = true;
 
-		g_lab->addCurTime(theDelay / ONESECOND, theDelay % ONESECOND, &_crumbSecs, &_crumbMicros);
+		addCurTime(theDelay / ONESECOND, theDelay % ONESECOND, &_crumbSecs, &_crumbMicros);
 	}
 
 	return moveDir;


Commit: b3269dc80d2a2e1dca9ac24854578befe5004f4f
    https://github.com/scummvm/scummvm/commit/b3269dc80d2a2e1dca9ac24854578befe5004f4f
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:52+01:00

Commit Message:
LAB: Move readMusic to the Music class

Changed paths:
    engines/lab/graphics.cpp
    engines/lab/labfun.h
    engines/lab/music.cpp
    engines/lab/music.h
    engines/lab/processroom.cpp



diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 52f92e5..6c93b51 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -181,23 +181,6 @@ void DisplayMan::freePict() {
 	_curBitmap = NULL;
 }
 
-/*****************************************************************************/
-/* Reads in a music file.  Ignores any graphics.                             */
-/*****************************************************************************/
-bool readMusic(const char *filename, bool waitTillFinished) {
-	Common::File *file = g_lab->_resource->openDataFile(filename, MKTAG('D', 'I', 'F', 'F'));
-	g_lab->_music->updateMusic();
-	if (!g_lab->_music->_doNotFilestopSoundEffect)
-		g_lab->_music->stopSoundEffect();
-	if (!file)
-		return false;
-
-	g_lab->_anim->_doBlack = false;
-	g_lab->_anim->readSound(waitTillFinished, file);
-
-	return true;
-}
-
 /*---------------------------------------------------------------------------*/
 /*------------ Does all the text rendering to the message boxes. ------------*/
 /*---------------------------------------------------------------------------*/
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index c56dbcd..80291f6 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -64,12 +64,6 @@ struct SaveGameHeader {
 	uint16 _direction;
 };
 
-/*----------------------------*/
-/*----- From graphics.c ------*/
-/*----------------------------*/
-
-bool readMusic(const char *filename, bool waitTillFinished);
-
 /*--------------------------*/
 /*----- From saveGame.c ----*/
 /*--------------------------*/
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 0f42064..66db0d8 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -308,4 +308,22 @@ void Music::resetMusic() {
 	_tFile = 0;
 }
 
+/*****************************************************************************/
+/* Reads in a music file.  Ignores any graphics.                             */
+/*****************************************************************************/
+bool Music::readMusic(const char *filename, bool waitTillFinished) {
+	Common::File *file = _vm->_resource->openDataFile(filename, MKTAG('D', 'I', 'F', 'F'));
+	updateMusic();
+	if (!_doNotFilestopSoundEffect)
+		stopSoundEffect();
+
+	if (!file)
+		return false;
+
+	_vm->_anim->_doBlack = false;
+	_vm->_anim->readSound(waitTillFinished, file);
+
+	return true;
+}
+
 } // End of namespace Lab
diff --git a/engines/lab/music.h b/engines/lab/music.h
index a94fae5..d292e9e 100644
--- a/engines/lab/music.h
+++ b/engines/lab/music.h
@@ -67,6 +67,7 @@ public:
 	void playSoundEffect(uint16 SampleSpeed, uint32 Length, void *Data);
 	void stopSoundEffect();
 	bool isSoundEffectActive() const;
+	bool readMusic(const char *filename, bool waitTillFinished);
 
 	bool _winmusic, _doNotFilestopSoundEffect;
 	bool _musicOn;
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index a4d3da2..932649c 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -304,20 +304,20 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 		case PLAYSOUND:
 			_music->_loopSoundEffect = false;
 			_music->_waitTillFinished = true;
-			readMusic((char *)aptr->Data, true);
+			_music->readMusic((char *)aptr->Data, true);
 			_music->_waitTillFinished = false;
 			break;
 
 		case PLAYSOUNDB:
 			_music->_loopSoundEffect = false;
 			_music->_waitTillFinished = false;
-			readMusic((char *)aptr->Data, false);
+			_music->readMusic((char *)aptr->Data, false);
 			break;
 
 		case PLAYSOUNDCONT:
 			_music->_doNotFilestopSoundEffect = true;
 			_music->_loopSoundEffect = true;
-			readMusic((char *)aptr->Data, _music->_waitTillFinished);
+			_music->readMusic((char *)aptr->Data, _music->_waitTillFinished);
 			break;
 
 		case SHOWDIFF:


Commit: 803dbcee90bad321532dea54219697aaec34608a
    https://github.com/scummvm/scummvm/commit/803dbcee90bad321532dea54219697aaec34608a
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:52+01:00

Commit Message:
LAB: Move _rooms to LabEngine, some renaming

Changed paths:
    engines/lab/engine.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/music.cpp
    engines/lab/music.h
    engines/lab/parsetypes.h
    engines/lab/processroom.cpp
    engines/lab/resource.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index e371858..f3d1361 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -41,9 +41,7 @@
 namespace Lab {
 
 /* Global parser data */
-extern RoomData *_rooms;
-
-bool ispal = false, MainDisplay = true;
+bool ispal = false;
 
 /* LAB: Labyrinth specific code for the special puzzles */
 #define SPECIALLOCK         100
@@ -226,31 +224,31 @@ bool LabEngine::doCloseUp(CloseDataPtr closePtr) {
 /******************************************************************************/
 /* Gets the current inventory name.                                           */
 /******************************************************************************/
-const char *LabEngine::getInvName(uint16 CurInv) {
-	if (MainDisplay)
-		return _inventory[CurInv].BInvName;
+const char *LabEngine::getInvName(uint16 curInv) {
+	if (_mainDisplay)
+		return _inventory[curInv].BInvName;
 
-	if ((CurInv == LAMPNUM) && _conditions->in(LAMPON))
+	if ((curInv == LAMPNUM) && _conditions->in(LAMPON))
 		return "P:Mines/120";
 
-	if ((CurInv == BELTNUM) && _conditions->in(BELTGLOW))
+	if ((curInv == BELTNUM) && _conditions->in(BELTGLOW))
 		return "P:Future/BeltGlow";
 
-	if (CurInv == WESTPAPERNUM) {
-		_curFileName = _inventory[CurInv].BInvName;
+	if (curInv == WESTPAPERNUM) {
+		_curFileName = _inventory[curInv].BInvName;
 		_anim->_noPalChange = true;
 		_graphics->readPict(_curFileName, false);
 		_anim->_noPalChange = false;
 		doWestPaper();
-	} else if (CurInv == NOTESNUM) {
-		_curFileName = _inventory[CurInv].BInvName;
+	} else if (curInv == NOTESNUM) {
+		_curFileName = _inventory[curInv].BInvName;
 		_anim->_noPalChange = true;
 		_graphics->readPict(_curFileName, false);
 		_anim->_noPalChange = false;
 		doNotes();
 	}
 
-	return _inventory[CurInv].BInvName;
+	return _inventory[curInv].BInvName;
 }
 
 /******************************************************************************/
@@ -274,7 +272,7 @@ void LabEngine::interfaceOn() {
 	}
 
 	if (_graphics->_longWinInFront)
-		_event->attachGadgetList(NULL);
+		_event->attachGadgetList(nullptr);
 	else if (_alternate)
 		_event->attachGadgetList(_invGadgetList);
 	else
@@ -284,8 +282,8 @@ void LabEngine::interfaceOn() {
 /******************************************************************************/
 /* If the user hits the "Use" gadget; things that can get used on themselves. */
 /******************************************************************************/
-bool LabEngine::doUse(uint16 CurInv) {
-	if (CurInv == MAPNUM) {                  /* LAB: Labyrinth specific */
+bool LabEngine::doUse(uint16 curInv) {
+	if (curInv == MAPNUM) {                  /* LAB: Labyrinth specific */
 		drawStaticMessage(kTextUseMap);
 		interfaceOff();
 		_anim->stopDiff();
@@ -295,7 +293,7 @@ bool LabEngine::doUse(uint16 CurInv) {
 		_graphics->setPalette(initcolors, 8);
 		_graphics->drawMessage(NULL);
 		_graphics->drawPanel();
-	} else if (CurInv == JOURNALNUM) {         /* LAB: Labyrinth specific */
+	} else if (curInv == JOURNALNUM) {         /* LAB: Labyrinth specific */
 		drawStaticMessage(kTextUseJournal);
 		interfaceOff();
 		_anim->stopDiff();
@@ -304,7 +302,7 @@ bool LabEngine::doUse(uint16 CurInv) {
 		doJournal();
 		_graphics->drawPanel();
 		_graphics->drawMessage(NULL);
-	} else if (CurInv == LAMPNUM) {            /* LAB: Labyrinth specific */
+	} else if (curInv == LAMPNUM) {            /* LAB: Labyrinth specific */
 		interfaceOff();
 
 		if (_conditions->in(LAMPON)) {
@@ -321,20 +319,20 @@ bool LabEngine::doUse(uint16 CurInv) {
 		_anim->_waitForEffect = false;
 
 		_anim->_doBlack = false;
-		_nextFileName = getInvName(CurInv);
-	} else if (CurInv == BELTNUM) {                    /* LAB: Labyrinth specific */
+		_nextFileName = getInvName(curInv);
+	} else if (curInv == BELTNUM) {                    /* LAB: Labyrinth specific */
 		if (!_conditions->in(BELTGLOW))
 			_conditions->inclElement(BELTGLOW);
 
 		_anim->_doBlack = false;
-		_nextFileName = getInvName(CurInv);
-	} else if (CurInv == WHISKEYNUM) {                 /* LAB: Labyrinth specific */
+		_nextFileName = getInvName(curInv);
+	} else if (curInv == WHISKEYNUM) {                 /* LAB: Labyrinth specific */
 		_conditions->inclElement(USEDHELMET);
 		drawStaticMessage(kTextUseWhiskey);
-	} else if (CurInv == PITHHELMETNUM) {              /* LAB: Labyrinth specific */
+	} else if (curInv == PITHHELMETNUM) {              /* LAB: Labyrinth specific */
 		_conditions->inclElement(USEDHELMET);
 		drawStaticMessage(kTextUsePith);
-	} else if (CurInv == HELMETNUM) {                  /* LAB: Labyrinth specific */
+	} else if (curInv == HELMETNUM) {                  /* LAB: Labyrinth specific */
 		_conditions->inclElement(USEDHELMET);
 		drawStaticMessage(kTextUseHelmet);
 	} else
@@ -346,47 +344,46 @@ bool LabEngine::doUse(uint16 CurInv) {
 /******************************************************************************/
 /* Decrements the current inventory number.                                   */
 /******************************************************************************/
-void LabEngine::decIncInv(uint16 *CurInv, bool dec) {
+void LabEngine::decIncInv(uint16 *curInv, bool decreaseFl) {
 	interfaceOff();
 
-	if (dec)
-		(*CurInv)--;
+	if (decreaseFl)
+		(*curInv)--;
 	else
-		(*CurInv)++;
+		(*curInv)++;
 
-	while (*CurInv && (*CurInv <= _numInv)) {
-		if (_conditions->in(*CurInv) && _inventory[*CurInv].BInvName) {
-			_nextFileName = getInvName(*CurInv);
+	while (*curInv && (*curInv <= _numInv)) {
+		if (_conditions->in(*curInv) && _inventory[*curInv].BInvName) {
+			_nextFileName = getInvName(*curInv);
 			break;
 		}
 
-		if (dec)
-			(*CurInv)--;
+		if (decreaseFl)
+			(*curInv)--;
 		else
-			(*CurInv)++;
+			(*curInv)++;
 	}
 
-	if ((*CurInv == 0) || (*CurInv > _numInv)) {
-		if (dec)
-			*CurInv = _numInv;
+	if ((*curInv == 0) || (*curInv > _numInv)) {
+		if (decreaseFl)
+			*curInv = _numInv;
 		else
-			*CurInv = 1;
+			*curInv = 1;
 
-		while (*CurInv && (*CurInv <= _numInv)) {
-			if (_conditions->in(*CurInv) && _inventory[*CurInv].BInvName) {
-				_nextFileName = getInvName(*CurInv);
+		while (*curInv && (*curInv <= _numInv)) {
+			if (_conditions->in(*curInv) && _inventory[*curInv].BInvName) {
+				_nextFileName = getInvName(*curInv);
 				break;
 			}
 
-			if (dec)
-				(*CurInv)--;
+			if (decreaseFl)
+				(*curInv)--;
 			else
-				(*CurInv)++;
+				(*curInv)++;
 		}
 	}
 }
 
-
 /******************************************************************************/
 /* The main game loop                                                         */
 /******************************************************************************/
@@ -394,7 +391,8 @@ void LabEngine::mainGameLoop() {
 	uint16 actionMode = 4;
 	uint16 curInv = MAPNUM;
 
-	bool forceDraw = false, GotMessage = true;
+	bool forceDraw = false;
+	bool gotMessage = true;
 
 	_graphics->setPalette(initcolors, 8);
 
@@ -424,7 +422,7 @@ void LabEngine::mainGameLoop() {
 	while (1) {
 		_event->processInput(true);
 
-		if (GotMessage) {
+		if (gotMessage) {
 			if (_quitLab || g_engine->shouldQuit()) {
 				_anim->stopDiff();
 				break;
@@ -441,7 +439,7 @@ void LabEngine::mainGameLoop() {
 			}
 
 			/* Sets the current picture properly on the screen */
-			if (MainDisplay)
+			if (_mainDisplay)
 				_nextFileName = getPictName(&_cptr);
 
 			if (_noUpdateDiff) {
@@ -456,11 +454,11 @@ void LabEngine::mainGameLoop() {
 				_curFileName = _nextFileName;
 
 				if (_cptr) {
-					if ((_cptr->CloseUpType == SPECIALLOCK) && MainDisplay)  /* LAB: Labyrinth specific code */
+					if ((_cptr->CloseUpType == SPECIALLOCK) && _mainDisplay)  /* LAB: Labyrinth specific code */
 						showCombination(_curFileName);
 					else if (((_cptr->CloseUpType == SPECIALBRICK)  ||
 					          (_cptr->CloseUpType == SPECIALBRICKNOMOUSE)) &&
-					         MainDisplay) /* LAB: Labyrinth specific code */
+					         _mainDisplay) /* LAB: Labyrinth specific code */
 						showTile(_curFileName, (bool)(_cptr->CloseUpType == SPECIALBRICKNOMOUSE));
 					else
 						_graphics->readPict(_curFileName, false);
@@ -489,7 +487,7 @@ void LabEngine::mainGameLoop() {
 		IntuiMessage *curMsg = getMsg();
 
 		if (curMsg == NULL) { /* Does music load and next animation frame when you've run out of messages */
-			GotMessage = false;
+			gotMessage = false;
 			_music->checkRoomMusic();
 			_music->updateMusic();
 			_anim->diffNextFrame();
@@ -506,7 +504,7 @@ void LabEngine::mainGameLoop() {
 					else if (result == VKEY_RTARROW)
 						code = 8;
 
-					GotMessage = true;
+					gotMessage = true;
 					mayShowCrumbIndicator();
 					_graphics->screenUpdate();
 					if (!from_crumbs(GADGETUP, code, 0, _event->updateAndGetMousePos(), curInv, curMsg, forceDraw, code, actionMode))
@@ -517,7 +515,7 @@ void LabEngine::mainGameLoop() {
 			mayShowCrumbIndicator();
 			_graphics->screenUpdate();
 		} else {
-			GotMessage = true;
+			gotMessage = true;
 
 			Common::Point curPos;
 			curPos.x  = curMsg->mouseX;
@@ -591,7 +589,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 						_anim->_doBlack = true;
 						_graphics->_doNotDrawMessage = false;
 
-						MainDisplay = true;
+						_mainDisplay = true;
 						interfaceOn(); /* Sets the correct gadget list */
 						_graphics->drawPanel();
 						drawRoomMessage(curInv, _cptr);
@@ -680,7 +678,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				_graphics->_doNotDrawMessage = false;
 				interfaceOn(); /* Sets the correct gadget list */
 
-				MainDisplay = false;
+				_mainDisplay = false;
 
 				if (lastInv && _conditions->in(lastInv)) {
 					curInv = lastInv;
@@ -809,7 +807,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			_anim->_doBlack = true;
 			_graphics->_doNotDrawMessage = false;
 
-			MainDisplay = true;
+			_mainDisplay = true;
 			interfaceOn(); /* Sets the correct gadget list */
 			_graphics->drawPanel();
 			drawRoomMessage(curInv, _cptr);
@@ -827,7 +825,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			doit = !saveRestoreGame();
 			_cptr = NULL;
 
-			MainDisplay = true;
+			_mainDisplay = true;
 
 			curInv = MAPNUM;
 			lastInv = MAPNUM;
@@ -851,12 +849,12 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 					perFlipGadget(oldActionMode);
 
 				drawStaticMessage(kTextUseOnWhat);
-				MainDisplay = true;
+				_mainDisplay = true;
 
 				_graphics->screenUpdate();
 			}
 		} else if (gadgetId == 2) {
-			MainDisplay = !MainDisplay;
+			_mainDisplay = !_mainDisplay;
 
 			if ((curInv == 0) || (curInv > _numInv)) {
 				curInv = 1;
@@ -904,7 +902,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 					_anim->_doBlack = true;
 					_graphics->_doNotDrawMessage = false;
 
-					MainDisplay = true;
+					_mainDisplay = true;
 					interfaceOn(); /* Sets the correct gadget list */
 					_graphics->drawPanel();
 					drawRoomMessage(curInv, _cptr);
@@ -919,16 +917,16 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				}
 			}
 		}
-	} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier) && MainDisplay) {
+	} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier) && _mainDisplay) {
 		interfaceOff();
-		MainDisplay = true;
+		_mainDisplay = true;
 
 		doit = false;
 
 		if (_cptr) {
-			if ((_cptr->CloseUpType == SPECIALLOCK) && MainDisplay) /* LAB: Labyrinth specific code */
+			if ((_cptr->CloseUpType == SPECIALLOCK) && _mainDisplay) /* LAB: Labyrinth specific code */
 				mouseCombination(curPos);
-			else if ((_cptr->CloseUpType == SPECIALBRICK) && MainDisplay)
+			else if ((_cptr->CloseUpType == SPECIALBRICK) && _mainDisplay)
 				mouseTile(curPos);
 			else
 				doit = true;
@@ -1022,7 +1020,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 		_alternate = !_alternate;
 		_anim->_doBlack = true;
 		_graphics->_doNotDrawMessage = false;
-		MainDisplay = true;
+		_mainDisplay = true;
 		interfaceOn(); /* Sets the correct gadget list */
 
 		if (_alternate) {
@@ -1163,7 +1161,7 @@ void LabEngine::mayShowCrumbIndicator() {
 	if (getPlatform() != Common::kPlatformWindows)
 		return;
 
-	if (_droppingCrumbs && MainDisplay) {
+	if (_droppingCrumbs && _mainDisplay) {
 		_event->mouseHide();
 		dropCrumbsImage.drawMaskImage(612, 4);
 		_event->mouseShow();
@@ -1177,7 +1175,7 @@ void LabEngine::mayShowCrumbIndicatorOff() {
 	if (getPlatform() != Common::kPlatformWindows)
 		return;
 
-	if (MainDisplay) {
+	if (_mainDisplay) {
 		_event->mouseHide();
 		dropCrumbsOffImage.drawMaskImage(612, 4);
 		_event->mouseShow();
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 5f2a4d5..83f09cd 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -72,11 +72,12 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_isCrumbWaiting = false;
 	_noUpdateDiff = false;
 	_quitLab = false;
+	_mainDisplay = true;
+
 	_numInv = 0;
 	_manyRooms = 0;
 	_direction = 0;
 	_highestCondition = 0;
-
 	_crumbSecs = 0;
 	_crumbMicros = 0;
 
@@ -85,6 +86,7 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_music = nullptr;
 	_anim = nullptr;
 	_graphics = nullptr;
+	_rooms = nullptr;
 
 	_lastTooLong = false;
 	_interfaceOff = false;
@@ -129,6 +131,7 @@ LabEngine::~LabEngine() {
 	delete _music;
 	delete _anim;
 	delete _graphics;
+	free(_rooms);
 
 	for (int i = 0; i < 16; i++)
 		delete _tiles[i];
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 384b559..27bae37 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -90,7 +90,7 @@ private:
 	bool _interfaceOff;
 	bool _noUpdateDiff;
 	bool _quitLab;
-
+	bool _mainDisplay;
 	// timing.cpp
 	void microDelay(uint32 secs, uint32 micros);
 
@@ -100,6 +100,7 @@ public:
 	Music *_music;
 	Anim *_anim;
 	DisplayMan *_graphics;
+	RoomData *_rooms;
 
 	int _roomNum;
 	CrumbData _breadCrumbs[MAX_CRUMBS];
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 218aae4..40e8eb9 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -45,8 +45,6 @@ namespace Lab {
 /*------------------------------ The Map stuff ------------------------------*/
 /*---------------------------------------------------------------------------*/
 
-extern RoomData *_rooms;
-
 static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge,
 			 *HRoom, *VRoom, *Maze, *HugeMaze, *Path, *MapNorth,
 			 *MapEast, *MapSouth, *MapWest, *XMark;
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 66db0d8..ddc6cbd 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -146,13 +146,13 @@ void Music::fillbuffer(byte *musicBuffer) {
 /*****************************************************************************/
 /* Starts up the music initially.                                            */
 /*****************************************************************************/
-void Music::startMusic(bool startatbegin) {
+void Music::startMusic(bool restartFl) {
 	if (!_musicOn)
 		return;
 
 	stopSoundEffect();
 
-	if (startatbegin) {
+	if (restartFl) {
 		_file->seek(0);
 		_leftinfile  = _file->size();
 	}
diff --git a/engines/lab/music.h b/engines/lab/music.h
index d292e9e..7905da7 100644
--- a/engines/lab/music.h
+++ b/engines/lab/music.h
@@ -79,7 +79,7 @@ public:
 private:
 	LabEngine *_vm;
 	void fillbuffer(byte *musicBuffer);
-	void startMusic(bool startatbegin);
+	void startMusic(bool restartFl);
 
 	Common::File *_file;
 	Common::File *_tFile;
diff --git a/engines/lab/parsetypes.h b/engines/lab/parsetypes.h
index 6be1ba2..9bfc2b0 100644
--- a/engines/lab/parsetypes.h
+++ b/engines/lab/parsetypes.h
@@ -103,8 +103,7 @@ namespace Lab {
 
 typedef struct closeData {
 	uint16 x1, y1, x2, y2;
-	int16 CloseUpType;                  /* if > 0, an object.  If < 0,
-                                                        an item */
+	int16 CloseUpType;          /* if > 0, an object.  If < 0, an item */
 	uint16 depth;               /* Level of the closeup. */
 	char *GraphicName, *Message;
 	closeData *NextCloseUp, *SubCloseUps;
@@ -121,14 +120,12 @@ struct ViewData {
 
 struct Action {
 	int16 ActionType, Param1, Param2, Param3;
-	byte *Data;            /* Message, or a pointer to array
-                                                  of messages. */
+	byte *Data;            /* Message, or a pointer to array of messages. */
 	Action *NextAction;
 };
 
 struct Rule {
 	int16 RuleType, Param1, Param2, *Condition;
-
 	Action *ActionList;
 	Rule *NextRule;
 };
@@ -150,8 +147,6 @@ struct InventoryData {
 	char *name, *BInvName;
 };
 
-
-
 /* Map Flags */
 
 /* Where the doors are; in a corridor, assumed to be left doors */
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 932649c..f254d4b 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -44,8 +44,6 @@ namespace Lab {
 
 #define NOFILE         "no file"
 
-RoomData *_rooms;
-
 /*****************************************************************************/
 /* Generates a random number.                                                */
 /*****************************************************************************/
@@ -81,10 +79,10 @@ static bool checkConditions(int16 *condition) {
 /* Gets the current ViewDataPointer.                                         */
 /*****************************************************************************/
 ViewData *getViewData(uint16 roomNum, uint16 direction) {
-	if (!_rooms[roomNum]._roomMsg)
+	if (!g_lab->_rooms[roomNum]._roomMsg)
 		g_lab->_resource->readViews(roomNum);
 
-	ViewData *view = _rooms[roomNum]._view[direction];
+	ViewData *view = g_lab->_rooms[roomNum]._view[direction];
 
 	do {
 		if (checkConditions(view->Condition))
@@ -195,13 +193,13 @@ bool processArrow(uint16 *direction, uint16 arrow) {
 		uint16 room = 1;
 
 		if (*direction == NORTH)
-			room = _rooms[g_lab->_roomNum]._northDoor;
+			room = g_lab->_rooms[g_lab->_roomNum]._northDoor;
 		else if (*direction == SOUTH)
-			room = _rooms[g_lab->_roomNum]._southDoor;
+			room = g_lab->_rooms[g_lab->_roomNum]._southDoor;
 		else if (*direction == EAST)
-			room = _rooms[g_lab->_roomNum]._eastDoor;
+			room = g_lab->_rooms[g_lab->_roomNum]._eastDoor;
 		else if (*direction == WEST)
-			room = _rooms[g_lab->_roomNum]._westDoor;
+			room = g_lab->_rooms[g_lab->_roomNum]._westDoor;
 
 		if (room == 0)
 			return false;
@@ -574,11 +572,11 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr lcptr, Clo
 	action++;
 
 	if (lcptr) {
-		RuleList *rules = _rooms[g_lab->_roomNum]._rules;
+		RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;
 
 		if ((rules == NULL) && (roomNum == 0)) {
 			g_lab->_resource->readViews(roomNum);
-			rules = _rooms[roomNum]._rules;
+			rules = g_lab->_rooms[roomNum]._rules;
 		}
 
 		for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
@@ -629,11 +627,11 @@ bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *
 static bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr lcptr, CloseDataPtr *set, bool allowDefaults) {
 	if (lcptr)
 		if (lcptr->CloseUpType > 0) {
-			RuleList *rules = _rooms[roomNum]._rules;
+			RuleList *rules = g_lab->_rooms[roomNum]._rules;
 
 			if ((rules == NULL) && (roomNum == 0)) {
 				g_lab->_resource->readViews(roomNum);
-				rules = _rooms[roomNum]._rules;
+				rules = g_lab->_rooms[roomNum]._rules;
 			}
 
 			for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
@@ -689,7 +687,7 @@ bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *lcptr) {
 /* Goes thru the rules if the user tries to go forward.                      */
 /*****************************************************************************/
 bool doGoForward(CloseDataPtr *lcptr) {
-	RuleList *rules = _rooms[g_lab->_roomNum]._rules;
+	RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;
 
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 		if (((*rule)->RuleType == GOFORWARD) && ((*rule)->Param1 == (g_lab->_direction + 1))) {
@@ -710,7 +708,7 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *lcptr) {
 	from++;
 	to++;
 
-	RuleList *rules = _rooms[g_lab->_roomNum]._rules;
+	RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;
 
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 		if (((*rule)->RuleType == TURN) ||
@@ -730,7 +728,7 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *lcptr) {
 /* Goes thru the rules if the user tries to go to the main view              */
 /*****************************************************************************/
 bool doMainView(CloseDataPtr *lcptr) {
-	RuleList *rules = _rooms[g_lab->_roomNum]._rules;
+	RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 		if ((*rule)->RuleType == GOMAINVIEW) {
 			if (checkConditions((*rule)->Condition)) {
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 654ce97..f8a70cc 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -34,8 +34,6 @@
 
 namespace Lab {
 
-extern RoomData *_rooms;
-
 Resource::Resource(LabEngine *vm) : _vm(vm) {
 	readStaticText();
 }
@@ -93,22 +91,22 @@ bool Resource::readRoomData(const char *fileName) {
 
 	_vm->_manyRooms = dataFile->readUint16LE();
 	_vm->_highestCondition = dataFile->readUint16LE();
-	_rooms = (RoomData *)malloc((_vm->_manyRooms + 1) * sizeof(RoomData));
-	memset(_rooms, 0, (_vm->_manyRooms + 1) * sizeof(RoomData));
+	_vm->_rooms = (RoomData *)malloc((_vm->_manyRooms + 1) * sizeof(RoomData));
+	memset(_vm->_rooms, 0, (_vm->_manyRooms + 1) * sizeof(RoomData));
 
 	for (uint16 i = 1; i <= _vm->_manyRooms; i++) {
-		_rooms[i]._northDoor = dataFile->readUint16LE();
-		_rooms[i]._southDoor = dataFile->readUint16LE();
-		_rooms[i]._eastDoor = dataFile->readUint16LE();
-		_rooms[i]._westDoor = dataFile->readUint16LE();
-		_rooms[i]._wipeType = dataFile->readByte();
-
-		_rooms[i]._view[NORTH] = nullptr;
-		_rooms[i]._view[SOUTH] = nullptr;
-		_rooms[i]._view[EAST] = nullptr;
-		_rooms[i]._view[WEST] = nullptr;
-		_rooms[i]._rules = nullptr;
-		_rooms[i]._roomMsg = nullptr;
+		_vm->_rooms[i]._northDoor = dataFile->readUint16LE();
+		_vm->_rooms[i]._southDoor = dataFile->readUint16LE();
+		_vm->_rooms[i]._eastDoor = dataFile->readUint16LE();
+		_vm->_rooms[i]._westDoor = dataFile->readUint16LE();
+		_vm->_rooms[i]._wipeType = dataFile->readByte();
+
+		_vm->_rooms[i]._view[NORTH] = nullptr;
+		_vm->_rooms[i]._view[SOUTH] = nullptr;
+		_vm->_rooms[i]._view[EAST] = nullptr;
+		_vm->_rooms[i]._view[WEST] = nullptr;
+		_vm->_rooms[i]._rules = nullptr;
+		_vm->_rooms[i]._roomMsg = nullptr;
 	}
 
 	delete dataFile;
@@ -136,12 +134,12 @@ bool Resource::readViews(uint16 roomNum) {
 	Common::String fileName = "LAB:Rooms/" + Common::String::format("%d", roomNum);
 	Common::File *dataFile = openDataFile(fileName.c_str(), MKTAG('R', 'O', 'M', '4'));
 
-	_rooms[roomNum]._roomMsg = readString(dataFile);
-	_rooms[roomNum]._view[NORTH] = readView(dataFile);
-	_rooms[roomNum]._view[SOUTH] = readView(dataFile);
-	_rooms[roomNum]._view[EAST] = readView(dataFile);
-	_rooms[roomNum]._view[WEST] = readView(dataFile);
-	_rooms[roomNum]._rules = readRule(dataFile);
+	_vm->_rooms[roomNum]._roomMsg = readString(dataFile);
+	_vm->_rooms[roomNum]._view[NORTH] = readView(dataFile);
+	_vm->_rooms[roomNum]._view[SOUTH] = readView(dataFile);
+	_vm->_rooms[roomNum]._view[EAST] = readView(dataFile);
+	_vm->_rooms[roomNum]._view[WEST] = readView(dataFile);
+	_vm->_rooms[roomNum]._rules = readRule(dataFile);
 
 	_vm->_music->updateMusic();
 


Commit: 62c4acc6b36639ebcbd2d9161af9b563e0c561f1
    https://github.com/scummvm/scummvm/commit/62c4acc6b36639ebcbd2d9161af9b563e0c561f1
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:52+01:00

Commit Message:
LAB: Change the gadget lists to use Common::List

Changed paths:
    engines/lab/engine.cpp
    engines/lab/eventman.cpp
    engines/lab/eventman.h
    engines/lab/graphics.cpp
    engines/lab/interface.cpp
    engines/lab/interface.h
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/resource.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index f3d1361..d300f47 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -130,9 +130,8 @@ void LabEngine::freeScreens() {
 /* Permanently flips the imagery of a gadget.                                 */
 /******************************************************************************/
 void LabEngine::perFlipGadget(uint16 gadgetId) {
-	Gadget *topGadget = _moveGadgetList;
-
-	while (topGadget) {
+	for (GadgetList::iterator gadget = _moveGadgetList.begin(); gadget != _moveGadgetList.end(); ++gadget) {
+		Gadget *topGadget = *gadget;
 		if (topGadget->GadgetID == gadgetId) {
 			Image *tmpImage = topGadget->_image;
 			topGadget->_image = topGadget->_altImage;
@@ -144,9 +143,8 @@ void LabEngine::perFlipGadget(uint16 gadgetId) {
 				_event->mouseShow();
 			}
 
-			return;
-		} else
-			topGadget = topGadget->NextGadget;
+			break;
+		}
 	}
 }
 
@@ -274,9 +272,9 @@ void LabEngine::interfaceOn() {
 	if (_graphics->_longWinInFront)
 		_event->attachGadgetList(nullptr);
 	else if (_alternate)
-		_event->attachGadgetList(_invGadgetList);
+		_event->attachGadgetList(&_invGadgetList);
 	else
-		_event->attachGadgetList(_moveGadgetList);
+		_event->attachGadgetList(&_moveGadgetList);
 }
 
 /******************************************************************************/
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 0b3f71e..aeb6fa3 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -57,30 +57,29 @@ static byte MouseData[] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
 /* Checks whether or not the cords fall within one of the gadgets in a list  */
 /* of gadgets.                                                               */
 /*****************************************************************************/
-Gadget *EventManager::checkGadgetHit(Gadget *gadgetList, Common::Point pos) {
-	while (gadgetList != NULL) {
-		if ((pos.x >= gadgetList->x) && (pos.y >= gadgetList->y) &&
-		    (pos.x <= (gadgetList->x + gadgetList->_image->_width)) &&
-		    (pos.y <= (gadgetList->y + gadgetList->_image->_height)) &&
-		     !(GADGETOFF & gadgetList->GadgetFlags)) {
+Gadget *EventManager::checkGadgetHit(GadgetList *gadgetList, Common::Point pos) {
+	for (GadgetList::iterator gadgetItr = gadgetList->begin(); gadgetItr != gadgetList->end(); ++gadgetItr) {
+		Gadget *gadget = *gadgetItr;
+		if ((pos.x >= gadget->x) && (pos.y >= gadget->y) &&
+			(pos.x <= (gadget->x + gadget->_image->_width)) &&
+			(pos.y <= (gadget->y + gadget->_image->_height)) &&
+			!(GADGETOFF & gadget->GadgetFlags)) {
 			if (_vm->_isHiRes) {
-				_hitGadget = gadgetList;
+				_hitGadget = gadget;
 			} else {
 				mouseHide();
-				gadgetList->_altImage->drawImage(gadgetList->x, gadgetList->y);
+				gadget->_altImage->drawImage(gadget->x, gadget->y);
 				mouseShow();
 
 				for (uint16 i = 0; i < 3; i++)
 					_vm->waitTOF();
 
 				mouseHide();
-				gadgetList->_image->drawImage(gadgetList->x, gadgetList->y);
+				gadget->_image->drawImage(gadget->x, gadget->y);
 				mouseShow();
 			}
 
-			return gadgetList;
-		} else {
-			gadgetList = gadgetList->NextGadget;
+			return gadget;
 		}
 	}
 
@@ -89,7 +88,7 @@ Gadget *EventManager::checkGadgetHit(Gadget *gadgetList, Common::Point pos) {
 
 
 
-void EventManager::attachGadgetList(Gadget *gadgetList) {
+void EventManager::attachGadgetList(GadgetList *gadgetList) {
 	if (_screenGadgetList != gadgetList)
 		_lastGadgetHit = nullptr;
 
diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h
index 156fb96..a156a8a 100644
--- a/engines/lab/eventman.h
+++ b/engines/lab/eventman.h
@@ -55,10 +55,10 @@ private:
 public:
 	EventManager (LabEngine *vm);
 
-	Gadget *_screenGadgetList;
+	GadgetList *_screenGadgetList;
 	Gadget *_hitGadget;
 
-	Gadget *checkGadgetHit(Gadget *gadgetList, Common::Point pos);
+	Gadget *checkGadgetHit(GadgetList *gadgetList, Common::Point pos);
 	void initMouse();
 	void updateMouse();
 	void mouseShow();
@@ -67,7 +67,7 @@ public:
 	void setMousePos(Common::Point pos);
 	bool mouseButton(uint16 *x, uint16 *y, bool leftButton);
 	Gadget *mouseGadget();
-	void attachGadgetList(Gadget *gadgetList);
+	void attachGadgetList(GadgetList *gadgetList);
 	void mouseHandler(int flag, Common::Point pos);
 	bool keyPress(uint16 *keyCode);
 	bool haveNextChar();
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 6c93b51..375ab22 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -806,7 +806,7 @@ void DisplayMan::drawPanel() {
 	if (!_vm->_alternate) {
 		setAPen(4);
 		drawHLine(0, VGAScaleY(170) + 1, VGAScaleX(319)); /* The horizontal lines under the black one */
-		drawGadgetList(_vm->_moveGadgetList);
+		drawGadgetList(&_vm->_moveGadgetList);
 	} else {
 		if (_vm->getPlatform() != Common::kPlatformWindows) {
 			drawVLine(VGAScaleX(124), VGAScaleY(170) + 1, VGAScaleY(199)); /* Vertical Black lines */
@@ -832,7 +832,7 @@ void DisplayMan::drawPanel() {
 			drawVLine(VGAScaleX(232), VGAScaleY(170) + 2, VGAScaleY(198));
 		}
 
-		drawGadgetList(_vm->_invGadgetList);
+		drawGadgetList(&_vm->_invGadgetList);
 	}
 
 	_vm->_event->mouseShow();
@@ -856,25 +856,16 @@ bool DisplayMan::setUpScreens() {
 	// The key mapping was only set for the Windows version.
 	// It's very convenient to have those shortcut, so I added them
 	// for all versions. (Strangerke)
-	_vm->_moveGadgetList = createButton(1, y, 0, 't', _vm->_moveImages[0], _vm->_moveImages[1]);
-	Gadget *curGadget = _vm->_moveGadgetList;
-	curGadget->NextGadget = createButton(33, y, 1, 'm', _vm->_moveImages[2], _vm->_moveImages[3]);
-	curGadget = curGadget->NextGadget;
-	curGadget->NextGadget = createButton(65, y, 2, 'o', _vm->_moveImages[4], _vm->_moveImages[5]);
-	curGadget = curGadget->NextGadget;
-	curGadget->NextGadget = createButton(97, y, 3, 'c', _vm->_moveImages[6], _vm->_moveImages[7]);
-	curGadget = curGadget->NextGadget;
-	curGadget->NextGadget = createButton(129, y, 4, 'l', _vm->_moveImages[8], _vm->_moveImages[9]);
-	curGadget = curGadget->NextGadget;
-	curGadget->NextGadget = createButton(161, y, 5, 'i', _vm->_moveImages[12], _vm->_moveImages[13]);
-	curGadget = curGadget->NextGadget;
-	curGadget->NextGadget = createButton(193, y, 6, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]);
-	curGadget = curGadget->NextGadget;
-	curGadget->NextGadget = createButton(225, y, 7, VKEY_UPARROW, _vm->_moveImages[16], _vm->_moveImages[17]);
-	curGadget = curGadget->NextGadget;
-	curGadget->NextGadget = createButton(257, y, 8, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]);
-	curGadget = curGadget->NextGadget;
-	curGadget->NextGadget = createButton(289, y, 9, 'p', _vm->_moveImages[10], _vm->_moveImages[11]);
+	_vm->_moveGadgetList.push_back(createButton(  1, y, 0,          't',  _vm->_moveImages[0],  _vm->_moveImages[1]));
+	_vm->_moveGadgetList.push_back(createButton( 33, y, 1,          'm',  _vm->_moveImages[2],  _vm->_moveImages[3]));
+	_vm->_moveGadgetList.push_back(createButton( 65, y, 2,          'o',  _vm->_moveImages[4],  _vm->_moveImages[5]));
+	_vm->_moveGadgetList.push_back(createButton( 97, y, 3,          'c',  _vm->_moveImages[6],  _vm->_moveImages[7]));
+	_vm->_moveGadgetList.push_back(createButton(129, y, 4,          'l',  _vm->_moveImages[8],  _vm->_moveImages[9]));
+	_vm->_moveGadgetList.push_back(createButton(161, y, 5,          'i', _vm->_moveImages[12], _vm->_moveImages[13]));
+	_vm->_moveGadgetList.push_back(createButton(193, y, 6, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]));
+	_vm->_moveGadgetList.push_back(createButton(225, y, 7, VKEY_UPARROW, _vm->_moveImages[16], _vm->_moveImages[17]));
+	_vm->_moveGadgetList.push_back(createButton(257, y, 8, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]));
+	_vm->_moveGadgetList.push_back(createButton(289, y, 9,          'p', _vm->_moveImages[10], _vm->_moveImages[11]));
 
 	Common::File *invFile = _vm->_resource->openDataFile("P:Inv");
 	if (_vm->getPlatform() == Common::kPlatformWindows) {
@@ -884,25 +875,18 @@ bool DisplayMan::setUpScreens() {
 		for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++)
 			_vm->_invImages[imgIdx] = new Image(invFile);
 	}
-	_vm->_invGadgetList = createButton(24, y, 0, 'm', _vm->_invImages[0], _vm->_invImages[1]);
-	curGadget = _vm->_invGadgetList;
-	curGadget->NextGadget = createButton(56, y, 1, 'g', _vm->_invImages[2], _vm->_invImages[3]);
-	curGadget = curGadget->NextGadget;
-	curGadget->NextGadget = createButton(94, y, 2, 'u', _vm->_invImages[4], _vm->_invImages[5]);
-	curGadget = curGadget->NextGadget;
-	curGadget->NextGadget = createButton(126, y, 3, 'l', _vm->_moveImages[8], _vm->_moveImages[9]);
-	curGadget = curGadget->NextGadget;
-	curGadget->NextGadget = createButton(164, y, 4, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]);
-	curGadget = curGadget->NextGadget;
-	curGadget->NextGadget = createButton(196, y, 5, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]);
+	_vm->_invGadgetList.push_back(createButton( 24, y, 0,          'm',   _vm->_invImages[0],   _vm->_invImages[1]));
+	_vm->_invGadgetList.push_back(createButton( 56, y, 1,          'g',   _vm->_invImages[2],   _vm->_invImages[3]));
+	_vm->_invGadgetList.push_back(createButton( 94, y, 2,          'u',   _vm->_invImages[4],   _vm->_invImages[5]));
+	_vm->_invGadgetList.push_back(createButton(126, y, 3,          'l',  _vm->_moveImages[8],  _vm->_moveImages[9]));
+	_vm->_invGadgetList.push_back(createButton(164, y, 4, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]));
+	_vm->_invGadgetList.push_back(createButton(196, y, 5, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]));
 
 	// The windows version has 2 extra gadgets for breadcrumb trail
 	// TODO: the game is really hard to play without those, maybe we could add something to enable that.
 	if (_vm->getPlatform() == Common::kPlatformWindows) {
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(234, y, 6, 'b', _vm->_invImages[6], _vm->_invImages[7]);
-		curGadget = curGadget->NextGadget;
-		curGadget->NextGadget = createButton(266, y, 7, 'f', _vm->_invImages[8], _vm->_invImages[9]);
+		_vm->_invGadgetList.push_back(createButton(234, y, 6, 'b', _vm->_invImages[6], _vm->_invImages[7]));
+		_vm->_invGadgetList.push_back(createButton(266, y, 7, 'f', _vm->_invImages[8], _vm->_invImages[9]));
 	}
 
 	delete invFile;
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 61cfc6c..d437fd2 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -52,7 +52,6 @@ Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image
 		gptr->KeyEquiv = key;
 		gptr->_image = im;
 		gptr->_altImage = imalt;
-		gptr->NextGadget = NULL;
 
 		return gptr;
 	} else
@@ -62,15 +61,12 @@ Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image
 
 
 
-void freeButtonList(Gadget *gptrlist) {
-	Gadget *next = gptrlist;
-
-	while (next) {
-		Gadget *gptr = next;
-		next = next->NextGadget;
-
-		free(gptr);
+void freeButtonList(GadgetList *gadgetList) {
+	for (GadgetList::iterator gadget = gadgetList->begin(); gadget != gadgetList->end(); ++gadget) {
+		free(*gadget);
 	}
+
+	gadgetList->clear();
 }
 
 
@@ -79,14 +75,12 @@ void freeButtonList(Gadget *gptrlist) {
 /*****************************************************************************/
 /* Draws a gadget list to the screen.                                        */
 /*****************************************************************************/
-void drawGadgetList(Gadget *gadlist) {
-	while (gadlist) {
-		gadlist->_image->drawImage(gadlist->x, gadlist->y);
+void drawGadgetList(GadgetList *gadgetList) {
+	for (GadgetList::iterator gadget = gadgetList->begin(); gadget != gadgetList->end(); ++gadget) {
+		(*gadget)->_image->drawImage((*gadget)->x, (*gadget)->y);
 
-		if (GADGETOFF & gadlist->GadgetFlags)
-			disableGadget(gadlist, 1);
-
-		gadlist = gadlist->NextGadget;
+		if (GADGETOFF & (*gadget)->GadgetFlags)
+			disableGadget((*gadget), 1);
 	}
 }
 
@@ -124,24 +118,26 @@ uint16 makeGadgetKeyEquiv(uint16 key) {
 /* Checks whether or not the cords fall within one of the gadgets in a list  */
 /* of gadgets.                                                               */
 /*****************************************************************************/
-Gadget *LabEngine::checkNumGadgetHit(Gadget *gadlist, uint16 key) {
+Gadget *LabEngine::checkNumGadgetHit(GadgetList *gadgetList, uint16 key) {
 	uint16 gkey = key - '0';
 
-	while (gadlist != NULL) {
-		if ((gkey - 1 == gadlist->GadgetID || (gkey == 0 && gadlist->GadgetID == 9) ||
-		        (gadlist->KeyEquiv != 0 && makeGadgetKeyEquiv(key) == gadlist->KeyEquiv))
-		        && !(GADGETOFF & gadlist->GadgetFlags)) {
+	if (!gadgetList)
+		return NULL;
+
+	for (GadgetList::iterator gadgetItr = gadgetList->begin(); gadgetItr != gadgetList->end(); ++gadgetItr) {
+		Gadget *gadget = *gadgetItr;
+		if ((gkey - 1 == gadget->GadgetID || (gkey == 0 && gadget->GadgetID == 9) ||
+			(gadget->KeyEquiv != 0 && makeGadgetKeyEquiv(key) == gadget->KeyEquiv))
+		        && !(GADGETOFF & gadget->GadgetFlags)) {
 			_event->mouseHide();
-			gadlist->_altImage->drawImage(gadlist->x, gadlist->y);
+			gadget->_altImage->drawImage(gadget->x, gadget->y);
 			_event->mouseShow();
 			g_system->delayMillis(80);
 			_event->mouseHide();
-			gadlist->_image->drawImage(gadlist->x, gadlist->y);
+			gadget->_image->drawImage(gadget->x, gadget->y);
 			_event->mouseShow();
 
-			return gadlist;
-		} else {
-			gadlist = gadlist->NextGadget;
+			return gadget;
 		}
 	}
 
diff --git a/engines/lab/interface.h b/engines/lab/interface.h
index 42cfb2f..83c8bad 100644
--- a/engines/lab/interface.h
+++ b/engines/lab/interface.h
@@ -48,7 +48,6 @@ struct Gadget {
 	uint16 KeyEquiv; // if not zero, a key that activates gadget
 	uint32 GadgetFlags;
 	Image *_image, *_altImage;
-	Gadget *NextGadget;
 };
 
 extern Common::KeyState _keyPressed;
@@ -57,7 +56,7 @@ extern Common::KeyState _keyPressed;
 
 #define GADGETOFF 0x01
 
-
+typedef Common::List<Gadget *> GadgetList;
 
 /* Defines for the Class variable in IntuiMessage */
 #define SIZEVERIFY  0x00000001
@@ -112,8 +111,8 @@ extern Common::KeyState _keyPressed;
 /*---------------------------------------------------------------------------*/
 
 Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt);
-void freeButtonList(void *gptrlist);
-void drawGadgetList(Gadget *gadlist);
+void freeButtonList(GadgetList *gadgetList);
+void drawGadgetList(GadgetList *gadgetList);
 void disableGadget(Gadget *curgad, uint16 pencolor);
 void enableGadget(Gadget *curgad);
 IntuiMessage *getMsg();
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 83f09cd..02abf80 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -103,8 +103,6 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	for (int i = 0; i < 16; i++)
 		_tiles[i] = nullptr;
 
-	_moveGadgetList = nullptr;
-	_invGadgetList = nullptr;
 	_curFileName = nullptr;
 	_nextFileName = nullptr;
 	_newFileName = nullptr;
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 27bae37..656406d 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -61,6 +61,8 @@ enum GameFeatures {
 #define UPSCROLL       3
 #define DOWNSCROLL     4
 
+typedef Common::List<Gadget *> GadgetList;
+
 class LabEngine : public Engine {
 public:
 	LabEngine(OSystem *syst, const ADGameDescription *gameDesc);
@@ -123,8 +125,8 @@ public:
 	const char *_newFileName;  /* When ProcessRoom.c decides to change the filename
                                     of the current picture. */
 	TextFont *_msgFont;
-	Gadget *_moveGadgetList;
-	Gadget *_invGadgetList;
+	GadgetList _moveGadgetList;
+	GadgetList _invGadgetList;
 	Image *_moveImages[20];
 	Image *_invImages[10];
 	Image *_numberImages[10];
@@ -147,7 +149,7 @@ public:
 	void interfaceOff();
 	void interfaceOn();
 	void decIncInv(uint16 *CurInv, bool dec);
-	Gadget *checkNumGadgetHit(Gadget *gadlist, uint16 key);
+	Gadget *checkNumGadgetHit(GadgetList *gadgetList, uint16 key);
 	IntuiMessage *getMsg();
 	void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein);
 	void processMap(uint16 CurRoom);
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 40e8eb9..a565f31 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -56,11 +56,12 @@ extern char *LOWERFLOORS, *MIDDLEFLOORS, *UPPERFLOORS, *MEDMAZEFLOORS, *HEDGEMAZ
 
 static uint16 MapGadX[3] = {101, 55, 8}, MapGadY[3] = {105, 105, 105};
 
-static Gadget downgadget = { 101, 105, 2, VKEY_DNARROW, 0L, NULL, NULL, NULL },
-			  upgadget   = {  55, 105, 1, VKEY_UPARROW, 0L, NULL, NULL, &downgadget },
-			  backgadget = {   8, 105, 0, 0, 0L, NULL, NULL, &upgadget };
+static Gadget
+	backgadget = { 8, 105, 0, 0, 0L, NULL, NULL },
+	upgadget = { 55, 105, 1, VKEY_UPARROW, 0L, NULL, NULL },
+	downgadget = { 101, 105, 2, VKEY_DNARROW, 0L, NULL, NULL };
 
-static Gadget *MapGadgetList = &backgadget;
+static GadgetList *MapGadgetList;
 
 #define LOWERFLOOR     1
 #define MIDDLEFLOOR    2
@@ -93,9 +94,13 @@ static uint16 mapScaleY(uint16 y) {
 /* Loads in the map data.                                                    */
 /*****************************************************************************/
 static bool loadMapData() {
-	Gadget *gptr;
 	uint16 counter;
 
+	MapGadgetList = new GadgetList();
+	MapGadgetList->push_back(&backgadget);
+	MapGadgetList->push_back(&upgadget);
+	MapGadgetList->push_back(&downgadget);
+
 	Common::File *mapImages = g_lab->_resource->openDataFile("P:MapImage");
 
 	Map = new Image(mapImages);
@@ -126,12 +131,10 @@ static bool loadMapData() {
 	delete mapImages;
 
 	counter = 0;
-	gptr = MapGadgetList;
 
-	while (gptr) {
-		gptr->x = g_lab->_graphics->VGAScaleX(MapGadX[counter]);
-		gptr->y = g_lab->_graphics->VGAScaleY(MapGadY[counter]);
-		gptr = gptr->NextGadget;
+	for (GadgetList::iterator gadget = MapGadgetList->begin(); gadget != MapGadgetList->end(); ++gadget) {
+		(*gadget)->x = g_lab->_graphics->VGAScaleX(MapGadX[counter]);
+		(*gadget)->y = g_lab->_graphics->VGAScaleY(MapGadY[counter]);
 		counter++;
 	}
 
@@ -156,6 +159,9 @@ static bool loadMapData() {
 }
 
 static void freeMapData() {
+	MapGadgetList->clear();
+	delete MapGadgetList;
+
 	delete[] Maps;
 	Maps = NULL;
 }
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index f8a70cc..c8aea63 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -225,7 +225,7 @@ int16 *Resource::readConditions(Common::File *file) {
 
 RuleList *Resource::readRule(Common::File *file) {
 	char c;
-	RuleList *rules = new Common::List<Rule *>();
+	RuleList *rules = new RuleList();
 
 	do {
 		c = file->readByte();
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index c4751ce..8afeeea 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -155,7 +155,6 @@ void LabEngine::doWestPaper() {
 /*****************************************************************************/
 static bool loadJournalData() {
 	char filename[20];
-	Gadget *TopGadget = &BackG;
 	bool bridge, dirty, news, clean;
 
 	journalFont = g_lab->_resource->getFont("P:Journal.fon");	// FIXME: memory leak
@@ -206,16 +205,21 @@ static bool loadJournalData() {
 
 	uint16 counter = 0;
 
-	while (TopGadget) {
-		TopGadget->x = g_lab->_graphics->VGAScaleX(JGadX[counter]);
+	GadgetList journalGadgetList;
+	journalGadgetList.push_back(&BackG);
+	journalGadgetList.push_back(&CancelG);
+	journalGadgetList.push_back(&ForwardG);
+
+	for (GadgetList::iterator gadgetIter = journalGadgetList.begin(); gadgetIter != journalGadgetList.end(); ++gadgetIter) {
+		Gadget *gadget = *gadgetIter;
+		gadget->x = g_lab->_graphics->VGAScaleX(JGadX[counter]);
 
 		if (counter == 1)
-			TopGadget->y = g_lab->_graphics->VGAScaleY(JGadY[counter]) + g_lab->_graphics->SVGACord(1);
+			gadget->y = g_lab->_graphics->VGAScaleY(JGadY[counter]) + g_lab->_graphics->SVGACord(1);
 		else
-			TopGadget->y = g_lab->_graphics->VGAScaleY(JGadY[counter]) - g_lab->_graphics->SVGACord(1);
+			gadget->y = g_lab->_graphics->VGAScaleY(JGadY[counter]) - g_lab->_graphics->SVGACord(1);
 
-		TopGadget->GadgetID = counter;
-		TopGadget = TopGadget->NextGadget;
+		gadget->GadgetID = counter;
 		counter++;
 	}
 
@@ -372,6 +376,11 @@ void LabEngine::processJournal() {
 /* Does the journal processing.                                              */
 /*****************************************************************************/
 void LabEngine::doJournal() {
+	GadgetList journalGadgetList;
+	journalGadgetList.push_back(&BackG);
+	journalGadgetList.push_back(&CancelG);
+	journalGadgetList.push_back(&ForwardG);
+
 	_graphics->blackAllScreen();
 
 	lastpage    = false;
@@ -381,9 +390,6 @@ void LabEngine::doJournal() {
 	JBackImage._height = _graphics->_screenHeight;
 	JBackImage._imageData   = NULL;
 
-	BackG.NextGadget = &CancelG;
-	CancelG.NextGadget = &ForwardG;
-
 	ScreenImage = JBackImage;
 	ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
 
@@ -392,12 +398,13 @@ void LabEngine::doJournal() {
 
 	drawJournal(0, true);
 
-	_event->attachGadgetList(&BackG);
+	_event->attachGadgetList(&journalGadgetList);
 	_event->mouseShow();
 	processJournal();
 	_event->attachGadgetList(NULL);
 	_graphics->fade(false, 0);
 	_event->mouseHide();
+	journalGadgetList.clear();
 
 	ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
 


Commit: 2611b62d5ec07868d52b8a014932c937eddfceea
    https://github.com/scummvm/scummvm/commit/2611b62d5ec07868d52b8a014932c937eddfceea
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:52+01:00

Commit Message:
LAB: Rename parse types

Changed paths:
    engines/lab/engine.cpp
    engines/lab/parsetypes.h
    engines/lab/processroom.cpp
    engines/lab/resource.cpp
    engines/lab/savegame.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index d300f47..17ae4cc 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -97,14 +97,14 @@ void LabEngine::drawRoomMessage(uint16 curInv, CloseDataPtr closePtr) {
 	}
 
 	if (_alternate) {
-		if ((curInv <= _numInv) && _conditions->in(curInv) && _inventory[curInv].BInvName) {
+		if ((curInv <= _numInv) && _conditions->in(curInv) && _inventory[curInv]._bitmapName) {
 			if ((curInv == LAMPNUM) && _conditions->in(LAMPON))  /* LAB: Labyrinth specific */
 				drawStaticMessage(kTextLampOn);
-			else if (_inventory[curInv].Many > 1) {
-				Common::String roomMessage = Common::String(_inventory[curInv].name) + "  (" + Common::String::format("%d", _inventory[curInv].Many) + ")";
+			else if (_inventory[curInv]._many > 1) {
+				Common::String roomMessage = Common::String(_inventory[curInv]._name) + "  (" + Common::String::format("%d", _inventory[curInv]._many) + ")";
 				_graphics->drawMessage(roomMessage.c_str());
 			} else
-				_graphics->drawMessage(_inventory[curInv].name);
+				_graphics->drawMessage(_inventory[curInv]._name);
 		}
 	} else
 		drawDirection(closePtr);
@@ -182,32 +182,32 @@ bool LabEngine::doCloseUp(CloseDataPtr closePtr) {
 		lutertmargin = 128;
 	}
 
-	switch (closePtr->CloseUpType) {
+	switch (closePtr->_closeUpType) {
 	case MUSEUMMONITOR:
 	case LIBRARYMONITOR:
 	case WINDOWMONITOR:
-		doMonitor(closePtr->GraphicName, closePtr->Message, false, monltmargin, montopmargin, monrtmargin, 165);
+		doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, monrtmargin, 165);
 		break;
 	case GRAMAPHONEMONITOR:
-		doMonitor(closePtr->GraphicName, closePtr->Message, false, monltmargin, montopmargin, 171, 165);
+		doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, 171, 165);
 		break;
 	case UNICYCLEMONITOR:
-		doMonitor(closePtr->GraphicName, closePtr->Message, false, 100, montopmargin, monrtmargin, 165);
+		doMonitor(closePtr->_graphicName, closePtr->_message, false, 100, montopmargin, monrtmargin, 165);
 		break;
 	case STATUEMONITOR:
-		doMonitor(closePtr->GraphicName, closePtr->Message, false, 117, montopmargin, monrtmargin, 165);
+		doMonitor(closePtr->_graphicName, closePtr->_message, false, 117, montopmargin, monrtmargin, 165);
 		break;
 	case TALISMANMONITOR:
-		doMonitor(closePtr->GraphicName, closePtr->Message, false, monltmargin, montopmargin, 184, 165);
+		doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, 184, 165);
 		break;
 	case LUTEMONITOR:
-		doMonitor(closePtr->GraphicName, closePtr->Message, false, monltmargin, montopmargin, lutertmargin, 165);
+		doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, lutertmargin, 165);
 		break;
 	case CLOCKMONITOR:
-		doMonitor(closePtr->GraphicName, closePtr->Message, false, monltmargin, montopmargin, 206, 165);
+		doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, 206, 165);
 		break;
 	case TERMINALMONITOR:
-		doMonitor(closePtr->GraphicName, closePtr->Message, true, monltmargin, montopmargin, monrtmargin, 165);
+		doMonitor(closePtr->_graphicName, closePtr->_message, true, monltmargin, montopmargin, monrtmargin, 165);
 		break;
 	default:
 		return false;
@@ -224,7 +224,7 @@ bool LabEngine::doCloseUp(CloseDataPtr closePtr) {
 /******************************************************************************/
 const char *LabEngine::getInvName(uint16 curInv) {
 	if (_mainDisplay)
-		return _inventory[curInv].BInvName;
+		return _inventory[curInv]._bitmapName;
 
 	if ((curInv == LAMPNUM) && _conditions->in(LAMPON))
 		return "P:Mines/120";
@@ -233,20 +233,20 @@ const char *LabEngine::getInvName(uint16 curInv) {
 		return "P:Future/BeltGlow";
 
 	if (curInv == WESTPAPERNUM) {
-		_curFileName = _inventory[curInv].BInvName;
+		_curFileName = _inventory[curInv]._bitmapName;
 		_anim->_noPalChange = true;
 		_graphics->readPict(_curFileName, false);
 		_anim->_noPalChange = false;
 		doWestPaper();
 	} else if (curInv == NOTESNUM) {
-		_curFileName = _inventory[curInv].BInvName;
+		_curFileName = _inventory[curInv]._bitmapName;
 		_anim->_noPalChange = true;
 		_graphics->readPict(_curFileName, false);
 		_anim->_noPalChange = false;
 		doNotes();
 	}
 
-	return _inventory[curInv].BInvName;
+	return _inventory[curInv]._bitmapName;
 }
 
 /******************************************************************************/
@@ -351,7 +351,7 @@ void LabEngine::decIncInv(uint16 *curInv, bool decreaseFl) {
 		(*curInv)++;
 
 	while (*curInv && (*curInv <= _numInv)) {
-		if (_conditions->in(*curInv) && _inventory[*curInv].BInvName) {
+		if (_conditions->in(*curInv) && _inventory[*curInv]._bitmapName) {
 			_nextFileName = getInvName(*curInv);
 			break;
 		}
@@ -369,7 +369,7 @@ void LabEngine::decIncInv(uint16 *curInv, bool decreaseFl) {
 			*curInv = 1;
 
 		while (*curInv && (*curInv <= _numInv)) {
-			if (_conditions->in(*curInv) && _inventory[*curInv].BInvName) {
+			if (_conditions->in(*curInv) && _inventory[*curInv]._bitmapName) {
 				_nextFileName = getInvName(*curInv);
 				break;
 			}
@@ -452,12 +452,12 @@ void LabEngine::mainGameLoop() {
 				_curFileName = _nextFileName;
 
 				if (_cptr) {
-					if ((_cptr->CloseUpType == SPECIALLOCK) && _mainDisplay)  /* LAB: Labyrinth specific code */
+					if ((_cptr->_closeUpType == SPECIALLOCK) && _mainDisplay)  /* LAB: Labyrinth specific code */
 						showCombination(_curFileName);
-					else if (((_cptr->CloseUpType == SPECIALBRICK)  ||
-					          (_cptr->CloseUpType == SPECIALBRICKNOMOUSE)) &&
+					else if (((_cptr->_closeUpType == SPECIALBRICK)  ||
+					          (_cptr->_closeUpType == SPECIALBRICKNOMOUSE)) &&
 					         _mainDisplay) /* LAB: Labyrinth specific code */
-						showTile(_curFileName, (bool)(_cptr->CloseUpType == SPECIALBRICKNOMOUSE));
+						showTile(_curFileName, (bool)(_cptr->_closeUpType == SPECIALBRICKNOMOUSE));
 					else
 						_graphics->readPict(_curFileName, false);
 				} else
@@ -535,11 +535,11 @@ void LabEngine::mainGameLoop() {
 
 	if (_inventory) {
 		for (int i = 1; i <= _numInv; i++) {
-			if (_inventory[i].name)
-				free(_inventory[i].name);
+			if (_inventory[i]._name)
+				free(_inventory[i]._name);
 
-			if (_inventory[i].BInvName)
-				free(_inventory[i].BInvName);
+			if (_inventory[i]._bitmapName)
+				free(_inventory[i]._bitmapName);
 		}
 
 		free(_inventory);
@@ -552,7 +552,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 	uint16 oldDirection = 0;
 	uint16 lastInv = MAPNUM;
-	CloseDataPtr oldcptr, tempcptr, hcptr = NULL;
+	CloseDataPtr oldcptr, tempcptr, hcptr = nullptr;
 	ViewData *VPtr;
 	bool doit;
 	uint16 NewDir;
@@ -862,7 +862,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			}
 
 			if ((curInv <= _numInv) && _conditions->in(curInv) &&
-			        _inventory[curInv].BInvName)
+			        _inventory[curInv]._bitmapName)
 				_nextFileName = getInvName(curInv);
 
 			_graphics->screenUpdate();
@@ -922,9 +922,9 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 		doit = false;
 
 		if (_cptr) {
-			if ((_cptr->CloseUpType == SPECIALLOCK) && _mainDisplay) /* LAB: Labyrinth specific code */
+			if ((_cptr->_closeUpType == SPECIALLOCK) && _mainDisplay) /* LAB: Labyrinth specific code */
 				mouseCombination(curPos);
-			else if ((_cptr->CloseUpType == SPECIALBRICK) && _mainDisplay)
+			else if ((_cptr->_closeUpType == SPECIALBRICK) && _mainDisplay)
 				mouseTile(curPos);
 			else
 				doit = true;
@@ -963,8 +963,8 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				if (_cptr == tempcptr) {
 					if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2)))
 						drawStaticMessage(kTextNothing);
-				} else if (tempcptr->GraphicName) {
-					if (*(tempcptr->GraphicName)) {
+				} else if (tempcptr->_graphicName) {
+					if (*(tempcptr->_graphicName)) {
 						_anim->_doBlack = true;
 						_cptr = tempcptr;
 					} else if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2)))
@@ -987,7 +987,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 		_graphics->screenUpdate();
 	} else if (msgClass == DELTAMOVE) {
 		VPtr = getViewData(_roomNum, _direction);
-		oldcptr = VPtr->closeUps;
+		oldcptr = VPtr->_closeUps;
 
 		if (hcptr == NULL) {
 			tempcptr = _cptr;
@@ -997,18 +997,18 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				if (_cptr == NULL)
 					hcptr = oldcptr;
 				else
-					hcptr = _cptr->SubCloseUps;
+					hcptr = _cptr->_subCloseUps;
 			} else
-				hcptr = tempcptr->NextCloseUp;
+				hcptr = tempcptr->_nextCloseUp;
 		} else
-			hcptr = hcptr->NextCloseUp;
+			hcptr = hcptr->_nextCloseUp;
 
 
 		if (hcptr == NULL) {
 			if (_cptr == NULL)
 				hcptr = oldcptr;
 			else
-				hcptr = _cptr->SubCloseUps;
+				hcptr = _cptr->_subCloseUps;
 		}
 
 		if (hcptr)
diff --git a/engines/lab/parsetypes.h b/engines/lab/parsetypes.h
index 9bfc2b0..b345e1e 100644
--- a/engines/lab/parsetypes.h
+++ b/engines/lab/parsetypes.h
@@ -37,8 +37,6 @@ namespace Lab {
 
 #define MAXFILELEN 31
 
-
-
 /*------------------------------- Action types ------------------------------*/
 #define PLAYSOUND     1
 #define PLAYSOUNDCONT 2
@@ -77,8 +75,6 @@ namespace Lab {
 #define CSHOWMESSAGE 35
 #define PLAYSOUNDB   36
 
-
-
 /* Rule Types */
 #define ACTION      1
 #define OPERATE     2
@@ -88,8 +84,6 @@ namespace Lab {
 #define GOMAINVIEW  6
 #define TURNFROMTO  7
 
-
-
 /*----------------------------- Rule Type Action ----------------------------*/
 #define TAKE        1
 #define MOVE        2
@@ -101,50 +95,60 @@ namespace Lab {
 #pragma pack(push, 1)
 #endif
 
-typedef struct closeData {
+typedef struct CloseData {
 	uint16 x1, y1, x2, y2;
-	int16 CloseUpType;          /* if > 0, an object.  If < 0, an item */
-	uint16 depth;               /* Level of the closeup. */
-	char *GraphicName, *Message;
-	closeData *NextCloseUp, *SubCloseUps;
+	int16 _closeUpType;          /* if > 0, an object.  If < 0, an item */
+	uint16 _depth;               /* Level of the closeup. */
+	char *_graphicName;
+	char *_message;
+	CloseData *_nextCloseUp;
+	CloseData *_subCloseUps;
 } CloseData;
 
 typedef CloseData *CloseDataPtr;
 
 struct ViewData {
-	int16 *Condition;
-	char *GraphicName;
-	struct ViewData *NextCondition;
-	CloseDataPtr closeUps;
+	int16 *_condition;
+	char *_graphicName;
+	struct ViewData *_nextCondition;
+	CloseDataPtr _closeUps;
 };
 
 struct Action {
-	int16 ActionType, Param1, Param2, Param3;
-	byte *Data;            /* Message, or a pointer to array of messages. */
-	Action *NextAction;
+	int16 _actionType;
+	int16 _param1;
+	int16 _param2;
+	int16 _param3;
+	byte *_data;            /* Message, or a pointer to array of messages. */
+	Action *_nextAction;
 };
 
 struct Rule {
-	int16 RuleType, Param1, Param2, *Condition;
-	Action *ActionList;
-	Rule *NextRule;
+	int16 _ruleType;
+	int16 _param1;
+	int16 _param2;
+	int16 *_condition;
+	Action *_actionList;
+	Rule *_nextRule;
 };
 
 typedef Common::List<Rule *> RuleList;
 
 struct RoomData {
-	uint16 _northDoor, _southDoor, _eastDoor, _westDoor;
-
+	uint16 _northDoor;
+	uint16 _southDoor;
+	uint16 _eastDoor;
+	uint16 _westDoor;
 	byte _wipeType;
-
 	ViewData *_view[4];
 	RuleList *_rules;
 	char *_roomMsg;
 };
 
 struct InventoryData {
-	uint16 Many;
-	char *name, *BInvName;
+	uint16 _many;
+	char *_name;
+	char *_bitmapName;
 };
 
 /* Map Flags */
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index f254d4b..015b854 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -85,10 +85,10 @@ ViewData *getViewData(uint16 roomNum, uint16 direction) {
 	ViewData *view = g_lab->_rooms[roomNum]._view[direction];
 
 	do {
-		if (checkConditions(view->Condition))
+		if (checkConditions(view->_condition))
 			break;
 
-		view = view->NextCondition;
+		view = view->_nextCondition;
 	} while (true);
 
 	return view;
@@ -99,9 +99,9 @@ ViewData *getViewData(uint16 roomNum, uint16 direction) {
 /*****************************************************************************/
 static CloseData *getObject(uint16 x, uint16 y, CloseDataPtr lcptr) {
 	if (lcptr == NULL) {
-		lcptr = getViewData(g_lab->_roomNum, g_lab->_direction)->closeUps;
+		lcptr = getViewData(g_lab->_roomNum, g_lab->_direction)->_closeUps;
 	} else {
-		lcptr = lcptr->SubCloseUps;
+		lcptr = lcptr->_subCloseUps;
 	}
 
 	while (lcptr != NULL) {
@@ -109,7 +109,7 @@ static CloseData *getObject(uint16 x, uint16 y, CloseDataPtr lcptr) {
 		        (x <= g_lab->_graphics->scaleX(lcptr->x2)) && (y <= g_lab->_graphics->scaleY(lcptr->y2)))
 			return lcptr;
 
-		lcptr = lcptr->NextCloseUp;
+		lcptr = lcptr->_nextCloseUp;
 	}
 
 	return NULL;
@@ -127,15 +127,15 @@ static CloseDataPtr findCPtrMatch(CloseDataPtr cpmain, CloseDataPtr list) {
 	while (list) {
 		if ((cpmain->x1 == list->x1) && (cpmain->x2 == list->x2) &&
 		        (cpmain->y1 == list->y1) && (cpmain->y2 == list->y2) &&
-		        (cpmain->depth == list->depth))
+		        (cpmain->_depth == list->_depth))
 			return list;
 
-		cptr = findCPtrMatch(cpmain, list->SubCloseUps);
+		cptr = findCPtrMatch(cpmain, list->_subCloseUps);
 
 		if (cptr)
 			return cptr;
 		else
-			list = list->NextCloseUp;
+			list = list->_nextCloseUp;
 	}
 
 	return NULL;
@@ -148,21 +148,21 @@ char *getPictName(CloseDataPtr *lcptr) {
 	ViewData *viewPtr = getViewData(g_lab->_roomNum, g_lab->_direction);
 
 	if (*lcptr != NULL) {
-		*lcptr = findCPtrMatch(*lcptr, viewPtr->closeUps);
+		*lcptr = findCPtrMatch(*lcptr, viewPtr->_closeUps);
 
 		if (*lcptr)
-			return (*lcptr)->GraphicName;
+			return (*lcptr)->_graphicName;
 	}
 
-	return viewPtr->GraphicName;
+	return viewPtr->_graphicName;
 }
 
 /*****************************************************************************/
 /* Draws the current direction to the screen.                                */
 /*****************************************************************************/
 void LabEngine::drawDirection(CloseDataPtr lcptr) {
-	if (lcptr != NULL && lcptr->Message) {
-		_graphics->drawMessage(lcptr->Message);
+	if (lcptr != NULL && lcptr->_message) {
+		_graphics->drawMessage(lcptr->_message);
 		return;
 	}
 
@@ -236,9 +236,9 @@ void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords)
 	uint16 x1, y1, x2, y2;
 
 	if (*cptr == NULL) {
-		lcptr = getViewData(g_lab->_roomNum, g_lab->_direction)->closeUps;
+		lcptr = getViewData(g_lab->_roomNum, g_lab->_direction)->_closeUps;
 	} else
-		lcptr = (*cptr)->SubCloseUps;
+		lcptr = (*cptr)->_subCloseUps;
 
 	while (lcptr != NULL) {
 		if (!useAbsoluteCoords) {
@@ -253,12 +253,12 @@ void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords)
 			y2 = g_lab->_graphics->scaleY(lcptr->y2);
 		}
 
-		if (pos.x >= x1 && pos.y >= y1 && pos.x <= x2 && pos.y <= y2 && lcptr->GraphicName) {
+		if (pos.x >= x1 && pos.y >= y1 && pos.x <= x2 && pos.y <= y2 && lcptr->_graphicName) {
 			*cptr = lcptr;
 			return;
 		}
 
-		lcptr = lcptr->NextCloseUp;
+		lcptr = lcptr->_nextCloseUp;
 	}
 }
 
@@ -269,23 +269,23 @@ bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
 	CloseDataPtr lcptr;
 
 	if (*cptr == NULL) {
-		lcptr = getViewData(g_lab->_roomNum, g_lab->_direction)->closeUps;
-	} else if ((*cptr)->CloseUpType < 0) {
-		g_lab->_conditions->inclElement(abs((*cptr)->CloseUpType));
+		lcptr = getViewData(g_lab->_roomNum, g_lab->_direction)->_closeUps;
+	} else if ((*cptr)->_closeUpType < 0) {
+		g_lab->_conditions->inclElement(abs((*cptr)->_closeUpType));
 		return true;
 	} else
-		lcptr = (*cptr)->SubCloseUps;
+		lcptr = (*cptr)->_subCloseUps;
 
 
 	while (lcptr != NULL) {
 		if ((x >= g_lab->_graphics->scaleX(lcptr->x1)) && (y >= g_lab->_graphics->scaleY(lcptr->y1)) &&
 		        (x <= g_lab->_graphics->scaleX(lcptr->x2)) && (y <= g_lab->_graphics->scaleY(lcptr->y2)) &&
-		        (lcptr->CloseUpType < 0)) {
-			g_lab->_conditions->inclElement(abs(lcptr->CloseUpType));
+		        (lcptr->_closeUpType < 0)) {
+			g_lab->_conditions->inclElement(abs(lcptr->_closeUpType));
 			return true;
 		}
 
-		lcptr = lcptr->NextCloseUp;
+		lcptr = lcptr->_nextCloseUp;
 	}
 
 	return false;
@@ -298,42 +298,42 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 	while (aptr) {
 		_music->updateMusic();
 
-		switch (aptr->ActionType) {
+		switch (aptr->_actionType) {
 		case PLAYSOUND:
 			_music->_loopSoundEffect = false;
 			_music->_waitTillFinished = true;
-			_music->readMusic((char *)aptr->Data, true);
+			_music->readMusic((char *)aptr->_data, true);
 			_music->_waitTillFinished = false;
 			break;
 
 		case PLAYSOUNDB:
 			_music->_loopSoundEffect = false;
 			_music->_waitTillFinished = false;
-			_music->readMusic((char *)aptr->Data, false);
+			_music->readMusic((char *)aptr->_data, false);
 			break;
 
 		case PLAYSOUNDCONT:
 			_music->_doNotFilestopSoundEffect = true;
 			_music->_loopSoundEffect = true;
-			_music->readMusic((char *)aptr->Data, _music->_waitTillFinished);
+			_music->readMusic((char *)aptr->_data, _music->_waitTillFinished);
 			break;
 
 		case SHOWDIFF:
-			_graphics->readPict((char *)aptr->Data, true);
+			_graphics->readPict((char *)aptr->_data, true);
 			break;
 
 		case SHOWDIFFCONT:
-			_graphics->readPict((char *)aptr->Data, false);
+			_graphics->readPict((char *)aptr->_data, false);
 			break;
 
 		case LOADDIFF:
-			if (aptr->Data)
-				_graphics->loadPict((char *)aptr->Data);          /* Puts a file into memory */
+			if (aptr->_data)
+				_graphics->loadPict((char *)aptr->_data);          /* Puts a file into memory */
 
 			break;
 
 		case WIPECMD:
-			_graphics->doWipe(aptr->Param1, lcptr, (char *)aptr->Data);
+			_graphics->doWipe(aptr->_param1, lcptr, (char *)aptr->_data);
 			break;
 
 		case NOUPDATE:
@@ -356,20 +356,20 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			break;
 
 		case SETELEMENT:
-			_conditions->inclElement(aptr->Param1);
+			_conditions->inclElement(aptr->_param1);
 			break;
 
 		case UNSETELEMENT:
-			_conditions->exclElement(aptr->Param1);
+			_conditions->exclElement(aptr->_param1);
 			break;
 
 		case SHOWMESSAGE:
 			_graphics->_doNotDrawMessage = false;
 
 			if (_graphics->_longWinInFront)
-				_graphics->longDrawMessage((char *)aptr->Data);
+				_graphics->longDrawMessage((char *)aptr->_data);
 			else
-				_graphics->drawMessage((char *)aptr->Data);
+				_graphics->drawMessage((char *)aptr->_data);
 
 			_graphics->_doNotDrawMessage = true;
 			break;
@@ -377,22 +377,22 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 		case CSHOWMESSAGE:
 			if (*lcptr == NULL) {
 				_graphics->_doNotDrawMessage = false;
-				_graphics->drawMessage((char *)aptr->Data);
+				_graphics->drawMessage((char *)aptr->_data);
 				_graphics->_doNotDrawMessage = true;
 			}
 
 			break;
 
 		case SHOWMESSAGES: {
-				char **str = (char **)aptr->Data;
+				char **str = (char **)aptr->_data;
 				_graphics->_doNotDrawMessage = false;
-				_graphics->drawMessage(str[getRandom(aptr->Param1)]);
+				_graphics->drawMessage(str[getRandom(aptr->_param1)]);
 				_graphics->_doNotDrawMessage = true;
 			}
 			break;
 
 		case SETPOSITION:
-			if (aptr->Param1 & 0x8000) {
+			if (aptr->_param1 & 0x8000) {
 				// This is a Wyrmkeep Windows trial version, thus stop at this
 				// point, since we can't check for game payment status
 				_graphics->readPict(getPictName(lcptr), true);
@@ -402,14 +402,14 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 				continue;
 			}
 
-			_roomNum   = aptr->Param1;
-			_direction = aptr->Param2 - 1;
+			_roomNum   = aptr->_param1;
+			_direction = aptr->_param2 - 1;
 			*lcptr      = NULL;
 			_anim->_doBlack = true;
 			break;
 
 		case SETCLOSEUP: {
-				CloseDataPtr tlcptr = getObject(g_lab->_graphics->scaleX(aptr->Param1), g_lab->_graphics->scaleY(aptr->Param2), *lcptr);
+				CloseDataPtr tlcptr = getObject(g_lab->_graphics->scaleX(aptr->_param1), g_lab->_graphics->scaleY(aptr->_param2), *lcptr);
 
 				if (tlcptr)
 					*lcptr = tlcptr;
@@ -421,17 +421,17 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			break;
 
 		case SUBINV:
-			if (_inventory[aptr->Param1].Many)
-				(_inventory[aptr->Param1].Many)--;
+			if (_inventory[aptr->_param1]._many)
+				(_inventory[aptr->_param1]._many)--;
 
-			if (_inventory[aptr->Param1].Many == 0)
-				_conditions->exclElement(aptr->Param1);
+			if (_inventory[aptr->_param1]._many == 0)
+				_conditions->exclElement(aptr->_param1);
 
 			break;
 
 		case ADDINV:
-			(_inventory[aptr->Param1].Many) += aptr->Param2;
-			_conditions->inclElement(aptr->Param1);
+			(_inventory[aptr->_param1]._many) += aptr->_param2;
+			_conditions->inclElement(aptr->_param1);
 			break;
 
 		case SHOWDIR:
@@ -441,7 +441,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 		case WAITSECS: {
 				uint32 startSecs, startMicros, curSecs, curMicros;
 
-				addCurTime(aptr->Param1, 0, &startSecs, &startMicros);
+				addCurTime(aptr->_param1, 0, &startSecs, &startMicros);
 
 				_graphics->screenUpdate();
 
@@ -466,7 +466,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			break;
 
 		case CHANGEMUSIC:
-			_music->changeMusic((const char *)aptr->Data);
+			_music->changeMusic((const char *)aptr->_data);
 			_music->setMusicReset(false);
 			break;
 
@@ -516,13 +516,13 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			break;
 
 		case SPECIALCMD:
-			if (aptr->Param1 == 0)
+			if (aptr->_param1 == 0)
 				_anim->_doBlack = true;
-			else if (aptr->Param1 == 1)
+			else if (aptr->_param1 == 1)
 				_anim->_doBlack = (_cptr == NULL);
-			else if (aptr->Param1 == 2)
+			else if (aptr->_param1 == 2)
 				_anim->_doBlack = (_cptr != NULL);
-			else if (aptr->Param1 == 5) { /* inverse the palette */
+			else if (aptr->_param1 == 5) { /* inverse the palette */
 				for (uint16 idx = (8 * 3); idx < (255 * 3); idx++)
 					_anim->_diffPalette[idx] = 255 - _anim->_diffPalette[idx];
 
@@ -530,16 +530,16 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 				_graphics->setPalette(_anim->_diffPalette, 256);
 				waitTOF();
 				waitTOF();
-			} else if (aptr->Param1 == 4) { /* white the palette */
+			} else if (aptr->_param1 == 4) { /* white the palette */
 				_graphics->whiteScreen();
 				waitTOF();
 				waitTOF();
-			} else if (aptr->Param1 == 6) { /* Restore the palette */
+			} else if (aptr->_param1 == 6) { /* Restore the palette */
 				waitTOF();
 				_graphics->setPalette(_anim->_diffPalette, 256);
 				waitTOF();
 				waitTOF();
-			} else if (aptr->Param1 == 7) { /* Quick pause */
+			} else if (aptr->_param1 == 7) { /* Quick pause */
 				waitTOF();
 				waitTOF();
 				waitTOF();
@@ -548,7 +548,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			break;
 		}
 
-		aptr = aptr->NextAction;
+		aptr = aptr->_nextAction;
 	}
 
 	if (_music->_loopSoundEffect) {
@@ -580,14 +580,14 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr lcptr, Clo
 		}
 
 		for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
-			if (((*rule)->RuleType == ACTION) &&
-				(((*rule)->Param1 == action) || (((*rule)->Param1 == 0) && allowDefaults))) {
-				if ((((*rule)->Param2 == lcptr->CloseUpType) ||
-					(((*rule)->Param2 == 0) && allowDefaults))
+			if (((*rule)->_ruleType == ACTION) &&
+				(((*rule)->_param1 == action) || (((*rule)->_param1 == 0) && allowDefaults))) {
+				if ((((*rule)->_param2 == lcptr->_closeUpType) ||
+					(((*rule)->_param2 == 0) && allowDefaults))
 				        ||
-						((action == 1) && ((*rule)->Param2 == (-lcptr->CloseUpType)))) {
-					if (checkConditions((*rule)->Condition)) {
-						g_lab->doActions((*rule)->ActionList, set);
+						((action == 1) && ((*rule)->_param2 == (-lcptr->_closeUpType)))) {
+					if (checkConditions((*rule)->_condition)) {
+						g_lab->doActions((*rule)->_actionList, set);
 						return true;
 					}
 				}
@@ -626,7 +626,7 @@ bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *
 /*****************************************************************************/
 static bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr lcptr, CloseDataPtr *set, bool allowDefaults) {
 	if (lcptr)
-		if (lcptr->CloseUpType > 0) {
+		if (lcptr->_closeUpType > 0) {
 			RuleList *rules = g_lab->_rooms[roomNum]._rules;
 
 			if ((rules == NULL) && (roomNum == 0)) {
@@ -635,11 +635,11 @@ static bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr lcptr, C
 			}
 
 			for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
-				if (((*rule)->RuleType == OPERATE) &&
-				        (((*rule)->Param1 == itemNum) || (((*rule)->Param1 == 0) && allowDefaults)) &&
-						(((*rule)->Param2 == lcptr->CloseUpType) || (((*rule)->Param2 == 0) && allowDefaults))) {
-					if (checkConditions((*rule)->Condition)) {
-						g_lab->doActions((*rule)->ActionList, set);
+				if (((*rule)->_ruleType == OPERATE) &&
+				        (((*rule)->_param1 == itemNum) || (((*rule)->_param1 == 0) && allowDefaults)) &&
+						(((*rule)->_param2 == lcptr->_closeUpType) || (((*rule)->_param2 == 0) && allowDefaults))) {
+					if (checkConditions((*rule)->_condition)) {
+						g_lab->doActions((*rule)->_actionList, set);
 						return true;
 					}
 				}
@@ -690,9 +690,9 @@ bool doGoForward(CloseDataPtr *lcptr) {
 	RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;
 
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
-		if (((*rule)->RuleType == GOFORWARD) && ((*rule)->Param1 == (g_lab->_direction + 1))) {
-			if (checkConditions((*rule)->Condition)) {
-				g_lab->doActions((*rule)->ActionList, lcptr);
+		if (((*rule)->_ruleType == GOFORWARD) && ((*rule)->_param1 == (g_lab->_direction + 1))) {
+			if (checkConditions((*rule)->_condition)) {
+				g_lab->doActions((*rule)->_actionList, lcptr);
 				return true;
 			}
 		}
@@ -711,11 +711,11 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *lcptr) {
 	RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;
 
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
-		if (((*rule)->RuleType == TURN) ||
-		        (((*rule)->RuleType == TURNFROMTO) &&
-		         ((*rule)->Param1   == from) && ((*rule)->Param2 == to))) {
-			if (checkConditions((*rule)->Condition)) {
-				g_lab->doActions((*rule)->ActionList, lcptr);
+		if (((*rule)->_ruleType == TURN) ||
+		        (((*rule)->_ruleType == TURNFROMTO) &&
+		         ((*rule)->_param1   == from) && ((*rule)->_param2 == to))) {
+			if (checkConditions((*rule)->_condition)) {
+				g_lab->doActions((*rule)->_actionList, lcptr);
 				return true;
 			}
 		}
@@ -730,9 +730,9 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *lcptr) {
 bool doMainView(CloseDataPtr *lcptr) {
 	RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
-		if ((*rule)->RuleType == GOMAINVIEW) {
-			if (checkConditions((*rule)->Condition)) {
-				g_lab->doActions((*rule)->ActionList, lcptr);
+		if ((*rule)->_ruleType == GOMAINVIEW) {
+			if (checkConditions((*rule)->_condition)) {
+				g_lab->doActions((*rule)->_actionList, lcptr);
 				return true;
 			}
 		}
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index c8aea63..538b6f6 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -120,9 +120,9 @@ InventoryData *Resource::readInventory(const char *fileName) {
 	InventoryData *inventory = (InventoryData *)malloc((_vm->_numInv + 1) * sizeof(InventoryData));
 
 	for (uint16 i = 1; i <= _vm->_numInv; i++) {
-		inventory[i].Many = dataFile->readUint16LE();
-		inventory[i].name = readString(dataFile);
-		inventory[i].BInvName = readString(dataFile);
+		inventory[i]._many = dataFile->readUint16LE();
+		inventory[i]._name = readString(dataFile);
+		inventory[i]._bitmapName = readString(dataFile);
 	}
 
 	delete dataFile;
@@ -232,11 +232,11 @@ RuleList *Resource::readRule(Common::File *file) {
 
 		if (c == 1) {
 			Rule *rule = new Rule();;
-			rule->RuleType = file->readSint16LE();
-			rule->Param1 = file->readSint16LE();
-			rule->Param2 = file->readSint16LE();
-			rule->Condition = readConditions(file);
-			rule->ActionList = readAction(file);
+			rule->_ruleType = file->readSint16LE();
+			rule->_param1 = file->readSint16LE();
+			rule->_param2 = file->readSint16LE();
+			rule->_condition = readConditions(file);
+			rule->_actionList = readAction(file);
 			rules->push_back(rule);
 		}
 	} while (c == 1);
@@ -259,24 +259,24 @@ Action *Resource::readAction(Common::File *file) {
 			if (!head)
 				head = action;
 			if (prev)
-				prev->NextAction = action;
-			action->ActionType = file->readSint16LE();
-			action->Param1 = file->readSint16LE();
-			action->Param2 = file->readSint16LE();
-			action->Param3 = file->readSint16LE();
+				prev->_nextAction = action;
+			action->_actionType = file->readSint16LE();
+			action->_param1 = file->readSint16LE();
+			action->_param2 = file->readSint16LE();
+			action->_param3 = file->readSint16LE();
 
-			if (action->ActionType == SHOWMESSAGES) {
-				messages = (char **)malloc(action->Param1 * 4);
+			if (action->_actionType == SHOWMESSAGES) {
+				messages = (char **)malloc(action->_param1 * 4);
 
-				for (int i = 0; i < action->Param1; i++)
+				for (int i = 0; i < action->_param1; i++)
 					messages[i] = readString(file);
 
-				action->Data = (byte *)messages;
+				action->_data = (byte *)messages;
 			} else {
-				action->Data = (byte *)readString(file);
+				action->_data = (byte *)readString(file);
 			}
 
-			action->NextAction = NULL;
+			action->_nextAction = NULL;
 			prev = action;
 		}
 	} while (c == 1);
@@ -298,17 +298,17 @@ CloseData *Resource::readCloseUps(uint16 depth, Common::File *file) {
 			if (!head)
 				head = closeup;
 			if (prev)
-				prev->NextCloseUp = closeup;
+				prev->_nextCloseUp = closeup;
 			closeup->x1 = file->readUint16LE();
 			closeup->y1 = file->readUint16LE();
 			closeup->x2 = file->readUint16LE();
 			closeup->y2 = file->readUint16LE();
-			closeup->CloseUpType = file->readSint16LE();
-			closeup->depth = depth;
-			closeup->GraphicName = readString(file);
-			closeup->Message = readString(file);
-			closeup->SubCloseUps = readCloseUps(depth + 1, file);
-			closeup->NextCloseUp = NULL;
+			closeup->_closeUpType = file->readSint16LE();
+			closeup->_depth = depth;
+			closeup->_graphicName = readString(file);
+			closeup->_message = readString(file);
+			closeup->_subCloseUps = readCloseUps(depth + 1, file);
+			closeup->_nextCloseUp = NULL;
 			prev = closeup;
 		}
 	} while (c != '\0');
@@ -330,11 +330,11 @@ ViewData *Resource::readView(Common::File *file) {
 			if (!head)
 				head = view;
 			if (prev)
-				prev->NextCondition = view;
-			view->Condition = readConditions(file);
-			view->GraphicName = readString(file);
-			view->closeUps = readCloseUps(0, file);
-			view->NextCondition = NULL;
+				prev->_nextCondition = view;
+			view->_condition = readConditions(file);
+			view->_graphicName = readString(file);
+			view->_closeUps = readCloseUps(0, file);
+			view->_nextCondition = NULL;
 			prev = view;
 		}
 	} while (c == 1);
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 133e4b1..b28d1a2 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -128,7 +128,7 @@ bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc)
 		return false;
 
 	// Load scene pic
-	CloseDataPtr cPtr = NULL;
+	CloseDataPtr cPtr = nullptr;
 	g_lab->_graphics->readPict(getPictName(&cPtr), true);
 
 	writeSaveGameHeader(file, desc);
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 8afeeea..f4c8439 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -435,14 +435,14 @@ bool LabEngine::saveRestoreGame() {
 				desc = dialog->createDefaultSaveDescription(slot);
 			}
 
-			isOK = saveGame(_direction, _inventory[QUARTERNUM].Many, slot, desc);
+			isOK = saveGame(_direction, _inventory[QUARTERNUM]._many, slot, desc);
 		}
 	} else {
 		// Restore
 		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
 		int slot = dialog->runModalWithCurrentTarget();
 		if (slot >= 0) {
-			isOK = loadGame(&_direction, &(_inventory[QUARTERNUM].Many), slot);
+			isOK = loadGame(&_direction, &(_inventory[QUARTERNUM]._many), slot);
 			if (isOK)
 				_music->resetMusic();
 		}
@@ -534,7 +534,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 			if (_cptr == startcptr)
 				Test = StartFileName;
 			else
-				Test = _cptr->GraphicName;
+				Test = _cptr->_graphicName;
 
 			if (strcmp(Test, TextFileName)) {
 				monitorPage      = 0;


Commit: 0f41d8894ca14f7ab4de3adae09576425bd634ea
    https://github.com/scummvm/scummvm/commit/0f41d8894ca14f7ab4de3adae09576425bd634ea
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:52+01:00

Commit Message:
LAB: Simplify usage of the DIFF file buffer

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index edf677b..545b487 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -58,8 +58,7 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 	_frameNum = 0;
 	_playOnce = false;
 	_buffer = nullptr;
-	_storeDiffFile = nullptr;
-	_diffFile = &_storeDiffFile;
+	_diffFile = nullptr;
 	_size = 0;
 	_rawDiffBM._bytesPerRow = 0;
 	_rawDiffBM._flags = 0;
@@ -70,7 +69,6 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 	_stopPlayingEnd = false;
 	_sampleSpeed = 0;
 	_doBlack = false;
-	_start = nullptr;
 	_diffWidth = 0;
 	_diffHeight = 0;
 	_stopSound = false;
@@ -461,7 +459,7 @@ void Anim::diffNextFrame() {
 			_frameNum++;
 
 			if ((_frameNum == 1) && (_continuous || (!_playOnce)))
-				_buffer = *_diffFile;
+				_buffer = _diffFile;
 
 			_isAnim = (_frameNum >= 3) && (!_playOnce);
 			_curBit = 0;
@@ -473,54 +471,54 @@ void Anim::diffNextFrame() {
 		}
 
 		_vm->_music->updateMusic();
-		_header = READ_LE_UINT32(*_diffFile);
-		*_diffFile += 4;
+		_header = READ_LE_UINT32(_diffFile);
+		_diffFile += 4;
 
-		_size = READ_LE_UINT32(*_diffFile);
-		*_diffFile += 4;
+		_size = READ_LE_UINT32(_diffFile);
+		_diffFile += 4;
 
 		switch (_header) {
 		case 8L:
-			readBlock(_diffPalette, _size, _diffFile);
+			readBlock(_diffPalette, _size, &_diffFile);
 			_isPal = true;
 			break;
 
 		case 10L:
-			_rawDiffBM._planes[_curBit] = *_diffFile;
+			_rawDiffBM._planes[_curBit] = _diffFile;
 
 			if (_isBM)
-				(*_diffFile) += _size;
+				_diffFile += _size;
 			else {
-				readBlock(DrawBitMap->_planes[_curBit], _size, _diffFile);
+				readBlock(DrawBitMap->_planes[_curBit], _size, &_diffFile);
 			}
 
 			_curBit++;
 			break;
 
 		case 11L:
-			(*_diffFile) += 4;
-			runLengthDecode(DrawBitMap->_planes[_curBit], *_diffFile);
+			_diffFile += 4;
+			runLengthDecode(DrawBitMap->_planes[_curBit], _diffFile);
 			_curBit++;
-			(*_diffFile) += _size - 4;
+			_diffFile += _size - 4;
 			break;
 
 		case 12L:
-			(*_diffFile) += 4;
-			VRunLengthDecode(DrawBitMap->_planes[_curBit], *_diffFile, DrawBitMap->_bytesPerRow);
+			_diffFile += 4;
+			VRunLengthDecode(DrawBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow);
 			_curBit++;
-			(*_diffFile) += _size - 4;
+			_diffFile += _size - 4;
 			break;
 
 		case 20L:
-			unDiff(DrawBitMap->_planes[_curBit], DispBitMap->_planes[_curBit], *_diffFile, DrawBitMap->_bytesPerRow, false);
+			unDiff(DrawBitMap->_planes[_curBit], DispBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, false);
 			_curBit++;
-			(*_diffFile) += _size;
+			_diffFile += _size;
 			break;
 
 		case 21L:
-			unDiff(DrawBitMap->_planes[_curBit], DispBitMap->_planes[_curBit], *_diffFile, DrawBitMap->_bytesPerRow, true);
+			unDiff(DrawBitMap->_planes[_curBit], DispBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, true);
 			_curBit++;
-			(*_diffFile) += _size;
+			_diffFile += _size;
 			break;
 
 		case 25L:
@@ -543,13 +541,13 @@ void Anim::diffNextFrame() {
 			_size -= 8L;
 
 
-			(*_diffFile) += 4;
-			_sampleSpeed = READ_LE_UINT16(*_diffFile);
-			(*_diffFile) += 4;
+			_diffFile += 4;
+			_sampleSpeed = READ_LE_UINT16(_diffFile);
+			_diffFile += 4;
 
-			byte *music = *_diffFile;
+			byte *music = _diffFile;
 			uint32 musicsize = _size;
-			(*_diffFile) += _size;
+			_diffFile += _size;
 
 			_vm->_music->playSoundEffect(_sampleSpeed, musicsize, music);
 			break;
@@ -578,11 +576,11 @@ void Anim::diffNextFrame() {
 			}
 
 			_frameNum = 4;  /* Random frame number so it never gets back to 2 */
-			*_diffFile = _buffer;
+			_diffFile = _buffer;
 			break;
 
 		default:
-			(*_diffFile) += _size;
+			_diffFile += _size;
 			break;
 		}
 	}
@@ -601,7 +599,6 @@ void Anim::playDiff(byte *buffer) {
 	_numChunks   = 1;
 	_donePal     = false;
 	_stopPlayingEnd = false;
-	_diffFile    = &_storeDiffFile;
 
 	_isPlaying   = true;
 
@@ -610,52 +607,46 @@ void Anim::playDiff(byte *buffer) {
 		_vm->_graphics->blackScreen();
 	}
 
-	_start = buffer;				   /* Make a copy of the pointer to the start of the file    */
-	*_diffFile = _start;               /* Now can modify the file without modifying the original */
-
-	if (_start == NULL) {
-		_isPlaying = false;
-		return;
-	}
+	_diffFile = buffer;
 
 	_continuous = false;
-	uint32 signature = READ_BE_UINT32(*_diffFile);
-	(*_diffFile) += 4;
+	uint32 signature = READ_BE_UINT32(_diffFile);
+	_diffFile += 4;
 
-	_header = READ_LE_UINT32(*_diffFile);
-	(*_diffFile) += 4;
+	_header = READ_LE_UINT32(_diffFile);
+	_diffFile += 4;
 
 	if ((signature != MKTAG('D', 'I', 'F', 'F')) || (_header != 1219009121L)) {
 		_isPlaying = false;
 		return;
 	}
 
-	_header = READ_LE_UINT32(*_diffFile);
-	(*_diffFile) += 4;
+	_header = READ_LE_UINT32(_diffFile);
+	_diffFile += 4;
 
-	_size = READ_LE_UINT32(*_diffFile);
-	(*_diffFile) += 4;
+	_size = READ_LE_UINT32(_diffFile);
+	_diffFile += 4;
 
 	if (_header == 0) {
 		// sizeof(headerdata) != 18, but the padding might be at the end
-		_headerdata._version = READ_LE_UINT16(*_diffFile);
-		(*_diffFile) += 2;
-		_headerdata._width = READ_LE_UINT16(*_diffFile);
-		(*_diffFile) += 2;
-		_headerdata._height = READ_LE_UINT16(*_diffFile);
-		(*_diffFile) += 2;
-		_headerdata._depth = *_diffFile[0];
-		(*_diffFile)++;
-		_headerdata._fps = *_diffFile[0];
-		(*_diffFile)++;
-		_headerdata._bufferSize = READ_LE_UINT32(*_diffFile);
-		(*_diffFile) += 4;
-		_headerdata._machine = READ_LE_UINT16(*_diffFile);
-		(*_diffFile) += 2;
-		_headerdata._flags = READ_LE_UINT32(*_diffFile);
-		(*_diffFile) += 4;
-
-		(*_diffFile) += _size - 18;
+		_headerdata._version = READ_LE_UINT16(_diffFile);
+		_diffFile += 2;
+		_headerdata._width = READ_LE_UINT16(_diffFile);
+		_diffFile += 2;
+		_headerdata._height = READ_LE_UINT16(_diffFile);
+		_diffFile += 2;
+		_headerdata._depth = _diffFile[0];
+		_diffFile++;
+		_headerdata._fps = _diffFile[0];
+		_diffFile++;
+		_headerdata._bufferSize = READ_LE_UINT32(_diffFile);
+		_diffFile += 4;
+		_headerdata._machine = READ_LE_UINT16(_diffFile);
+		_diffFile += 2;
+		_headerdata._flags = READ_LE_UINT32(_diffFile);
+		_diffFile += 4;
+
+		_diffFile += _size - 18;
 
 		_continuous = CONTINUOUS & _headerdata._flags;
 		_diffWidth = _headerdata._width;
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 6c4c8be..f799ae4 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -77,12 +77,10 @@ private:
 	uint16 _frameNum;
 	bool _playOnce;
 	byte *_buffer;
-	byte *_storeDiffFile;
-	byte **_diffFile;
+	byte *_diffFile;
 	uint32 _size;
 	bool _stopPlayingEnd;
 	uint16 _sampleSpeed;
-	byte *_start;
 	uint32 _diffWidth;
 	uint32 _diffHeight;
 	bool _stopSound;


Commit: 2eb430dcff861bfe1809e10d57e26e79b8beb9ed
    https://github.com/scummvm/scummvm/commit/2eb430dcff861bfe1809e10d57e26e79b8beb9ed
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:52+01:00

Commit Message:
LAB: Simplify the calling code of playSoundEffect()

Changed paths:
    engines/lab/anim.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 545b487..7d2d171 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -530,7 +530,7 @@ void Anim::diffNextFrame() {
 			break;
 
 		case 30L:
-		case 31L: {
+		case 31L:
 			if (_waitForEffect) {
 				while (_vm->_music->isSoundEffectActive()) {
 					_vm->_music->updateMusic();
@@ -545,13 +545,9 @@ void Anim::diffNextFrame() {
 			_sampleSpeed = READ_LE_UINT16(_diffFile);
 			_diffFile += 4;
 
-			byte *music = _diffFile;
-			uint32 musicsize = _size;
+			_vm->_music->playSoundEffect(_sampleSpeed, _size, _diffFile);
 			_diffFile += _size;
-
-			_vm->_music->playSoundEffect(_sampleSpeed, musicsize, music);
 			break;
-				  }
 		case 65535L:
 			if ((_frameNum == 1) || _playOnce || _stopPlayingEnd) {
 				int didTOF = 0;


Commit: d264621832bbfe99cb1232f7fd8165cdc2ecc475
    https://github.com/scummvm/scummvm/commit/d264621832bbfe99cb1232f7fd8165cdc2ecc475
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:52+01:00

Commit Message:
LAB: Fix compilation

Changed paths:
    engines/lab/resource.cpp



diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 538b6f6..c6c1105 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -179,13 +179,13 @@ Common::File *Resource::openDataFile(const char *fileName, uint32 fileHeader) {
 	Common::File *dataFile = new Common::File();
 	dataFile->open(translateFileName(fileName));
 	if (!dataFile->isOpen())
-		error("openDataFile: Couldn't open %s (%s)", translateFileName(fileName), fileName);
+		error("openDataFile: Couldn't open %s (%s)", translateFileName(fileName).c_str(), fileName);
 
 	if (fileHeader > 0) {
 		uint32 headerTag = dataFile->readUint32BE();
 		if (headerTag != fileHeader) {
 			dataFile->close();
-			error("openDataFile: Unexpected header in %s (%s) - expected: %d, got: %d", translateFileName(fileName), fileName, fileHeader, headerTag);
+			error("openDataFile: Unexpected header in %s (%s) - expected: %d, got: %d", translateFileName(fileName).c_str(), fileName, fileHeader, headerTag);
 		}
 	}
 


Commit: 895d29c1ae411d6a28135451e91e88eba1693f99
    https://github.com/scummvm/scummvm/commit/895d29c1ae411d6a28135451e91e88eba1693f99
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:52+01:00

Commit Message:
LAB: Some more renaming, remove useless variables

Changed paths:
    engines/lab/engine.cpp
    engines/lab/eventman.cpp
    engines/lab/interface.cpp
    engines/lab/interface.h
    engines/lab/intro.cpp
    engines/lab/map.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 17ae4cc..80035f3 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -132,7 +132,7 @@ void LabEngine::freeScreens() {
 void LabEngine::perFlipGadget(uint16 gadgetId) {
 	for (GadgetList::iterator gadget = _moveGadgetList.begin(); gadget != _moveGadgetList.end(); ++gadget) {
 		Gadget *topGadget = *gadget;
-		if (topGadget->GadgetID == gadgetId) {
+		if (topGadget->_gadgetID == gadgetId) {
 			Image *tmpImage = topGadget->_image;
 			topGadget->_image = topGadget->_altImage;
 			topGadget->_altImage = tmpImage;
@@ -516,11 +516,11 @@ void LabEngine::mainGameLoop() {
 			gotMessage = true;
 
 			Common::Point curPos;
-			curPos.x  = curMsg->mouseX;
-			curPos.y  = curMsg->mouseY;
+			curPos.x  = curMsg->_mouseX;
+			curPos.y  = curMsg->_mouseY;
 
 			_followingCrumbs = false;
-			if (!from_crumbs(curMsg->msgClass, curMsg->code, curMsg->qualifier, curPos, curInv, curMsg, forceDraw, curMsg->gadgetID, actionMode))
+			if (!from_crumbs(curMsg->_msgClass, curMsg->_code, curMsg->_qualifier, curPos, curInv, curMsg, forceDraw, curMsg->_gadgetID, actionMode))
 				break;
 		}
 	}
@@ -618,14 +618,14 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 					_music->updateMusic();
 					_anim->diffNextFrame();
 				} else {
-					if (curMsg->msgClass == RAWKEY) {
-						if ((curMsg->code == 'Y') || (curMsg->code == 'y') || (curMsg->code == 'Q') || (curMsg->code == 'q')) {
+					if (curMsg->_msgClass == RAWKEY) {
+						if ((curMsg->_code == 'Y') || (curMsg->_code == 'y') || (curMsg->_code == 'Q') || (curMsg->_code == 'q')) {
 							doit = true;
 							break;
-						} else if (curMsg->code < 128) {
+						} else if (curMsg->_code < 128) {
 							break;
 						}
-					} else if (curMsg->msgClass == MOUSEBUTTONS) {
+					} else if (curMsg->_msgClass == MOUSEBUTTONS) {
 						break;
 					}
 				}
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index aeb6fa3..b1b1a68 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -63,7 +63,7 @@ Gadget *EventManager::checkGadgetHit(GadgetList *gadgetList, Common::Point pos)
 		if ((pos.x >= gadget->x) && (pos.y >= gadget->y) &&
 			(pos.x <= (gadget->x + gadget->_image->_width)) &&
 			(pos.y <= (gadget->y + gadget->_image->_height)) &&
-			!(GADGETOFF & gadget->GadgetFlags)) {
+			!(GADGETOFF & gadget->_flags)) {
 			if (_vm->_isHiRes) {
 				_hitGadget = gadget;
 			} else {
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index d437fd2..a044fda 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -48,8 +48,8 @@ Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image
 	if ((gptr = new Gadget())) {
 		gptr->x = x;
 		gptr->y = y;
-		gptr->GadgetID = id;
-		gptr->KeyEquiv = key;
+		gptr->_gadgetID = id;
+		gptr->_keyEquiv = key;
 		gptr->_image = im;
 		gptr->_altImage = imalt;
 
@@ -79,7 +79,7 @@ void drawGadgetList(GadgetList *gadgetList) {
 	for (GadgetList::iterator gadget = gadgetList->begin(); gadget != gadgetList->end(); ++gadget) {
 		(*gadget)->_image->drawImage((*gadget)->x, (*gadget)->y);
 
-		if (GADGETOFF & (*gadget)->GadgetFlags)
+		if (GADGETOFF & (*gadget)->_flags)
 			disableGadget((*gadget), 1);
 	}
 }
@@ -90,7 +90,7 @@ void drawGadgetList(GadgetList *gadgetList) {
 /*****************************************************************************/
 void disableGadget(Gadget *curgad, uint16 pencolor) {
 	g_lab->_graphics->overlayRect(pencolor, curgad->x, curgad->y, curgad->x + curgad->_image->_width - 1, curgad->y + curgad->_image->_height - 1);
-	curgad->GadgetFlags |= GADGETOFF;
+	curgad->_flags |= GADGETOFF;
 }
 
 
@@ -100,7 +100,7 @@ void disableGadget(Gadget *curgad, uint16 pencolor) {
 /*****************************************************************************/
 void enableGadget(Gadget *curgad) {
 	curgad->_image->drawImage(curgad->x, curgad->y);
-	curgad->GadgetFlags &= !(GADGETOFF);
+	curgad->_flags &= !(GADGETOFF);
 }
 
 
@@ -126,9 +126,9 @@ Gadget *LabEngine::checkNumGadgetHit(GadgetList *gadgetList, uint16 key) {
 
 	for (GadgetList::iterator gadgetItr = gadgetList->begin(); gadgetItr != gadgetList->end(); ++gadgetItr) {
 		Gadget *gadget = *gadgetItr;
-		if ((gkey - 1 == gadget->GadgetID || (gkey == 0 && gadget->GadgetID == 9) ||
-			(gadget->KeyEquiv != 0 && makeGadgetKeyEquiv(key) == gadget->KeyEquiv))
-		        && !(GADGETOFF & gadget->GadgetFlags)) {
+		if ((gkey - 1 == gadget->_gadgetID || (gkey == 0 && gadget->_gadgetID == 9) ||
+			(gadget->_keyEquiv != 0 && makeGadgetKeyEquiv(key) == gadget->_keyEquiv))
+		        && !(GADGETOFF & gadget->_flags)) {
 			_event->mouseHide();
 			gadget->_altImage->drawImage(gadget->x, gadget->y);
 			_event->mouseShow();
@@ -156,30 +156,30 @@ IntuiMessage *LabEngine::getMsg() {
 
 	if ((curgad = _event->mouseGadget()) != NULL) {
 		_event->updateMouse();
-		IMessage.msgClass = GADGETUP;
-		IMessage.code  = curgad->GadgetID;
-		IMessage.gadgetID = curgad->GadgetID;
-		IMessage.qualifier = Qualifiers;
+		IMessage._msgClass = GADGETUP;
+		IMessage._code  = curgad->_gadgetID;
+		IMessage._gadgetID = curgad->_gadgetID;
+		IMessage._qualifier = Qualifiers;
 		return &IMessage;
-	} else if (_event->mouseButton(&IMessage.mouseX, &IMessage.mouseY, true)) { /* Left Button */
-		IMessage.qualifier = IEQUALIFIER_LEFTBUTTON | Qualifiers;
-		IMessage.msgClass = MOUSEBUTTONS;
+	} else if (_event->mouseButton(&IMessage._mouseX, &IMessage._mouseY, true)) { /* Left Button */
+		IMessage._qualifier = IEQUALIFIER_LEFTBUTTON | Qualifiers;
+		IMessage._msgClass = MOUSEBUTTONS;
 		return &IMessage;
-	} else if (_event->mouseButton(&IMessage.mouseX, &IMessage.mouseY, false)) { /* Right Button */
-		IMessage.qualifier = IEQUALIFIER_RBUTTON | Qualifiers;
-		IMessage.msgClass = MOUSEBUTTONS;
+	} else if (_event->mouseButton(&IMessage._mouseX, &IMessage._mouseY, false)) { /* Right Button */
+		IMessage._qualifier = IEQUALIFIER_RBUTTON | Qualifiers;
+		IMessage._msgClass = MOUSEBUTTONS;
 		return &IMessage;
-	} else if (_event->keyPress(&IMessage.code)) { /* Keyboard key */
-		curgad = checkNumGadgetHit(_event->_screenGadgetList, IMessage.code);
+	} else if (_event->keyPress(&IMessage._code)) { /* Keyboard key */
+		curgad = checkNumGadgetHit(_event->_screenGadgetList, IMessage._code);
 
 		if (curgad) {
-			IMessage.msgClass = GADGETUP;
-			IMessage.code  = curgad->GadgetID;
-			IMessage.gadgetID = curgad->GadgetID;
+			IMessage._msgClass = GADGETUP;
+			IMessage._code  = curgad->_gadgetID;
+			IMessage._gadgetID = curgad->_gadgetID;
 		} else
-			IMessage.msgClass = RAWKEY;
+			IMessage._msgClass = RAWKEY;
 
-		IMessage.qualifier = Qualifiers;
+		IMessage._qualifier = Qualifiers;
 		return &IMessage;
 	} else
 		return NULL;
diff --git a/engines/lab/interface.h b/engines/lab/interface.h
index 83c8bad..a8d1140 100644
--- a/engines/lab/interface.h
+++ b/engines/lab/interface.h
@@ -37,16 +37,16 @@
 namespace Lab {
 
 struct IntuiMessage {
-	uint32 msgClass;
-	uint16 code, qualifier, mouseX, mouseY, gadgetID;
-	uint32 seconds, micros;
+	uint32 _msgClass;
+	uint16 _code, _qualifier, _mouseX, _mouseY, _gadgetID;
+	uint32 _seconds, _micros;
 };
 
 
 struct Gadget {
-	uint16 x, y, GadgetID;
-	uint16 KeyEquiv; // if not zero, a key that activates gadget
-	uint32 GadgetFlags;
+	uint16 x, y, _gadgetID;
+	uint16 _keyEquiv; // if not zero, a key that activates gadget
+	uint32 _flags;
 	Image *_image, *_altImage;
 };
 
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 070b03f..7727ac1 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -53,8 +53,8 @@ void Intro::introEatMessages() {
 		if (msg == NULL)
 			return;
 		else {
-			if (((msg->msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & msg->qualifier)) ||
-			        ((msg->msgClass == RAWKEY) && (msg->code == 27))
+			if (((msg->_msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & msg->_qualifier)) ||
+			        ((msg->_msgClass == RAWKEY) && (msg->_code == 27))
 				)
 				_quitIntro = true;
 		}
@@ -151,9 +151,9 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 
 			_vm->waitTOF();
 		} else {
-			cls       = msg->msgClass;
-			qualifier = msg->qualifier;
-			code      = msg->code;
+			cls       = msg->_msgClass;
+			qualifier = msg->_qualifier;
+			code      = msg->_code;
 
 			if (((cls == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & qualifier)) ||
 			        ((cls == RAWKEY) && (code == 27))) {
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index a565f31..7256562 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -52,8 +52,6 @@ static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge,
 static uint16 MaxRooms;
 static MapData *Maps;
 
-extern char *LOWERFLOORS, *MIDDLEFLOORS, *UPPERFLOORS, *MEDMAZEFLOORS, *HEDGEMAZEFLOORS, *SURMAZEFLOORS, *CARNIVALFLOOR, *SURMAZEMSG;
-
 static uint16 MapGadX[3] = {101, 55, 8}, MapGadY[3] = {105, 105, 105};
 
 static Gadget
@@ -71,8 +69,6 @@ static GadgetList *MapGadgetList;
 #define SURMAZEFLOOR   6
 #define CARNIVAL       7
 
-
-
 static uint16 mapScaleX(uint16 x) {
 	if (g_lab->_isHiRes)
 		return (x - 45);
@@ -80,8 +76,6 @@ static uint16 mapScaleX(uint16 x) {
 		return ((x - 45) >> 1);
 }
 
-
-
 static uint16 mapScaleY(uint16 y) {
 	if (g_lab->_isHiRes)
 		return y;
@@ -89,7 +83,6 @@ static uint16 mapScaleY(uint16 y) {
 		return ((y - 35) >> 1) - (y >> 6);
 }
 
-
 /*****************************************************************************/
 /* Loads in the map data.                                                    */
 /*****************************************************************************/
@@ -532,12 +525,12 @@ void LabEngine::processMap(uint16 CurRoom) {
 				place = 1;
 
 		} else {
-			Class     = Msg->msgClass;
-			Code      = Msg->code;
-			GadgetID  = Msg->gadgetID;
-			Qualifier = Msg->qualifier;
-			MouseX    = Msg->mouseX;
-			MouseY    = Msg->mouseY;
+			Class     = Msg->_msgClass;
+			Code      = Msg->_code;
+			GadgetID  = Msg->_gadgetID;
+			Qualifier = Msg->_qualifier;
+			MouseX    = Msg->_mouseX;
+			MouseY    = Msg->_mouseY;
 
 			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) ||
 			        ((Class == RAWKEY) && (Code == 27)))
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index f4c8439..0bed418 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -200,8 +200,8 @@ static bool loadJournalData() {
 
 	delete journalFile;
 
-	BackG.KeyEquiv = VKEY_LTARROW;
-	ForwardG.KeyEquiv = VKEY_RTARROW;
+	BackG._keyEquiv = VKEY_LTARROW;
+	ForwardG._keyEquiv = VKEY_RTARROW;
 
 	uint16 counter = 0;
 
@@ -219,7 +219,7 @@ static bool loadJournalData() {
 		else
 			gadget->y = g_lab->_graphics->VGAScaleY(JGadY[counter]) - g_lab->_graphics->SVGACord(1);
 
-		gadget->GadgetID = counter;
+		gadget->_gadgetID = counter;
 		counter++;
 	}
 
@@ -345,9 +345,9 @@ void LabEngine::processJournal() {
 		if (Msg == NULL) {
 			_music->updateMusic();
 		} else {
-			Class     = Msg->msgClass;
-			Qualifier = Msg->qualifier;
-			GadID     = Msg->code;
+			Class     = Msg->_msgClass;
+			Qualifier = Msg->_qualifier;
+			GadID     = Msg->_code;
 
 			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) ||
 			        ((Class == RAWKEY) && (GadID == 27)))
@@ -554,11 +554,11 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 		if (Msg == NULL) {
 			_music->updateMusic();
 		} else {
-			Class     = Msg->msgClass;
-			Qualifier = Msg->qualifier;
-			MouseX    = Msg->mouseX;
-			MouseY    = Msg->mouseY;
-			Code      = Msg->code;
+			Class     = Msg->_msgClass;
+			Qualifier = Msg->_qualifier;
+			MouseX    = Msg->_mouseX;
+			MouseY    = Msg->_mouseY;
+			Code      = Msg->_code;
 
 			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) ||
 			        ((Class == RAWKEY) && (Code == 27)))


Commit: 5636181b78bcffa934cb00b14edb68c2d3319139
    https://github.com/scummvm/scummvm/commit/5636181b78bcffa934cb00b14edb68c2d3319139
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:52+01:00

Commit Message:
LAB: Move text functions to DisplayMan, some renaming

Changed paths:
  R engines/lab/text.cpp
  R engines/lab/text.h
  R engines/lab/vga.cpp
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/graphics.h
    engines/lab/intro.cpp
    engines/lab/intro.h
    engines/lab/map.cpp
    engines/lab/module.mk
    engines/lab/resource.cpp
    engines/lab/resource.h
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 80035f3..ce89225 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -32,7 +32,6 @@
 #include "lab/labfun.h"
 #include "lab/anim.h"
 #include "lab/image.h"
-#include "lab/text.h"
 #include "lab/intro.h"
 #include "lab/parsefun.h"
 #include "lab/interface.h"
@@ -1076,8 +1075,7 @@ void LabEngine::go() {
 		}
 	}
 
-	closeFont(_msgFont);
-
+	_graphics->closeFont(_msgFont);
 	_graphics->freePict();
 
 	freeScreens();
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 375ab22..857c252 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -34,7 +34,6 @@
 #include "lab/image.h"
 #include "lab/labfun.h"
 #include "lab/parsefun.h"
-#include "lab/text.h"
 #include "lab/resource.h"
 #include "lab/graphics.h"
 
@@ -208,7 +207,7 @@ static void getWord(char *wordBuffer, const char *mainBuffer, uint16 *wordWidth)
 /* Gets a line of text for flowText; makes sure that its length is less than  */
 /* or equal to the maximum width.                                             */
 /******************************************************************************/
-static void getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer, uint16 lineWidth) {
+void DisplayMan::getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer, uint16 lineWidth) {
 	uint16 curWidth = 0, wordWidth;
 	char wordBuffer[100];
 	bool doit = true;
@@ -1159,9 +1158,128 @@ void DisplayMan::fade(bool fadein, uint16 res) {
 				(0xF00 & fadeNumOut(0xF00 & FadePalette[palIdx], 0xF00 & res, i));
 		}
 
-		g_lab->_graphics->setAmigaPal(newpal, 16);
-		g_lab->waitTOF();
-		g_lab->_music->updateMusic();
+		setAmigaPal(newpal, 16);
+		_vm->waitTOF();
+		_vm->_music->updateMusic();
+	}
+}
+
+/*****************************************************************************/
+/* Closes a font and frees all memory associated with it.                    */
+/*****************************************************************************/
+void DisplayMan::closeFont(TextFont *tf) {
+	if (tf) {
+		if (tf->_data && tf->_dataLength)
+			delete[] tf->_data;
+
+		delete tf;
+	}
+}
+
+/*****************************************************************************/
+/* Returns the length of a text in the specified font.                       */
+/*****************************************************************************/
+uint16 DisplayMan::textLength(TextFont *tf, const char *text, uint16 numchars) {
+	uint16 length = 0;
+
+	if (tf) {
+		for (uint16 i = 0; i < numchars; i++) {
+			length += tf->_widths[(uint)*text];
+			text++;
+		}
+	}
+
+	return length;
+}
+
+/*****************************************************************************/
+/* Returns the height of a specified font.                                   */
+/*****************************************************************************/
+uint16 DisplayMan::textHeight(TextFont *tf) {
+	return (tf) ? tf->_height : 0;
+}
+
+/*****************************************************************************/
+/* Draws the text to the screen.                                             */
+/*****************************************************************************/
+void DisplayMan::text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numchars) {
+	byte *VGATop, *VGACur, *VGATemp, *VGATempLine, *cdata;
+	uint32 RealOffset, SegmentOffset;
+	int32 templeft, LeftInSegment;
+	uint16 bwidth, mask, curpage, data;
+
+	VGATop = getCurrentDrawingBuffer();
+
+	for (uint16 i = 0; i < numchars; i++) {
+		RealOffset = (_screenWidth * y) + x;
+		curpage    = RealOffset / _screenBytesPerPage;
+		SegmentOffset = RealOffset - (curpage * _screenBytesPerPage);
+		LeftInSegment = _screenBytesPerPage - SegmentOffset;
+		VGACur = VGATop + SegmentOffset;
+
+		if (tf->_widths[(uint)*text]) {
+			cdata = tf->_data + tf->_offsets[(uint)*text];
+			bwidth = *cdata++;
+			VGATemp = VGACur;
+			VGATempLine = VGACur;
+
+			for (uint16 rows = 0; rows < tf->_height; rows++) {
+				VGATemp = VGATempLine;
+				templeft = LeftInSegment;
+
+				for (uint16 cols = 0; cols < bwidth; cols++) {
+					data = *cdata++;
+
+					if (data && (templeft >= 8)) {
+						for (int j = 7; j >= 0; j--) {
+							if ((1 << j) & data)
+								*VGATemp = color;
+							VGATemp++;
+						}
+
+						templeft -= 8;
+					} else if (data) {
+						mask = 0x80;
+						templeft = LeftInSegment;
+
+						for (uint16 counterb = 0; counterb < 8; counterb++) {
+							if (templeft <= 0) {
+								curpage++;
+								VGATemp = (byte *)(VGATop - templeft);
+								/* Set up VGATempLine for next line */
+								VGATempLine -= _screenBytesPerPage;
+								/* Set up LeftInSegment for next line */
+								LeftInSegment += _screenBytesPerPage + templeft;
+								templeft += _screenBytesPerPage;
+							}
+
+							if (mask & data)
+								*VGATemp = color;
+
+							VGATemp++;
+
+							mask = mask >> 1;
+							templeft--;
+						}
+					} else {
+						templeft -= 8;
+						VGATemp += 8;
+					}
+				}
+
+				VGATempLine += _screenWidth;
+				LeftInSegment -= _screenWidth;
+
+				if (LeftInSegment <= 0) {
+					curpage++;
+					VGATempLine -= _screenBytesPerPage;
+					LeftInSegment += _screenBytesPerPage;
+				}
+			}
+		}
+
+		x += tf->_widths[(int)*text];
+		text++;
 	}
 }
 } // End of namespace Lab
diff --git a/engines/lab/graphics.h b/engines/lab/graphics.h
index 564f041..5d97507 100644
--- a/engines/lab/graphics.h
+++ b/engines/lab/graphics.h
@@ -37,6 +37,14 @@ namespace Lab {
 
 class LabEngine;
 
+struct TextFont {
+	uint32 _dataLength;
+	uint16 _height;
+	byte _widths[256];
+	uint16 _offsets[256];
+	byte *_data;
+};
+
 class DisplayMan {
 private:
 	LabEngine *_vm;
@@ -129,6 +137,11 @@ public:
 	void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void fade(bool fadein, uint16 res);
+	void closeFont(TextFont *tf);
+	uint16 textLength(TextFont *tf, const char *text, uint16 numchars);
+	uint16 textHeight(TextFont *tf);
+	void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numchars);
+	void getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer, uint16 lineWidth);
 
 	bool _longWinInFront;
 	bool _lastMessageLong;
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 7727ac1..4b0ed66 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -444,7 +444,7 @@ void Intro::introSequence() {
 		_vm->_anim->_doBlack = true;
 	}
 
-	closeFont(msgFont);
+	_vm->_graphics->closeFont(msgFont);
 }
 
 } // End of namespace Lab
diff --git a/engines/lab/intro.h b/engines/lab/intro.h
index 47b61da..c532bdf 100644
--- a/engines/lab/intro.h
+++ b/engines/lab/intro.h
@@ -32,7 +32,6 @@
 #define LAB_INTRO_H
 
 #include "lab/intro.h"
-#include "lab/text.h"
 
 namespace Lab {
 
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 7256562..b7006a3 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -32,12 +32,10 @@
 #include "lab/labfun.h"
 #include "lab/anim.h"
 #include "lab/image.h"
-#include "lab/text.h"
 #include "lab/parsefun.h"
 #include "lab/parsetypes.h"
 #include "lab/resource.h"
 #include "lab/interface.h"
-#include "lab/text.h"
 
 namespace Lab {
 
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index 3985b14..5c0aed5 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -17,7 +17,6 @@ MODULE_OBJS := \
 	resource.o \
 	savegame.o \
 	special.o \
-	text.o \
 	tilepuzzle.o \
 	timing.o
 
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index c6c1105..f76aea0 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -29,7 +29,6 @@
  */
 
 #include "lab/lab.h"
-#include "lab/text.h"
 #include "lab/resource.h"
 
 namespace Lab {
@@ -58,14 +57,14 @@ TextFont *Resource::getFont(const char *fileName) {
 	_vm->_music->updateMusic();
 
 	TextFont *textfont = new TextFont();
-	textfont->DataLength = fileSize - headerSize;
-	textfont->Height = dataFile->readUint16LE();
-	dataFile->read(textfont->Widths, 256);
+	textfont->_dataLength = fileSize - headerSize;
+	textfont->_height = dataFile->readUint16LE();
+	dataFile->read(textfont->_widths, 256);
 	for (int i = 0; i < 256; i++)
-		textfont->Offsets[i] = dataFile->readUint16LE();
+		textfont->_offsets[i] = dataFile->readUint16LE();
 	dataFile->skip(4);
-	textfont->data = new byte[textfont->DataLength + 4];
-	dataFile->read(textfont->data, textfont->DataLength);
+	textfont->_data = new byte[textfont->_dataLength + 4];
+	dataFile->read(textfont->_data, textfont->_dataLength);
 	return textfont;
 }
 
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index 99996a1..e050a15 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -32,7 +32,6 @@
 #define LAB_RESOURCE_H
 
 #include "lab/labfun.h"
-#include "lab/text.h"
 
 namespace Lab {
 
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 0bed418..6642865 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -39,7 +39,6 @@
 #include "lab/parsefun.h"
 #include "lab/interface.h"
 #include "lab/anim.h"
-#include "lab/text.h"
 #include "lab/parsetypes.h"
 #include "lab/resource.h"
 
@@ -105,7 +104,7 @@ void LabEngine::doNotes() {
 	g_lab->_graphics->flowText(noteFont, -2 + g_lab->_graphics->SVGACord(1), 0, 0, false, false, true, true, g_lab->_graphics->VGAScaleX(25) + g_lab->_graphics->SVGACord(15), g_lab->_graphics->VGAScaleY(50), g_lab->_graphics->VGAScaleX(295) - g_lab->_graphics->SVGACord(15), g_lab->_graphics->VGAScaleY(148), ntext);
 	g_lab->_graphics->setPalette(g_lab->_anim->_diffPalette, 256);
 
-	closeFont(noteFont);
+	g_lab->_graphics->closeFont(noteFont);
 	delete[] ntext;
 }
 
@@ -123,7 +122,7 @@ void LabEngine::doWestPaper() {
 	paperFont = g_lab->_resource->getFont("P:News22.fon");
 	ntext = g_lab->_resource->getText("Lab:Rooms/Date");
 	g_lab->_graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, g_lab->_graphics->VGAScaleX(57), g_lab->_graphics->VGAScaleY(77) + g_lab->_graphics->SVGACord(2), g_lab->_graphics->VGAScaleX(262), g_lab->_graphics->VGAScaleY(91), ntext);
-	closeFont(paperFont);
+	g_lab->_graphics->closeFont(paperFont);
 	delete[] ntext;
 
 	paperFont = g_lab->_resource->getFont("P:News32.fon");
@@ -135,7 +134,7 @@ void LabEngine::doWestPaper() {
 		g_lab->_graphics->flowText(paperFont, -8 - g_lab->_graphics->SVGACord(1), 0, 0, false, true, false, true, g_lab->_graphics->VGAScaleX(57), g_lab->_graphics->VGAScaleY(86) - g_lab->_graphics->SVGACord(2), g_lab->_graphics->VGAScaleX(262), g_lab->_graphics->VGAScaleY(132), ntext);
 	} else
 		y = 115 - g_lab->_graphics->SVGACord(5);
-	closeFont(paperFont);
+	g_lab->_graphics->closeFont(paperFont);
 	delete[] ntext;
 
 	paperFont = g_lab->_resource->getFont("P:Note.fon");
@@ -145,7 +144,7 @@ void LabEngine::doWestPaper() {
 	ntext = g_lab->_resource->getText("Lab:Rooms/Col2");
 	CharsPrinted = g_lab->_graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 162, y, 275, 148, ntext);
 	delete[] ntext;
-	closeFont(paperFont);
+	g_lab->_graphics->closeFont(paperFont);
 
 	g_lab->_graphics->setPalette(g_lab->_anim->_diffPalette, 256);
 }
@@ -470,7 +469,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
 		numlines += (*text - '0');
 		text += 2;
 
-		fheight = textHeight(monitorFont);
+		fheight = g_lab->_graphics->textHeight(monitorFont);
 		x1 = MonButton->_width + _graphics->VGAScaleX(3);
 		MonGadHeight = MonButton->_height + _graphics->VGAScaleY(3);
 
@@ -645,7 +644,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 	_graphics->fade(false, 0);
 	_event->mouseHide();
 	delete[] ntext;
-	closeFont(monitorFont);
+	g_lab->_graphics->closeFont(monitorFont);
 
 	_graphics->setAPen(0);
 	_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);
diff --git a/engines/lab/text.cpp b/engines/lab/text.cpp
deleted file mode 100644
index f784c21..0000000
--- a/engines/lab/text.cpp
+++ /dev/null
@@ -1,156 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "lab/lab.h"
-#include "lab/labfun.h"
-#include "lab/text.h"
-
-namespace Lab {
-
-/*****************************************************************************/
-/* Closes a font and frees all memory associated with it.                    */
-/*****************************************************************************/
-void closeFont(TextFont *tf) {
-	if (tf) {
-		if (tf->data && tf->DataLength)
-			delete[] tf->data;
-
-		delete tf;
-	}
-}
-
-/*****************************************************************************/
-/* Returns the length of a text in the specified font.                       */
-/*****************************************************************************/
-uint16 textLength(TextFont *tf, const char *text, uint16 numchars) {
-	uint16 length = 0;
-
-	if (tf) {
-		for (uint16 i = 0; i < numchars; i++) {
-			length += tf->Widths[(uint)*text];
-			text++;
-		}
-	}
-
-	return length;
-}
-
-/*****************************************************************************/
-/* Returns the height of a specified font.                                   */
-/*****************************************************************************/
-uint16 textHeight(TextFont *tf) {
-	return (tf) ? tf->Height : 0;
-}
-
-/*****************************************************************************/
-/* Draws the text to the screen.                                             */
-/*****************************************************************************/
-void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numchars) {
-	byte *VGATop, *VGACur, *VGATemp, *VGATempLine, *cdata;
-	uint32 RealOffset, SegmentOffset;
-	int32 templeft, LeftInSegment;
-	uint16 bwidth, mask, curpage, data;
-
-	VGATop = g_lab->_graphics->getCurrentDrawingBuffer();
-
-	for (uint16 i = 0; i < numchars; i++) {
-		RealOffset = (g_lab->_graphics->_screenWidth * y) + x;
-		curpage    = RealOffset / g_lab->_graphics->_screenBytesPerPage;
-		SegmentOffset = RealOffset - (curpage * g_lab->_graphics->_screenBytesPerPage);
-		LeftInSegment = g_lab->_graphics->_screenBytesPerPage - SegmentOffset;
-		VGACur = VGATop + SegmentOffset;
-
-		if (tf->Widths[(uint)*text]) {
-			cdata = tf->data + tf->Offsets[(uint)*text];
-			bwidth = *cdata++;
-			VGATemp = VGACur;
-			VGATempLine = VGACur;
-
-			for (uint16 rows = 0; rows < tf->Height; rows++) {
-				VGATemp = VGATempLine;
-				templeft = LeftInSegment;
-
-				for (uint16 cols = 0; cols < bwidth; cols++) {
-					data = *cdata++;
-
-					if (data && (templeft >= 8)) {
-						for (int j = 7; j >= 0; j--) {
-							if ((1 << j) & data)
-								*VGATemp = color;
-							VGATemp++;
-						}
-
-						templeft -= 8;
-					} else if (data) {
-						mask = 0x80;
-						templeft = LeftInSegment;
-
-						for (uint16 counterb = 0; counterb < 8; counterb++) {
-							if (templeft <= 0) {
-								curpage++;
-								VGATemp = (byte *)(VGATop - templeft);
-								/* Set up VGATempLine for next line */
-								VGATempLine -= g_lab->_graphics->_screenBytesPerPage;
-								/* Set up LeftInSegment for next line */
-								LeftInSegment += g_lab->_graphics->_screenBytesPerPage + templeft;
-								templeft += g_lab->_graphics->_screenBytesPerPage;
-							}
-
-							if (mask & data)
-								*VGATemp = color;
-
-							VGATemp++;
-
-							mask = mask >> 1;
-							templeft--;
-						}
-					} else {
-						templeft -= 8;
-						VGATemp += 8;
-					}
-				}
-
-				VGATempLine += g_lab->_graphics->_screenWidth;
-				LeftInSegment -= g_lab->_graphics->_screenWidth;
-
-				if (LeftInSegment <= 0) {
-					curpage++;
-					VGATempLine -= g_lab->_graphics->_screenBytesPerPage;
-					LeftInSegment += g_lab->_graphics->_screenBytesPerPage;
-				}
-			}
-		}
-
-		x += tf->Widths[(int)*text];
-		text++;
-	}
-}
-
-} // End of namespace Lab
diff --git a/engines/lab/text.h b/engines/lab/text.h
deleted file mode 100644
index 7401f02..0000000
--- a/engines/lab/text.h
+++ /dev/null
@@ -1,59 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#ifndef LAB_TEXT_H
-#define LAB_TEXT_H
-
-namespace Lab {
-
-#if defined(WIN32)
-#pragma pack(push, 1)
-#endif
-
-struct TextFont {
-	uint32 DataLength;
-	uint16 Height;
-	byte Widths[256];
-	uint16 Offsets[256];
-	byte *data;
-};
-
-#if defined(WIN32)
-#pragma pack(pop)
-#endif
-
-void closeFont(TextFont *tf);
-uint16 textLength(TextFont *tf, const char *text, uint16 numchars);
-uint16 textHeight(TextFont *tf);
-void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numchars);
-
-} // End of namespace Lab
-
-#endif /* LAB_TEXT_H */
diff --git a/engines/lab/vga.cpp b/engines/lab/vga.cpp
deleted file mode 100644
index b80f338..0000000
--- a/engines/lab/vga.cpp
+++ /dev/null
@@ -1,33 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-namespace Lab {
-
-} // End of namespace Lab


Commit: f3a24ff593024e3a997ed1a9160d32a84eb42d74
    https://github.com/scummvm/scummvm/commit/f3a24ff593024e3a997ed1a9160d32a84eb42d74
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:53+01:00

Commit Message:
LAB: Some refactoring, remove dead code and a useless return value

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h
    engines/lab/graphics.cpp
    engines/lab/graphics.h
    engines/lab/special.cpp
    engines/lab/tilepuzzle.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 7d2d171..ee63660 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -33,9 +33,7 @@
 
 namespace Lab {
 
-extern BitMap *DrawBitMap;
 extern byte **startoffile;
-extern BitMap *DispBitMap;
 
 Anim::Anim(LabEngine *vm) : _vm(vm) {
 	_header = 0;
@@ -71,12 +69,11 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 	_doBlack = false;
 	_diffWidth = 0;
 	_diffHeight = 0;
-	_stopSound = false;
 	_dataBytesPerRow = 0;
+	DrawBitMap = &bit2;
 
 	for (int i = 0; i < 3 * 256; i++)
 		_diffPalette[i] = 0;
-
 }
 
 /*------------------------ unDiff Horizontal Memory -------------------------*/
@@ -85,7 +82,7 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 /* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
 /* is also a byte.                                                           */
 /*****************************************************************************/
-void Anim::unDIFFByteByte(byte *dest, byte *diff) {
+void Anim::unDiffByteByte(byte *dest, byte *diff) {
 	uint16 skip, copy;
 
 	while (1) {
@@ -115,7 +112,7 @@ void Anim::unDIFFByteByte(byte *dest, byte *diff) {
 /* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
 /* is a word.                                                                */
 /*****************************************************************************/
-void Anim::unDIFFByteWord(uint16 *dest, uint16 *diff) {
+void Anim::unDiffByteWord(uint16 *dest, uint16 *diff) {
 	uint16 skip, copy;
 
 	while (1) {
@@ -168,13 +165,13 @@ void Anim::unDIFFByteWord(uint16 *dest, uint16 *diff) {
 /*****************************************************************************/
 /* UnDiffs a coded DIFF string onto an already initialized piece of memory.  */
 /*****************************************************************************/
-bool Anim::unDIFFMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySize) {
+bool Anim::unDiffMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySize) {
 	if (headerSize == 1) {
 		if (copySize == 1)
-			unDIFFByteByte(dest, diff);
+			unDiffByteByte(dest, diff);
 
 		else if (copySize == 2)
-			unDIFFByteWord((uint16 *)dest, (uint16 *)diff);
+			unDiffByteWord((uint16 *)dest, (uint16 *)diff);
 
 		else
 			return false;
@@ -190,7 +187,7 @@ bool Anim::unDIFFMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySi
 /* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
 /* is a byte.                                                                */
 /*****************************************************************************/
-void Anim::VUnDIFFByteByte(byte *dest, byte *diff, uint16 bytesPerRow) {
+void Anim::VUnDiffByteByte(byte *dest, byte *diff, uint16 bytesPerRow) {
 	byte *curPtr;
 	uint16 skip, copy;
 	uint16 counter = 0;
@@ -228,7 +225,7 @@ void Anim::VUnDIFFByteByte(byte *dest, byte *diff, uint16 bytesPerRow) {
 /* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
 /* is a word.                                                                */
 /*****************************************************************************/
-void Anim::VUnDIFFByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow) {
+void Anim::VUnDiffByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow) {
 	uint16 *curPtr;
 	uint16 skip, copy;
 	uint16 counter = 0;
@@ -268,7 +265,7 @@ void Anim::VUnDIFFByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow) {
 /* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
 /* is a long.                                                                */
 /*****************************************************************************/
-void Anim::VUnDIFFByteLong(uint32 *dest, uint32 *diff, uint16 bytesPerRow) {
+void Anim::VUnDiffByteLong(uint32 *dest, uint32 *diff, uint16 bytesPerRow) {
 	uint32 *_curPtr;
 	uint16 skip, copy;
 
@@ -310,14 +307,14 @@ void Anim::VUnDIFFByteLong(uint32 *dest, uint32 *diff, uint16 bytesPerRow) {
 /*****************************************************************************/
 /* UnDiffs a coded DIFF string onto an already initialized piece of memory.  */
 /*****************************************************************************/
-bool Anim::VUnDIFFMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySize, uint16 bytesPerRow) {
+bool Anim::VUnDiffMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySize, uint16 bytesPerRow) {
 	if (headerSize == 1) {
 		if (copySize == 1)
-			VUnDIFFByteByte(dest, diff, bytesPerRow);
+			VUnDiffByteByte(dest, diff, bytesPerRow);
 		else if (copySize == 2)
-			VUnDIFFByteWord((uint16 *)dest, (uint16 *)diff, bytesPerRow);
+			VUnDiffByteWord((uint16 *)dest, (uint16 *)diff, bytesPerRow);
 		else if (copySize == 4)
-			VUnDIFFByteLong((uint32 *)dest, (uint32 *)diff, bytesPerRow);
+			VUnDiffByteLong((uint32 *)dest, (uint32 *)diff, bytesPerRow);
 		else
 			return false;
 	} else
@@ -407,9 +404,9 @@ void Anim::unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesPerRow
 	diffData++;
 
 	if (isV)
-		VUnDIFFMemory(newBuf, diffData, 1, bufType + 1, bytesPerRow);
+		VUnDiffMemory(newBuf, diffData, 1, bufType + 1, bytesPerRow);
 	else
-		unDIFFMemory(newBuf, diffData, 1, bufType + 1);
+		unDiffMemory(newBuf, diffData, 1, bufType + 1);
 }
 
 void Anim::readBlock(void *Buffer, uint32 Size, byte **File) {
@@ -421,12 +418,12 @@ void Anim::diffNextFrame() {
 	if (_header == 65535)  /* Already done. */
 		return;
 
-	if (DispBitMap->_flags & BITMAPF_VIDEO) {
-		DispBitMap->_planes[0] = _vm->_graphics->getCurrentDrawingBuffer();
-		DispBitMap->_planes[1] = DispBitMap->_planes[0] + 0x10000;
-		DispBitMap->_planes[2] = DispBitMap->_planes[1] + 0x10000;
-		DispBitMap->_planes[3] = DispBitMap->_planes[2] + 0x10000;
-		DispBitMap->_planes[4] = DispBitMap->_planes[3] + 0x10000;
+	if (_vm->_graphics->_dispBitMap->_flags & BITMAPF_VIDEO) {
+		_vm->_graphics->_dispBitMap->_planes[0] = _vm->_graphics->getCurrentDrawingBuffer();
+		_vm->_graphics->_dispBitMap->_planes[1] = _vm->_graphics->_dispBitMap->_planes[0] + 0x10000;
+		_vm->_graphics->_dispBitMap->_planes[2] = _vm->_graphics->_dispBitMap->_planes[1] + 0x10000;
+		_vm->_graphics->_dispBitMap->_planes[3] = _vm->_graphics->_dispBitMap->_planes[2] + 0x10000;
+		_vm->_graphics->_dispBitMap->_planes[4] = _vm->_graphics->_dispBitMap->_planes[3] + 0x10000;
 	}
 
 	_vm->_event->mouseHide();
@@ -464,7 +461,7 @@ void Anim::diffNextFrame() {
 			_isAnim = (_frameNum >= 3) && (!_playOnce);
 			_curBit = 0;
 
-			if (DispBitMap->_flags & BITMAPF_VIDEO)
+			if (_vm->_graphics->_dispBitMap->_flags & BITMAPF_VIDEO)
 				_vm->_graphics->screenUpdate();
 
 			return; /* done with the next frame. */
@@ -510,13 +507,13 @@ void Anim::diffNextFrame() {
 			break;
 
 		case 20L:
-			unDiff(DrawBitMap->_planes[_curBit], DispBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, false);
+			unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, false);
 			_curBit++;
 			_diffFile += _size;
 			break;
 
 		case 21L:
-			unDiff(DrawBitMap->_planes[_curBit], DispBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, true);
+			unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, true);
 			_curBit++;
 			_diffFile += _size;
 			break;
@@ -550,15 +547,15 @@ void Anim::diffNextFrame() {
 			break;
 		case 65535L:
 			if ((_frameNum == 1) || _playOnce || _stopPlayingEnd) {
-				int didTOF = 0;
+				bool didTOF = false;
 
 				if (_waitForEffect) {
 					while (_vm->_music->isSoundEffectActive()) {
 						_vm->_music->updateMusic();
 						_vm->waitTOF();
 
-						if (DispBitMap->_flags & BITMAPF_VIDEO)
-							didTOF = 1;
+						if (_vm->_graphics->_dispBitMap->_flags & BITMAPF_VIDEO)
+							didTOF = true;
 					}
 				}
 
@@ -692,13 +689,6 @@ void Anim::stopDiffEnd() {
 }
 
 /*****************************************************************************/
-/* Stops the continuous sound from playing.                                  */
-/*****************************************************************************/
-void Anim::stopSound() {
-	_stopSound = true;
-}
-
-/*****************************************************************************/
 /* Reads in a DIFF file.                                                     */
 /*****************************************************************************/
 bool Anim::readDiff(byte *buffer, bool playOnce) {
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index f799ae4..54efa4f 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -83,15 +83,25 @@ private:
 	uint16 _sampleSpeed;
 	uint32 _diffWidth;
 	uint32 _diffHeight;
-	bool _stopSound;
 	uint16 _dataBytesPerRow;
+	BitMap bit2;
+	BitMap *DrawBitMap;
 
-	void unDIFFByteByte(byte *dest, byte *diff);
-	void unDIFFByteWord(uint16 *dest, uint16 *diff);
-	void VUnDIFFByteByte(byte *Dest, byte *diff, uint16 bytesperrow);
-	void VUnDIFFByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow);
-	void VUnDIFFByteLong(uint32 *Dest, uint32 *diff, uint16 bytesperrow);
+	bool unDiffMemory(byte *dest,           /* Where to Un-DIFF */
+		byte *diff,           /* The DIFFed code. */
+		uint16 headerSize,    /* Size of header (1, 2 or 4 bytes) (only supports 1 currently */
+		uint16 copySize);     /* Size of minimum copy or skip. (1, 2 or 4 bytes) */
+
+	void runLengthDecode(byte *dest, byte *source);
+	void VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow);
+	void unDiffByteByte(byte *dest, byte *diff);
+	void unDiffByteWord(uint16 *dest, uint16 *diff);
+	bool VUnDiffMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySize, uint16 bytesPerRow);
+	void VUnDiffByteByte(byte *Dest, byte *diff, uint16 bytesperrow);
+	void VUnDiffByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow);
+	void VUnDiffByteLong(uint32 *Dest, uint32 *diff, uint16 bytesperrow);
 	void readBlock(void *Buffer, uint32 Size, byte **File);
+	void playDiff(byte *buffer);
 
 public:
 	Anim(LabEngine *vm);
@@ -105,21 +115,11 @@ public:
 	BitMap _rawDiffBM;
 
 	void unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesperrow, bool isV);
-	bool unDIFFMemory(byte *dest,           /* Where to Un-DIFF */
-					  byte *diff,           /* The DIFFed code. */
-					  uint16 headerSize,    /* Size of header (1, 2 or 4 bytes) (only supports 1 currently */
-					  uint16 copySize);     /* Size of minimum copy or skip. (1, 2 or 4 bytes) */
-
-	bool VUnDIFFMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySize, uint16 bytesPerRow);
-	void runLengthDecode(byte *dest, byte *source);
-	void VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow);
 	bool readDiff(byte *buffer, bool playOnce);
-	void playDiff(byte *buffer);
 	void diffNextFrame();
 	void readSound(bool waitTillFinished, Common::File *file);
 	void stopDiff();
 	void stopDiffEnd();
-	void stopSound();
 };
 
 } // End of namespace Lab
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 857c252..5147ac3 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -39,8 +39,6 @@
 
 namespace Lab {
 
-BitMap bit1, bit2, *DispBitMap = &bit1, *DrawBitMap = &bit1;
-
 DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) {
 	_longWinInFront = false;
 	_lastMessageLong = false;
@@ -57,6 +55,8 @@ DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) {
 	_screenWidth = 0;
 	_screenHeight = 0;
 
+	_dispBitMap = &bit1;
+
 	for (int i = 0; i < 256 * 3; i++)
 		_curvgapal[i] = 0;
 }
@@ -129,7 +129,7 @@ void DisplayMan::loadPict(const char *filename) {
 /*****************************************************************************/
 /* Reads in a picture into the dest bitmap.                                  */
 /*****************************************************************************/
-bool DisplayMan::readPict(const char *filename, bool playOnce) {
+void DisplayMan::readPict(const char *filename, bool playOnce) {
 	_vm->_anim->stopDiff();
 
 	loadPict(filename);
@@ -139,13 +139,11 @@ bool DisplayMan::readPict(const char *filename, bool playOnce) {
 	if (!_vm->_music->_doNotFilestopSoundEffect)
 		_vm->_music->stopSoundEffect();
 
-	DispBitMap->_bytesPerRow = _screenWidth;
-	DispBitMap->_rows        = _screenHeight;
-	DispBitMap->_flags       = BITMAPF_VIDEO;
+	_dispBitMap->_bytesPerRow = _screenWidth;
+	_dispBitMap->_rows        = _screenHeight;
+	_dispBitMap->_flags       = BITMAPF_VIDEO;
 
 	_vm->_anim->readDiff(_curBitmap, playOnce);
-
-	return true;
 }
 
 /*****************************************************************************/
@@ -161,14 +159,14 @@ byte *DisplayMan::readPictToMem(const char *filename, uint16 x, uint16 y) {
 	if (!_vm->_music->_doNotFilestopSoundEffect)
 		_vm->_music->stopSoundEffect();
 
-	DispBitMap->_bytesPerRow = x;
-	DispBitMap->_rows = y;
-	DispBitMap->_flags = BITMAPF_NONE;
-	DispBitMap->_planes[0] = _curBitmap;
-	DispBitMap->_planes[1] = DispBitMap->_planes[0] + 0x10000;
-	DispBitMap->_planes[2] = DispBitMap->_planes[1] + 0x10000;
-	DispBitMap->_planes[3] = DispBitMap->_planes[2] + 0x10000;
-	DispBitMap->_planes[4] = DispBitMap->_planes[3] + 0x10000;
+	_dispBitMap->_bytesPerRow = x;
+	_dispBitMap->_rows = y;
+	_dispBitMap->_flags = BITMAPF_NONE;
+	_dispBitMap->_planes[0] = _curBitmap;
+	_dispBitMap->_planes[1] = _dispBitMap->_planes[0] + 0x10000;
+	_dispBitMap->_planes[2] = _dispBitMap->_planes[1] + 0x10000;
+	_dispBitMap->_planes[3] = _dispBitMap->_planes[2] + 0x10000;
+	_dispBitMap->_planes[4] = _dispBitMap->_planes[3] + 0x10000;
 
 	_vm->_anim->readDiff(_curBitmap, true);
 
diff --git a/engines/lab/graphics.h b/engines/lab/graphics.h
index 5d97507..8e67cd2 100644
--- a/engines/lab/graphics.h
+++ b/engines/lab/graphics.h
@@ -32,6 +32,7 @@
 #define LAB_GRAPHICS_H
 
 #include "graphics/palette.h"
+#include "lab/anim.h"
 
 namespace Lab {
 
@@ -67,7 +68,7 @@ public:
 	int16 VGAScaleY(int16 y);
 	uint16 SVGACord(uint16 cord);
 	void loadPict(const char *filename);
-	bool readPict(const char *filename, bool playOnce);
+	void readPict(const char *filename, bool playOnce);
 	void freePict();
 	byte *readPictToMem(const char *filename, uint16 x, uint16 y);
 	void doScrollBlack();
@@ -152,6 +153,8 @@ public:
 	byte *_currentDisplayBuffer;
 	bool _doNotDrawMessage;
 	uint16 *FadePalette;
+	BitMap bit1;
+	BitMap *_dispBitMap;
 };
 
 } // End of namespace Lab
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 6642865..e491196 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -59,7 +59,6 @@ static uint16 monitorPage;
 static const char *TextFileName;
 
 Image *MonButton;
-extern BitMap *DispBitMap, *DrawBitMap;
 
 #define INCL(BITSET,BIT) ((BITSET) |= (BIT))
 #define SETBIT(BITSET,BITNUM)   INCL(BITSET, (1 << (BITNUM)))
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index 5ab0454..0d050cc 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -163,7 +163,7 @@ void LabEngine::changeTile(uint16 col, uint16 row) {
 		if (check) {
 			_conditions->inclElement(BRICKOPEN);  /* unlocked combination */
 			_anim->_doBlack = true;
-			check = _graphics->readPict("p:Up/BDOpen", true);
+			_graphics->readPict("p:Up/BDOpen", true);
 		}
 	}
 }


Commit: 87201cfed25e2b145d55c5d77fe0988d32444395
    https://github.com/scummvm/scummvm/commit/87201cfed25e2b145d55c5d77fe0988d32444395
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:53+01:00

Commit Message:
LAB: Rename and clean up some of the scene transition code

Changed paths:
    engines/lab/graphics.cpp
    engines/lab/graphics.h
    engines/lab/parsetypes.h
    engines/lab/processroom.cpp
    engines/lab/resource.cpp



diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 5147ac3..9555104 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -409,18 +409,6 @@ void DisplayMan::drawMessage(const char *str) {
 	}
 }
 
-/*---------------------------------------------------------------------------*/
-/*--------------------------- All the wipe stuff. ---------------------------*/
-/*---------------------------------------------------------------------------*/
-
-#define TRANSWIPE      1
-#define SCROLLWIPE     2
-#define SCROLLBLACK    3
-#define SCROLLBOUNCE   4
-#define TRANSPORTER    5
-#define READFIRSTFRAME 6
-#define READNEXTFRAME  7
-
 /*****************************************************************************/
 /* Scrolls the display to black.                                             */
 /*****************************************************************************/
@@ -736,19 +724,31 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 /*****************************************************************************/
 /* Does a certain number of pre-programmed wipes.                            */
 /*****************************************************************************/
-void DisplayMan::doWipe(uint16 wipeType, CloseDataPtr *cPtr, char *filename) {
-	if ((wipeType == TRANSWIPE) || (wipeType == TRANSPORTER))
+void DisplayMan::doTransition(TransitionType transitionType, CloseDataPtr *cPtr, char *filename) {
+	switch (transitionType) {
+	case kTransitionWipe:
+	case kTransitionTransporter:
 		doTransWipe(cPtr, filename);
-	else if (wipeType == SCROLLWIPE)
+		break;
+	case kTransitionScrollWipe:
 		doScrollWipe(filename);
-	else if (wipeType == SCROLLBLACK)
+		break;
+	case kTransitionScrollBlack:
 		doScrollBlack();
-	else if (wipeType == SCROLLBOUNCE)
+		break;
+	case kTransitionScrollBounce:
 		doScrollBounce();
-	else if (wipeType == READFIRSTFRAME)
+		break;
+	case kTransitionReadFirstFrame:
 		readPict(filename, false);
-	else if (wipeType == READNEXTFRAME)
+		break;
+	case kTransitionReadNextFrame:
 		_vm->_anim->diffNextFrame();
+		break;
+	case kTransitionNone:
+	default:
+		break;
+	}
 }
 
 /*****************************************************************************/
diff --git a/engines/lab/graphics.h b/engines/lab/graphics.h
index 8e67cd2..9011b22 100644
--- a/engines/lab/graphics.h
+++ b/engines/lab/graphics.h
@@ -46,6 +46,17 @@ struct TextFont {
 	byte *_data;
 };
 
+enum TransitionType {
+	kTransitionNone,
+	kTransitionWipe,
+	kTransitionScrollWipe,
+	kTransitionScrollBlack,
+	kTransitionScrollBounce,
+	kTransitionTransporter,
+	kTransitionReadFirstFrame,
+	kTransitionReadNextFrame
+};
+
 class DisplayMan {
 private:
 	LabEngine *_vm;
@@ -76,7 +87,7 @@ public:
 	void doScrollWipe(char *filename);
 	void doScrollBounce();
 	void doTransWipe(CloseDataPtr *cPtr, char *filename);
-	void doWipe(uint16 wipeType, CloseDataPtr *cPtr, char *filename);
+	void doTransition(TransitionType transitionType, CloseDataPtr *cPtr, char *filename);
 	void blackScreen();
 	void whiteScreen();
 	void blackAllScreen();
diff --git a/engines/lab/parsetypes.h b/engines/lab/parsetypes.h
index b345e1e..42c7269 100644
--- a/engines/lab/parsetypes.h
+++ b/engines/lab/parsetypes.h
@@ -45,7 +45,7 @@ namespace Lab {
 #define LOADDIFF      5
 #define LOADBM        6
 #define SHOWBM        7
-#define WIPECMD       8
+#define TRANSITION    8
 #define NOUPDATE      9
 #define FORCEUPDATE  10
 #define SHOWCURPICT  11
@@ -139,7 +139,7 @@ struct RoomData {
 	uint16 _southDoor;
 	uint16 _eastDoor;
 	uint16 _westDoor;
-	byte _wipeType;
+	byte _transitionType;
 	ViewData *_view[4];
 	RuleList *_rules;
 	char *_roomMsg;
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 015b854..d467c21 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -332,8 +332,8 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 
 			break;
 
-		case WIPECMD:
-			_graphics->doWipe(aptr->_param1, lcptr, (char *)aptr->_data);
+		case TRANSITION:
+			_graphics->doTransition((TransitionType)aptr->_param1, lcptr, (char *)aptr->_data);
 			break;
 
 		case NOUPDATE:
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index f76aea0..f99ab82 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -98,7 +98,7 @@ bool Resource::readRoomData(const char *fileName) {
 		_vm->_rooms[i]._southDoor = dataFile->readUint16LE();
 		_vm->_rooms[i]._eastDoor = dataFile->readUint16LE();
 		_vm->_rooms[i]._westDoor = dataFile->readUint16LE();
-		_vm->_rooms[i]._wipeType = dataFile->readByte();
+		_vm->_rooms[i]._transitionType = dataFile->readByte();
 
 		_vm->_rooms[i]._view[NORTH] = nullptr;
 		_vm->_rooms[i]._view[SOUTH] = nullptr;


Commit: 9cc30c3c6d6edb616bb76d15b46391bacf3e2052
    https://github.com/scummvm/scummvm/commit/9cc30c3c6d6edb616bb76d15b46391bacf3e2052
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:53+01:00

Commit Message:
LAB: Clean up processArrow()

Changed paths:
    engines/lab/engine.cpp
    engines/lab/parsefun.h
    engines/lab/processroom.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index ce89225..726a103 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -720,8 +720,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 				oldDirection = _direction;
 
-				NewDir = _direction;
-				processArrow(&NewDir, gadgetId - 6);
+				NewDir = processArrow(_direction, gadgetId - 6);
 				doTurn(_direction, NewDir, &_cptr);
 				_anim->_doBlack = true;
 				_direction = NewDir;
@@ -737,7 +736,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 						_anim->_doBlack = true;
 				} else {
 					_anim->_doBlack = true;
-					processArrow(&_direction, gadgetId - 6);
+					_direction = processArrow(_direction, gadgetId - 6);
 
 					if (oldRoomNum != _roomNum) {
 						drawStaticMessage(kTextGoForward);
diff --git a/engines/lab/parsefun.h b/engines/lab/parsefun.h
index 7f88951..c45727d 100644
--- a/engines/lab/parsefun.h
+++ b/engines/lab/parsefun.h
@@ -45,7 +45,7 @@ bool parse(const char *inputFile);
 ViewData *getViewData(uint16 roomNum, uint16 direction);
 char *getPictName(CloseDataPtr *lcptr);
 void drawDirection(CloseDataPtr lcptr);
-bool processArrow(uint16 *direction, uint16 arrow);
+uint16 processArrow(uint16 curDirection, uint16 arrow);
 void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords = false);
 bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr);
 bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *lcptr);
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index d467c21..1487888 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -188,44 +188,45 @@ void LabEngine::drawDirection(CloseDataPtr lcptr) {
 /*****************************************************************************/
 /* process a arrow gadget movement.                                          */
 /*****************************************************************************/
-bool processArrow(uint16 *direction, uint16 arrow) {
-	if (arrow == 1) { /* Forward */
+uint16 processArrow(uint16 curDirection, uint16 arrow) {
+	if (arrow == 1) { // Forward
 		uint16 room = 1;
 
-		if (*direction == NORTH)
+		if (curDirection == NORTH)
 			room = g_lab->_rooms[g_lab->_roomNum]._northDoor;
-		else if (*direction == SOUTH)
+		else if (curDirection == SOUTH)
 			room = g_lab->_rooms[g_lab->_roomNum]._southDoor;
-		else if (*direction == EAST)
+		else if (curDirection == EAST)
 			room = g_lab->_rooms[g_lab->_roomNum]._eastDoor;
-		else if (*direction == WEST)
+		else if (curDirection == WEST)
 			room = g_lab->_rooms[g_lab->_roomNum]._westDoor;
 
-		if (room == 0)
-			return false;
-		else
+		if (room != 0)
 			g_lab->_roomNum = room;
-	} else if (arrow == 0) { /* Left */
-		if (*direction == NORTH)
-			*direction = WEST;
-		else if (*direction == WEST)
-			*direction = SOUTH;
-		else if (*direction == SOUTH)
-			*direction = EAST;
+
+		return curDirection;
+	} else if (arrow == 0) { // Left
+		if (curDirection == NORTH)
+			return WEST;
+		else if (curDirection == WEST)
+			return SOUTH;
+		else if (curDirection == SOUTH)
+			return EAST;
 		else
-			*direction = NORTH;
-	} else if (arrow == 2) { /* Right */
-		if (*direction == NORTH)
-			*direction = EAST;
-		else if (*direction == EAST)
-			*direction = SOUTH;
-		else if (*direction == SOUTH)
-			*direction = WEST;
+			return NORTH;
+	} else if (arrow == 2) { // Right
+		if (curDirection == NORTH)
+			return EAST;
+		else if (curDirection == EAST)
+			return SOUTH;
+		else if (curDirection == SOUTH)
+			return WEST;
 		else
-			*direction = NORTH;
+			return NORTH;
 	}
 
-	return true;
+	// Should never reach here!
+	return curDirection;
 }
 
 /*****************************************************************************/


Commit: 75c9d0b585b8468489e350f885b89af37b79b543
    https://github.com/scummvm/scummvm/commit/75c9d0b585b8468489e350f885b89af37b79b543
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:53+01:00

Commit Message:
LAB: Fix spelling

Changed paths:
    engines/lab/intro.cpp
    engines/lab/processroom.cpp



diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 4b0ed66..da44916 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -38,8 +38,8 @@ Intro::Intro(LabEngine *vm) : _vm(vm) {
 }
 
 /******************************************************************************/
-/* Goes thru, and responds to all the intuition messages currently in the     */
-/* the message port.                                                          */
+/* Goes through, and responds to all the intuition messages currently in the  */
+/* message queue.                                                             */
 /******************************************************************************/
 void Intro::introEatMessages() {
 	while (1) {
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 1487888..0b43966 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -651,7 +651,7 @@ static bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr lcptr, C
 }
 
 /*****************************************************************************/
-/* Goes thru the rules if the user tries to operate an item on an object.    */
+/* Goes through the rules if the user tries to operate an item on an object. */
 /*****************************************************************************/
 bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *lcptr) {
 	CloseDataPtr tlcptr;
@@ -685,7 +685,7 @@ bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *lcptr) {
 }
 
 /*****************************************************************************/
-/* Goes thru the rules if the user tries to go forward.                      */
+/* Goes through the rules if the user tries to go forward.                   */
 /*****************************************************************************/
 bool doGoForward(CloseDataPtr *lcptr) {
 	RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;
@@ -703,7 +703,7 @@ bool doGoForward(CloseDataPtr *lcptr) {
 }
 
 /*****************************************************************************/
-/* Goes thru the rules if the user tries to turn.                            */
+/* Goes through the rules if the user tries to turn.                         */
 /*****************************************************************************/
 bool doTurn(uint16 from, uint16 to, CloseDataPtr *lcptr) {
 	from++;
@@ -726,7 +726,7 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *lcptr) {
 }
 
 /*****************************************************************************/
-/* Goes thru the rules if the user tries to go to the main view              */
+/* Goes through the rules if the user tries to go to the main view           */
 /*****************************************************************************/
 bool doMainView(CloseDataPtr *lcptr) {
 	RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;


Commit: 1e11090edc2c6e253fcae3a5f2c3c52e62f9a0a0
    https://github.com/scummvm/scummvm/commit/1e11090edc2c6e253fcae3a5f2c3c52e62f9a0a0
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:53+01:00

Commit Message:
LAB: Remove useless return

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 726a103..53e61c4 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -156,8 +156,6 @@ void LabEngine::eatMessages() {
 	do {
 		msg = getMsg();
 	} while (msg);
-
-	return;
 }
 
 /******************************************************************************/


Commit: 4f1a8f9fa4bdd1ae11460ac89463772c4814a1e1
    https://github.com/scummvm/scummvm/commit/4f1a8f9fa4bdd1ae11460ac89463772c4814a1e1
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:53+01:00

Commit Message:
LAB: Merge the uniffMemory() code into unDiff()

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index ee63660..bb5c5e9 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -162,25 +162,6 @@ void Anim::unDiffByteWord(uint16 *dest, uint16 *diff) {
 	}
 }
 
-/*****************************************************************************/
-/* UnDiffs a coded DIFF string onto an already initialized piece of memory.  */
-/*****************************************************************************/
-bool Anim::unDiffMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySize) {
-	if (headerSize == 1) {
-		if (copySize == 1)
-			unDiffByteByte(dest, diff);
-
-		else if (copySize == 2)
-			unDiffByteWord((uint16 *)dest, (uint16 *)diff);
-
-		else
-			return false;
-	} else
-		error("unDIFFMemory: HeaderSize is %d", headerSize);
-
-	return true;
-}
-
 /*------------------------- unDiff Vertical Memory --------------------------*/
 
 /*****************************************************************************/
@@ -305,25 +286,6 @@ void Anim::VUnDiffByteLong(uint32 *dest, uint32 *diff, uint16 bytesPerRow) {
 }
 
 /*****************************************************************************/
-/* UnDiffs a coded DIFF string onto an already initialized piece of memory.  */
-/*****************************************************************************/
-bool Anim::VUnDiffMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySize, uint16 bytesPerRow) {
-	if (headerSize == 1) {
-		if (copySize == 1)
-			VUnDiffByteByte(dest, diff, bytesPerRow);
-		else if (copySize == 2)
-			VUnDiffByteWord((uint16 *)dest, (uint16 *)diff, bytesPerRow);
-		else if (copySize == 4)
-			VUnDiffByteLong((uint32 *)dest, (uint32 *)diff, bytesPerRow);
-		else
-			return false;
-	} else
-		return (false);
-
-	return true;
-}
-
-/*****************************************************************************/
 /* Runlength decodes a chunk of memory.                                      */
 /*****************************************************************************/
 void Anim::runLengthDecode(byte *dest, byte *source) {
@@ -403,10 +365,19 @@ void Anim::unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesPerRow
 	byte bufType = *diffData;
 	diffData++;
 
-	if (isV)
-		VUnDiffMemory(newBuf, diffData, 1, bufType + 1, bytesPerRow);
-	else
-		unDiffMemory(newBuf, diffData, 1, bufType + 1);
+	if (isV) {
+		if (bufType == 0)
+			VUnDiffByteByte(newBuf, diffData, bytesPerRow);
+		else if (bufType == 1)
+			VUnDiffByteWord((uint16 *)newBuf, (uint16 *)diffData, bytesPerRow);
+		else if (bufType == 3)
+			VUnDiffByteLong((uint32 *)newBuf, (uint32 *)diffData, bytesPerRow);
+	} else {
+		if (bufType == 0)
+			unDiffByteByte(newBuf, diffData);
+		else if (bufType == 1)
+			unDiffByteWord((uint16 *)newBuf, (uint16 *)diffData);
+	}
 }
 
 void Anim::readBlock(void *Buffer, uint32 Size, byte **File) {
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 54efa4f..9841347 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -87,16 +87,10 @@ private:
 	BitMap bit2;
 	BitMap *DrawBitMap;
 
-	bool unDiffMemory(byte *dest,           /* Where to Un-DIFF */
-		byte *diff,           /* The DIFFed code. */
-		uint16 headerSize,    /* Size of header (1, 2 or 4 bytes) (only supports 1 currently */
-		uint16 copySize);     /* Size of minimum copy or skip. (1, 2 or 4 bytes) */
-
 	void runLengthDecode(byte *dest, byte *source);
 	void VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow);
 	void unDiffByteByte(byte *dest, byte *diff);
 	void unDiffByteWord(uint16 *dest, uint16 *diff);
-	bool VUnDiffMemory(byte *dest, byte *diff, uint16 headerSize, uint16 copySize, uint16 bytesPerRow);
 	void VUnDiffByteByte(byte *Dest, byte *diff, uint16 bytesperrow);
 	void VUnDiffByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow);
 	void VUnDiffByteLong(uint32 *Dest, uint32 *diff, uint16 bytesperrow);


Commit: 5ccc0fd7c6469e1b1bac6b32a4624a88e0c78278
    https://github.com/scummvm/scummvm/commit/5ccc0fd7c6469e1b1bac6b32a4624a88e0c78278
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:53+01:00

Commit Message:
LAB: Clean up checkGadgetHit() a bit

Changed paths:
    engines/lab/eventman.cpp



diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index b1b1a68..1c204b7 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -60,10 +60,10 @@ static byte MouseData[] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
 Gadget *EventManager::checkGadgetHit(GadgetList *gadgetList, Common::Point pos) {
 	for (GadgetList::iterator gadgetItr = gadgetList->begin(); gadgetItr != gadgetList->end(); ++gadgetItr) {
 		Gadget *gadget = *gadgetItr;
-		if ((pos.x >= gadget->x) && (pos.y >= gadget->y) &&
-			(pos.x <= (gadget->x + gadget->_image->_width)) &&
-			(pos.y <= (gadget->y + gadget->_image->_height)) &&
-			!(GADGETOFF & gadget->_flags)) {
+		Common::Rect gadgetRect(gadget->x, gadget->y, gadget->x + gadget->_image->_width - 1, gadget->y + gadget->_image->_height - 1);
+		bool gadgetIsEnabled = !(gadget->_flags & GADGETOFF);
+
+		if (gadgetRect.contains(pos) && gadgetIsEnabled) {
 			if (_vm->_isHiRes) {
 				_hitGadget = gadget;
 			} else {
@@ -86,8 +86,6 @@ Gadget *EventManager::checkGadgetHit(GadgetList *gadgetList, Common::Point pos)
 	return NULL;
 }
 
-
-
 void EventManager::attachGadgetList(GadgetList *gadgetList) {
 	if (_screenGadgetList != gadgetList)
 		_lastGadgetHit = nullptr;


Commit: 6bba608fc06658cec8f0bc09874739ae8b4bc9e4
    https://github.com/scummvm/scummvm/commit/6bba608fc06658cec8f0bc09874739ae8b4bc9e4
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:53+01:00

Commit Message:
LAB: Get rid of _numHidden

Changed paths:
    engines/lab/eventman.cpp
    engines/lab/eventman.h



diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 1c204b7..4c50cb7 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -98,7 +98,6 @@ EventManager::EventManager(LabEngine *vm) : _vm(vm) {
 	_rightClick = false;
 
 	_mouseHidden = true;
-	_numHidden   = 1;
 	_lastGadgetHit = nullptr;
 	_screenGadgetList = nullptr;
 	_hitGadget = nullptr;
@@ -113,9 +112,6 @@ EventManager::EventManager(LabEngine *vm) : _vm(vm) {
 }
 
 void EventManager::mouseHandler(int flag, Common::Point pos) {
-	if (_numHidden >= 2)
-		return;
-
 	if (flag & 0x02) { /* Left mouse button click */
 		Gadget *tmp = NULL;
 		if (_screenGadgetList)
@@ -172,10 +168,7 @@ void EventManager::initMouse() {
 /* Shows the mouse.                                                          */
 /*****************************************************************************/
 void EventManager::mouseShow() {
-	if (_numHidden)
-		_numHidden--;
-
-	if ((_numHidden == 0) && _mouseHidden) {
+	if (_mouseHidden) {
 		processInput();
 		_mouseHidden = false;
 	}
@@ -187,9 +180,7 @@ void EventManager::mouseShow() {
 /* Hides the mouse.                                                          */
 /*****************************************************************************/
 void EventManager::mouseHide() {
-	_numHidden++;
-
-	if (_numHidden && !_mouseHidden) {
+	if (!_mouseHidden) {
 		_mouseHidden = true;
 
 		g_system->showMouse(false);
diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h
index a156a8a..11d8dfd 100644
--- a/engines/lab/eventman.h
+++ b/engines/lab/eventman.h
@@ -44,7 +44,6 @@ private:
 	bool _rightClick;
 
 	bool _mouseHidden;
-	int32 _numHidden;
 	Gadget *_lastGadgetHit;
 	uint16 _nextKeyIn;
 	uint16 _nextKeyOut;


Commit: 156ad539ffe30c9a09952f7b97e285a5a5096b0d
    https://github.com/scummvm/scummvm/commit/156ad539ffe30c9a09952f7b97e285a5a5096b0d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:53+01:00

Commit Message:
LAB: Move readSound() into the Music class

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h
    engines/lab/music.cpp
    engines/lab/music.h



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index bb5c5e9..c5493e0 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -668,48 +668,4 @@ bool Anim::readDiff(byte *buffer, bool playOnce) {
 	return true;
 }
 
-void Anim::readSound(bool waitTillFinished, Common::File *file) {
-	uint32 magicBytes = file->readUint32LE();
-	if (magicBytes != 1219009121L)
-		return;
-
-	uint32 soundTag = file->readUint32LE();
-	uint32 soundSize = file->readUint32LE();
-
-	if (soundTag == 0)
-		file->skip(soundSize);	// skip the header
-	else
-		return;
-
-	while (soundTag != 65535) {
-		_vm->_music->updateMusic();
-		soundTag = file->readUint32LE();
-		soundSize = file->readUint32LE() - 8;
-
-		if ((soundTag == 30) || (soundTag == 31)) {
-			if (waitTillFinished) {
-				while (_vm->_music->isSoundEffectActive()) {
-					_vm->_music->updateMusic();
-					_vm->waitTOF();
-				}
-			}
-
-			file->skip(4);
-
-			uint16 sampleRate = file->readUint16LE();
-			file->skip(2);
-			byte *soundData = (byte *)malloc(soundSize);
-			file->read(soundData, soundSize);
-			_vm->_music->playSoundEffect(sampleRate, soundSize, soundData);
-		} else if (soundTag == 65535L) {
-			if (waitTillFinished) {
-				while (_vm->_music->isSoundEffectActive()) {
-					_vm->_music->updateMusic();
-					_vm->waitTOF();
-				}
-			}
-		} else
-			file->skip(soundSize);
-	}
-}
 } // End of namespace Lab
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 9841347..a0438d8 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -111,7 +111,6 @@ public:
 	void unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesperrow, bool isV);
 	bool readDiff(byte *buffer, bool playOnce);
 	void diffNextFrame();
-	void readSound(bool waitTillFinished, Common::File *file);
 	void stopDiff();
 	void stopDiffEnd();
 };
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index ddc6cbd..1260fd8 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -321,9 +321,56 @@ bool Music::readMusic(const char *filename, bool waitTillFinished) {
 		return false;
 
 	_vm->_anim->_doBlack = false;
-	_vm->_anim->readSound(waitTillFinished, file);
+	readSound(waitTillFinished, file);
 
 	return true;
 }
 
+void Music::readSound(bool waitTillFinished, Common::File *file) {
+	uint32 magicBytes = file->readUint32LE();
+	if (magicBytes != 1219009121L)
+		return;
+
+	uint32 soundTag = file->readUint32LE();
+	uint32 soundSize = file->readUint32LE();
+
+	if (soundTag == 0)
+		file->skip(soundSize);	// skip the header
+	else
+		return;
+
+	while (soundTag != 65535) {
+		updateMusic();
+		soundTag = file->readUint32LE();
+		soundSize = file->readUint32LE() - 8;
+
+		if ((soundTag == 30) || (soundTag == 31)) {
+			if (waitTillFinished) {
+				while (isSoundEffectActive()) {
+					updateMusic();
+					_vm->waitTOF();
+				}
+			}
+
+			file->skip(4);
+
+			uint16 sampleRate = file->readUint16LE();
+			file->skip(2);
+			byte *soundData = (byte *)malloc(soundSize);
+			file->read(soundData, soundSize);
+			playSoundEffect(sampleRate, soundSize, soundData);
+		}
+		else if (soundTag == 65535L) {
+			if (waitTillFinished) {
+				while (isSoundEffectActive()) {
+					updateMusic();
+					_vm->waitTOF();
+				}
+			}
+		}
+		else
+			file->skip(soundSize);
+	}
+}
+
 } // End of namespace Lab
diff --git a/engines/lab/music.h b/engines/lab/music.h
index 7905da7..942f737 100644
--- a/engines/lab/music.h
+++ b/engines/lab/music.h
@@ -77,9 +77,11 @@ public:
 	bool _doReset;
 
 private:
-	LabEngine *_vm;
 	void fillbuffer(byte *musicBuffer);
 	void startMusic(bool restartFl);
+	void readSound(bool waitTillFinished, Common::File *file);
+
+	LabEngine *_vm;
 
 	Common::File *_file;
 	Common::File *_tFile;


Commit: 0e886461d0c60f1d3f1f790da8755e35ed2883d3
    https://github.com/scummvm/scummvm/commit/0e886461d0c60f1d3f1f790da8755e35ed2883d3
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:53+01:00

Commit Message:
LAB: Replace some uses of malloc() with new

Changed paths:
    engines/lab/engine.cpp
    engines/lab/interface.cpp
    engines/lab/lab.cpp
    engines/lab/labsets.cpp
    engines/lab/music.cpp
    engines/lab/resource.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 53e61c4..ee61e2f 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -526,20 +526,20 @@ void LabEngine::mainGameLoop() {
 	delete _roomsFound;
 
 	if (_rooms) {
-		free(_rooms);
+		delete[] _rooms;
 		_rooms = nullptr;
 	}
 
 	if (_inventory) {
 		for (int i = 1; i <= _numInv; i++) {
 			if (_inventory[i]._name)
-				free(_inventory[i]._name);
+				delete _inventory[i]._name;
 
 			if (_inventory[i]._bitmapName)
-				free(_inventory[i]._bitmapName);
+				delete _inventory[i]._bitmapName;
 		}
 
-		free(_inventory);
+		delete[] _inventory;
 	}
 }
 
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index a044fda..9ab570a 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -63,7 +63,7 @@ Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image
 
 void freeButtonList(GadgetList *gadgetList) {
 	for (GadgetList::iterator gadget = gadgetList->begin(); gadget != gadgetList->end(); ++gadget) {
-		free(*gadget);
+		delete *gadget;
 	}
 
 	gadgetList->clear();
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 02abf80..3def003 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -129,7 +129,7 @@ LabEngine::~LabEngine() {
 	delete _music;
 	delete _anim;
 	delete _graphics;
-	free(_rooms);
+	delete[] _rooms;
 
 	for (int i = 0; i < 16; i++)
 		delete _tiles[i];
diff --git a/engines/lab/labsets.cpp b/engines/lab/labsets.cpp
index 2598587..f09f669 100644
--- a/engines/lab/labsets.cpp
+++ b/engines/lab/labsets.cpp
@@ -37,12 +37,13 @@ namespace Lab {
 LargeSet::LargeSet(uint16 last, LabEngine *vm) : _vm(vm) {
 	last = (((last + 15) >> 4) << 4);
 
-	_array = (uint16 *)calloc(last >> 3, 2);
+	_array = new uint16[last >> 3];
+	memset(_array, 0, last >> 3);
 	_lastElement = last;
 }
 
 LargeSet::~LargeSet() {
-	free(_array);
+	delete[] _array;
 }
 
 bool LargeSet::in(uint16 element) {
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 1260fd8..8fd88ff 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -356,6 +356,8 @@ void Music::readSound(bool waitTillFinished, Common::File *file) {
 
 			uint16 sampleRate = file->readUint16LE();
 			file->skip(2);
+			// NOTE: We need to use malloc(), cause this will be freed with free()
+			// by the music code
 			byte *soundData = (byte *)malloc(soundSize);
 			file->read(soundData, soundSize);
 			playSoundEffect(sampleRate, soundSize, soundData);
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index f99ab82..de1e9dc 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -90,7 +90,7 @@ bool Resource::readRoomData(const char *fileName) {
 
 	_vm->_manyRooms = dataFile->readUint16LE();
 	_vm->_highestCondition = dataFile->readUint16LE();
-	_vm->_rooms = (RoomData *)malloc((_vm->_manyRooms + 1) * sizeof(RoomData));
+	_vm->_rooms = new RoomData[_vm->_manyRooms + 1];
 	memset(_vm->_rooms, 0, (_vm->_manyRooms + 1) * sizeof(RoomData));
 
 	for (uint16 i = 1; i <= _vm->_manyRooms; i++) {
@@ -116,7 +116,7 @@ InventoryData *Resource::readInventory(const char *fileName) {
 	Common::File *dataFile = openDataFile(fileName, MKTAG('I', 'N', 'V', '1'));
 
 	_vm->_numInv = dataFile->readUint16LE();
-	InventoryData *inventory = (InventoryData *)malloc((_vm->_numInv + 1) * sizeof(InventoryData));
+	InventoryData *inventory = new InventoryData[_vm->_numInv + 1];
 
 	for (uint16 i = 1; i <= _vm->_numInv; i++) {
 		inventory[i]._many = dataFile->readUint16LE();
@@ -195,7 +195,7 @@ char *Resource::readString(Common::File *file) {
 	byte size = file->readByte();
 	if (!size)
 		return NULL;
-	char *str = (char *)malloc(size);
+	char *str = new char[size];
 	char *c = str;
 	for (int i = 0; i < size; i++) {
 		*c = file->readByte();
@@ -209,8 +209,7 @@ char *Resource::readString(Common::File *file) {
 
 int16 *Resource::readConditions(Common::File *file) {
 	int16 i = 0, cond;
-	//int16 *list = new int16[25];
-	int16 *list = (int16 *)malloc(25 * 2);
+	int16 *list = new int16[25];
 	memset(list, 0, 25 * 2);
 
 	do {
@@ -254,7 +253,7 @@ Action *Resource::readAction(Common::File *file) {
 		c = file->readByte();
 
 		if (c == 1) {
-			action = (Action *)malloc(sizeof(Action));
+			action = new Action();
 			if (!head)
 				head = action;
 			if (prev)
@@ -293,7 +292,7 @@ CloseData *Resource::readCloseUps(uint16 depth, Common::File *file) {
 		c = file->readByte();
 
 		if (c != '\0') {
-			closeup = (CloseData *)malloc(sizeof(CloseData));
+			closeup = new CloseData();
 			if (!head)
 				head = closeup;
 			if (prev)
@@ -325,7 +324,7 @@ ViewData *Resource::readView(Common::File *file) {
 		c = file->readByte();
 
 		if (c == 1) {
-			view = (ViewData *)malloc(sizeof(ViewData));
+			view = new ViewData();
 			if (!head)
 				head = view;
 			if (prev)


Commit: b6397c0af78e6cfecd1f1f7fe9c0686cd6e27daa
    https://github.com/scummvm/scummvm/commit/b6397c0af78e6cfecd1f1f7fe9c0686cd6e27daa
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:54+01:00

Commit Message:
LAB: Use the correct bitmap buffer in the Anim class

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h
    engines/lab/lab.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index c5493e0..b28222c 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -70,7 +70,7 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 	_diffWidth = 0;
 	_diffHeight = 0;
 	_dataBytesPerRow = 0;
-	DrawBitMap = &bit2;
+	DrawBitMap = &_vm->_graphics->bit1;
 
 	for (int i = 0; i < 3 * 256; i++)
 		_diffPalette[i] = 0;
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index a0438d8..28927ba 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -84,7 +84,6 @@ private:
 	uint32 _diffWidth;
 	uint32 _diffHeight;
 	uint16 _dataBytesPerRow;
-	BitMap bit2;
 	BitMap *DrawBitMap;
 
 	void runLengthDecode(byte *dest, byte *source);
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 3def003..ec81fdf 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -144,8 +144,8 @@ Common::Error LabEngine::run() {
 	_event = new EventManager(this);
 	_resource = new Resource(this);
 	_music = new Music(this);
-	_anim = new Anim(this);
 	_graphics = new DisplayMan(this);
+	_anim = new Anim(this);
 
 	if (getPlatform() == Common::kPlatformWindows) {
 		// Check if this is the Wyrmkeep trial


Commit: 320e658cb1e1d266cb3bf91ad9202ff83f88a9ad
    https://github.com/scummvm/scummvm/commit/320e658cb1e1d266cb3bf91ad9202ff83f88a9ad
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:54+01:00

Commit Message:
LAB: Get rid of the intermediate display bitmap pointer

Changed paths:
    engines/lab/anim.cpp
    engines/lab/graphics.cpp
    engines/lab/graphics.h



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index b28222c..6e12e92 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -70,7 +70,7 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 	_diffWidth = 0;
 	_diffHeight = 0;
 	_dataBytesPerRow = 0;
-	DrawBitMap = &_vm->_graphics->bit1;
+	DrawBitMap = &_vm->_graphics->_dispBitMap;
 
 	for (int i = 0; i < 3 * 256; i++)
 		_diffPalette[i] = 0;
@@ -389,12 +389,12 @@ void Anim::diffNextFrame() {
 	if (_header == 65535)  /* Already done. */
 		return;
 
-	if (_vm->_graphics->_dispBitMap->_flags & BITMAPF_VIDEO) {
-		_vm->_graphics->_dispBitMap->_planes[0] = _vm->_graphics->getCurrentDrawingBuffer();
-		_vm->_graphics->_dispBitMap->_planes[1] = _vm->_graphics->_dispBitMap->_planes[0] + 0x10000;
-		_vm->_graphics->_dispBitMap->_planes[2] = _vm->_graphics->_dispBitMap->_planes[1] + 0x10000;
-		_vm->_graphics->_dispBitMap->_planes[3] = _vm->_graphics->_dispBitMap->_planes[2] + 0x10000;
-		_vm->_graphics->_dispBitMap->_planes[4] = _vm->_graphics->_dispBitMap->_planes[3] + 0x10000;
+	if (_vm->_graphics->_dispBitMap._flags & BITMAPF_VIDEO) {
+		_vm->_graphics->_dispBitMap._planes[0] = _vm->_graphics->getCurrentDrawingBuffer();
+		_vm->_graphics->_dispBitMap._planes[1] = _vm->_graphics->_dispBitMap._planes[0] + 0x10000;
+		_vm->_graphics->_dispBitMap._planes[2] = _vm->_graphics->_dispBitMap._planes[1] + 0x10000;
+		_vm->_graphics->_dispBitMap._planes[3] = _vm->_graphics->_dispBitMap._planes[2] + 0x10000;
+		_vm->_graphics->_dispBitMap._planes[4] = _vm->_graphics->_dispBitMap._planes[3] + 0x10000;
 	}
 
 	_vm->_event->mouseHide();
@@ -432,7 +432,7 @@ void Anim::diffNextFrame() {
 			_isAnim = (_frameNum >= 3) && (!_playOnce);
 			_curBit = 0;
 
-			if (_vm->_graphics->_dispBitMap->_flags & BITMAPF_VIDEO)
+			if (_vm->_graphics->_dispBitMap._flags & BITMAPF_VIDEO)
 				_vm->_graphics->screenUpdate();
 
 			return; /* done with the next frame. */
@@ -478,13 +478,13 @@ void Anim::diffNextFrame() {
 			break;
 
 		case 20L:
-			unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, false);
+			unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap._planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, false);
 			_curBit++;
 			_diffFile += _size;
 			break;
 
 		case 21L:
-			unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, true);
+			unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap._planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, true);
 			_curBit++;
 			_diffFile += _size;
 			break;
@@ -525,7 +525,7 @@ void Anim::diffNextFrame() {
 						_vm->_music->updateMusic();
 						_vm->waitTOF();
 
-						if (_vm->_graphics->_dispBitMap->_flags & BITMAPF_VIDEO)
+						if (_vm->_graphics->_dispBitMap._flags & BITMAPF_VIDEO)
 							didTOF = true;
 					}
 				}
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 9555104..9dd2307 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -55,8 +55,6 @@ DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) {
 	_screenWidth = 0;
 	_screenHeight = 0;
 
-	_dispBitMap = &bit1;
-
 	for (int i = 0; i < 256 * 3; i++)
 		_curvgapal[i] = 0;
 }
@@ -139,9 +137,9 @@ void DisplayMan::readPict(const char *filename, bool playOnce) {
 	if (!_vm->_music->_doNotFilestopSoundEffect)
 		_vm->_music->stopSoundEffect();
 
-	_dispBitMap->_bytesPerRow = _screenWidth;
-	_dispBitMap->_rows        = _screenHeight;
-	_dispBitMap->_flags       = BITMAPF_VIDEO;
+	_dispBitMap._bytesPerRow = _screenWidth;
+	_dispBitMap._rows        = _screenHeight;
+	_dispBitMap._flags       = BITMAPF_VIDEO;
 
 	_vm->_anim->readDiff(_curBitmap, playOnce);
 }
@@ -159,14 +157,14 @@ byte *DisplayMan::readPictToMem(const char *filename, uint16 x, uint16 y) {
 	if (!_vm->_music->_doNotFilestopSoundEffect)
 		_vm->_music->stopSoundEffect();
 
-	_dispBitMap->_bytesPerRow = x;
-	_dispBitMap->_rows = y;
-	_dispBitMap->_flags = BITMAPF_NONE;
-	_dispBitMap->_planes[0] = _curBitmap;
-	_dispBitMap->_planes[1] = _dispBitMap->_planes[0] + 0x10000;
-	_dispBitMap->_planes[2] = _dispBitMap->_planes[1] + 0x10000;
-	_dispBitMap->_planes[3] = _dispBitMap->_planes[2] + 0x10000;
-	_dispBitMap->_planes[4] = _dispBitMap->_planes[3] + 0x10000;
+	_dispBitMap._bytesPerRow = x;
+	_dispBitMap._rows = y;
+	_dispBitMap._flags = BITMAPF_NONE;
+	_dispBitMap._planes[0] = _curBitmap;
+	_dispBitMap._planes[1] = _dispBitMap._planes[0] + 0x10000;
+	_dispBitMap._planes[2] = _dispBitMap._planes[1] + 0x10000;
+	_dispBitMap._planes[3] = _dispBitMap._planes[2] + 0x10000;
+	_dispBitMap._planes[4] = _dispBitMap._planes[3] + 0x10000;
 
 	_vm->_anim->readDiff(_curBitmap, true);
 
diff --git a/engines/lab/graphics.h b/engines/lab/graphics.h
index 9011b22..9975cf3 100644
--- a/engines/lab/graphics.h
+++ b/engines/lab/graphics.h
@@ -164,8 +164,7 @@ public:
 	byte *_currentDisplayBuffer;
 	bool _doNotDrawMessage;
 	uint16 *FadePalette;
-	BitMap bit1;
-	BitMap *_dispBitMap;
+	BitMap _dispBitMap;
 };
 
 } // End of namespace Lab


Commit: 5bc48cbbddc47ba3d1893776178c19bd33dbee4c
    https://github.com/scummvm/scummvm/commit/5bc48cbbddc47ba3d1893776178c19bd33dbee4c
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:54+01:00

Commit Message:
LAB: Move utility functions to a separate class

Changed paths:
  A engines/lab/utils.cpp
  A engines/lab/utils.h
    engines/lab/anim.cpp
    engines/lab/anim.h
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/graphics.h
    engines/lab/interface.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/module.mk
    engines/lab/processroom.cpp
    engines/lab/special.cpp
    engines/lab/tilepuzzle.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 6e12e92..777a09e 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -69,317 +69,12 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 	_doBlack = false;
 	_diffWidth = 0;
 	_diffHeight = 0;
-	_dataBytesPerRow = 0;
 	DrawBitMap = &_vm->_graphics->_dispBitMap;
 
 	for (int i = 0; i < 3 * 256; i++)
 		_diffPalette[i] = 0;
 }
 
-/*------------------------ unDiff Horizontal Memory -------------------------*/
-
-/*****************************************************************************/
-/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
-/* is also a byte.                                                           */
-/*****************************************************************************/
-void Anim::unDiffByteByte(byte *dest, byte *diff) {
-	uint16 skip, copy;
-
-	while (1) {
-		skip = *diff;
-		diff++;
-		copy = *diff;
-		diff++;
-
-		if (skip == 255) {
-			if (copy == 0) {
-				skip = READ_LE_UINT16(diff);
-				diff += 2;
-				copy = READ_LE_UINT16(diff);
-				diff += 2;
-			} else if (copy == 255)
-				return;
-		}
-
-		dest += skip;
-		memcpy(dest, diff, copy);
-		dest += copy;
-		diff += copy;
-	}
-}
-
-/*****************************************************************************/
-/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
-/* is a word.                                                                */
-/*****************************************************************************/
-void Anim::unDiffByteWord(uint16 *dest, uint16 *diff) {
-	uint16 skip, copy;
-
-	while (1) {
-		skip = ((byte *)diff)[0];
-		copy = ((byte *)diff)[1];
-
-		diff++;
-
-		if (skip == 255) {
-			if (copy == 0) {
-				skip = READ_LE_UINT16(diff);
-				diff++;
-				copy = READ_LE_UINT16(diff);
-				diff++;
-			} else if (copy == 255)
-				return;
-		}
-
-		dest += skip;
-
-		while (copy > 3) {
-			*dest = READ_LE_UINT16(diff);
-			dest++;
-			diff++;
-
-			*dest = READ_LE_UINT16(diff);
-			dest++;
-			diff++;
-
-			*dest = READ_LE_UINT16(diff);
-			dest++;
-			diff++;
-
-			*dest = READ_LE_UINT16(diff);
-			dest++;
-			diff++;
-
-			copy -= 4;
-		}
-
-		while (copy) {
-			*dest = READ_LE_UINT16(diff);
-			dest++;
-			diff++;
-			copy--;
-		}
-	}
-}
-
-/*------------------------- unDiff Vertical Memory --------------------------*/
-
-/*****************************************************************************/
-/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
-/* is a byte.                                                                */
-/*****************************************************************************/
-void Anim::VUnDiffByteByte(byte *dest, byte *diff, uint16 bytesPerRow) {
-	byte *curPtr;
-	uint16 skip, copy;
-	uint16 counter = 0;
-
-
-	while (counter < _dataBytesPerRow) {
-		curPtr = dest + counter;
-
-		for (;;) {
-			skip = *diff;
-			diff++;
-			copy = *diff;
-			diff++;
-
-			if (skip == 255) {
-				counter += copy;
-				break;
-			}
-
-			else {
-				curPtr += (skip * bytesPerRow);
-
-				while (copy) {
-					copy--;
-					*curPtr = *diff;
-					curPtr += bytesPerRow;
-					diff++;
-				}
-			}
-		}
-	}
-}
-
-/*****************************************************************************/
-/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
-/* is a word.                                                                */
-/*****************************************************************************/
-void Anim::VUnDiffByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow) {
-	uint16 *curPtr;
-	uint16 skip, copy;
-	uint16 counter = 0;
-
-	uint16 wordsPerRow = bytesPerRow / 2;
-
-	while (counter < (_dataBytesPerRow >> 1)) {
-		curPtr = dest + counter;
-
-		for (;;) {
-			skip = ((byte *)diff)[0];
-			copy = ((byte *)diff)[1];
-
-			diff++;
-
-
-			if (skip == 255) {
-				counter += copy;
-				break;
-			}
-
-			else {
-				curPtr += (skip * wordsPerRow);
-
-				while (copy) {
-					*curPtr = *diff; //swapUShort(*diff);
-					curPtr += wordsPerRow;
-					diff++;
-					copy--;
-				}
-			}
-		}
-	}
-}
-
-/*****************************************************************************/
-/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
-/* is a long.                                                                */
-/*****************************************************************************/
-void Anim::VUnDiffByteLong(uint32 *dest, uint32 *diff, uint16 bytesPerRow) {
-	uint32 *_curPtr;
-	uint16 skip, copy;
-
-	uint16 counter = 0;
-	byte *diff1 = (byte *)diff;
-
-	uint16 longsperrow = bytesPerRow / 4;
-
-	while (counter < (_dataBytesPerRow >> 2)) {
-		_curPtr = dest + counter;
-
-		for (;;) {
-			skip = *diff1;
-			diff1++;
-
-			copy = *diff1;
-			diff1++;
-
-
-			if (skip == 255) {
-				counter += copy;
-				break;
-			}
-
-			else {
-				_curPtr += (skip * longsperrow);
-
-				while (copy) {
-					*_curPtr = *(uint32 *)diff1; //swapULong(*diff);
-					_curPtr += longsperrow;
-					diff1 += 4;
-					copy--;
-				}
-			}
-		}
-	}
-}
-
-/*****************************************************************************/
-/* Runlength decodes a chunk of memory.                                      */
-/*****************************************************************************/
-void Anim::runLengthDecode(byte *dest, byte *source) {
-	int8 num;
-	int16 count;
-
-	while (1) {
-		num = (int8)*source;
-		source++;
-
-		if (num == 127) {
-			return;
-		} else if (num > '\0') {
-			memcpy(dest, source, num);
-			source += num;
-			dest   += num;
-		} else {
-			count = (int16)(-num);
-			num   = *source;
-			source++;
-
-			while (count) {
-				*dest = num;
-				dest++;
-				count--;
-			}
-		}
-	}
-}
-
-/*****************************************************************************/
-/* Does a vertical run length decode.                                        */
-/*****************************************************************************/
-void Anim::VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow) {
-	int8 num;
-	int16 count;
-	byte *top = dest;
-
-	for (uint16 i = 0; i < _dataBytesPerRow; i++) {
-		dest = top;
-		dest += i;
-
-		num = (int8)*source;
-		source++;
-
-		while (num != 127) {
-			if (num > '\0') {
-				while (num) {
-					*dest = *source;
-					source++;
-					dest += bytesPerRow;
-					num--;
-				}
-			} else {
-				count = (int16)(-num);
-				num   = (int8)*source;
-				source++;
-
-				while (count) {
-					*dest = num;
-					dest += bytesPerRow;
-					count--;
-				}
-			}
-
-			num = *source;
-			source++;
-		}
-	}
-}
-
-/*****************************************************************************/
-/* Does the undiffing between the bitmaps.                                   */
-/*****************************************************************************/
-void Anim::unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesPerRow, bool isV) {
-	diffData++;
-	byte bufType = *diffData;
-	diffData++;
-
-	if (isV) {
-		if (bufType == 0)
-			VUnDiffByteByte(newBuf, diffData, bytesPerRow);
-		else if (bufType == 1)
-			VUnDiffByteWord((uint16 *)newBuf, (uint16 *)diffData, bytesPerRow);
-		else if (bufType == 3)
-			VUnDiffByteLong((uint32 *)newBuf, (uint32 *)diffData, bytesPerRow);
-	} else {
-		if (bufType == 0)
-			unDiffByteByte(newBuf, diffData);
-		else if (bufType == 1)
-			unDiffByteWord((uint16 *)newBuf, (uint16 *)diffData);
-	}
-}
-
 void Anim::readBlock(void *Buffer, uint32 Size, byte **File) {
 	memcpy(Buffer, *File, (size_t)Size);
 	(*File) += Size;
@@ -465,26 +160,26 @@ void Anim::diffNextFrame() {
 
 		case 11L:
 			_diffFile += 4;
-			runLengthDecode(DrawBitMap->_planes[_curBit], _diffFile);
+			_vm->_utils->runLengthDecode(DrawBitMap->_planes[_curBit], _diffFile);
 			_curBit++;
 			_diffFile += _size - 4;
 			break;
 
 		case 12L:
 			_diffFile += 4;
-			VRunLengthDecode(DrawBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow);
+			_vm->_utils->VRunLengthDecode(DrawBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow);
 			_curBit++;
 			_diffFile += _size - 4;
 			break;
 
 		case 20L:
-			unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap._planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, false);
+			_vm->_utils->unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap._planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, false);
 			_curBit++;
 			_diffFile += _size;
 			break;
 
 		case 21L:
-			unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap._planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, true);
+			_vm->_utils->unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap._planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, true);
 			_curBit++;
 			_diffFile += _size;
 			break;
@@ -615,7 +310,7 @@ void Anim::playDiff(byte *buffer) {
 		_continuous = CONTINUOUS & _headerdata._flags;
 		_diffWidth = _headerdata._width;
 		_diffHeight = _headerdata._height;
-		_dataBytesPerRow = _diffWidth;
+		_vm->_utils->setBytesPerRow(_diffWidth);
 
 		_numChunks = (((int32) _diffWidth) * _diffHeight) / 0x10000;
 
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 28927ba..121edea 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -83,16 +83,8 @@ private:
 	uint16 _sampleSpeed;
 	uint32 _diffWidth;
 	uint32 _diffHeight;
-	uint16 _dataBytesPerRow;
 	BitMap *DrawBitMap;
 
-	void runLengthDecode(byte *dest, byte *source);
-	void VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow);
-	void unDiffByteByte(byte *dest, byte *diff);
-	void unDiffByteWord(uint16 *dest, uint16 *diff);
-	void VUnDiffByteByte(byte *Dest, byte *diff, uint16 bytesperrow);
-	void VUnDiffByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow);
-	void VUnDiffByteLong(uint32 *Dest, uint32 *diff, uint16 bytesperrow);
 	void readBlock(void *Buffer, uint32 Size, byte **File);
 	void playDiff(byte *buffer);
 
@@ -107,7 +99,6 @@ public:
 	bool _noPalChange;   /* Don't change the palette.            */
 	BitMap _rawDiffBM;
 
-	void unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesperrow, bool isV);
 	bool readDiff(byte *buffer, bool playOnce);
 	void diffNextFrame();
 	void stopDiff();
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index ee61e2f..07c49d5 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -941,7 +941,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 					_curFileName = _newFileName;
 				else if (doActionRule(curPos, TAKE - 1, 0, &_cptr))
 					_curFileName = _newFileName;
-				else if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2)))
+				else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 					drawStaticMessage(kTextNothing);
 			} else if ((actionMode == 1) /* Manipulate an object */  ||
 			         (actionMode == 2) /* Open up a "door" */      ||
@@ -949,7 +949,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				if (doActionRule(curPos, actionMode, _roomNum, &_cptr))
 					_curFileName = _newFileName;
 				else if (!doActionRule(curPos, actionMode, 0, &_cptr)) {
-					if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2)))
+					if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 						drawStaticMessage(kTextNothing);
 				}
 			} else if (actionMode == 4) { /* Look at closeups */
@@ -957,15 +957,15 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				setCurClose(curPos, &tempcptr);
 
 				if (_cptr == tempcptr) {
-					if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2)))
+					if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 						drawStaticMessage(kTextNothing);
 				} else if (tempcptr->_graphicName) {
 					if (*(tempcptr->_graphicName)) {
 						_anim->_doBlack = true;
 						_cptr = tempcptr;
-					} else if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2)))
+					} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 						drawStaticMessage(kTextNothing);
-				} else if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2)))
+				} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 					drawStaticMessage(kTextNothing);
 			} else if ((actionMode == 5)  &&
 			         _conditions->in(curInv)) { /* Use an item on something else */
@@ -974,7 +974,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 					if (!_conditions->in(curInv))
 						decIncInv(&curInv, false);
-				} else if (curPos.y < (_graphics->VGAScaleY(149) + _graphics->SVGACord(2)))
+				} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 					drawStaticMessage(kTextNothing);
 			}
 		}
@@ -1008,7 +1008,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 		}
 
 		if (hcptr)
-			_event->setMousePos(Common::Point(_graphics->scaleX((hcptr->x1 + hcptr->x2) / 2), _graphics->scaleY((hcptr->y1 + hcptr->y2) / 2)));
+			_event->setMousePos(Common::Point(_utils->scaleX((hcptr->x1 + hcptr->x2) / 2), _utils->scaleY((hcptr->y1 + hcptr->y2) / 2)));
 	} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) {
 		eatMessages();
 		_alternate = !_alternate;
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 9dd2307..97ec7cc 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -63,55 +63,6 @@ DisplayMan::~DisplayMan() {
 	freePict();
 }
 
-/*****************************************************************************/
-/* Scales the x co-ordinates to that of the new display.  In the room parser */
-/* file, co-ordinates are set up on a 360x336 display.                       */
-/*****************************************************************************/
-uint16 DisplayMan::scaleX(uint16 x) {
-	if (_vm->_isHiRes)
-		return (uint16)((x * 16) / 9);
-	else
-		return (uint16)((x * 8) / 9);
-}
-
-/*****************************************************************************/
-/* Scales the y co-ordinates to that of the new display.  In the room parser */
-/* file, co-ordinates are set up on a 368x336 display.                       */
-/*****************************************************************************/
-uint16 DisplayMan::scaleY(uint16 y) {
-	if (_vm->_isHiRes)
-		return (y + (y / 14));
-	else
-		return ((y * 10) / 24);
-}
-
-/*****************************************************************************/
-/* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
-/*****************************************************************************/
-int16 DisplayMan::VGAScaleX(int16 x) {
-	if (_vm->_isHiRes)
-		return (x * 2);
-	else
-		return x;
-}
-
-/*****************************************************************************/
-/* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
-/*****************************************************************************/
-int16 DisplayMan::VGAScaleY(int16 y) {
-	if (_vm->_isHiRes)
-		return ((y * 12) / 5);
-	else
-		return y;
-}
-
-uint16 DisplayMan::SVGACord(uint16 cord) {
-	if (_vm->_isHiRes)
-		return cord;
-	else
-		return 0;
-}
-
 /*---------------------------------------------------------------------------*/
 /*------ From readPict.c.  Reads in pictures and animations from disk. ------*/
 /*---------------------------------------------------------------------------*/
@@ -305,16 +256,18 @@ uint32 DisplayMan::flowText(void *font,      /* the TextAttr pointer */
 }
 
 uint32 DisplayMan::flowTextScaled(void *font,      /* the TextAttr pointer */
-	int16 spacing,          /* How much vertical spacing between the lines */
-	byte pencolor,         /* pen number to use for text */
-	byte backpen,          /* the background color */
-	bool fillback,                /* Whether to fill the background */
-	bool centerh,                 /* Whether to center the text horizontally */
-	bool centerv,                 /* Whether to center the text vertically */
+	int16 spacing,                /* How much vertical spacing between the lines */
+	byte penColor,                /* pen number to use for text */
+	byte backPen,                 /* the background color */
+	bool fillBack,                /* Whether to fill the background */
+	bool centerX,                 /* Whether to center the text horizontally */
+	bool centerY,                 /* Whether to center the text vertically */
 	bool output,                  /* Whether to output any text */
-	uint16 x1,               /* Cords */
-	uint16 y1, uint16 x2, uint16 y2, const char *str) {
-	return flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, VGAScaleX(x1), VGAScaleY(y1), VGAScaleX(x2), VGAScaleY(y2), str);
+	uint16 x1, uint16 y1,         /* Cords */
+	uint16 x2, uint16 y2, const char *str) {
+	return flowText(font, spacing, penColor, backPen, fillBack, centerX, centerY, output,
+					_vm->_utils->vgaScaleX(x1), _vm->_utils->vgaScaleY(y1),
+					_vm->_utils->vgaScaleX(x2), _vm->_utils->vgaScaleY(y2), str);
 }
 
 /******************************************************************************/
@@ -351,10 +304,10 @@ void DisplayMan::createBox(uint16 y2) {
 	rectFillScaled(4, 154, 315, y2 - 2);
 
 	setAPen(0);                 /* Box around message area */
-	drawHLine(VGAScaleX(2), VGAScaleY(152), VGAScaleX(317));
-	drawVLine(VGAScaleX(317), VGAScaleY(152), VGAScaleY(y2));
-	drawHLine(VGAScaleX(2), VGAScaleY(y2), VGAScaleX(317));
-	drawVLine(VGAScaleX(2), VGAScaleY(152), VGAScaleY(y2));
+	drawHLine(_vm->_utils->vgaScaleX(2), _vm->_utils->vgaScaleY(152), _vm->_utils->vgaScaleX(317));
+	drawVLine(_vm->_utils->vgaScaleX(317), _vm->_utils->vgaScaleY(152), _vm->_utils->vgaScaleY(y2));
+	drawHLine(_vm->_utils->vgaScaleX(2), _vm->_utils->vgaScaleY(y2), _vm->_utils->vgaScaleX(317));
+	drawVLine(_vm->_utils->vgaScaleX(2), _vm->_utils->vgaScaleY(152), _vm->_utils->vgaScaleY(y2));
 }
 
 int32 DisplayMan::longDrawMessage(const char *str) {
@@ -370,7 +323,7 @@ int32 DisplayMan::longDrawMessage(const char *str) {
 	if (!_longWinInFront) {
 		_longWinInFront = true;
 		setAPen(3);                 /* Clear Area */
-		rectFill(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319), VGAScaleY(199));
+		rectFill(0, _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319), _vm->_utils->vgaScaleY(199));
 	}
 
 	createBox(198);
@@ -389,7 +342,7 @@ void DisplayMan::drawMessage(const char *str) {
 	}
 
 	if (str) {
-		if ((textLength(_vm->_msgFont, str, strlen(str)) > VGAScaleX(306))) {
+		if ((textLength(_vm->_msgFont, str, strlen(str)) > _vm->_utils->vgaScaleX(306))) {
 			longDrawMessage(str);
 			_lastMessageLong = true;
 		} else {
@@ -400,7 +353,7 @@ void DisplayMan::drawMessage(const char *str) {
 
 			_vm->_event->mouseHide();
 			createBox(168);
-			text(_vm->_msgFont, VGAScaleX(7), VGAScaleY(155) + SVGACord(2), 1, str, strlen(str));
+			text(_vm->_msgFont, _vm->_utils->vgaScaleX(7), _vm->_utils->vgaScaleY(155) + _vm->_utils->svgaCord(2), 1, str, strlen(str));
 			_vm->_event->mouseShow();
 			_lastMessageLong = false;
 		}
@@ -415,8 +368,8 @@ void DisplayMan::doScrollBlack() {
 	Image im;
 	uint32 size, copysize;
 	byte *baseAddr;
-	uint16 width = VGAScaleX(320);
-	uint16 height = VGAScaleY(149) + SVGACord(2);
+	uint16 width = _vm->_utils->vgaScaleX(320);
+	uint16 height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
 	byte *mem = new byte[width * height];
 
 	_vm->_event->mouseHide();
@@ -430,7 +383,7 @@ void DisplayMan::doScrollBlack() {
 
 	baseAddr = getCurrentDrawingBuffer();
 
-	uint16 by      = VGAScaleX(4);
+	uint16 by = _vm->_utils->vgaScaleX(4);
 	uint16 nheight = height;
 
 	while (nheight) {
@@ -512,8 +465,8 @@ void DisplayMan::doScrollWipe(char *filename) {
 	uint16 startline = 0, onrow = 0;
 
 	_vm->_event->mouseHide();
-	uint16 width = VGAScaleX(320);
-	uint16 height = VGAScaleY(149) + SVGACord(2);
+	uint16 width = _vm->_utils->vgaScaleX(320);
+	uint16 height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
 
 	while (_vm->_music->isSoundEffectActive()) {
 		_vm->_music->updateMusic();
@@ -527,7 +480,7 @@ void DisplayMan::doScrollWipe(char *filename) {
 	byte *mem = _vm->_anim->_rawDiffBM._planes[0];
 
 	_vm->_music->updateMusic();
-	uint16 by = VGAScaleX(3);
+	uint16 by = _vm->_utils->vgaScaleX(3);
 	uint16 nheight = height;
 
 	while (onrow < _vm->_anim->_headerdata._height) {
@@ -552,11 +505,11 @@ void DisplayMan::doScrollWipe(char *filename) {
 		onrow += by;
 
 		if (nheight <= (height / 4))
-			by = VGAScaleX(5);
+			by = _vm->_utils->vgaScaleX(5);
 		else if (nheight <= (height / 3))
-			by = VGAScaleX(4);
+			by = _vm->_utils->vgaScaleX(4);
 		else if (nheight <= (height / 2))
-			by = VGAScaleX(3);
+			by = _vm->_utils->vgaScaleX(3);
 	}
 
 	_vm->_event->mouseShow();
@@ -580,8 +533,8 @@ void DisplayMan::doScrollBounce() {
 	}
 
 	_vm->_event->mouseHide();
-	int width = VGAScaleX(320);
-	int height = VGAScaleY(149) + SVGACord(2);
+	int width = _vm->_utils->vgaScaleX(320);
+	int height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
 	byte *mem = _vm->_anim->_rawDiffBM._planes[0];
 
 	_vm->_music->updateMusic();
@@ -787,44 +740,44 @@ void DisplayMan::drawPanel() {
 	_vm->_event->mouseHide();
 
 	setAPen(3);                 /* Clear Area */
-	rectFill(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319), VGAScaleY(199));
+	rectFill(0, _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319), _vm->_utils->vgaScaleY(199));
 
 	setAPen(0);                 /* First Line */
-	drawHLine(0, VGAScaleY(149) + SVGACord(2), VGAScaleX(319));
+	drawHLine(0, _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319));
 	setAPen(5);                 /* Second Line */
-	drawHLine(0, VGAScaleY(149) + 1 + SVGACord(2), VGAScaleX(319));
+	drawHLine(0, _vm->_utils->vgaScaleY(149) + 1 + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319));
 
 	/* Gadget Separators */
 	setAPen(0);
-	drawHLine(0, VGAScaleY(170), VGAScaleX(319));     /* First black line to separate buttons */
+	drawHLine(0, _vm->_utils->vgaScaleY(170), _vm->_utils->vgaScaleX(319));     /* First black line to separate buttons */
 
 	if (!_vm->_alternate) {
 		setAPen(4);
-		drawHLine(0, VGAScaleY(170) + 1, VGAScaleX(319)); /* The horizontal lines under the black one */
+		drawHLine(0, _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(319)); /* The horizontal lines under the black one */
 		drawGadgetList(&_vm->_moveGadgetList);
 	} else {
 		if (_vm->getPlatform() != Common::kPlatformWindows) {
-			drawVLine(VGAScaleX(124), VGAScaleY(170) + 1, VGAScaleY(199)); /* Vertical Black lines */
-			drawVLine(VGAScaleX(194), VGAScaleY(170) + 1, VGAScaleY(199));
+			drawVLine(_vm->_utils->vgaScaleX(124), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199)); /* Vertical Black lines */
+			drawVLine(_vm->_utils->vgaScaleX(194), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));
 		} else {
-			drawVLine(VGAScaleX(90), VGAScaleY(170) + 1, VGAScaleY(199));  /* Vertical Black lines */
-			drawVLine(VGAScaleX(160), VGAScaleY(170) + 1, VGAScaleY(199));
-			drawVLine(VGAScaleX(230), VGAScaleY(170) + 1, VGAScaleY(199));
+			drawVLine(_vm->_utils->vgaScaleX(90), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));  /* Vertical Black lines */
+			drawVLine(_vm->_utils->vgaScaleX(160), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));
+			drawVLine(_vm->_utils->vgaScaleX(230), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));
 		}
 
 		setAPen(4);
-		drawHLine(0, VGAScaleY(170) + 1, VGAScaleX(122));   /* The horizontal lines under the black one */
-		drawHLine(VGAScaleX(126), VGAScaleY(170) + 1, VGAScaleX(192));
-		drawHLine(VGAScaleX(196), VGAScaleY(170) + 1, VGAScaleX(319));
+		drawHLine(0, _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(122));   /* The horizontal lines under the black one */
+		drawHLine(_vm->_utils->vgaScaleX(126), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(192));
+		drawHLine(_vm->_utils->vgaScaleX(196), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(319));
+		drawVLine(_vm->_utils->vgaScaleX(1), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198)); /* The vertical high light lines */
 
-		drawVLine(VGAScaleX(1), VGAScaleY(170) + 2, VGAScaleY(198)); /* The vertical high light lines */
 		if (_vm->getPlatform() != Common::kPlatformWindows) {
-			drawVLine(VGAScaleX(126), VGAScaleY(170) + 2, VGAScaleY(198));
-			drawVLine(VGAScaleX(196), VGAScaleY(170) + 2, VGAScaleY(198));
+			drawVLine(_vm->_utils->vgaScaleX(126), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
+			drawVLine(_vm->_utils->vgaScaleX(196), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
 		} else {
-			drawVLine(VGAScaleX(92), VGAScaleY(170) + 2, VGAScaleY(198));
-			drawVLine(VGAScaleX(162), VGAScaleY(170) + 2, VGAScaleY(198));
-			drawVLine(VGAScaleX(232), VGAScaleY(170) + 2, VGAScaleY(198));
+			drawVLine(_vm->_utils->vgaScaleX(92), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
+			drawVLine(_vm->_utils->vgaScaleX(162), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
+			drawVLine(_vm->_utils->vgaScaleX(232), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
 		}
 
 		drawGadgetList(&_vm->_invGadgetList);
@@ -846,16 +799,16 @@ bool DisplayMan::setUpScreens() {
 	delete controlFile;
 
 	/* Creates the gadgets for the movement control panel */
-	uint16 y = VGAScaleY(173) - SVGACord(2);
+	uint16 y = _vm->_utils->vgaScaleY(173) - _vm->_utils->svgaCord(2);
 
 	// The key mapping was only set for the Windows version.
 	// It's very convenient to have those shortcut, so I added them
 	// for all versions. (Strangerke)
-	_vm->_moveGadgetList.push_back(createButton(  1, y, 0,          't',  _vm->_moveImages[0],  _vm->_moveImages[1]));
-	_vm->_moveGadgetList.push_back(createButton( 33, y, 1,          'm',  _vm->_moveImages[2],  _vm->_moveImages[3]));
-	_vm->_moveGadgetList.push_back(createButton( 65, y, 2,          'o',  _vm->_moveImages[4],  _vm->_moveImages[5]));
-	_vm->_moveGadgetList.push_back(createButton( 97, y, 3,          'c',  _vm->_moveImages[6],  _vm->_moveImages[7]));
-	_vm->_moveGadgetList.push_back(createButton(129, y, 4,          'l',  _vm->_moveImages[8],  _vm->_moveImages[9]));
+	_vm->_moveGadgetList.push_back(createButton(  1, y, 0,          't', _vm->_moveImages[0],  _vm->_moveImages[1]));
+	_vm->_moveGadgetList.push_back(createButton( 33, y, 1,          'm', _vm->_moveImages[2],  _vm->_moveImages[3]));
+	_vm->_moveGadgetList.push_back(createButton( 65, y, 2,          'o', _vm->_moveImages[4],  _vm->_moveImages[5]));
+	_vm->_moveGadgetList.push_back(createButton( 97, y, 3,          'c', _vm->_moveImages[6],  _vm->_moveImages[7]));
+	_vm->_moveGadgetList.push_back(createButton(129, y, 4,          'l', _vm->_moveImages[8],  _vm->_moveImages[9]));
 	_vm->_moveGadgetList.push_back(createButton(161, y, 5,          'i', _vm->_moveImages[12], _vm->_moveImages[13]));
 	_vm->_moveGadgetList.push_back(createButton(193, y, 6, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]));
 	_vm->_moveGadgetList.push_back(createButton(225, y, 7, VKEY_UPARROW, _vm->_moveImages[16], _vm->_moveImages[17]));
@@ -870,10 +823,10 @@ bool DisplayMan::setUpScreens() {
 		for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++)
 			_vm->_invImages[imgIdx] = new Image(invFile);
 	}
-	_vm->_invGadgetList.push_back(createButton( 24, y, 0,          'm',   _vm->_invImages[0],   _vm->_invImages[1]));
-	_vm->_invGadgetList.push_back(createButton( 56, y, 1,          'g',   _vm->_invImages[2],   _vm->_invImages[3]));
-	_vm->_invGadgetList.push_back(createButton( 94, y, 2,          'u',   _vm->_invImages[4],   _vm->_invImages[5]));
-	_vm->_invGadgetList.push_back(createButton(126, y, 3,          'l',  _vm->_moveImages[8],  _vm->_moveImages[9]));
+	_vm->_invGadgetList.push_back(createButton( 24, y, 0,          'm', _vm->_invImages[0],   _vm->_invImages[1]));
+	_vm->_invGadgetList.push_back(createButton( 56, y, 1,          'g', _vm->_invImages[2],   _vm->_invImages[3]));
+	_vm->_invGadgetList.push_back(createButton( 94, y, 2,          'u', _vm->_invImages[4],   _vm->_invImages[5]));
+	_vm->_invGadgetList.push_back(createButton(126, y, 3,          'l', _vm->_moveImages[8],  _vm->_moveImages[9]));
 	_vm->_invGadgetList.push_back(createButton(164, y, 4, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]));
 	_vm->_invGadgetList.push_back(createButton(196, y, 5, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]));
 
@@ -926,7 +879,7 @@ void DisplayMan::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 }
 
 void DisplayMan::rectFillScaled(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	rectFill(VGAScaleX(x1), VGAScaleY(y1), VGAScaleX(x2), VGAScaleY(y2));
+	rectFill(_vm->_utils->vgaScaleX(x1), _vm->_utils->vgaScaleY(y1), _vm->_utils->vgaScaleX(x2), _vm->_utils->vgaScaleY(y2));
 }
 
 /*****************************************************************************/
diff --git a/engines/lab/graphics.h b/engines/lab/graphics.h
index 9975cf3..1bfc027 100644
--- a/engines/lab/graphics.h
+++ b/engines/lab/graphics.h
@@ -73,11 +73,6 @@ public:
 	DisplayMan(LabEngine *lab);
 	virtual ~DisplayMan();
 
-	uint16 scaleX(uint16 x);
-	uint16 scaleY(uint16 y);
-	int16 VGAScaleX(int16 x);
-	int16 VGAScaleY(int16 y);
-	uint16 SVGACord(uint16 cord);
 	void loadPict(const char *filename);
 	void readPict(const char *filename, bool playOnce);
 	void freePict();
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 9ab570a..6aba151 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -43,7 +43,7 @@ Common::KeyState _keyPressed;
 Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt) {
 	Gadget *gptr;
 
-	x = g_lab->_graphics->VGAScaleX(x);
+	x = g_lab->_utils->vgaScaleX(x);
 
 	if ((gptr = new Gadget())) {
 		gptr->x = x;
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index ec81fdf..d1de3e1 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -87,6 +87,7 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_anim = nullptr;
 	_graphics = nullptr;
 	_rooms = nullptr;
+	_utils = nullptr;
 
 	_lastTooLong = false;
 	_interfaceOff = false;
@@ -130,6 +131,7 @@ LabEngine::~LabEngine() {
 	delete _anim;
 	delete _graphics;
 	delete[] _rooms;
+	delete _utils;
 
 	for (int i = 0; i < 16; i++)
 		delete _tiles[i];
@@ -146,6 +148,7 @@ Common::Error LabEngine::run() {
 	_music = new Music(this);
 	_graphics = new DisplayMan(this);
 	_anim = new Anim(this);
+	_utils = new Utils(this);
 
 	if (getPlatform() == Common::kPlatformWindows) {
 		// Check if this is the Wyrmkeep trial
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 656406d..44104fc 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -43,6 +43,7 @@
 #include "lab/anim.h"
 #include "lab/graphics.h"
 #include "lab/labsets.h"
+#include "lab/utils.h"
 
 struct ADGameDescription;
 
@@ -103,6 +104,7 @@ public:
 	Anim *_anim;
 	DisplayMan *_graphics;
 	RoomData *_rooms;
+	Utils *_utils;
 
 	int _roomNum;
 	CrumbData _breadCrumbs[MAX_CRUMBS];
@@ -179,8 +181,6 @@ private:
 	void mayShowCrumbIndicator();
 	void mayShowCrumbIndicatorOff();
 	const char *getInvName(uint16 curInv);
-	int VGAUnScaleX(int x);
-	int VGAUnScaleY(int y);
 	void mouseTile(Common::Point pos);
 	void changeTile(uint16 col, uint16 row);
 	void mouseCombination(Common::Point pos);
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index b7006a3..4136b28 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -124,8 +124,8 @@ static bool loadMapData() {
 	counter = 0;
 
 	for (GadgetList::iterator gadget = MapGadgetList->begin(); gadget != MapGadgetList->end(); ++gadget) {
-		(*gadget)->x = g_lab->_graphics->VGAScaleX(MapGadX[counter]);
-		(*gadget)->y = g_lab->_graphics->VGAScaleY(MapGadY[counter]);
+		(*gadget)->x = g_lab->_utils->vgaScaleX(MapGadX[counter]);
+		(*gadget)->y = g_lab->_utils->vgaScaleY(MapGadY[counter]);
 		counter++;
 	}
 
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index 5c0aed5..fccc438 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -18,7 +18,8 @@ MODULE_OBJS := \
 	savegame.o \
 	special.o \
 	tilepuzzle.o \
-	timing.o
+	timing.o \
+	utils.o
 
 # This module can be built as a plugin
 ifeq ($(ENABLE_LAB), DYNAMIC_PLUGIN)
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 0b43966..b033c69 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -105,8 +105,8 @@ static CloseData *getObject(uint16 x, uint16 y, CloseDataPtr lcptr) {
 	}
 
 	while (lcptr != NULL) {
-		if ((x >= g_lab->_graphics->scaleX(lcptr->x1)) && (y >= g_lab->_graphics->scaleY(lcptr->y1)) &&
-		        (x <= g_lab->_graphics->scaleX(lcptr->x2)) && (y <= g_lab->_graphics->scaleY(lcptr->y2)))
+		if ((x >= g_lab->_utils->scaleX(lcptr->x1)) && (y >= g_lab->_utils->scaleY(lcptr->y1)) &&
+		        (x <= g_lab->_utils->scaleX(lcptr->x2)) && (y <= g_lab->_utils->scaleY(lcptr->y2)))
 			return lcptr;
 
 		lcptr = lcptr->_nextCloseUp;
@@ -248,10 +248,10 @@ void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords)
 			x2 = lcptr->x2;
 			y2 = lcptr->y2;
 		} else {
-			x1 = g_lab->_graphics->scaleX(lcptr->x1);
-			y1 = g_lab->_graphics->scaleY(lcptr->y1);
-			x2 = g_lab->_graphics->scaleX(lcptr->x2);
-			y2 = g_lab->_graphics->scaleY(lcptr->y2);
+			x1 = g_lab->_utils->scaleX(lcptr->x1);
+			y1 = g_lab->_utils->scaleY(lcptr->y1);
+			x2 = g_lab->_utils->scaleX(lcptr->x2);
+			y2 = g_lab->_utils->scaleY(lcptr->y2);
 		}
 
 		if (pos.x >= x1 && pos.y >= y1 && pos.x <= x2 && pos.y <= y2 && lcptr->_graphicName) {
@@ -279,8 +279,8 @@ bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
 
 
 	while (lcptr != NULL) {
-		if ((x >= g_lab->_graphics->scaleX(lcptr->x1)) && (y >= g_lab->_graphics->scaleY(lcptr->y1)) &&
-		        (x <= g_lab->_graphics->scaleX(lcptr->x2)) && (y <= g_lab->_graphics->scaleY(lcptr->y2)) &&
+		if ((x >= g_lab->_utils->scaleX(lcptr->x1)) && (y >= g_lab->_utils->scaleY(lcptr->y1)) &&
+		        (x <= g_lab->_utils->scaleX(lcptr->x2)) && (y <= g_lab->_utils->scaleY(lcptr->y2)) &&
 		        (lcptr->_closeUpType < 0)) {
 			g_lab->_conditions->inclElement(abs(lcptr->_closeUpType));
 			return true;
@@ -410,7 +410,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			break;
 
 		case SETCLOSEUP: {
-				CloseDataPtr tlcptr = getObject(g_lab->_graphics->scaleX(aptr->_param1), g_lab->_graphics->scaleY(aptr->_param2), *lcptr);
+				CloseDataPtr tlcptr = getObject(g_lab->_utils->scaleX(aptr->_param1), g_lab->_utils->scaleY(aptr->_param2), *lcptr);
 
 				if (tlcptr)
 					*lcptr = tlcptr;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index e491196..41fcad7 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -100,7 +100,7 @@ void LabEngine::doNotes() {
 	TextFont *noteFont = g_lab->_resource->getFont("P:Note.fon");
 	char *ntext = g_lab->_resource->getText("Lab:Rooms/Notes");
 
-	g_lab->_graphics->flowText(noteFont, -2 + g_lab->_graphics->SVGACord(1), 0, 0, false, false, true, true, g_lab->_graphics->VGAScaleX(25) + g_lab->_graphics->SVGACord(15), g_lab->_graphics->VGAScaleY(50), g_lab->_graphics->VGAScaleX(295) - g_lab->_graphics->SVGACord(15), g_lab->_graphics->VGAScaleY(148), ntext);
+	g_lab->_graphics->flowText(noteFont, -2 + g_lab->_utils->svgaCord(1), 0, 0, false, false, true, true, g_lab->_utils->vgaScaleX(25) + g_lab->_utils->svgaCord(15), g_lab->_utils->vgaScaleY(50), g_lab->_utils->vgaScaleX(295) - g_lab->_utils->svgaCord(15), g_lab->_utils->vgaScaleY(148), ntext);
 	g_lab->_graphics->setPalette(g_lab->_anim->_diffPalette, 256);
 
 	g_lab->_graphics->closeFont(noteFont);
@@ -120,19 +120,19 @@ void LabEngine::doWestPaper() {
 
 	paperFont = g_lab->_resource->getFont("P:News22.fon");
 	ntext = g_lab->_resource->getText("Lab:Rooms/Date");
-	g_lab->_graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, g_lab->_graphics->VGAScaleX(57), g_lab->_graphics->VGAScaleY(77) + g_lab->_graphics->SVGACord(2), g_lab->_graphics->VGAScaleX(262), g_lab->_graphics->VGAScaleY(91), ntext);
+	g_lab->_graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, g_lab->_utils->vgaScaleX(57), g_lab->_utils->vgaScaleY(77) + g_lab->_utils->svgaCord(2), g_lab->_utils->vgaScaleX(262), g_lab->_utils->vgaScaleY(91), ntext);
 	g_lab->_graphics->closeFont(paperFont);
 	delete[] ntext;
 
 	paperFont = g_lab->_resource->getFont("P:News32.fon");
 	ntext = g_lab->_resource->getText("Lab:Rooms/Headline");
 	FileLen = strlen(ntext) - 1;
-	CharsPrinted = g_lab->_graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, g_lab->_graphics->VGAScaleX(57), g_lab->_graphics->VGAScaleY(86) - g_lab->_graphics->SVGACord(2), g_lab->_graphics->VGAScaleX(262), g_lab->_graphics->VGAScaleY(118), ntext);
+	CharsPrinted = g_lab->_graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, g_lab->_utils->vgaScaleX(57), g_lab->_utils->vgaScaleY(86) - g_lab->_utils->svgaCord(2), g_lab->_utils->vgaScaleX(262), g_lab->_utils->vgaScaleY(118), ntext);
 	if (CharsPrinted < FileLen) {
-		y = 130 - g_lab->_graphics->SVGACord(5);
-		g_lab->_graphics->flowText(paperFont, -8 - g_lab->_graphics->SVGACord(1), 0, 0, false, true, false, true, g_lab->_graphics->VGAScaleX(57), g_lab->_graphics->VGAScaleY(86) - g_lab->_graphics->SVGACord(2), g_lab->_graphics->VGAScaleX(262), g_lab->_graphics->VGAScaleY(132), ntext);
+		y = 130 - g_lab->_utils->svgaCord(5);
+		g_lab->_graphics->flowText(paperFont, -8 - g_lab->_utils->svgaCord(1), 0, 0, false, true, false, true, g_lab->_utils->vgaScaleX(57), g_lab->_utils->vgaScaleY(86) - g_lab->_utils->svgaCord(2), g_lab->_utils->vgaScaleX(262), g_lab->_utils->vgaScaleY(132), ntext);
 	} else
-		y = 115 - g_lab->_graphics->SVGACord(5);
+		y = 115 - g_lab->_utils->svgaCord(5);
 	g_lab->_graphics->closeFont(paperFont);
 	delete[] ntext;
 
@@ -210,12 +210,12 @@ static bool loadJournalData() {
 
 	for (GadgetList::iterator gadgetIter = journalGadgetList.begin(); gadgetIter != journalGadgetList.end(); ++gadgetIter) {
 		Gadget *gadget = *gadgetIter;
-		gadget->x = g_lab->_graphics->VGAScaleX(JGadX[counter]);
+		gadget->x = g_lab->_utils->vgaScaleX(JGadX[counter]);
 
 		if (counter == 1)
-			gadget->y = g_lab->_graphics->VGAScaleY(JGadY[counter]) + g_lab->_graphics->SVGACord(1);
+			gadget->y = g_lab->_utils->vgaScaleY(JGadY[counter]) + g_lab->_utils->svgaCord(1);
 		else
-			gadget->y = g_lab->_graphics->VGAScaleY(JGadY[counter]) - g_lab->_graphics->SVGACord(1);
+			gadget->y = g_lab->_utils->vgaScaleY(JGadY[counter]) - g_lab->_utils->svgaCord(1);
 
 		gadget->_gadgetID = counter;
 		counter++;
@@ -247,16 +247,16 @@ static void drawJournalText() {
 
 	if (JPage <= 1) {
 		CurText = journaltexttitle;
-		g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, true, true, true, g_lab->_graphics->VGAScaleX(52), g_lab->_graphics->VGAScaleY(32), g_lab->_graphics->VGAScaleX(152), g_lab->_graphics->VGAScaleY(148), CurText);
+		g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, true, true, true, g_lab->_utils->vgaScaleX(52), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(152), g_lab->_utils->vgaScaleY(148), CurText);
 	} else {
 		CurText = (char *)(journaltext + CharsDrawn);
-		CharsDrawn += g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_graphics->VGAScaleX(52), g_lab->_graphics->VGAScaleY(32), g_lab->_graphics->VGAScaleX(152), g_lab->_graphics->VGAScaleY(148), CurText);
+		CharsDrawn += g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_utils->vgaScaleX(52), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(152), g_lab->_utils->vgaScaleY(148), CurText);
 	}
 
 	g_lab->_music->updateMusic();
 	CurText = (char *)(journaltext + CharsDrawn);
 	lastpage = (*CurText == 0);
-	g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_graphics->VGAScaleX(171), g_lab->_graphics->VGAScaleY(32), g_lab->_graphics->VGAScaleX(271), g_lab->_graphics->VGAScaleY(148), CurText);
+	g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_utils->vgaScaleX(171), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(271), g_lab->_utils->vgaScaleY(148), CurText);
 
 	CurText = (char *)(journaltext + CharsDrawn);
 	lastpage = lastpage || (*CurText == 0);
@@ -469,8 +469,8 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
 		text += 2;
 
 		fheight = g_lab->_graphics->textHeight(monitorFont);
-		x1 = MonButton->_width + _graphics->VGAScaleX(3);
-		MonGadHeight = MonButton->_height + _graphics->VGAScaleY(3);
+		x1 = MonButton->_width + _utils->vgaScaleX(3);
+		MonGadHeight = MonButton->_height + _utils->vgaScaleY(3);
 
 		if (MonGadHeight > fheight)
 			yspacing = MonGadHeight - fheight;
@@ -563,20 +563,20 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 				return;
 
 			else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) {
-				if ((MouseY >= g_lab->_graphics->VGAScaleY(171)) && (MouseY <= g_lab->_graphics->VGAScaleY(200))) {
-					if ((MouseX >= g_lab->_graphics->VGAScaleX(259)) && (MouseX <= g_lab->_graphics->VGAScaleX(289))) {
+				if ((MouseY >= g_lab->_utils->vgaScaleY(171)) && (MouseY <= g_lab->_utils->vgaScaleY(200))) {
+					if ((MouseX >= g_lab->_utils->vgaScaleX(259)) && (MouseX <= g_lab->_utils->vgaScaleX(289))) {
 						if (!lastpage) {
 							monitorPage += 1;
 							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
 						}
-					} else if ((MouseX >= g_lab->_graphics->VGAScaleX(0)) && (MouseX <= g_lab->_graphics->VGAScaleX(31))) {
+					} else if ((MouseX >= g_lab->_utils->vgaScaleX(0)) && (MouseX <= g_lab->_utils->vgaScaleX(31))) {
 						return;
-					} else if ((MouseX >= g_lab->_graphics->VGAScaleX(290)) && (MouseX <= g_lab->_graphics->VGAScaleX(320))) {
+					} else if ((MouseX >= g_lab->_utils->vgaScaleX(290)) && (MouseX <= g_lab->_utils->vgaScaleX(320))) {
 						if (monitorPage >= 1) {
 							monitorPage -= 1;
 							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
 						}
-					} else if ((MouseX >= g_lab->_graphics->VGAScaleX(31)) && (MouseX <= g_lab->_graphics->VGAScaleX(59))) {
+					} else if ((MouseX >= g_lab->_utils->vgaScaleX(31)) && (MouseX <= g_lab->_utils->vgaScaleX(59))) {
 						if (isinteractive) {
 							monitorPage = 0;
 
@@ -611,10 +611,10 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	char *ntext;
 
-	x1 = _graphics->VGAScaleX(x1);
-	x2 = _graphics->VGAScaleX(x2);
-	y1 = _graphics->VGAScaleY(y1);
-	y2 = _graphics->VGAScaleY(y2);
+	x1 = _utils->vgaScaleX(x1);
+	x2 = _utils->vgaScaleX(x2);
+	y1 = _utils->vgaScaleY(y1);
+	y2 = _utils->vgaScaleY(y2);
 
 	TextFileName = textfile;
 
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index 0d050cc..3b7d5ce 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -63,31 +63,11 @@ void LabEngine::initTilePuzzle() {
 }
 
 /*****************************************************************************/
-/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
-/*****************************************************************************/
-int LabEngine::VGAUnScaleX(int x) {
-	if (_isHiRes)
-		return (x / 2);
-	else
-		return x;
-}
-
-/*****************************************************************************/
-/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
-/*****************************************************************************/
-int LabEngine::VGAUnScaleY(int y) {
-	if (_isHiRes)
-		return ((y * 5) / 12);
-	else
-		return y;
-}
-
-/*****************************************************************************/
 /* Processes mouse clicks and changes the combination.                       */
 /*****************************************************************************/
 void LabEngine::mouseTile(Common::Point pos) {
-	int x = VGAUnScaleX(pos.x);
-	int y = VGAUnScaleY(pos.y);
+	int x = _utils->vgaUnscaleX(pos.x);
+	int y = _utils->vgaUnscaleY(pos.y);
 
 	if ((x < 101) || (y < 26))
 		return;
@@ -174,8 +154,8 @@ void LabEngine::changeTile(uint16 col, uint16 row) {
 void LabEngine::mouseCombination(Common::Point pos) {
 	uint16 number;
 
-	int x = VGAUnScaleX(pos.x);
-	int y = VGAUnScaleY(pos.y);
+	int x = _utils->vgaUnscaleX(pos.x);
+	int y = _utils->vgaUnscaleY(pos.y);
 
 	if ((y >= 63) && (y <= 99)) {
 		if ((x >= 44) && (x < 83))
@@ -205,20 +185,20 @@ void LabEngine::doTile(bool showsolution) {
 	int16 rows, cols;
 
 	if (showsolution) {
-		rowm = _graphics->VGAScaleY(23);
-		colm = _graphics->VGAScaleX(27);
+		rowm = _utils->vgaScaleY(23);
+		colm = _utils->vgaScaleX(27);
 
-		rows = _graphics->VGAScaleY(31);
-		cols = _graphics->VGAScaleX(105);
+		rows = _utils->vgaScaleY(31);
+		cols = _utils->vgaScaleX(105);
 	} else {
 		_graphics->setAPen(0);
 		_graphics->rectFillScaled(97, 22, 220, 126);
 
-		rowm = _graphics->VGAScaleY(25);
-		colm = _graphics->VGAScaleX(30);
+		rowm = _utils->vgaScaleY(25);
+		colm = _utils->vgaScaleX(30);
 
-		rows = _graphics->VGAScaleY(25);
-		cols = _graphics->VGAScaleX(100);
+		rows = _utils->vgaScaleY(25);
+		cols = _utils->vgaScaleX(100);
 	}
 
 	while (row < 4) {
@@ -270,33 +250,33 @@ void LabEngine::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 	uint16 last = 0, x1, y1;
 
 	if (scrolltype == LEFTSCROLL) {
-		dX = _graphics->VGAScaleX(5);
-		sx = _graphics->VGAScaleX(5);
+		dX = _utils->vgaScaleX(5);
+		sx = _utils->vgaScaleX(5);
 		last = 6;
 	} else if (scrolltype == RIGHTSCROLL) {
-		dX = _graphics->VGAScaleX(-5);
-		dx = _graphics->VGAScaleX(-5);
-		sx = _graphics->VGAScaleX(5);
+		dX = _utils->vgaScaleX(-5);
+		dx = _utils->vgaScaleX(-5);
+		sx = _utils->vgaScaleX(5);
 		last = 6;
 	} else if (scrolltype == UPSCROLL) {
-		dY = _graphics->VGAScaleY(5);
-		sy = _graphics->VGAScaleY(5);
+		dY = _utils->vgaScaleY(5);
+		sy = _utils->vgaScaleY(5);
 		last = 5;
 	} else if (scrolltype == DOWNSCROLL) {
-		dY = _graphics->VGAScaleY(-5);
-		dy = _graphics->VGAScaleY(-5);
-		sy = _graphics->VGAScaleY(5);
+		dY = _utils->vgaScaleY(-5);
+		dy = _utils->vgaScaleY(-5);
+		sy = _utils->vgaScaleY(5);
 		last = 5;
 	}
 
-	sx += _graphics->SVGACord(2);
+	sx += _utils->svgaCord(2);
 
-	x1 = _graphics->VGAScaleX(100) + (col * _graphics->VGAScaleX(30)) + dx;
-	y1 = _graphics->VGAScaleY(25) + (row * _graphics->VGAScaleY(25)) + dy;
+	x1 = _utils->vgaScaleX(100) + (col * _utils->vgaScaleX(30)) + dx;
+	y1 = _utils->vgaScaleY(25) + (row * _utils->vgaScaleY(25)) + dy;
 
 	for (uint16 i = 0; i < last; i++) {
 		waitTOF();
-		scrollRaster(dX, dY, x1, y1, x1 + _graphics->VGAScaleX(28) + sx, y1 + _graphics->VGAScaleY(23) + sy);
+		scrollRaster(dX, dY, x1, y1, x1 + _utils->vgaScaleX(28) + sx, y1 + _utils->vgaScaleY(23) + sy);
 		x1 += dX;
 		y1 += dY;
 	}
@@ -331,8 +311,8 @@ void LabEngine::changeCombination(uint16 number) {
 			waitTOF();
 
 		display._imageData = _graphics->getCurrentDrawingBuffer();
-		_graphics->scrollDisplayY(2, _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), _graphics->VGAScaleX(COMBINATION_X[number]) + (_numberImages[combnum])->_width - 1, _graphics->VGAScaleY(65) + (_numberImages[combnum])->_height);
-		_numberImages[combnum]->blitBitmap(0, (_numberImages[combnum])->_height - (2 * i), &(display), _graphics->VGAScaleX(COMBINATION_X[number]), _graphics->VGAScaleY(65), (_numberImages[combnum])->_width, 2, false);
+		_graphics->scrollDisplayY(2, _utils->vgaScaleX(COMBINATION_X[number]), _utils->vgaScaleY(65), _utils->vgaScaleX(COMBINATION_X[number]) + (_numberImages[combnum])->_width - 1, _utils->vgaScaleY(65) + (_numberImages[combnum])->_height);
+		_numberImages[combnum]->blitBitmap(0, (_numberImages[combnum])->_height - (2 * i), &(display), _utils->vgaScaleX(COMBINATION_X[number]), _utils->vgaScaleY(65), (_numberImages[combnum])->_width, 2, false);
 	}
 
 	for (uint16 i = 0; i < 6; i++)
@@ -357,7 +337,7 @@ void LabEngine::scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2
 /*****************************************************************************/
 void LabEngine::doCombination() {
 	for (uint16 i = 0; i <= 5; i++)
-		_numberImages[_combination[i]]->drawImage(_graphics->VGAScaleX(COMBINATION_X[i]), _graphics->VGAScaleY(65));
+		_numberImages[_combination[i]]->drawImage(_utils->vgaScaleX(COMBINATION_X[i]), _utils->vgaScaleY(65));
 }
 
 /*****************************************************************************/
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
new file mode 100644
index 0000000..9e057f8
--- /dev/null
+++ b/engines/lab/utils.cpp
@@ -0,0 +1,413 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/lab.h"
+#include "lab/utils.h"
+
+namespace Lab {
+Utils::Utils(LabEngine *vm) : _vm(vm) {
+	_dataBytesPerRow = 0;
+}
+
+/*****************************************************************************/
+/* Scales the x co-ordinates to that of the new display.  In the room parser */
+/* file, co-ordinates are set up on a 360x336 display.                       */
+/*****************************************************************************/
+uint16 Utils::scaleX(uint16 x) {
+	if (_vm->_isHiRes)
+		return (uint16)((x * 16) / 9);
+	else
+		return (uint16)((x * 8) / 9);
+}
+
+/*****************************************************************************/
+/* Scales the y co-ordinates to that of the new display.  In the room parser */
+/* file, co-ordinates are set up on a 368x336 display.                       */
+/*****************************************************************************/
+uint16 Utils::scaleY(uint16 y) {
+	if (_vm->_isHiRes)
+		return (y + (y / 14));
+	else
+		return ((y * 10) / 24);
+}
+
+/*****************************************************************************/
+/* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
+/*****************************************************************************/
+int16 Utils::vgaScaleX(int16 x) {
+	if (_vm->_isHiRes)
+		return (x * 2);
+	else
+		return x;
+}
+
+/*****************************************************************************/
+/* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
+/*****************************************************************************/
+int16 Utils::vgaScaleY(int16 y) {
+	if (_vm->_isHiRes)
+		return ((y * 12) / 5);
+	else
+		return y;
+}
+
+uint16 Utils::svgaCord(uint16 cord) {
+	if (_vm->_isHiRes)
+		return cord;
+	else
+		return 0;
+}
+
+/*****************************************************************************/
+/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
+/*****************************************************************************/
+int Utils::vgaUnscaleX(int x) {
+	if (_vm->_isHiRes)
+		return (x / 2);
+	else
+		return x;
+}
+
+/*****************************************************************************/
+/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
+/*****************************************************************************/
+int Utils::vgaUnscaleY(int y) {
+	if (_vm->_isHiRes)
+		return ((y * 5) / 12);
+	else
+		return y;
+}
+
+/*****************************************************************************/
+/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
+/* is also a byte.                                                           */
+/*****************************************************************************/
+void Utils::unDiffByteByte(byte *dest, byte *diff) {
+	uint16 skip, copy;
+
+	while (1) {
+		skip = *diff;
+		diff++;
+		copy = *diff;
+		diff++;
+
+		if (skip == 255) {
+			if (copy == 0) {
+				skip = READ_LE_UINT16(diff);
+				diff += 2;
+				copy = READ_LE_UINT16(diff);
+				diff += 2;
+			} else if (copy == 255)
+				return;
+		}
+
+		dest += skip;
+		memcpy(dest, diff, copy);
+		dest += copy;
+		diff += copy;
+	}
+}
+
+/*****************************************************************************/
+/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
+/* is a word.                                                                */
+/*****************************************************************************/
+void Utils::unDiffByteWord(uint16 *dest, uint16 *diff) {
+	uint16 skip, copy;
+
+	while (1) {
+		skip = ((byte *)diff)[0];
+		copy = ((byte *)diff)[1];
+
+		diff++;
+
+		if (skip == 255) {
+			if (copy == 0) {
+				skip = READ_LE_UINT16(diff);
+				diff++;
+				copy = READ_LE_UINT16(diff);
+				diff++;
+			} else if (copy == 255)
+				return;
+		}
+
+		dest += skip;
+
+		while (copy > 3) {
+			*dest = READ_LE_UINT16(diff);
+			dest++;
+			diff++;
+
+			*dest = READ_LE_UINT16(diff);
+			dest++;
+			diff++;
+
+			*dest = READ_LE_UINT16(diff);
+			dest++;
+			diff++;
+
+			*dest = READ_LE_UINT16(diff);
+			dest++;
+			diff++;
+
+			copy -= 4;
+		}
+
+		while (copy) {
+			*dest = READ_LE_UINT16(diff);
+			dest++;
+			diff++;
+			copy--;
+		}
+	}
+}
+
+/*------------------------- unDiff Vertical Memory --------------------------*/
+
+/*****************************************************************************/
+/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
+/* is a byte.                                                                */
+/*****************************************************************************/
+void Utils::VUnDiffByteByte(byte *dest, byte *diff, uint16 bytesPerRow) {
+	byte *curPtr;
+	uint16 skip, copy;
+	uint16 counter = 0;
+
+
+	while (counter < _dataBytesPerRow) {
+		curPtr = dest + counter;
+
+		for (;;) {
+			skip = *diff;
+			diff++;
+			copy = *diff;
+			diff++;
+
+			if (skip == 255) {
+				counter += copy;
+				break;
+			}
+
+			else {
+				curPtr += (skip * bytesPerRow);
+
+				while (copy) {
+					copy--;
+					*curPtr = *diff;
+					curPtr += bytesPerRow;
+					diff++;
+				}
+			}
+		}
+	}
+}
+
+/*****************************************************************************/
+/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
+/* is a word.                                                                */
+/*****************************************************************************/
+void Utils::VUnDiffByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow) {
+	uint16 *curPtr;
+	uint16 skip, copy;
+	uint16 counter = 0;
+
+	uint16 wordsPerRow = bytesPerRow / 2;
+
+	while (counter < (_dataBytesPerRow >> 1)) {
+		curPtr = dest + counter;
+
+		for (;;) {
+			skip = ((byte *)diff)[0];
+			copy = ((byte *)diff)[1];
+
+			diff++;
+
+
+			if (skip == 255) {
+				counter += copy;
+				break;
+			}
+
+			else {
+				curPtr += (skip * wordsPerRow);
+
+				while (copy) {
+					*curPtr = *diff; //swapUShort(*diff);
+					curPtr += wordsPerRow;
+					diff++;
+					copy--;
+				}
+			}
+		}
+	}
+}
+
+/*****************************************************************************/
+/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
+/* is a long.                                                                */
+/*****************************************************************************/
+void Utils::VUnDiffByteLong(uint32 *dest, uint32 *diff, uint16 bytesPerRow) {
+	uint32 *_curPtr;
+	uint16 skip, copy;
+
+	uint16 counter = 0;
+	byte *diff1 = (byte *)diff;
+
+	uint16 longsperrow = bytesPerRow / 4;
+
+	while (counter < (_dataBytesPerRow >> 2)) {
+		_curPtr = dest + counter;
+
+		for (;;) {
+			skip = *diff1;
+			diff1++;
+
+			copy = *diff1;
+			diff1++;
+
+
+			if (skip == 255) {
+				counter += copy;
+				break;
+			}
+
+			else {
+				_curPtr += (skip * longsperrow);
+
+				while (copy) {
+					*_curPtr = *(uint32 *)diff1; //swapULong(*diff);
+					_curPtr += longsperrow;
+					diff1 += 4;
+					copy--;
+				}
+			}
+		}
+	}
+}
+
+/*****************************************************************************/
+/* Runlength decodes a chunk of memory.                                      */
+/*****************************************************************************/
+void Utils::runLengthDecode(byte *dest, byte *source) {
+	int8 num;
+	int16 count;
+
+	while (1) {
+		num = (int8)*source;
+		source++;
+
+		if (num == 127) {
+			return;
+		} else if (num > '\0') {
+			memcpy(dest, source, num);
+			source += num;
+			dest   += num;
+		} else {
+			count = (int16)(-num);
+			num   = *source;
+			source++;
+
+			while (count) {
+				*dest = num;
+				dest++;
+				count--;
+			}
+		}
+	}
+}
+
+/*****************************************************************************/
+/* Does a vertical run length decode.                                        */
+/*****************************************************************************/
+void Utils::VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow) {
+	int8 num;
+	int16 count;
+	byte *top = dest;
+
+	for (uint16 i = 0; i < _dataBytesPerRow; i++) {
+		dest = top;
+		dest += i;
+
+		num = (int8)*source;
+		source++;
+
+		while (num != 127) {
+			if (num > '\0') {
+				while (num) {
+					*dest = *source;
+					source++;
+					dest += bytesPerRow;
+					num--;
+				}
+			} else {
+				count = (int16)(-num);
+				num   = (int8)*source;
+				source++;
+
+				while (count) {
+					*dest = num;
+					dest += bytesPerRow;
+					count--;
+				}
+			}
+
+			num = *source;
+			source++;
+		}
+	}
+}
+
+/*****************************************************************************/
+/* Does the undiffing between the bitmaps.                                   */
+/*****************************************************************************/
+void Utils::unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesPerRow, bool isV) {
+	diffData++;
+	byte bufType = *diffData;
+	diffData++;
+
+	if (isV) {
+		if (bufType == 0)
+			VUnDiffByteByte(newBuf, diffData, bytesPerRow);
+		else if (bufType == 1)
+			VUnDiffByteWord((uint16 *)newBuf, (uint16 *)diffData, bytesPerRow);
+		else if (bufType == 3)
+			VUnDiffByteLong((uint32 *)newBuf, (uint32 *)diffData, bytesPerRow);
+	} else {
+		if (bufType == 0)
+			unDiffByteByte(newBuf, diffData);
+		else if (bufType == 1)
+			unDiffByteWord((uint16 *)newBuf, (uint16 *)diffData);
+	}
+}
+
+void Utils::setBytesPerRow(int num) {
+	_dataBytesPerRow = num;
+}
+} // End of namespace Lab
diff --git a/engines/lab/utils.h b/engines/lab/utils.h
new file mode 100644
index 0000000..4fa168d
--- /dev/null
+++ b/engines/lab/utils.h
@@ -0,0 +1,66 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#ifndef LAB_UTILS_H
+#define LAB_UTILS_H
+
+namespace Lab {
+
+class Utils {
+private:
+	LabEngine *_vm;
+	uint16 _dataBytesPerRow;
+
+	void unDiffByteByte(byte *dest, byte *diff);
+	void unDiffByteWord(uint16 *dest, uint16 *diff);
+	void VUnDiffByteByte(byte *Dest, byte *diff, uint16 bytesperrow);
+	void VUnDiffByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow);
+	void VUnDiffByteLong(uint32 *Dest, uint32 *diff, uint16 bytesperrow);
+
+public:
+	Utils(LabEngine *vm);
+	
+	uint16 scaleX(uint16 x);
+	uint16 scaleY(uint16 y);
+	int16 vgaScaleX(int16 x);
+	int16 vgaScaleY(int16 y);
+	uint16 svgaCord(uint16 cord);
+	int vgaUnscaleX(int x);
+	int vgaUnscaleY(int y);
+	void unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesperrow, bool isV);
+	void runLengthDecode(byte *dest, byte *source);
+	void VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow);
+	void setBytesPerRow(int num);
+};
+
+
+} // End of namespace Lab
+
+#endif // LAB_UTILS_H


Commit: 743b492ac796b1c3048a611681e21e7040dc1c0c
    https://github.com/scummvm/scummvm/commit/743b492ac796b1c3048a611681e21e7040dc1c0c
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:54+01:00

Commit Message:
LAB: Add safeguards in unDiff()

Changed paths:
    engines/lab/utils.cpp



diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index 9e057f8..6d4784d 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -399,11 +399,15 @@ void Utils::unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesPerRo
 			VUnDiffByteWord((uint16 *)newBuf, (uint16 *)diffData, bytesPerRow);
 		else if (bufType == 3)
 			VUnDiffByteLong((uint32 *)newBuf, (uint32 *)diffData, bytesPerRow);
+		else
+			error("Unexpected variable compression scheme %d", bufType);
 	} else {
 		if (bufType == 0)
 			unDiffByteByte(newBuf, diffData);
 		else if (bufType == 1)
 			unDiffByteWord((uint16 *)newBuf, (uint16 *)diffData);
+		else
+			error("Unexpected compression scheme %d", bufType);
 	}
 }
 


Commit: 80592779289461d42e166a40f8a1204e6159e62b
    https://github.com/scummvm/scummvm/commit/80592779289461d42e166a40f8a1204e6159e62b
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:54+01:00

Commit Message:
LAB: remove some useless forward references and includes

Changed paths:
    engines/lab/labfun.h
    engines/lab/music.h
    engines/lab/parsetypes.h
    engines/lab/processroom.cpp
    engines/lab/resource.h



diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 80291f6..e67d0f7 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -34,11 +34,6 @@
 #include "common/events.h"
 #include "lab/parsetypes.h"
 
-// For the Music class - TODO: Move to another header file
-#include "audio/mixer.h"
-#include "audio/audiostream.h"
-#include "audio/decoders/raw.h"
-
 #include "common/file.h"
 #include "common/savefile.h"
 
@@ -54,9 +49,6 @@ class LabEngine;
 #define EAST    2
 #define WEST    3
 
-struct TextFont;
-struct Gadget;
-
 struct SaveGameHeader {
 	byte _version;
 	SaveStateDescriptor _descr;
diff --git a/engines/lab/music.h b/engines/lab/music.h
index 942f737..3114817 100644
--- a/engines/lab/music.h
+++ b/engines/lab/music.h
@@ -33,7 +33,6 @@
 
 #include "common/events.h"
 
-// For the Music class - TODO: Move to another header file
 #include "audio/mixer.h"
 #include "audio/audiostream.h"
 #include "audio/decoders/raw.h"
diff --git a/engines/lab/parsetypes.h b/engines/lab/parsetypes.h
index 42c7269..c7780ae 100644
--- a/engines/lab/parsetypes.h
+++ b/engines/lab/parsetypes.h
@@ -35,8 +35,6 @@
 
 namespace Lab {
 
-#define MAXFILELEN 31
-
 /*------------------------------- Action types ------------------------------*/
 #define PLAYSOUND     1
 #define PLAYSOUNDCONT 2
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index b033c69..7acf683 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -41,7 +41,6 @@
 namespace Lab {
 
 /* Global parser data */
-
 #define NOFILE         "no file"
 
 /*****************************************************************************/
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index e050a15..cf7f350 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -32,6 +32,7 @@
 #define LAB_RESOURCE_H
 
 #include "lab/labfun.h"
+#include "lab/graphics.h"
 
 namespace Lab {
 


Commit: 6aff1b450d60507d1ebe49ea7a3d2ce76a3e3ea5
    https://github.com/scummvm/scummvm/commit/6aff1b450d60507d1ebe49ea7a3d2ce76a3e3ea5
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:54+01:00

Commit Message:
LAB: Move scene transition functions into a separate file

Changed paths:
  A engines/lab/transitions.cpp
    engines/lab/graphics.cpp
    engines/lab/module.mk



diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 97ec7cc..80eae97 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -360,379 +360,6 @@ void DisplayMan::drawMessage(const char *str) {
 	}
 }
 
-/*****************************************************************************/
-/* Scrolls the display to black.                                             */
-/*****************************************************************************/
-void DisplayMan::doScrollBlack() {
-	byte *tempmem;
-	Image im;
-	uint32 size, copysize;
-	byte *baseAddr;
-	uint16 width = _vm->_utils->vgaScaleX(320);
-	uint16 height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
-	byte *mem = new byte[width * height];
-
-	_vm->_event->mouseHide();
-
-	im._width = width;
-	im._height = height;
-	im._imageData = mem;
-	_vm->_music->updateMusic();
-	im.readScreenImage(0, 0);
-	_vm->_music->updateMusic();
-
-	baseAddr = getCurrentDrawingBuffer();
-
-	uint16 by = _vm->_utils->vgaScaleX(4);
-	uint16 nheight = height;
-
-	while (nheight) {
-		_vm->_music->updateMusic();
-
-		if (!_vm->_isHiRes)
-			_vm->waitTOF();
-
-		baseAddr = getCurrentDrawingBuffer();
-
-		if (by > nheight)
-			by = nheight;
-
-		mem += by * width;
-		nheight -= by;
-		size = (int32)nheight * (int32)width;
-		tempmem = mem;
-
-		while (size) {
-			if (size > _screenBytesPerPage)
-				copysize = _screenBytesPerPage;
-			else
-				copysize = size;
-
-			size -= copysize;
-
-			memcpy(baseAddr, tempmem, copysize);
-			tempmem += copysize;
-		}
-
-		setAPen(0);
-		rectFill(0, nheight, width - 1, nheight + by - 1);
-
-		screenUpdate();
-
-		if (!_vm->_isHiRes) {
-			if (nheight <= (height / 8))
-				by = 1;
-			else if (nheight <= (height / 4))
-				by = 2;
-			else if (nheight <= (height / 2))
-				by = 3;
-		}
-	}
-
-	delete[] mem;
-	freePict();
-	_vm->_event->mouseShow();
-}
-
-void DisplayMan::copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem) {
-	byte *baseAddr = getCurrentDrawingBuffer();
-
-	uint32 size = (int32)(height - nheight) * (int32)width;
-	mem += startline * width;
-	uint16 curPage = ((int32)nheight * (int32)width) / _screenBytesPerPage;
-	uint32 offSet = ((int32)nheight * (int32)width) - (curPage * _screenBytesPerPage);
-
-	while (size) {
-		uint32 copysize;
-		if (size > (_screenBytesPerPage - offSet))
-			copysize = _screenBytesPerPage - offSet;
-		else
-			copysize = size;
-
-		size -= copysize;
-
-		memcpy(baseAddr + (offSet >> 2), mem, copysize);
-		mem += copysize;
-		curPage++;
-		offSet = 0;
-	}
-}
-
-/*****************************************************************************/
-/* Scrolls the display to a new picture from a black screen.                 */
-/*****************************************************************************/
-void DisplayMan::doScrollWipe(char *filename) {
-	uint16 startline = 0, onrow = 0;
-
-	_vm->_event->mouseHide();
-	uint16 width = _vm->_utils->vgaScaleX(320);
-	uint16 height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
-
-	while (_vm->_music->isSoundEffectActive()) {
-		_vm->_music->updateMusic();
-		_vm->waitTOF();
-	}
-
-	_vm->_anim->_isBM = true;
-	readPict(filename, true);
-	setPalette(_vm->_anim->_diffPalette, 256);
-	_vm->_anim->_isBM = false;
-	byte *mem = _vm->_anim->_rawDiffBM._planes[0];
-
-	_vm->_music->updateMusic();
-	uint16 by = _vm->_utils->vgaScaleX(3);
-	uint16 nheight = height;
-
-	while (onrow < _vm->_anim->_headerdata._height) {
-		_vm->_music->updateMusic();
-
-		if ((by > nheight) && nheight)
-			by = nheight;
-
-		if ((startline + by) > (_vm->_anim->_headerdata._height - height - 1))
-			break;
-
-		if (nheight)
-			nheight -= by;
-
-		copyPage(width, height, nheight, startline, mem);
-
-		screenUpdate();
-
-		if (!nheight)
-			startline += by;
-
-		onrow += by;
-
-		if (nheight <= (height / 4))
-			by = _vm->_utils->vgaScaleX(5);
-		else if (nheight <= (height / 3))
-			by = _vm->_utils->vgaScaleX(4);
-		else if (nheight <= (height / 2))
-			by = _vm->_utils->vgaScaleX(3);
-	}
-
-	_vm->_event->mouseShow();
-}
-
-/*****************************************************************************/
-/* Does the scroll bounce.  Assumes bitmap already in memory.                */
-/*****************************************************************************/
-void DisplayMan::doScrollBounce() {
-	const uint16 *newby, *newby1;
-
-	const uint16 newbyd[5] = {5, 4, 3, 2, 1}, newby1d[8] = {3, 3, 2, 2, 2, 1, 1, 1};
-	const uint16 newbyw[5] = {10, 8, 6, 4, 2}, newby1w[8] = {6, 6, 4, 4, 4, 2, 2, 2};
-
-	if (_vm->getPlatform() != Common::kPlatformWindows) {
-		newby = newbyd;
-		newby1 = newby1d;
-	} else {
-		newby = newbyw;
-		newby1 = newby1w;
-	}
-
-	_vm->_event->mouseHide();
-	int width = _vm->_utils->vgaScaleX(320);
-	int height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
-	byte *mem = _vm->_anim->_rawDiffBM._planes[0];
-
-	_vm->_music->updateMusic();
-	int startline = _vm->_anim->_headerdata._height - height - 1;
-
-	for (int i = 0; i < 5; i++) {
-		_vm->_music->updateMusic();
-		startline -= newby[i];
-		copyPage(width, height, 0, startline, mem);
-
-		screenUpdate();
-		_vm->waitTOF();
-	}
-
-	for (int i = 8; i > 0; i--) {
-		_vm->_music->updateMusic();
-		startline += newby1[i - 1];
-		copyPage(width, height, 0, startline, mem);
-
-		screenUpdate();
-		_vm->waitTOF();
-	}
-
-	_vm->_event->mouseShow();
-}
-
-/*****************************************************************************/
-/* Does the transporter wipe.                                                */
-/*****************************************************************************/
-void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
-	uint16 lastY, curY, linesdone = 0, lineslast;
-	Image imSource, imDest;
-
-	if (_vm->_isHiRes) {
-		lineslast = 3;
-		lastY = 358;
-	} else {
-		lineslast = 1;
-		lastY = 148;
-	}
-
-	for (uint16 i = 0; i < 2; i++) {
-		curY = i * 2;
-
-		while (curY < lastY) {
-			if (linesdone >= lineslast) {
-				_vm->_music->updateMusic();
-				_vm->waitTOF();
-				linesdone = 0;
-			}
-
-			overlayRect(0, 0, curY, _screenWidth - 1, curY + 1);
-			curY += 4;
-			linesdone++;
-		}
-	}
-
-	setAPen(0);
-
-	for (uint16 i = 0; i < 2; i++) {
-		curY = i * 2;
-
-		while (curY <= lastY) {
-			if (linesdone >= lineslast) {
-				_vm->_music->updateMusic();
-				_vm->waitTOF();
-				linesdone = 0;
-			}
-
-			rectFill(0, curY, _screenWidth - 1, curY + 1);
-			curY += 4;
-			linesdone++;
-		}
-	}
-
-	if (filename == NULL)
-		_vm->_curFileName = getPictName(cPtr);
-	else if (filename[0] > ' ')
-		_vm->_curFileName = filename;
-	else
-		_vm->_curFileName = getPictName(cPtr);
-
-	byte *BitMapMem = readPictToMem(_vm->_curFileName, _screenWidth, lastY + 5);
-	setPalette(_vm->_anim->_diffPalette, 256);
-
-	if (BitMapMem) {
-		imSource._width = _screenWidth;
-		imSource._height = lastY;
-		imSource._imageData = BitMapMem;
-
-		imDest._width = _screenWidth;
-		imDest._height = _screenHeight;
-		imDest._imageData = getCurrentDrawingBuffer();
-
-		for (uint16 i = 0; i < 2; i++) {
-			curY = i * 2;
-
-			while (curY < lastY) {
-				if (linesdone >= lineslast) {
-					_vm->_music->updateMusic();
-					_vm->waitTOF();
-					linesdone = 0;
-				}
-
-				imDest._imageData = getCurrentDrawingBuffer();
-
-				imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, 2, false);
-				overlayRect(0, 0, curY, _screenWidth - 1, curY + 1);
-				curY += 4;
-				linesdone++;
-			}
-		}
-
-		for (uint16 i = 0; i < 2; i++) {
-			curY = i * 2;
-
-			while (curY <= lastY) {
-				if (linesdone >= lineslast) {
-					_vm->_music->updateMusic();
-					_vm->waitTOF();
-					linesdone = 0;
-				}
-
-				imDest._imageData = getCurrentDrawingBuffer();
-
-				if (curY == lastY)
-					imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, 1, false);
-				else
-					imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, 2, false);
-
-				curY += 4;
-				linesdone++;
-			}
-		}
-	}
-}
-
-/*****************************************************************************/
-/* Does a certain number of pre-programmed wipes.                            */
-/*****************************************************************************/
-void DisplayMan::doTransition(TransitionType transitionType, CloseDataPtr *cPtr, char *filename) {
-	switch (transitionType) {
-	case kTransitionWipe:
-	case kTransitionTransporter:
-		doTransWipe(cPtr, filename);
-		break;
-	case kTransitionScrollWipe:
-		doScrollWipe(filename);
-		break;
-	case kTransitionScrollBlack:
-		doScrollBlack();
-		break;
-	case kTransitionScrollBounce:
-		doScrollBounce();
-		break;
-	case kTransitionReadFirstFrame:
-		readPict(filename, false);
-		break;
-	case kTransitionReadNextFrame:
-		_vm->_anim->diffNextFrame();
-		break;
-	case kTransitionNone:
-	default:
-		break;
-	}
-}
-
-/*****************************************************************************/
-/* Changes the front screen to black.                                        */
-/*****************************************************************************/
-void DisplayMan::blackScreen() {
-	byte pal[256 * 3];
-	memset(pal, 0, 248 * 3);
-	writeColorRegs(pal, 8, 248);
-
-	g_system->delayMillis(32);
-}
-
-/*****************************************************************************/
-/* Changes the front screen to white.                                        */
-/*****************************************************************************/
-void DisplayMan::whiteScreen() {
-	byte pal[256 * 3];
-	memset(pal, 255, 248 * 3);
-	writeColorRegs(pal, 8, 248);
-}
-
-/*****************************************************************************/
-/* Changes the entire screen to black.                                       */
-/*****************************************************************************/
-void DisplayMan::blackAllScreen() {
-	byte pal[256 * 3];
-	memset(pal, 0, 256 * 3);
-	writeColorRegs(pal, 0, 256);
-
-	g_system->delayMillis(32);
-}
-
 /******************************************************************************/
 /* Draws the control panel display.                                           */
 /******************************************************************************/
@@ -1017,103 +644,6 @@ void DisplayMan::overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, u
 }
 
 /*****************************************************************************/
-/* Scrolls the display in the x direction by blitting.                       */
-/* The _tempScrollData variable must be initialized to some memory, or this   */
-/* function will fail.                                                       */
-/*****************************************************************************/
-void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	Image im;
-	uint16 temp;
-
-	im._imageData = _tempScrollData;
-
-	if (x1 > x2) {
-		temp = x2;
-		x2 = x1;
-		x1 = temp;
-	}
-
-	if (y1 > y2) {
-		temp = y2;
-		y2 = y1;
-		y1 = temp;
-	}
-
-	im._width = x2 - x1 + 1 - dx;
-	im._height = y2 - y1 + 1;
-
-	im.readScreenImage(x1, y1);
-	im.drawImage(x1 + dx, y1);
-
-	setAPen(0);
-	rectFill(x1, y1, x1 + dx - 1, y2);
-}
-
-/*****************************************************************************/
-/* Scrolls the display in the y direction by blitting.                       */
-/*****************************************************************************/
-void DisplayMan::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	Image im;
-	uint16 temp;
-
-	im._imageData = _tempScrollData;
-
-	if (x1 > x2) {
-		temp = x2;
-		x2 = x1;
-		x1 = temp;
-	}
-
-	if (y1 > y2) {
-		temp = y2;
-		y2 = y1;
-		y1 = temp;
-	}
-
-	im._width = x2 - x1 + 1;
-	im._height = y2 - y1 + 1 - dy;
-
-	im.readScreenImage(x1, y1);
-	im.drawImage(x1, y1 + dy);
-
-	setAPen(0);
-	rectFill(x1, y1, x2, y1 + dy - 1);
-}
-
-/*****************************************************************************/
-/* Does the fading of the Palette on the screen.                             */
-/*****************************************************************************/
-uint16 DisplayMan::fadeNumIn(uint16 num, uint16 res, uint16 counter) {
-	return (num - ((((int32)(15 - counter)) * ((int32)(num - res))) / 15));
-}
-
-
-uint16 DisplayMan::fadeNumOut(uint16 num, uint16 res, uint16 counter) {
-	return (num - ((((int32) counter) * ((int32)(num - res))) / 15));
-}
-
-void DisplayMan::fade(bool fadein, uint16 res) {
-	uint16 newpal[16];
-
-	for (uint16 i = 0; i < 16; i++) {
-		for (uint16 palIdx = 0; palIdx < 16; palIdx++) {
-			if (fadein)
-				newpal[palIdx] = (0x00F & fadeNumIn(0x00F & FadePalette[palIdx], 0x00F & res, i)) +
-				(0x0F0 & fadeNumIn(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) +
-				(0xF00 & fadeNumIn(0xF00 & FadePalette[palIdx], 0xF00 & res, i));
-			else
-				newpal[palIdx] = (0x00F & fadeNumOut(0x00F & FadePalette[palIdx], 0x00F & res, i)) +
-				(0x0F0 & fadeNumOut(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) +
-				(0xF00 & fadeNumOut(0xF00 & FadePalette[palIdx], 0xF00 & res, i));
-		}
-
-		setAmigaPal(newpal, 16);
-		_vm->waitTOF();
-		_vm->_music->updateMusic();
-	}
-}
-
-/*****************************************************************************/
 /* Closes a font and frees all memory associated with it.                    */
 /*****************************************************************************/
 void DisplayMan::closeFont(TextFont *tf) {
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index fccc438..f4cb284 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -19,6 +19,7 @@ MODULE_OBJS := \
 	special.o \
 	tilepuzzle.o \
 	timing.o \
+	transitions.o \
 	utils.o
 
 # This module can be built as a plugin
diff --git a/engines/lab/transitions.cpp b/engines/lab/transitions.cpp
new file mode 100644
index 0000000..caf52dc
--- /dev/null
+++ b/engines/lab/transitions.cpp
@@ -0,0 +1,507 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/lab.h"
+#include "lab/parsefun.h"
+#include "lab/graphics.h"
+
+namespace Lab {
+
+/*****************************************************************************/
+/* Scrolls the display to black.                                             */
+/*****************************************************************************/
+void DisplayMan::doScrollBlack() {
+	byte *tempmem;
+	Image im;
+	uint32 size, copysize;
+	byte *baseAddr;
+	uint16 width = _vm->_utils->vgaScaleX(320);
+	uint16 height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
+	byte *mem = new byte[width * height];
+
+	_vm->_event->mouseHide();
+
+	im._width = width;
+	im._height = height;
+	im._imageData = mem;
+	_vm->_music->updateMusic();
+	im.readScreenImage(0, 0);
+	_vm->_music->updateMusic();
+
+	baseAddr = getCurrentDrawingBuffer();
+
+	uint16 by = _vm->_utils->vgaScaleX(4);
+	uint16 nheight = height;
+
+	while (nheight) {
+		_vm->_music->updateMusic();
+
+		if (!_vm->_isHiRes)
+			_vm->waitTOF();
+
+		baseAddr = getCurrentDrawingBuffer();
+
+		if (by > nheight)
+			by = nheight;
+
+		mem += by * width;
+		nheight -= by;
+		size = (int32)nheight * (int32)width;
+		tempmem = mem;
+
+		while (size) {
+			if (size > _screenBytesPerPage)
+				copysize = _screenBytesPerPage;
+			else
+				copysize = size;
+
+			size -= copysize;
+
+			memcpy(baseAddr, tempmem, copysize);
+			tempmem += copysize;
+		}
+
+		setAPen(0);
+		rectFill(0, nheight, width - 1, nheight + by - 1);
+
+		screenUpdate();
+
+		if (!_vm->_isHiRes) {
+			if (nheight <= (height / 8))
+				by = 1;
+			else if (nheight <= (height / 4))
+				by = 2;
+			else if (nheight <= (height / 2))
+				by = 3;
+		}
+	}
+
+	delete[] mem;
+	freePict();
+	_vm->_event->mouseShow();
+}
+
+void DisplayMan::copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem) {
+	byte *baseAddr = getCurrentDrawingBuffer();
+
+	uint32 size = (int32)(height - nheight) * (int32)width;
+	mem += startline * width;
+	uint16 curPage = ((int32)nheight * (int32)width) / _screenBytesPerPage;
+	uint32 offSet = ((int32)nheight * (int32)width) - (curPage * _screenBytesPerPage);
+
+	while (size) {
+		uint32 copysize;
+		if (size > (_screenBytesPerPage - offSet))
+			copysize = _screenBytesPerPage - offSet;
+		else
+			copysize = size;
+
+		size -= copysize;
+
+		memcpy(baseAddr + (offSet >> 2), mem, copysize);
+		mem += copysize;
+		curPage++;
+		offSet = 0;
+	}
+}
+
+/*****************************************************************************/
+/* Scrolls the display to a new picture from a black screen.                 */
+/*****************************************************************************/
+void DisplayMan::doScrollWipe(char *filename) {
+	uint16 startline = 0, onrow = 0;
+
+	_vm->_event->mouseHide();
+	uint16 width = _vm->_utils->vgaScaleX(320);
+	uint16 height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
+
+	while (_vm->_music->isSoundEffectActive()) {
+		_vm->_music->updateMusic();
+		_vm->waitTOF();
+	}
+
+	_vm->_anim->_isBM = true;
+	readPict(filename, true);
+	setPalette(_vm->_anim->_diffPalette, 256);
+	_vm->_anim->_isBM = false;
+	byte *mem = _vm->_anim->_rawDiffBM._planes[0];
+
+	_vm->_music->updateMusic();
+	uint16 by = _vm->_utils->vgaScaleX(3);
+	uint16 nheight = height;
+
+	while (onrow < _vm->_anim->_headerdata._height) {
+		_vm->_music->updateMusic();
+
+		if ((by > nheight) && nheight)
+			by = nheight;
+
+		if ((startline + by) > (_vm->_anim->_headerdata._height - height - 1))
+			break;
+
+		if (nheight)
+			nheight -= by;
+
+		copyPage(width, height, nheight, startline, mem);
+
+		screenUpdate();
+
+		if (!nheight)
+			startline += by;
+
+		onrow += by;
+
+		if (nheight <= (height / 4))
+			by = _vm->_utils->vgaScaleX(5);
+		else if (nheight <= (height / 3))
+			by = _vm->_utils->vgaScaleX(4);
+		else if (nheight <= (height / 2))
+			by = _vm->_utils->vgaScaleX(3);
+	}
+
+	_vm->_event->mouseShow();
+}
+
+/*****************************************************************************/
+/* Does the scroll bounce.  Assumes bitmap already in memory.                */
+/*****************************************************************************/
+void DisplayMan::doScrollBounce() {
+	const uint16 *newby, *newby1;
+
+	const uint16 newbyd[5] = {5, 4, 3, 2, 1}, newby1d[8] = {3, 3, 2, 2, 2, 1, 1, 1};
+	const uint16 newbyw[5] = {10, 8, 6, 4, 2}, newby1w[8] = {6, 6, 4, 4, 4, 2, 2, 2};
+
+	if (_vm->getPlatform() != Common::kPlatformWindows) {
+		newby = newbyd;
+		newby1 = newby1d;
+	} else {
+		newby = newbyw;
+		newby1 = newby1w;
+	}
+
+	_vm->_event->mouseHide();
+	int width = _vm->_utils->vgaScaleX(320);
+	int height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
+	byte *mem = _vm->_anim->_rawDiffBM._planes[0];
+
+	_vm->_music->updateMusic();
+	int startline = _vm->_anim->_headerdata._height - height - 1;
+
+	for (int i = 0; i < 5; i++) {
+		_vm->_music->updateMusic();
+		startline -= newby[i];
+		copyPage(width, height, 0, startline, mem);
+
+		screenUpdate();
+		_vm->waitTOF();
+	}
+
+	for (int i = 8; i > 0; i--) {
+		_vm->_music->updateMusic();
+		startline += newby1[i - 1];
+		copyPage(width, height, 0, startline, mem);
+
+		screenUpdate();
+		_vm->waitTOF();
+	}
+
+	_vm->_event->mouseShow();
+}
+
+/*****************************************************************************/
+/* Does the transporter wipe.                                                */
+/*****************************************************************************/
+void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
+	uint16 lastY, curY, linesdone = 0, lineslast;
+	Image imSource, imDest;
+
+	if (_vm->_isHiRes) {
+		lineslast = 3;
+		lastY = 358;
+	} else {
+		lineslast = 1;
+		lastY = 148;
+	}
+
+	for (uint16 i = 0; i < 2; i++) {
+		curY = i * 2;
+
+		while (curY < lastY) {
+			if (linesdone >= lineslast) {
+				_vm->_music->updateMusic();
+				_vm->waitTOF();
+				linesdone = 0;
+			}
+
+			overlayRect(0, 0, curY, _screenWidth - 1, curY + 1);
+			curY += 4;
+			linesdone++;
+		}
+	}
+
+	setAPen(0);
+
+	for (uint16 i = 0; i < 2; i++) {
+		curY = i * 2;
+
+		while (curY <= lastY) {
+			if (linesdone >= lineslast) {
+				_vm->_music->updateMusic();
+				_vm->waitTOF();
+				linesdone = 0;
+			}
+
+			rectFill(0, curY, _screenWidth - 1, curY + 1);
+			curY += 4;
+			linesdone++;
+		}
+	}
+
+	if (filename == NULL)
+		_vm->_curFileName = getPictName(cPtr);
+	else if (filename[0] > ' ')
+		_vm->_curFileName = filename;
+	else
+		_vm->_curFileName = getPictName(cPtr);
+
+	byte *BitMapMem = readPictToMem(_vm->_curFileName, _screenWidth, lastY + 5);
+	setPalette(_vm->_anim->_diffPalette, 256);
+
+	if (BitMapMem) {
+		imSource._width = _screenWidth;
+		imSource._height = lastY;
+		imSource._imageData = BitMapMem;
+
+		imDest._width = _screenWidth;
+		imDest._height = _screenHeight;
+		imDest._imageData = getCurrentDrawingBuffer();
+
+		for (uint16 i = 0; i < 2; i++) {
+			curY = i * 2;
+
+			while (curY < lastY) {
+				if (linesdone >= lineslast) {
+					_vm->_music->updateMusic();
+					_vm->waitTOF();
+					linesdone = 0;
+				}
+
+				imDest._imageData = getCurrentDrawingBuffer();
+
+				imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, 2, false);
+				overlayRect(0, 0, curY, _screenWidth - 1, curY + 1);
+				curY += 4;
+				linesdone++;
+			}
+		}
+
+		for (uint16 i = 0; i < 2; i++) {
+			curY = i * 2;
+
+			while (curY <= lastY) {
+				if (linesdone >= lineslast) {
+					_vm->_music->updateMusic();
+					_vm->waitTOF();
+					linesdone = 0;
+				}
+
+				imDest._imageData = getCurrentDrawingBuffer();
+
+				if (curY == lastY)
+					imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, 1, false);
+				else
+					imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, 2, false);
+
+				curY += 4;
+				linesdone++;
+			}
+		}
+	}
+}
+
+/*****************************************************************************/
+/* Does a certain number of pre-programmed wipes.                            */
+/*****************************************************************************/
+void DisplayMan::doTransition(TransitionType transitionType, CloseDataPtr *cPtr, char *filename) {
+	switch (transitionType) {
+	case kTransitionWipe:
+	case kTransitionTransporter:
+		doTransWipe(cPtr, filename);
+		break;
+	case kTransitionScrollWipe:
+		doScrollWipe(filename);
+		break;
+	case kTransitionScrollBlack:
+		doScrollBlack();
+		break;
+	case kTransitionScrollBounce:
+		doScrollBounce();
+		break;
+	case kTransitionReadFirstFrame:
+		readPict(filename, false);
+		break;
+	case kTransitionReadNextFrame:
+		_vm->_anim->diffNextFrame();
+		break;
+	case kTransitionNone:
+	default:
+		break;
+	}
+}
+
+/*****************************************************************************/
+/* Changes the front screen to black.                                        */
+/*****************************************************************************/
+void DisplayMan::blackScreen() {
+	byte pal[256 * 3];
+	memset(pal, 0, 248 * 3);
+	writeColorRegs(pal, 8, 248);
+
+	g_system->delayMillis(32);
+}
+
+/*****************************************************************************/
+/* Changes the front screen to white.                                        */
+/*****************************************************************************/
+void DisplayMan::whiteScreen() {
+	byte pal[256 * 3];
+	memset(pal, 255, 248 * 3);
+	writeColorRegs(pal, 8, 248);
+}
+
+/*****************************************************************************/
+/* Changes the entire screen to black.                                       */
+/*****************************************************************************/
+void DisplayMan::blackAllScreen() {
+	byte pal[256 * 3];
+	memset(pal, 0, 256 * 3);
+	writeColorRegs(pal, 0, 256);
+
+	g_system->delayMillis(32);
+}
+
+/*****************************************************************************/
+/* Scrolls the display in the x direction by blitting.                       */
+/* The _tempScrollData variable must be initialized to some memory, or this   */
+/* function will fail.                                                       */
+/*****************************************************************************/
+void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+	Image im;
+	uint16 temp;
+
+	im._imageData = _tempScrollData;
+
+	if (x1 > x2) {
+		temp = x2;
+		x2 = x1;
+		x1 = temp;
+	}
+
+	if (y1 > y2) {
+		temp = y2;
+		y2 = y1;
+		y1 = temp;
+	}
+
+	im._width = x2 - x1 + 1 - dx;
+	im._height = y2 - y1 + 1;
+
+	im.readScreenImage(x1, y1);
+	im.drawImage(x1 + dx, y1);
+
+	setAPen(0);
+	rectFill(x1, y1, x1 + dx - 1, y2);
+}
+
+/*****************************************************************************/
+/* Scrolls the display in the y direction by blitting.                       */
+/*****************************************************************************/
+void DisplayMan::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+	Image im;
+	uint16 temp;
+
+	im._imageData = _tempScrollData;
+
+	if (x1 > x2) {
+		temp = x2;
+		x2 = x1;
+		x1 = temp;
+	}
+
+	if (y1 > y2) {
+		temp = y2;
+		y2 = y1;
+		y1 = temp;
+	}
+
+	im._width = x2 - x1 + 1;
+	im._height = y2 - y1 + 1 - dy;
+
+	im.readScreenImage(x1, y1);
+	im.drawImage(x1, y1 + dy);
+
+	setAPen(0);
+	rectFill(x1, y1, x2, y1 + dy - 1);
+}
+
+/*****************************************************************************/
+/* Does the fading of the Palette on the screen.                             */
+/*****************************************************************************/
+uint16 DisplayMan::fadeNumIn(uint16 num, uint16 res, uint16 counter) {
+	return (num - ((((int32)(15 - counter)) * ((int32)(num - res))) / 15));
+}
+
+
+uint16 DisplayMan::fadeNumOut(uint16 num, uint16 res, uint16 counter) {
+	return (num - ((((int32) counter) * ((int32)(num - res))) / 15));
+}
+
+void DisplayMan::fade(bool fadein, uint16 res) {
+	uint16 newpal[16];
+
+	for (uint16 i = 0; i < 16; i++) {
+		for (uint16 palIdx = 0; palIdx < 16; palIdx++) {
+			if (fadein)
+				newpal[palIdx] = (0x00F & fadeNumIn(0x00F & FadePalette[palIdx], 0x00F & res, i)) +
+				(0x0F0 & fadeNumIn(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) +
+				(0xF00 & fadeNumIn(0xF00 & FadePalette[palIdx], 0xF00 & res, i));
+			else
+				newpal[palIdx] = (0x00F & fadeNumOut(0x00F & FadePalette[palIdx], 0x00F & res, i)) +
+				(0x0F0 & fadeNumOut(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) +
+				(0xF00 & fadeNumOut(0xF00 & FadePalette[palIdx], 0xF00 & res, i));
+		}
+
+		setAmigaPal(newpal, 16);
+		_vm->waitTOF();
+		_vm->_music->updateMusic();
+	}
+}
+
+} // End of namespace Lab


Commit: dcefb696eddb21120648ea5f8f9514ca368f958d
    https://github.com/scummvm/scummvm/commit/dcefb696eddb21120648ea5f8f9514ca368f958d
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:54+01:00

Commit Message:
LAB: Remove more extern variables

Changed paths:
    engines/lab/anim.cpp
    engines/lab/interface.cpp
    engines/lab/interface.h
    engines/lab/lab.h
    engines/lab/parsefun.h
    engines/lab/parsetypes.h
    engines/lab/processroom.cpp
    engines/lab/savegame.cpp
    engines/lab/transitions.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 777a09e..a9e7860 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -33,8 +33,6 @@
 
 namespace Lab {
 
-extern byte **startoffile;
-
 Anim::Anim(LabEngine *vm) : _vm(vm) {
 	_header = 0;
 	_curBit = 0;
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 6aba151..09c3fc8 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -36,8 +36,6 @@
 
 namespace Lab {
 
-extern bool IsHiRes;
-
 Common::KeyState _keyPressed;
 
 Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt) {
diff --git a/engines/lab/interface.h b/engines/lab/interface.h
index a8d1140..3e0460b 100644
--- a/engines/lab/interface.h
+++ b/engines/lab/interface.h
@@ -50,10 +50,7 @@ struct Gadget {
 	Image *_image, *_altImage;
 };
 
-extern Common::KeyState _keyPressed;
-
 /* Defines for the GadgetFlags portion */
-
 #define GADGETOFF 0x01
 
 typedef Common::List<Gadget *> GadgetList;
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 44104fc..af93367 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -64,6 +64,13 @@ enum GameFeatures {
 
 typedef Common::List<Gadget *> GadgetList;
 
+struct CrumbData {
+	uint16 _roomNum;
+	uint16 _direction;
+};
+
+#define MAX_CRUMBS          128
+
 class LabEngine : public Engine {
 public:
 	LabEngine(OSystem *syst, const ADGameDescription *gameDesc);
@@ -170,6 +177,7 @@ public:
 	int followCrumbs();
 
 	void changeVolume(int delta);
+	char *getPictName(CloseDataPtr *lcptr);
 
 private:
 	// engine.cpp
diff --git a/engines/lab/parsefun.h b/engines/lab/parsefun.h
index c45727d..78f7904 100644
--- a/engines/lab/parsefun.h
+++ b/engines/lab/parsefun.h
@@ -43,7 +43,6 @@ bool parse(const char *inputFile);
 /* From ProcessRoom.c */
 
 ViewData *getViewData(uint16 roomNum, uint16 direction);
-char *getPictName(CloseDataPtr *lcptr);
 void drawDirection(CloseDataPtr lcptr);
 uint16 processArrow(uint16 curDirection, uint16 arrow);
 void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords = false);
diff --git a/engines/lab/parsetypes.h b/engines/lab/parsetypes.h
index c7780ae..1f03bc3 100644
--- a/engines/lab/parsetypes.h
+++ b/engines/lab/parsetypes.h
@@ -191,13 +191,6 @@ struct MapData {
 #pragma pack(pop)
 #endif
 
-struct CrumbData {
-	uint16 _roomNum;
-	uint16 _direction;
-};
-
-#define MAX_CRUMBS          128
-
 } // End of namespace Lab
 
 #endif /* LAB_PARSETYPES_H */
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 7acf683..8afa543 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -143,7 +143,7 @@ static CloseDataPtr findCPtrMatch(CloseDataPtr cpmain, CloseDataPtr list) {
 /*****************************************************************************/
 /* Returns the current picture name.                                         */
 /*****************************************************************************/
-char *getPictName(CloseDataPtr *lcptr) {
+char *LabEngine::getPictName(CloseDataPtr *lcptr) {
 	ViewData *viewPtr = getViewData(g_lab->_roomNum, g_lab->_direction);
 
 	if (*lcptr != NULL) {
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index b28d1a2..23e73c5 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -43,8 +43,6 @@ namespace Lab {
 #define SAVEGAME_VERSION  1
 
 /*----- The machine independent section of saveGame.c -----*/
-/* Lab: Labyrinth specific */
-extern char *getPictName(CloseDataPtr *lcptr);
 
 void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName) {
 	out->writeUint32BE(SAVEGAME_ID);
@@ -129,7 +127,7 @@ bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc)
 
 	// Load scene pic
 	CloseDataPtr cPtr = nullptr;
-	g_lab->_graphics->readPict(getPictName(&cPtr), true);
+	g_lab->_graphics->readPict(g_lab->getPictName(&cPtr), true);
 
 	writeSaveGameHeader(file, desc);
 	file->writeUint16LE(g_lab->_roomNum);
diff --git a/engines/lab/transitions.cpp b/engines/lab/transitions.cpp
index caf52dc..11064c1 100644
--- a/engines/lab/transitions.cpp
+++ b/engines/lab/transitions.cpp
@@ -285,11 +285,11 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 	}
 
 	if (filename == NULL)
-		_vm->_curFileName = getPictName(cPtr);
+		_vm->_curFileName = _vm->getPictName(cPtr);
 	else if (filename[0] > ' ')
 		_vm->_curFileName = filename;
 	else
-		_vm->_curFileName = getPictName(cPtr);
+		_vm->_curFileName = _vm->getPictName(cPtr);
 
 	byte *BitMapMem = readPictToMem(_vm->_curFileName, _screenWidth, lastY + 5);
 	setPalette(_vm->_anim->_diffPalette, 256);


Commit: fb86132314f7da2ea35d0f7c73b28102823a0049
    https://github.com/scummvm/scummvm/commit/fb86132314f7da2ea35d0f7c73b28102823a0049
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:54+01:00

Commit Message:
LAB: Fix some coding style in tilepuzzle

Changed paths:
    engines/lab/tilepuzzle.cpp



diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index 3b7d5ce..cdc6735 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -86,33 +86,33 @@ void LabEngine::changeTile(uint16 col, uint16 row) {
 	int16 scrolltype = -1;
 
 	if (row > 0) {
-		if (_curTile[col] [row - 1] == 0) {
-			_curTile[col] [row - 1] = _curTile[col] [row];
-			_curTile[col] [row] = 0;
+		if (_curTile[col][row - 1] == 0) {
+			_curTile[col][row - 1] = _curTile[col][row];
+			_curTile[col][row] = 0;
 			scrolltype = DOWNSCROLL;
 		}
 	}
 
 	if (col > 0) {
-		if (_curTile[col - 1] [row] == 0) {
-			_curTile[col - 1] [row] = _curTile[col] [row];
-			_curTile[col] [row] = 0;
+		if (_curTile[col - 1][row] == 0) {
+			_curTile[col - 1][row] = _curTile[col][row];
+			_curTile[col][row] = 0;
 			scrolltype = RIGHTSCROLL;
 		}
 	}
 
 	if (row < 3) {
-		if (_curTile[col] [row + 1] == 0) {
-			_curTile[col] [row + 1] = _curTile[col] [row];
-			_curTile[col] [row] = 0;
+		if (_curTile[col][row + 1] == 0) {
+			_curTile[col][row + 1] = _curTile[col][row];
+			_curTile[col][row] = 0;
 			scrolltype = UPSCROLL;
 		}
 	}
 
 	if (col < 3) {
-		if (_curTile[col + 1] [row] == 0) {
-			_curTile[col + 1] [row] = _curTile[col] [row];
-			_curTile[col] [row] = 0;
+		if (_curTile[col + 1][row] == 0) {
+			_curTile[col + 1][row] = _curTile[col][row];
+			_curTile[col][row] = 0;
 			scrolltype = LEFTSCROLL;
 		}
 	}
@@ -132,7 +132,7 @@ void LabEngine::changeTile(uint16 col, uint16 row) {
 
 		while (row < 4) {
 			while (col < 4) {
-				check = check && (_curTile[row] [col] == SOLUTION[row] [col]);
+				check &= (_curTile[row][col] == SOLUTION[row][col]);
 				col++;
 			}
 
@@ -204,9 +204,9 @@ void LabEngine::doTile(bool showsolution) {
 	while (row < 4) {
 		while (col < 4) {
 			if (showsolution)
-				num = SOLUTION[col] [row];
+				num = SOLUTION[col][row];
 			else
-				num = _curTile[col] [row];
+				num = _curTile[col][row];
 
 			if (showsolution || num)
 				_tiles[num]->drawImage(cols + (col * colm), rows + (row * rowm));
@@ -316,7 +316,7 @@ void LabEngine::changeCombination(uint16 number) {
 	}
 
 	for (uint16 i = 0; i < 6; i++)
-		unlocked = (_combination[i] == solution[i]) && unlocked;
+		unlocked &= (_combination[i] == solution[i]);
 
 	if (unlocked)
 		_conditions->inclElement(COMBINATIONUNLOCKED);


Commit: 2d21f51c34e3cdb8dd2aa4d0364600e4bf7e488a
    https://github.com/scummvm/scummvm/commit/2d21f51c34e3cdb8dd2aa4d0364600e4bf7e488a
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:54+01:00

Commit Message:
LAB: Some cleanup of the transition code

Changed paths:
    engines/lab/transitions.cpp



diff --git a/engines/lab/transitions.cpp b/engines/lab/transitions.cpp
index 11064c1..80a24dd 100644
--- a/engines/lab/transitions.cpp
+++ b/engines/lab/transitions.cpp
@@ -250,59 +250,48 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 		lastY = 148;
 	}
 
-	for (uint16 i = 0; i < 2; i++) {
-		curY = i * 2;
-
-		while (curY < lastY) {
-			if (linesdone >= lineslast) {
-				_vm->_music->updateMusic();
-				_vm->waitTOF();
-				linesdone = 0;
-			}
-
-			overlayRect(0, 0, curY, _screenWidth - 1, curY + 1);
-			curY += 4;
-			linesdone++;
-		}
-	}
-
-	setAPen(0);
+	for (uint16 j = 0; j < 2; j++) {
+		for (uint16 i = 0; i < 2; i++) {
+			curY = i * 2;
 
-	for (uint16 i = 0; i < 2; i++) {
-		curY = i * 2;
+			while (curY < lastY) {
+				if (linesdone >= lineslast) {
+					_vm->_music->updateMusic();
+					_vm->waitTOF();
+					linesdone = 0;
+				}
 
-		while (curY <= lastY) {
-			if (linesdone >= lineslast) {
-				_vm->_music->updateMusic();
-				_vm->waitTOF();
-				linesdone = 0;
-			}
+				if (j == 9)
+					overlayRect(0, 0, curY, _screenWidth - 1, curY + 1);
+				else
+					rectFill(0, curY, _screenWidth - 1, curY + 1);
+				curY += 4;
+				linesdone++;
+			}	// while
+		}	// for i
 
-			rectFill(0, curY, _screenWidth - 1, curY + 1);
-			curY += 4;
-			linesdone++;
-		}
-	}
+		setAPen(0);
+	}	// for j
 
 	if (filename == NULL)
-		_vm->_curFileName = _vm->getPictName(cPtr);
+		_vm->_curFileName = g_lab->getPictName(cPtr);
 	else if (filename[0] > ' ')
 		_vm->_curFileName = filename;
 	else
-		_vm->_curFileName = _vm->getPictName(cPtr);
+		_vm->_curFileName = g_lab->getPictName(cPtr);
 
 	byte *BitMapMem = readPictToMem(_vm->_curFileName, _screenWidth, lastY + 5);
 	setPalette(_vm->_anim->_diffPalette, 256);
 
-	if (BitMapMem) {
-		imSource._width = _screenWidth;
-		imSource._height = lastY;
-		imSource._imageData = BitMapMem;
+	imSource._width = _screenWidth;
+	imSource._height = lastY;
+	imSource._imageData = BitMapMem;
 
-		imDest._width = _screenWidth;
-		imDest._height = _screenHeight;
-		imDest._imageData = getCurrentDrawingBuffer();
+	imDest._width = _screenWidth;
+	imDest._height = _screenHeight;
+	imDest._imageData = getCurrentDrawingBuffer();
 
+	for (uint16 j = 0; j < 2; j++) {
 		for (uint16 i = 0; i < 2; i++) {
 			curY = i * 2;
 
@@ -315,35 +304,18 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 
 				imDest._imageData = getCurrentDrawingBuffer();
 
-				imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, 2, false);
-				overlayRect(0, 0, curY, _screenWidth - 1, curY + 1);
-				curY += 4;
-				linesdone++;
-			}
-		}
-
-		for (uint16 i = 0; i < 2; i++) {
-			curY = i * 2;
-
-			while (curY <= lastY) {
-				if (linesdone >= lineslast) {
-					_vm->_music->updateMusic();
-					_vm->waitTOF();
-					linesdone = 0;
-				}
-
-				imDest._imageData = getCurrentDrawingBuffer();
-
-				if (curY == lastY)
-					imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, 1, false);
-				else
+				if (j == 0) {
 					imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, 2, false);
-
+					overlayRect(0, 0, curY, _screenWidth - 1, curY + 1);
+				} else {
+					uint16 bitmapHeight = (curY == lastY) ? 1 : 2;
+					imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, bitmapHeight, false);
+				}
 				curY += 4;
 				linesdone++;
-			}
-		}
-	}
+			}	// while
+		}	// for i
+	}	// for j
 }
 
 /*****************************************************************************/


Commit: daf06557547066b1068f974ee37f69ecee975e7c
    https://github.com/scummvm/scummvm/commit/daf06557547066b1068f974ee37f69ecee975e7c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:54+01:00

Commit Message:
LAB: Use SWAP<> to simplify the transition code

Changed paths:
    engines/lab/transitions.cpp



diff --git a/engines/lab/transitions.cpp b/engines/lab/transitions.cpp
index 80a24dd..b7d8e8c 100644
--- a/engines/lab/transitions.cpp
+++ b/engines/lab/transitions.cpp
@@ -386,21 +386,14 @@ void DisplayMan::blackAllScreen() {
 /*****************************************************************************/
 void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	Image im;
-	uint16 temp;
 
 	im._imageData = _tempScrollData;
 
-	if (x1 > x2) {
-		temp = x2;
-		x2 = x1;
-		x1 = temp;
-	}
+	if (x1 > x2)
+		SWAP<uint16>(x1, x2);
 
-	if (y1 > y2) {
-		temp = y2;
-		y2 = y1;
-		y1 = temp;
-	}
+	if (y1 > y2)
+		SWAP<uint16>(y1, y2);
 
 	im._width = x2 - x1 + 1 - dx;
 	im._height = y2 - y1 + 1;
@@ -417,21 +410,14 @@ void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint1
 /*****************************************************************************/
 void DisplayMan::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	Image im;
-	uint16 temp;
 
 	im._imageData = _tempScrollData;
 
-	if (x1 > x2) {
-		temp = x2;
-		x2 = x1;
-		x1 = temp;
-	}
+	if (x1 > x2)
+		SWAP<uint16>(x1, x2);
 
-	if (y1 > y2) {
-		temp = y2;
-		y2 = y1;
-		y1 = temp;
-	}
+	if (y1 > y2)
+		SWAP<uint16>(y1, y2);
 
 	im._width = x2 - x1 + 1;
 	im._height = y2 - y1 + 1 - dy;


Commit: 00d61638ac02f54de21664303af3a726bc921860
    https://github.com/scummvm/scummvm/commit/00d61638ac02f54de21664303af3a726bc921860
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:54+01:00

Commit Message:
LAB: Merge parsetypes.h and parsefun.h into processroom.h

Changed paths:
  A engines/lab/processroom.h
  R engines/lab/parsefun.h
  R engines/lab/parsetypes.h
    engines/lab/detection.cpp
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/graphics.h
    engines/lab/lab.h
    engines/lab/labfun.h
    engines/lab/map.cpp
    engines/lab/processroom.cpp
    engines/lab/special.cpp
    engines/lab/transitions.cpp



diff --git a/engines/lab/detection.cpp b/engines/lab/detection.cpp
index 3b01d77..b61b4e4 100644
--- a/engines/lab/detection.cpp
+++ b/engines/lab/detection.cpp
@@ -30,7 +30,6 @@
 
 #include "engines/advancedDetector.h"
 
-#include "common/system.h"
 #include "common/str-array.h"
 #include "common/savefile.h"
 
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 07c49d5..d2e7a55 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -33,7 +33,7 @@
 #include "lab/anim.h"
 #include "lab/image.h"
 #include "lab/intro.h"
-#include "lab/parsefun.h"
+#include "lab/processroom.h"
 #include "lab/interface.h"
 #include "lab/resource.h"
 
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 80eae97..8da54cc 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -30,10 +30,9 @@
 
 #include "lab/lab.h"
 #include "lab/anim.h"
-#include "lab/parsetypes.h"
 #include "lab/image.h"
 #include "lab/labfun.h"
-#include "lab/parsefun.h"
+#include "lab/processroom.h"
 #include "lab/resource.h"
 #include "lab/graphics.h"
 
diff --git a/engines/lab/graphics.h b/engines/lab/graphics.h
index 1bfc027..9c25295 100644
--- a/engines/lab/graphics.h
+++ b/engines/lab/graphics.h
@@ -33,6 +33,7 @@
 
 #include "graphics/palette.h"
 #include "lab/anim.h"
+#include "lab/processroom.h"
 
 namespace Lab {
 
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index af93367..fb2d20d 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -33,6 +33,7 @@
 
 #include "common/array.h"
 #include "common/events.h"
+#include "common/system.h"
 
 #include "engines/engine.h"
 #include "lab/labfun.h"
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index e67d0f7..e0a3b08 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -32,11 +32,8 @@
 #define LAB_LABFUN_H
 
 #include "common/events.h"
-#include "lab/parsetypes.h"
-
 #include "common/file.h"
 #include "common/savefile.h"
-
 #include "engines/savestate.h"
 
 namespace Lab {
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 4136b28..8c71d1a 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -32,8 +32,7 @@
 #include "lab/labfun.h"
 #include "lab/anim.h"
 #include "lab/image.h"
-#include "lab/parsefun.h"
-#include "lab/parsetypes.h"
+#include "lab/processroom.h"
 #include "lab/resource.h"
 #include "lab/interface.h"
 
diff --git a/engines/lab/parsefun.h b/engines/lab/parsefun.h
deleted file mode 100644
index 78f7904..0000000
--- a/engines/lab/parsefun.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#ifndef LAB_PARSEFUN_H
-#define LAB_PARSEFUN_H
-
-#include "lab/labfun.h"
-#include "lab/parsetypes.h"
-
-namespace Lab {
-
-/* From Parser.c */
-
-bool parse(const char *inputFile);
-
-/* From ProcessRoom.c */
-
-ViewData *getViewData(uint16 roomNum, uint16 direction);
-void drawDirection(CloseDataPtr lcptr);
-uint16 processArrow(uint16 curDirection, uint16 arrow);
-void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords = false);
-bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr);
-bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *lcptr);
-bool doOperateRule(int16 x, int16 y, int16 itemNum, CloseDataPtr *lcptr);
-bool doGoForward(CloseDataPtr *lcptr);
-bool doTurn(uint16 from, uint16 to, CloseDataPtr *lcptr);
-bool doMainView(CloseDataPtr *lcptr);
-
-} // End of namespace Lab
-
-#endif /* LAB_PARSEFUN_H */
diff --git a/engines/lab/parsetypes.h b/engines/lab/parsetypes.h
deleted file mode 100644
index 1f03bc3..0000000
--- a/engines/lab/parsetypes.h
+++ /dev/null
@@ -1,196 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#ifndef LAB_PARSETYPES_H
-#define LAB_PARSETYPES_H
-
-#include "common/system.h"
-
-namespace Lab {
-
-/*------------------------------- Action types ------------------------------*/
-#define PLAYSOUND     1
-#define PLAYSOUNDCONT 2
-#define SHOWDIFF      3
-#define SHOWDIFFCONT  4
-#define LOADDIFF      5
-#define LOADBM        6
-#define SHOWBM        7
-#define TRANSITION    8
-#define NOUPDATE      9
-#define FORCEUPDATE  10
-#define SHOWCURPICT  11
-#define SETELEMENT   12
-#define UNSETELEMENT 13
-#define SHOWMESSAGE  14
-#define SHOWMESSAGES 15
-#define SETPOSITION  16
-#define SETCLOSEUP   17
-#define MAINVIEW     18
-#define SUBINV       19
-#define ADDINV       20
-#define SHOWDIR      21
-#define WAITSECS     22
-#define STOPMUSIC    23
-#define STARTMUSIC   24
-#define CHANGEMUSIC  25
-#define RESETMUSIC   26
-#define FILLMUSIC    27
-#define WAITSOUND    28
-#define CLEARSOUND   29
-#define WINMUSIC     30
-#define WINGAME      31
-#define LOSTGAME     32
-#define RESETBUFFER  33
-#define SPECIALCMD   34
-#define CSHOWMESSAGE 35
-#define PLAYSOUNDB   36
-
-/* Rule Types */
-#define ACTION      1
-#define OPERATE     2
-#define GOFORWARD   3
-#define CONDITIONS  4
-#define TURN        5
-#define GOMAINVIEW  6
-#define TURNFROMTO  7
-
-/*----------------------------- Rule Type Action ----------------------------*/
-#define TAKE        1
-#define MOVE        2
-#define OPENDOOR    3
-#define CLOSEDOOR   4
-#define TAKEDEF     5
-
-#if defined(WIN32)
-#pragma pack(push, 1)
-#endif
-
-typedef struct CloseData {
-	uint16 x1, y1, x2, y2;
-	int16 _closeUpType;          /* if > 0, an object.  If < 0, an item */
-	uint16 _depth;               /* Level of the closeup. */
-	char *_graphicName;
-	char *_message;
-	CloseData *_nextCloseUp;
-	CloseData *_subCloseUps;
-} CloseData;
-
-typedef CloseData *CloseDataPtr;
-
-struct ViewData {
-	int16 *_condition;
-	char *_graphicName;
-	struct ViewData *_nextCondition;
-	CloseDataPtr _closeUps;
-};
-
-struct Action {
-	int16 _actionType;
-	int16 _param1;
-	int16 _param2;
-	int16 _param3;
-	byte *_data;            /* Message, or a pointer to array of messages. */
-	Action *_nextAction;
-};
-
-struct Rule {
-	int16 _ruleType;
-	int16 _param1;
-	int16 _param2;
-	int16 *_condition;
-	Action *_actionList;
-	Rule *_nextRule;
-};
-
-typedef Common::List<Rule *> RuleList;
-
-struct RoomData {
-	uint16 _northDoor;
-	uint16 _southDoor;
-	uint16 _eastDoor;
-	uint16 _westDoor;
-	byte _transitionType;
-	ViewData *_view[4];
-	RuleList *_rules;
-	char *_roomMsg;
-};
-
-struct InventoryData {
-	uint16 _many;
-	char *_name;
-	char *_bitmapName;
-};
-
-/* Map Flags */
-
-/* Where the doors are; in a corridor, assumed to be left doors */
-#define     NORTHDOOR        1L
-#define     EASTDOOR         2L
-#define     SOUTHDOOR        4L
-#define     WESTDOOR         8L
-
-/* Where the doors are in corridors; M means middle, R means right, B means bottom */
-#define     NORTHMDOOR      16L
-#define     NORTHRDOOR      32L
-#define     SOUTHMDOOR      64L
-#define     SOUTHRDOOR     128L
-
-#define     EASTMDOOR       16L
-#define     EASTBDOOR       32L
-#define     WESTMDOOR       64L
-#define     WESTBDOOR      128L
-
-/* Special Map ID's */
-#define     NORMAL           0
-#define     UPARROWROOM      1
-#define     DOWNARROWROOM    2
-#define     BRIDGEROOM       3
-#define     VCORRIDOR        4
-#define     HCORRIDOR        5
-#define     MEDMAZE          6
-#define     HEDGEMAZE        7
-#define     SURMAZE          8
-#define     MULTIMAZEF1      9
-#define     MULTIMAZEF2     10
-#define     MULTIMAZEF3     11
-
-struct MapData {
-	uint16 x, y, PageNumber, SpecialID;
-	uint32 MapFlags;
-};
-
-#if defined(WIN32)
-#pragma pack(pop)
-#endif
-
-} // End of namespace Lab
-
-#endif /* LAB_PARSETYPES_H */
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 8afa543..fa270de 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -32,8 +32,7 @@
 
 #include "lab/lab.h"
 #include "lab/labfun.h"
-#include "lab/parsetypes.h"
-#include "lab/parsefun.h"
+#include "lab/processroom.h"
 #include "lab/resource.h"
 #include "lab/anim.h"
 #include "lab/interface.h"
diff --git a/engines/lab/processroom.h b/engines/lab/processroom.h
new file mode 100644
index 0000000..d69dae1
--- /dev/null
+++ b/engines/lab/processroom.h
@@ -0,0 +1,206 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#ifndef LAB_PROCESSROOM_H
+#define LAB_PROCESSROOM_H
+
+namespace Lab {
+
+	/*------------------------------- Action types ------------------------------*/
+#define PLAYSOUND     1
+#define PLAYSOUNDCONT 2
+#define SHOWDIFF      3
+#define SHOWDIFFCONT  4
+#define LOADDIFF      5
+#define LOADBM        6
+#define SHOWBM        7
+#define TRANSITION    8
+#define NOUPDATE      9
+#define FORCEUPDATE  10
+#define SHOWCURPICT  11
+#define SETELEMENT   12
+#define UNSETELEMENT 13
+#define SHOWMESSAGE  14
+#define SHOWMESSAGES 15
+#define SETPOSITION  16
+#define SETCLOSEUP   17
+#define MAINVIEW     18
+#define SUBINV       19
+#define ADDINV       20
+#define SHOWDIR      21
+#define WAITSECS     22
+#define STOPMUSIC    23
+#define STARTMUSIC   24
+#define CHANGEMUSIC  25
+#define RESETMUSIC   26
+#define FILLMUSIC    27
+#define WAITSOUND    28
+#define CLEARSOUND   29
+#define WINMUSIC     30
+#define WINGAME      31
+#define LOSTGAME     32
+#define RESETBUFFER  33
+#define SPECIALCMD   34
+#define CSHOWMESSAGE 35
+#define PLAYSOUNDB   36
+
+	/* Rule Types */
+#define ACTION      1
+#define OPERATE     2
+#define GOFORWARD   3
+#define CONDITIONS  4
+#define TURN        5
+#define GOMAINVIEW  6
+#define TURNFROMTO  7
+
+	/*----------------------------- Rule Type Action ----------------------------*/
+#define TAKE        1
+#define MOVE        2
+#define OPENDOOR    3
+#define CLOSEDOOR   4
+#define TAKEDEF     5
+
+#if defined(WIN32)
+#pragma pack(push, 1)
+#endif
+
+typedef struct CloseData {
+	uint16 x1, y1, x2, y2;
+	int16 _closeUpType;          /* if > 0, an object.  If < 0, an item */
+	uint16 _depth;               /* Level of the closeup. */
+	char *_graphicName;
+	char *_message;
+	CloseData *_nextCloseUp;
+	CloseData *_subCloseUps;
+} CloseData;
+
+typedef CloseData *CloseDataPtr;
+
+struct ViewData {
+	int16 *_condition;
+	char *_graphicName;
+	struct ViewData *_nextCondition;
+	CloseDataPtr _closeUps;
+};
+
+struct Action {
+	int16 _actionType;
+	int16 _param1;
+	int16 _param2;
+	int16 _param3;
+	byte *_data;            /* Message, or a pointer to array of messages. */
+	Action *_nextAction;
+};
+
+struct Rule {
+	int16 _ruleType;
+	int16 _param1;
+	int16 _param2;
+	int16 *_condition;
+	Action *_actionList;
+	Rule *_nextRule;
+};
+
+typedef Common::List<Rule *> RuleList;
+
+struct RoomData {
+	uint16 _northDoor;
+	uint16 _southDoor;
+	uint16 _eastDoor;
+	uint16 _westDoor;
+	byte _transitionType;
+	ViewData *_view[4];
+	RuleList *_rules;
+	char *_roomMsg;
+};
+
+struct InventoryData {
+	uint16 _many;
+	char *_name;
+	char *_bitmapName;
+};
+
+/* Map Flags */
+
+/* Where the doors are; in a corridor, assumed to be left doors */
+#define     NORTHDOOR        1L
+#define     EASTDOOR         2L
+#define     SOUTHDOOR        4L
+#define     WESTDOOR         8L
+
+/* Where the doors are in corridors; M means middle, R means right, B means bottom */
+#define     NORTHMDOOR      16L
+#define     NORTHRDOOR      32L
+#define     SOUTHMDOOR      64L
+#define     SOUTHRDOOR     128L
+
+#define     EASTMDOOR       16L
+#define     EASTBDOOR       32L
+#define     WESTMDOOR       64L
+#define     WESTBDOOR      128L
+
+/* Special Map ID's */
+#define     NORMAL           0
+#define     UPARROWROOM      1
+#define     DOWNARROWROOM    2
+#define     BRIDGEROOM       3
+#define     VCORRIDOR        4
+#define     HCORRIDOR        5
+#define     MEDMAZE          6
+#define     HEDGEMAZE        7
+#define     SURMAZE          8
+#define     MULTIMAZEF1      9
+#define     MULTIMAZEF2     10
+#define     MULTIMAZEF3     11
+
+struct MapData {
+	uint16 x, y, PageNumber, SpecialID;
+	uint32 MapFlags;
+};
+
+#if defined(WIN32)
+#pragma pack(pop)
+#endif
+
+bool parse(const char *inputFile);
+ViewData *getViewData(uint16 roomNum, uint16 direction);
+void drawDirection(CloseDataPtr lcptr);
+uint16 processArrow(uint16 curDirection, uint16 arrow);
+void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords = false);
+bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr);
+bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *lcptr);
+bool doOperateRule(int16 x, int16 y, int16 itemNum, CloseDataPtr *lcptr);
+bool doGoForward(CloseDataPtr *lcptr);
+bool doTurn(uint16 from, uint16 to, CloseDataPtr *lcptr);
+bool doMainView(CloseDataPtr *lcptr);
+
+} // End of namespace Lab
+
+#endif /* LAB_PROCESSROOM_H */
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 41fcad7..469d8ab 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -36,10 +36,9 @@
 #include "lab/lab.h"
 #include "lab/labfun.h"
 #include "lab/image.h"
-#include "lab/parsefun.h"
+#include "lab/processroom.h"
 #include "lab/interface.h"
 #include "lab/anim.h"
-#include "lab/parsetypes.h"
 #include "lab/resource.h"
 
 namespace Lab {
diff --git a/engines/lab/transitions.cpp b/engines/lab/transitions.cpp
index b7d8e8c..c8a497c 100644
--- a/engines/lab/transitions.cpp
+++ b/engines/lab/transitions.cpp
@@ -29,7 +29,7 @@
  */
 
 #include "lab/lab.h"
-#include "lab/parsefun.h"
+#include "lab/processroom.h"
 #include "lab/graphics.h"
 
 namespace Lab {


Commit: 73eb0d2f284809d6bec2336d0647e9905368c3cd
    https://github.com/scummvm/scummvm/commit/73eb0d2f284809d6bec2336d0647e9905368c3cd
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:55+01:00

Commit Message:
LAB: Revert incorrect change

Changed paths:
    engines/lab/transitions.cpp



diff --git a/engines/lab/transitions.cpp b/engines/lab/transitions.cpp
index c8a497c..7090181 100644
--- a/engines/lab/transitions.cpp
+++ b/engines/lab/transitions.cpp
@@ -274,11 +274,11 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 	}	// for j
 
 	if (filename == NULL)
-		_vm->_curFileName = g_lab->getPictName(cPtr);
+		_vm->_curFileName = _vm->getPictName(cPtr);
 	else if (filename[0] > ' ')
 		_vm->_curFileName = filename;
 	else
-		_vm->_curFileName = g_lab->getPictName(cPtr);
+		_vm->_curFileName = _vm->getPictName(cPtr);
 
 	byte *BitMapMem = readPictToMem(_vm->_curFileName, _screenWidth, lastY + 5);
 	setPalette(_vm->_anim->_diffPalette, 256);


Commit: 6b9264d9da41d8be08ea46076026901374d3d106
    https://github.com/scummvm/scummvm/commit/6b9264d9da41d8be08ea46076026901374d3d106
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:55+01:00

Commit Message:
LAB: Refactoring the vgaUnscale code and the way it's used

Changed paths:
    engines/lab/tilepuzzle.cpp
    engines/lab/utils.cpp
    engines/lab/utils.h



diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index cdc6735..2739473 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -66,17 +66,16 @@ void LabEngine::initTilePuzzle() {
 /* Processes mouse clicks and changes the combination.                       */
 /*****************************************************************************/
 void LabEngine::mouseTile(Common::Point pos) {
-	int x = _utils->vgaUnscaleX(pos.x);
-	int y = _utils->vgaUnscaleY(pos.y);
+	Common::Point realPos = _utils->vgaUnscale(pos);
 
-	if ((x < 101) || (y < 26))
+	if ((realPos.x < 101) || (realPos.y < 26))
 		return;
 
-	x = (x - 101) / 30;
-	y = (y -  26) / 25;
+	int tileX = (realPos.x - 101) / 30;
+	int tileY = (realPos.y -  26) / 25;
 
-	if ((x < 4) && (y < 4))
-		changeTile(x, y);
+	if ((tileX < 4) && (tileY < 4))
+		changeTile(tileX, tileY);
 }
 
 /*****************************************************************************/
@@ -152,29 +151,26 @@ void LabEngine::changeTile(uint16 col, uint16 row) {
 /* Processes mouse clicks and changes the combination.                       */
 /*****************************************************************************/
 void LabEngine::mouseCombination(Common::Point pos) {
-	uint16 number;
-
-	int x = _utils->vgaUnscaleX(pos.x);
-	int y = _utils->vgaUnscaleY(pos.y);
-
-	if ((y >= 63) && (y <= 99)) {
-		if ((x >= 44) && (x < 83))
-			number = 0;
-		else if (x < 127)
-			number = 1;
-		else if (x < 165)
-			number = 2;
-		else if (x < 210)
-			number = 3;
-		else if (x < 245)
-			number = 4;
-		else if (x < 286)
-			number = 5;
-		else
-			return;
+	Common::Point realPos = _utils->vgaUnscale(pos);
 
-		changeCombination(number);
-	}
+	if (!Common::Rect(44, 63, 285, 99).contains(realPos))
+		return;
+
+	uint16 number = 0;
+	if (realPos.x < 83)
+		number = 0;
+	else if (realPos.x < 127)
+		number = 1;
+	else if (realPos.x < 165)
+		number = 2;
+	else if (realPos.x < 210)
+		number = 3;
+	else if (realPos.x < 245)
+		number = 4;
+	else if (realPos.x < 286)
+		number = 5;
+
+	changeCombination(number);
 }
 
 /*****************************************************************************/
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index 6d4784d..041a970 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -59,7 +59,7 @@ uint16 Utils::scaleY(uint16 y) {
 }
 
 /*****************************************************************************/
-/* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
+/* Scales the VGA coords to SVGA if necessary; otherwise, returns VGA coords.*/
 /*****************************************************************************/
 int16 Utils::vgaScaleX(int16 x) {
 	if (_vm->_isHiRes)
@@ -69,7 +69,7 @@ int16 Utils::vgaScaleX(int16 x) {
 }
 
 /*****************************************************************************/
-/* Scales the VGA cords to SVGA if necessary; otherwise, returns VGA cords.  */
+/* Scales the VGA coords to SVGA if necessary; otherwise, returns VGA coords.*/
 /*****************************************************************************/
 int16 Utils::vgaScaleY(int16 y) {
 	if (_vm->_isHiRes)
@@ -86,23 +86,18 @@ uint16 Utils::svgaCord(uint16 cord) {
 }
 
 /*****************************************************************************/
-/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
+/* Converts SVGA coords to VGA if necessary, otherwise returns VGA coords.   */
 /*****************************************************************************/
-int Utils::vgaUnscaleX(int x) {
-	if (_vm->_isHiRes)
-		return (x / 2);
-	else
-		return x;
-}
+Common::Point Utils::vgaUnscale(Common::Point pos) {
+	Common::Point result;
+	if (_vm->_isHiRes) {
+		result.x = pos.x / 2;
+		result.y = (pos.y * 5) / 12;
+	} else {
+		result = pos;
+	}
 
-/*****************************************************************************/
-/* Converts SVGA cords to VGA if necessary, otherwise returns VGA cords.     */
-/*****************************************************************************/
-int Utils::vgaUnscaleY(int y) {
-	if (_vm->_isHiRes)
-		return ((y * 5) / 12);
-	else
-		return y;
+	return result;
 }
 
 /*****************************************************************************/
diff --git a/engines/lab/utils.h b/engines/lab/utils.h
index 4fa168d..4414736 100644
--- a/engines/lab/utils.h
+++ b/engines/lab/utils.h
@@ -52,8 +52,7 @@ public:
 	int16 vgaScaleX(int16 x);
 	int16 vgaScaleY(int16 y);
 	uint16 svgaCord(uint16 cord);
-	int vgaUnscaleX(int x);
-	int vgaUnscaleY(int y);
+	Common::Point vgaUnscale(Common::Point pos);
 	void unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesperrow, bool isV);
 	void runLengthDecode(byte *dest, byte *source);
 	void VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow);


Commit: 9cc70b6f03ecaafdf8696a03e74dce11942cb07e
    https://github.com/scummvm/scummvm/commit/9cc70b6f03ecaafdf8696a03e74dce11942cb07e
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:55+01:00

Commit Message:
LAB: Some more refactoring and renaming

Changed paths:
    engines/lab/interface.cpp
    engines/lab/tilepuzzle.cpp



diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 09c3fc8..7f6776a 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -39,12 +39,10 @@ namespace Lab {
 Common::KeyState _keyPressed;
 
 Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt) {
-	Gadget *gptr;
+	Gadget *gptr = new Gadget();
 
-	x = g_lab->_utils->vgaScaleX(x);
-
-	if ((gptr = new Gadget())) {
-		gptr->x = x;
+	if (gptr) {
+		gptr->x = g_lab->_utils->vgaScaleX(x);
 		gptr->y = y;
 		gptr->_gadgetID = id;
 		gptr->_keyEquiv = key;
@@ -53,12 +51,9 @@ Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image
 
 		return gptr;
 	} else
-		return NULL;
+		return nullptr;
 }
 
-
-
-
 void freeButtonList(GadgetList *gadgetList) {
 	for (GadgetList::iterator gadget = gadgetList->begin(); gadget != gadgetList->end(); ++gadget) {
 		delete *gadget;
@@ -67,9 +62,6 @@ void freeButtonList(GadgetList *gadgetList) {
 	gadgetList->clear();
 }
 
-
-
-
 /*****************************************************************************/
 /* Draws a gadget list to the screen.                                        */
 /*****************************************************************************/
@@ -82,7 +74,6 @@ void drawGadgetList(GadgetList *gadgetList) {
 	}
 }
 
-
 /*****************************************************************************/
 /* Dims a gadget, and makes it unavailable for using.                        */
 /*****************************************************************************/
@@ -91,8 +82,6 @@ void disableGadget(Gadget *curgad, uint16 pencolor) {
 	curgad->_flags |= GADGETOFF;
 }
 
-
-
 /*****************************************************************************/
 /* Undims a gadget, and makes it available again.                            */
 /*****************************************************************************/
@@ -101,7 +90,6 @@ void enableGadget(Gadget *curgad) {
 	curgad->_flags &= !(GADGETOFF);
 }
 
-
 /*****************************************************************************/
 /* Make a key press have the right case for a gadget KeyEquiv value.         */
 /*****************************************************************************/
@@ -113,14 +101,14 @@ uint16 makeGadgetKeyEquiv(uint16 key) {
 }
 
 /*****************************************************************************/
-/* Checks whether or not the cords fall within one of the gadgets in a list  */
+/* Checks whether or not the coords fall within one of the gadgets in a list  */
 /* of gadgets.                                                               */
 /*****************************************************************************/
 Gadget *LabEngine::checkNumGadgetHit(GadgetList *gadgetList, uint16 key) {
 	uint16 gkey = key - '0';
 
 	if (!gadgetList)
-		return NULL;
+		return nullptr;
 
 	for (GadgetList::iterator gadgetItr = gadgetList->begin(); gadgetItr != gadgetList->end(); ++gadgetItr) {
 		Gadget *gadget = *gadgetItr;
@@ -145,26 +133,24 @@ Gadget *LabEngine::checkNumGadgetHit(GadgetList *gadgetList, uint16 key) {
 IntuiMessage IMessage;
 
 IntuiMessage *LabEngine::getMsg() {
-	Gadget *curgad;
-	int Qualifiers;
-
 	_event->updateMouse();
 
-	Qualifiers = _keyPressed.flags;
+	int qualifiers = _keyPressed.flags;
+	Gadget *curgad  = _event->mouseGadget();
 
-	if ((curgad = _event->mouseGadget()) != NULL) {
+	if (curgad) {
 		_event->updateMouse();
 		IMessage._msgClass = GADGETUP;
 		IMessage._code  = curgad->_gadgetID;
 		IMessage._gadgetID = curgad->_gadgetID;
-		IMessage._qualifier = Qualifiers;
+		IMessage._qualifier = qualifiers;
 		return &IMessage;
 	} else if (_event->mouseButton(&IMessage._mouseX, &IMessage._mouseY, true)) { /* Left Button */
-		IMessage._qualifier = IEQUALIFIER_LEFTBUTTON | Qualifiers;
+		IMessage._qualifier = IEQUALIFIER_LEFTBUTTON | qualifiers;
 		IMessage._msgClass = MOUSEBUTTONS;
 		return &IMessage;
 	} else if (_event->mouseButton(&IMessage._mouseX, &IMessage._mouseY, false)) { /* Right Button */
-		IMessage._qualifier = IEQUALIFIER_RBUTTON | Qualifiers;
+		IMessage._qualifier = IEQUALIFIER_RBUTTON | qualifiers;
 		IMessage._msgClass = MOUSEBUTTONS;
 		return &IMessage;
 	} else if (_event->keyPress(&IMessage._code)) { /* Keyboard key */
@@ -177,10 +163,10 @@ IntuiMessage *LabEngine::getMsg() {
 		} else
 			IMessage._msgClass = RAWKEY;
 
-		IMessage._qualifier = Qualifiers;
+		IMessage._qualifier = qualifiers;
 		return &IMessage;
 	} else
-		return NULL;
+		return nullptr;
 }
 
 } // End of namespace Lab
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index 2739473..4d95d4c 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -243,7 +243,7 @@ void LabEngine::showTile(const char *filename, bool showsolution) {
 /*****************************************************************************/
 void LabEngine::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 	int16 dX = 0, dY = 0, dx = 0, dy = 0, sx = 0, sy = 0;
-	uint16 last = 0, x1, y1;
+	uint16 last = 0;
 
 	if (scrolltype == LEFTSCROLL) {
 		dX = _utils->vgaScaleX(5);
@@ -267,8 +267,8 @@ void LabEngine::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 
 	sx += _utils->svgaCord(2);
 
-	x1 = _utils->vgaScaleX(100) + (col * _utils->vgaScaleX(30)) + dx;
-	y1 = _utils->vgaScaleY(25) + (row * _utils->vgaScaleY(25)) + dy;
+	uint16 x1 = _utils->vgaScaleX(100) + (col * _utils->vgaScaleX(30)) + dx;
+	uint16 y1 = _utils->vgaScaleY(25) + (row * _utils->vgaScaleY(25)) + dy;
 
 	for (uint16 i = 0; i < last; i++) {
 		waitTOF();


Commit: 3a1ee647610efa61a053d7f2fc0951e6248cb915
    https://github.com/scummvm/scummvm/commit/3a1ee647610efa61a053d7f2fc0951e6248cb915
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:55+01:00

Commit Message:
LAB: Review spacing

Changed paths:
    engines/lab/anim.cpp
    engines/lab/detection.cpp
    engines/lab/engine.cpp
    engines/lab/eventman.cpp
    engines/lab/graphics.cpp
    engines/lab/image.h
    engines/lab/interface.cpp
    engines/lab/intro.cpp
    engines/lab/lab.h
    engines/lab/labsets.h
    engines/lab/map.cpp
    engines/lab/processroom.cpp
    engines/lab/savegame.cpp
    engines/lab/special.cpp
    engines/lab/timing.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index a9e7860..d8b3b2f 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -247,17 +247,16 @@ void Anim::diffNextFrame() {
 /* A separate task launched by readDiff.  Plays the DIFF.                    */
 /*****************************************************************************/
 void Anim::playDiff(byte *buffer) {
-	_waitSec   = 0L;
+	_waitSec = 0L;
 	_waitMicros = 0L;
 	_delayMicros = 0L;
-	_header      = 0;
+	_header = 0;
 	_curBit = 0;
 	_frameNum = 0;
-	_numChunks   = 1;
-	_donePal     = false;
+	_numChunks = 1;
+	_donePal = false;
 	_stopPlayingEnd = false;
-
-	_isPlaying   = true;
+	_isPlaying = true;
 
 	if (_doBlack) {
 		_doBlack = false;
diff --git a/engines/lab/detection.cpp b/engines/lab/detection.cpp
index b61b4e4..67890da 100644
--- a/engines/lab/detection.cpp
+++ b/engines/lab/detection.cpp
@@ -102,14 +102,14 @@ static const ADGameDescription labDescriptions[] = {
 };
 
 static const char *const directoryGlobs[] = {
-        "fonts",
+		"fonts",
 		"game",
 		"pict",
 		"spict",
 		"rooms",
 		"h2",
 		"intro",
-        0
+		0
 };
 
 namespace Lab {
@@ -167,10 +167,9 @@ bool LabMetaEngine::hasFeature(MetaEngineFeature f) const {
 }
 
 bool Lab::LabEngine::hasFeature(EngineFeature f) const {
-    return
-        (f == kSupportsRTL);
-        //(f == kSupportsLoadingDuringRuntime) ||
-        //(f == kSupportsSavingDuringRuntime);
+	return (f == kSupportsRTL);
+	//(f == kSupportsLoadingDuringRuntime) ||
+	//(f == kSupportsSavingDuringRuntime);
 }
 
 SaveStateList LabMetaEngine::listSaves(const char *target) const {
@@ -186,17 +185,17 @@ SaveStateList LabMetaEngine::listSaves(const char *target) const {
 	SaveStateList saveList;
 
 	for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
-	        // Obtain the last 3 digits of the filename, since they correspond to the save slot
-	        int slotNum = atoi(file->c_str() + file->size() - 3);
+		// Obtain the last 3 digits of the filename, since they correspond to the save slot
+		int slotNum = atoi(file->c_str() + file->size() - 3);
 
-	        if (slotNum >= 0 && slotNum <= 999) {
-	            Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
-	            if (in) {
+		if (slotNum >= 0 && slotNum <= 999) {
+			Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
+			if (in) {
 					if (Lab::readSaveGameHeader(in, header))
-	                    saveList.push_back(SaveStateDescriptor(slotNum, header._descr.getDescription()));
-	                delete in;
-	            }
-	        }
+						saveList.push_back(SaveStateDescriptor(slotNum, header._descr.getDescription()));
+					delete in;
+			}
+		}
 	}
 
 	return saveList;
@@ -219,14 +218,14 @@ void LabMetaEngine::removeSaveState(const char *target, int slot) const {
 	Common::sort(filenames.begin(), filenames.end());   // Sort (hopefully ensuring we are sorted numerically..)
 
 	for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
-	    // Obtain the last 3 digits of the filename, since they correspond to the save slot
-	    int slotNum = atoi(file->c_str() + file->size() - 3);
-
-	    // Rename every slot greater than the deleted slot,
-	    if (slotNum > slot) {
-	        saveFileMan->renameSavefile(file->c_str(), filename.c_str());
-	        filename = Common::String::format("%s.%03u", target, ++slot);
-	    }
+		// Obtain the last 3 digits of the filename, since they correspond to the save slot
+		int slotNum = atoi(file->c_str() + file->size() - 3);
+
+		// Rename every slot greater than the deleted slot,
+		if (slotNum > slot) {
+			saveFileMan->renameSavefile(file->c_str(), filename.c_str());
+			filename = Common::String::format("%s.%03u", target, ++slot);
+		}
 	}
 }
 
@@ -235,20 +234,20 @@ SaveStateDescriptor LabMetaEngine::querySaveMetaInfos(const char *target, int sl
 	Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename.c_str());
 
 	if (in) {
-	    Lab::SaveGameHeader header;
+		Lab::SaveGameHeader header;
 
 		bool successfulRead = Lab::readSaveGameHeader(in, header);
-	    delete in;
+		delete in;
 
-	    if (successfulRead) {
-	        SaveStateDescriptor desc(slot, header._descr.getDescription());
+		if (successfulRead) {
+			SaveStateDescriptor desc(slot, header._descr.getDescription());
 			// Do not allow save slot 0 (used for auto-saving) to be deleted or
 			// overwritten.
 			//desc.setDeletableFlag(slot != 0);
 			//desc.setWriteProtectedFlag(slot == 0);
 
-	        return header._descr;
-	    }
+			return header._descr;
+		}
 	}
 
 	return SaveStateDescriptor();
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index d2e7a55..3e76e16 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -452,8 +452,8 @@ void LabEngine::mainGameLoop() {
 					if ((_cptr->_closeUpType == SPECIALLOCK) && _mainDisplay)  /* LAB: Labyrinth specific code */
 						showCombination(_curFileName);
 					else if (((_cptr->_closeUpType == SPECIALBRICK)  ||
-					          (_cptr->_closeUpType == SPECIALBRICKNOMOUSE)) &&
-					         _mainDisplay) /* LAB: Labyrinth specific code */
+								  (_cptr->_closeUpType == SPECIALBRICKNOMOUSE)) &&
+								  _mainDisplay) /* LAB: Labyrinth specific code */
 						showTile(_curFileName, (bool)(_cptr->_closeUpType == SPECIALBRICKNOMOUSE));
 					else
 						_graphics->readPict(_curFileName, false);
@@ -558,7 +558,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 	if ((msgClass == RAWKEY) && (!_graphics->_longWinInFront)) {
 		if (code == 13) { /* The return key */
-			msgClass     = MOUSEBUTTONS;
+			msgClass = MOUSEBUTTONS;
 			Qualifier = IEQUALIFIER_LEFTBUTTON;
 			curPos = _event->getMousePos();
 		} else if (getPlatform() == Common::kPlatformWindows &&
@@ -568,8 +568,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			_droppingCrumbs = true;
 			mayShowCrumbIndicator();
 			_graphics->screenUpdate();
-		} else if (code == 'f' || code == 'F' ||
-		         code == 'r' || code == 'R') {  /* Follow bread crumbs */
+		} else if (code == 'f' || code == 'F' || code == 'r' || code == 'R') {  /* Follow bread crumbs */
 			if (_droppingCrumbs) {
 				if (_numCrumbs > 0) {
 					_followingCrumbs = true;
@@ -599,8 +598,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 					_graphics->screenUpdate();
 				}
 			}
-		} else if ((code == 315) || (code == 'x') || (code == 'X')
-		         || (code == 'q') || (code == 'Q')) {  /* Quit? */
+		} else if ((code == 315) || (code == 'x') || (code == 'X') || (code == 'q') || (code == 'Q')) {  /* Quit? */
 			_graphics->_doNotDrawMessage = false;
 			_graphics->drawMessage("Do you want to quit? (Y/N)");
 			doit = false;
@@ -645,10 +643,9 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 	}
 
 	if (_graphics->_longWinInFront) {
-		if ((msgClass == RAWKEY) ||
-		        ((msgClass == MOUSEBUTTONS) &&
-		         ((IEQUALIFIER_LEFTBUTTON & Qualifier) ||
-		          (IEQUALIFIER_RBUTTON & Qualifier)))) {
+		if ((msgClass == RAWKEY) || ((msgClass == MOUSEBUTTONS) &&
+			  ((IEQUALIFIER_LEFTBUTTON & Qualifier) ||
+				(IEQUALIFIER_RBUTTON & Qualifier)))) {
 			_graphics->_longWinInFront = false;
 			_graphics->_doNotDrawMessage = false;
 			_graphics->drawPanel();
@@ -857,8 +854,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 					curInv++;
 			}
 
-			if ((curInv <= _numInv) && _conditions->in(curInv) &&
-			        _inventory[curInv]._bitmapName)
+			if ((curInv <= _numInv) && _conditions->in(curInv) && _inventory[curInv]._bitmapName)
 				_nextFileName = getInvName(curInv);
 
 			_graphics->screenUpdate();
@@ -944,8 +940,8 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 					drawStaticMessage(kTextNothing);
 			} else if ((actionMode == 1) /* Manipulate an object */  ||
-			         (actionMode == 2) /* Open up a "door" */      ||
-			         (actionMode == 3)) { /* Close a "door" */
+						  (actionMode == 2) /* Open up a "door" */      ||
+						  (actionMode == 3)) { /* Close a "door" */
 				if (doActionRule(curPos, actionMode, _roomNum, &_cptr))
 					_curFileName = _newFileName;
 				else if (!doActionRule(curPos, actionMode, 0, &_cptr)) {
@@ -967,8 +963,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 						drawStaticMessage(kTextNothing);
 				} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 					drawStaticMessage(kTextNothing);
-			} else if ((actionMode == 5)  &&
-			         _conditions->in(curInv)) { /* Use an item on something else */
+			} else if ((actionMode == 5)  && _conditions->in(curInv)) { /* Use an item on something else */
 				if (doOperateRule(curPos.x, curPos.y, curInv, &_cptr)) {
 					_curFileName = _newFileName;
 
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 4c50cb7..b840c0a 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -34,21 +34,23 @@
 
 namespace Lab {
 
-static byte MouseData[] = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
-						   1, 7, 1, 0, 0, 0, 0, 0, 0, 0,
-						   1, 7, 7, 1, 0, 0, 0, 0, 0, 0,
-						   1, 7, 7, 7, 1, 0, 0, 0, 0, 0,
-						   1, 7, 7, 7, 7, 1, 0, 0, 0, 0,
-						   1, 7, 7, 7, 7, 7, 1, 0, 0, 0,
-						   1, 7, 7, 7, 7, 7, 7, 1, 0, 0,
-						   1, 7, 7, 7, 7, 7, 7, 7, 1, 0,
-						   1, 7, 7, 7, 7, 7, 1, 1, 1, 1,
-						   1, 7, 7, 1, 7, 7, 1, 0, 0, 0,
-						   1, 7, 1, 0, 1, 7, 7, 1, 0, 0,
-						   1, 1, 0, 0, 1, 7, 7, 1, 0, 0,
-						   0, 0, 0, 0, 0, 1, 7, 7, 1, 0,
-						   0, 0, 0, 0, 0, 1, 7, 7, 1, 0,
-						   0, 0, 0, 0, 0, 0, 1, 1, 0, 0};
+static byte MouseData[] = {
+	1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
+	1, 7, 1, 0, 0, 0, 0, 0, 0, 0,
+	1, 7, 7, 1, 0, 0, 0, 0, 0, 0,
+	1, 7, 7, 7, 1, 0, 0, 0, 0, 0,
+	1, 7, 7, 7, 7, 1, 0, 0, 0, 0,
+	1, 7, 7, 7, 7, 7, 1, 0, 0, 0,
+	1, 7, 7, 7, 7, 7, 7, 1, 0, 0,
+	1, 7, 7, 7, 7, 7, 7, 7, 1, 0,
+	1, 7, 7, 7, 7, 7, 1, 1, 1, 1,
+	1, 7, 7, 1, 7, 7, 1, 0, 0, 0,
+	1, 7, 1, 0, 1, 7, 7, 1, 0, 0,
+	1, 1, 0, 0, 1, 7, 7, 1, 0, 0,
+	0, 0, 0, 0, 0, 1, 7, 7, 1, 0,
+	0, 0, 0, 0, 0, 1, 7, 7, 1, 0,
+	0, 0, 0, 0, 0, 0, 1, 1, 0, 0
+};
 
 #define MOUSE_WIDTH 10
 #define MOUSE_HEIGHT 15
@@ -152,7 +154,6 @@ void EventManager::updateMouse() {
 		_vm->_graphics->screenUpdate();
 }
 
-
 /*****************************************************************************/
 /* Initializes the mouse.                                                    */
 /*****************************************************************************/
@@ -163,7 +164,6 @@ void EventManager::initMouse() {
 	setMousePos(Common::Point(0, 0));
 }
 
-
 /*****************************************************************************/
 /* Shows the mouse.                                                          */
 /*****************************************************************************/
@@ -198,7 +198,6 @@ Common::Point EventManager::getMousePos() {
 		return Common::Point(_mousePos.x / 2, _mousePos.y);
 }
 
-
 /*****************************************************************************/
 /* Moves the mouse to new co-ordinates.                                      */
 /*****************************************************************************/
@@ -212,7 +211,6 @@ void EventManager::setMousePos(Common::Point pos) {
 		processInput();
 }
 
-
 /*****************************************************************************/
 /* Checks whether or not the mouse buttons have been pressed, and the last   */
 /* co-ordinates of the button press.  leftbutton tells whether to check the  */
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 8da54cc..aa118eb 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -138,8 +138,7 @@ void DisplayMan::freePict() {
 static void getWord(char *wordBuffer, const char *mainBuffer, uint16 *wordWidth) {
 	uint16 width = 0;
 
-	while ((mainBuffer[width] != ' ') && mainBuffer[width] &&
-	        (mainBuffer[width] != '\n')) {
+	while ((mainBuffer[width] != ' ') && mainBuffer[width] && (mainBuffer[width] != '\n')) {
 		wordBuffer[width] = mainBuffer[width];
 		width++;
 	}
@@ -190,16 +189,18 @@ void DisplayMan::getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer
 /* Note: Every individual word MUST be int16 enough to fit on a line, and     */
 /* each line less than 255 characters.                                        */
 /******************************************************************************/
-uint32 DisplayMan::flowText(void *font,      /* the TextAttr pointer */
-                int16 spacing,          /* How much vertical spacing between the lines */
-                byte pencolor,         /* pen number to use for text */
-                byte backpen,          /* the background color */
-                bool fillback,                /* Whether to fill the background */
-                bool centerh,                 /* Whether to center the text horizontally */
-                bool centerv,                 /* Whether to center the text vertically */
-                bool output,                  /* Whether to output any text */
-                uint16 x1,               /* Cords */
-                uint16 y1, uint16 x2, uint16 y2, const char *str) { /* The text itself */
+uint32 DisplayMan::flowText(
+			void *font,            /* the TextAttr pointer */
+			int16 spacing,         /* How much vertical spacing between the lines */
+			byte pencolor,         /* pen number to use for text */
+			byte backpen,          /* the background color */
+			bool fillback,         /* Whether to fill the background */
+			bool centerh,          /* Whether to center the text horizontally */
+			bool centerv,          /* Whether to center the text vertically */
+			bool output,           /* Whether to output any text */
+			uint16 x1, uint16 y1,  /* Cords */
+			uint16 x2, uint16 y2,
+			const char *str) {     /* The text itself */
 	TextFont *_msgFont = (TextFont *)font;
 	char linebuffer[256];
 	const char *temp;
@@ -272,16 +273,18 @@ uint32 DisplayMan::flowTextScaled(void *font,      /* the TextAttr pointer */
 /******************************************************************************/
 /* Calls flowText, but flows it to memory.  Same restrictions as flowText.    */
 /******************************************************************************/
-uint32 DisplayMan::flowTextToMem(Image *destIm, void *font,     /* the TextAttr pointer */
-                     int16 spacing,          /* How much vertical spacing between the lines */
-                     byte pencolor,         /* pen number to use for text */
-                     byte backpen,          /* the background color */
-                     bool fillback,                /* Whether to fill the background */
-                     bool centerh,                 /* Whether to center the text horizontally */
-                     bool centerv,                 /* Whether to center the text vertically */
-                     bool output,                  /* Whether to output any text */
-                     uint16 x1,               /* Cords */
-                     uint16 y1, uint16 x2, uint16 y2, const char *str) { /* The text itself */
+uint32 DisplayMan::flowTextToMem(Image *destIm,
+			void *font,            /* the TextAttr pointer */
+			int16 spacing,         /* How much vertical spacing between the lines */
+			byte pencolor,         /* pen number to use for text */
+			byte backpen,          /* the background color */
+			bool fillback,         /* Whether to fill the background */
+			bool centerh,          /* Whether to center the text horizontally */
+			bool centerv,          /* Whether to center the text vertically */
+			bool output,           /* Whether to output any text */
+			uint16 x1, uint16 y1,  /* Cords */
+			uint16 x2, uint16 y2,
+			const char *str) {     /* The text itself */
 	uint32 res, vgabyte = _screenBytesPerPage;
 	byte *tmp = _currentDisplayBuffer;
 
diff --git a/engines/lab/image.h b/engines/lab/image.h
index f443f4c..7f2c1ed 100644
--- a/engines/lab/image.h
+++ b/engines/lab/image.h
@@ -36,20 +36,19 @@ namespace Lab {
 class Image {
 public:
 	uint16 _width;
-    uint16 _height;
+	uint16 _height;
 	byte *_imageData;
 
-    Image() : _width(0), _height(0), _imageData(0) {}
-    Image(int w, int h, byte *d) : _width(w), _height(h), _imageData(d) {}
+	Image() : _width(0), _height(0), _imageData(0) {}
+	Image(int w, int h, byte *d) : _width(w), _height(h), _imageData(d) {}
 	Image(Common::File *s);
 
-    void drawImage(uint16 x, uint16 y);
-    void drawMaskImage(uint16 x, uint16 y);
-    void readScreenImage(uint16 x, uint16 y);
+	void drawImage(uint16 x, uint16 y);
+	void drawMaskImage(uint16 x, uint16 y);
+	void readScreenImage(uint16 x, uint16 y);
 	void blitBitmap(uint16 xs, uint16 ys, Image *ImDest, uint16 xd, uint16 yd, uint16 width, uint16 height, byte masked);
 };
 
-
 } // End of namespace Lab
 
 #endif // LAB_H
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 7f6776a..4e514ea 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -113,8 +113,8 @@ Gadget *LabEngine::checkNumGadgetHit(GadgetList *gadgetList, uint16 key) {
 	for (GadgetList::iterator gadgetItr = gadgetList->begin(); gadgetItr != gadgetList->end(); ++gadgetItr) {
 		Gadget *gadget = *gadgetItr;
 		if ((gkey - 1 == gadget->_gadgetID || (gkey == 0 && gadget->_gadgetID == 9) ||
-			(gadget->_keyEquiv != 0 && makeGadgetKeyEquiv(key) == gadget->_keyEquiv))
-		        && !(GADGETOFF & gadget->_flags)) {
+			  (gadget->_keyEquiv != 0 && makeGadgetKeyEquiv(key) == gadget->_keyEquiv))
+			  && !(GADGETOFF & gadget->_flags)) {
 			_event->mouseHide();
 			gadget->_altImage->drawImage(gadget->x, gadget->y);
 			_event->mouseShow();
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index da44916..2af4f44 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -54,14 +54,13 @@ void Intro::introEatMessages() {
 			return;
 		else {
 			if (((msg->_msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & msg->_qualifier)) ||
-			        ((msg->_msgClass == RAWKEY) && (msg->_code == 27))
+				  ((msg->_msgClass == RAWKEY) && (msg->_code == 27))
 				)
 				_quitIntro = true;
 		}
 	}
 }
 
-
 /*****************************************************************************/
 /* Reads in a picture.                                                       */
 /*****************************************************************************/
@@ -156,7 +155,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 			code      = msg->_code;
 
 			if (((cls == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & qualifier)) ||
-			        ((cls == RAWKEY) && (code == 27))) {
+				  ((cls == RAWKEY) && (code == 27))) {
 				_quitIntro = true;
 
 				if (isScreen)
@@ -278,8 +277,8 @@ void Intro::introSequence() {
 			break;
 
 		palette[i] = ((_vm->_anim->_diffPalette[i * 3] >> 2) << 8) +
-		             ((_vm->_anim->_diffPalette[i * 3 + 1] >> 2) << 4) +
-		              (_vm->_anim->_diffPalette[i * 3 + 2] >> 2);
+					((_vm->_anim->_diffPalette[i * 3 + 1] >> 2) << 4) +
+					(_vm->_anim->_diffPalette[i * 3 + 2] >> 2);
 	}
 
 	_vm->_music->updateMusic();
@@ -337,8 +336,8 @@ void Intro::introSequence() {
 
 	for (uint16 i = 0; i < 16; i++) {
 		palette[i] = ((_vm->_anim->_diffPalette[i * 3] >> 2) << 8) +
-		             ((_vm->_anim->_diffPalette[i * 3 + 1] >> 2) << 4) +
-		              (_vm->_anim->_diffPalette[i * 3 + 2] >> 2);
+					((_vm->_anim->_diffPalette[i * 3 + 1] >> 2) << 4) +
+					(_vm->_anim->_diffPalette[i * 3 + 2] >> 2);
 	}
 
 	doPictText("i.1", msgFont, true);
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index fb2d20d..7dec75f 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -132,8 +132,7 @@ public:
 
 	const char *_curFileName;
 	const char *_nextFileName;
-	const char *_newFileName;  /* When ProcessRoom.c decides to change the filename
-                                    of the current picture. */
+	const char *_newFileName;  /* When ProcessRoom.c decides to change the filename of the current picture. */
 	TextFont *_msgFont;
 	GadgetList _moveGadgetList;
 	GadgetList _invGadgetList;
diff --git a/engines/lab/labsets.h b/engines/lab/labsets.h
index 3251ee1..647730d 100644
--- a/engines/lab/labsets.h
+++ b/engines/lab/labsets.h
@@ -41,19 +41,19 @@ class LabEngine;
 
 class LargeSet {
 public:
-    LargeSet(uint16 last, LabEngine *vm);
-    ~LargeSet();
-    bool in(uint16 element);
-    void inclElement(uint16 element);
-    void exclElement(uint16 element);
-    bool readInitialConditions(const char *fileName);
+	LargeSet(uint16 last, LabEngine *vm);
+	~LargeSet();
+	bool in(uint16 element);
+	void inclElement(uint16 element);
+	void exclElement(uint16 element);
+	bool readInitialConditions(const char *fileName);
 
 private:
 	LabEngine *_vm;
 
 public:
-    uint16 _lastElement;
-    uint16 *_array;
+	uint16 _lastElement;
+	uint16 *_array;
 };
 
 } // End of namespace Lab
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 8c71d1a..405d7b8 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -357,9 +357,6 @@ static void getUpFloor(uint16 *Floor, bool *isfloor) {
 	} while ((!onFloor(*Floor)) && (*Floor <= CARNIVAL));
 }
 
-
-
-
 /*****************************************************************************/
 /* Figures out which floor, if any, should be gone to if the down arrow is   */
 /* hit.                                                                      */
@@ -391,10 +388,6 @@ static void getDownFloor(uint16 *Floor, bool *isfloor) {
 	} while ((!onFloor(*Floor)) && *Floor);
 }
 
-
-
-
-
 /*****************************************************************************/
 /* Draws the map                                                             */
 /*****************************************************************************/
@@ -422,9 +415,9 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 		}
 	}
 
-	if ((Maps[CurRoom].PageNumber == Floor)   /* Makes sure the X is drawn in corridors */
-	        && _roomsFound->in(CurRoom) /* NOTE: this here on purpose just in case there's some weird condition, like the surreal maze where there are no rooms */
-	        && Maps[CurRoom].x)
+	/* Makes sure the X is drawn in corridors */
+	/* NOTE: this here on purpose just in case there's some weird condition, like the surreal maze where there are no rooms */
+	if ((Maps[CurRoom].PageNumber == Floor) && _roomsFound->in(CurRoom) && Maps[CurRoom].x)
 		drawRoom(CurRoom, true);
 
 	tempfloor = Floor;
@@ -529,8 +522,7 @@ void LabEngine::processMap(uint16 CurRoom) {
 			MouseX    = Msg->_mouseX;
 			MouseY    = Msg->_mouseY;
 
-			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) ||
-			        ((Class == RAWKEY) && (Code == 27)))
+			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || ((Class == RAWKEY) && (Code == 27)))
 				return;
 
 			if (Class == GADGETUP) {
@@ -557,59 +549,49 @@ void LabEngine::processMap(uint16 CurRoom) {
 					} else
 						CurFloor = OldFloor;
 				}
-			}
-
-			else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) {
+			} else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) {
 				if ((CurFloor == LOWERFLOOR) && (MouseX >= mapScaleX(538)) && (MouseY >= mapScaleY(277))
-				        && (MouseX <= mapScaleX(633)) && (MouseY <= mapScaleY(352))
-				        && onFloor(SURMAZEFLOOR)) {
+					  && (MouseX <= mapScaleX(633)) && (MouseY <= mapScaleY(352))
+					  && onFloor(SURMAZEFLOOR)) {
 					CurFloor = SURMAZEFLOOR;
 
 					_graphics->fade(false, 0);
 					drawMap(CurRoom, CurMsg, CurFloor, false, false);
 					_graphics->fade(true, 0);
-				}
-
-				else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(358)) && (MouseY >= mapScaleY(71))
-				         && (MouseX <= mapScaleX(452)) && (MouseY <= mapScaleY(147))
-				         && onFloor(CARNIVAL)) {
+				} else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(358)) && (MouseY >= mapScaleY(71))
+							  && (MouseX <= mapScaleX(452)) && (MouseY <= mapScaleY(147))
+							  && onFloor(CARNIVAL)) {
 					CurFloor = CARNIVAL;
 
 					_graphics->fade(false, 0);
 					drawMap(CurRoom, CurMsg, CurFloor, false, false);
 					_graphics->fade(true, 0);
-				}
-
-				else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(557)) && (MouseY >= mapScaleY(325))
-				         && (MouseX <= mapScaleX(653)) && (MouseY <= mapScaleY(401))
-				         && onFloor(MEDMAZEFLOOR)) {
+				} else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(557)) && (MouseY >= mapScaleY(325))
+						  && (MouseX <= mapScaleX(653)) && (MouseY <= mapScaleY(401))
+						  && onFloor(MEDMAZEFLOOR)) {
 					CurFloor = MEDMAZEFLOOR;
 
 					_graphics->fade(false, 0);
 					drawMap(CurRoom, CurMsg, CurFloor, false, false);
 					_graphics->fade(true, 0);
-				}
-
-				else if ((CurFloor == UPPERFLOOR) && (MouseX >= mapScaleX(524)) && (MouseY >=  mapScaleY(97))
-				         && (MouseX <= mapScaleX(645)) && (MouseY <= mapScaleY(207))
-				         && onFloor(HEDGEMAZEFLOOR)) {
+				} else if ((CurFloor == UPPERFLOOR) && (MouseX >= mapScaleX(524)) && (MouseY >=  mapScaleY(97))
+						  && (MouseX <= mapScaleX(645)) && (MouseY <= mapScaleY(207))
+						  && onFloor(HEDGEMAZEFLOOR)) {
 					CurFloor = HEDGEMAZEFLOOR;
 
 					_graphics->fade(false, 0);
 					drawMap(CurRoom, CurMsg, CurFloor, false, false);
 					_graphics->fade(true, 0);
-				}
-
-				else if (MouseX > mapScaleX(314)) {
+				} else if (MouseX > mapScaleX(314)) {
 					OldMsg = CurMsg;
 
 					for (uint16 i = 1; i <= MaxRooms; i++) {
 						roomCoords(i, &x1, &y1, &x2, &y2);
 
 						if ((Maps[i].PageNumber == CurFloor)
-						        && _roomsFound->in(i)
-						        && (MouseX >= x1) && (MouseX <= x2)
-						        && (MouseY >= y1) && (MouseY <= y2)) {
+							  && _roomsFound->in(i)
+							  && (MouseX >= x1) && (MouseX <= x2)
+							  && (MouseY >= y1) && (MouseY <= y2)) {
 							CurMsg = i;
 						}
 					}
@@ -647,7 +629,6 @@ void LabEngine::processMap(uint16 CurRoom) {
 	}
 }
 
-
 /*****************************************************************************/
 /* Does the map processing.                                                  */
 /*****************************************************************************/
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index fa270de..e037522 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -104,7 +104,7 @@ static CloseData *getObject(uint16 x, uint16 y, CloseDataPtr lcptr) {
 
 	while (lcptr != NULL) {
 		if ((x >= g_lab->_utils->scaleX(lcptr->x1)) && (y >= g_lab->_utils->scaleY(lcptr->y1)) &&
-		        (x <= g_lab->_utils->scaleX(lcptr->x2)) && (y <= g_lab->_utils->scaleY(lcptr->y2)))
+			  (x <= g_lab->_utils->scaleX(lcptr->x2)) && (y <= g_lab->_utils->scaleY(lcptr->y2)))
 			return lcptr;
 
 		lcptr = lcptr->_nextCloseUp;
@@ -124,8 +124,8 @@ static CloseDataPtr findCPtrMatch(CloseDataPtr cpmain, CloseDataPtr list) {
 
 	while (list) {
 		if ((cpmain->x1 == list->x1) && (cpmain->x2 == list->x2) &&
-		        (cpmain->y1 == list->y1) && (cpmain->y2 == list->y2) &&
-		        (cpmain->_depth == list->_depth))
+			  (cpmain->y1 == list->y1) && (cpmain->y2 == list->y2) &&
+			  (cpmain->_depth == list->_depth))
 			return list;
 
 		cptr = findCPtrMatch(cpmain, list->_subCloseUps);
@@ -278,8 +278,8 @@ bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
 
 	while (lcptr != NULL) {
 		if ((x >= g_lab->_utils->scaleX(lcptr->x1)) && (y >= g_lab->_utils->scaleY(lcptr->y1)) &&
-		        (x <= g_lab->_utils->scaleX(lcptr->x2)) && (y <= g_lab->_utils->scaleY(lcptr->y2)) &&
-		        (lcptr->_closeUpType < 0)) {
+			  (x <= g_lab->_utils->scaleX(lcptr->x2)) && (y <= g_lab->_utils->scaleY(lcptr->y2)) &&
+			  (lcptr->_closeUpType < 0)) {
 			g_lab->_conditions->inclElement(abs(lcptr->_closeUpType));
 			return true;
 		}
@@ -449,8 +449,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 					_anim->diffNextFrame();
 					getTime(&curSecs, &curMicros);
 
-					if ((curSecs > startSecs) || ((curSecs == startSecs) &&
-					                              (curMicros >= startMicros)))
+					if ((curSecs > startSecs) || ((curSecs == startSecs) && (curMicros >= startMicros)))
 						break;
 				}
 			}
@@ -582,9 +581,8 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr lcptr, Clo
 			if (((*rule)->_ruleType == ACTION) &&
 				(((*rule)->_param1 == action) || (((*rule)->_param1 == 0) && allowDefaults))) {
 				if ((((*rule)->_param2 == lcptr->_closeUpType) ||
-					(((*rule)->_param2 == 0) && allowDefaults))
-				        ||
-						((action == 1) && ((*rule)->_param2 == (-lcptr->_closeUpType)))) {
+					  (((*rule)->_param2 == 0) && allowDefaults)) ||
+					  ((action == 1) && ((*rule)->_param2 == (-lcptr->_closeUpType)))) {
 					if (checkConditions((*rule)->_condition)) {
 						g_lab->doActions((*rule)->_actionList, set);
 						return true;
@@ -635,7 +633,7 @@ static bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr lcptr, C
 
 			for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 				if (((*rule)->_ruleType == OPERATE) &&
-				        (((*rule)->_param1 == itemNum) || (((*rule)->_param1 == 0) && allowDefaults)) &&
+					  (((*rule)->_param1 == itemNum) || (((*rule)->_param1 == 0) && allowDefaults)) &&
 						(((*rule)->_param2 == lcptr->_closeUpType) || (((*rule)->_param2 == 0) && allowDefaults))) {
 					if (checkConditions((*rule)->_condition)) {
 						g_lab->doActions((*rule)->_actionList, set);
@@ -711,8 +709,8 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *lcptr) {
 
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 		if (((*rule)->_ruleType == TURN) ||
-		        (((*rule)->_ruleType == TURNFROMTO) &&
-		         ((*rule)->_param1   == from) && ((*rule)->_param2 == to))) {
+			  (((*rule)->_ruleType == TURNFROMTO) &&
+			  ((*rule)->_param1 == from) && ((*rule)->_param2 == to))) {
 			if (checkConditions((*rule)->_condition)) {
 				g_lab->doActions((*rule)->_actionList, lcptr);
 				return true;
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 23e73c5..bf3f8a4 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -164,8 +164,6 @@ bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc)
 	return true;
 }
 
-
-
 /*****************************************************************************/
 /* Reads the game from disk.                                                 */
 /*****************************************************************************/
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 469d8ab..0d92772 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -62,12 +62,12 @@ Image *MonButton;
 #define INCL(BITSET,BIT) ((BITSET) |= (BIT))
 #define SETBIT(BITSET,BITNUM)   INCL(BITSET, (1 << (BITNUM)))
 #define INBIT(BITSET,BITNUM)    ( ((1 << (BITNUM)) & (BITSET)) > 0 )
-#define BRIDGE0   148
-#define BRIDGE1   104
-#define DIRTY     175
-#define NONEWS    135
-#define NOCLEAN   152
-#define QUARTERNUM           30
+#define BRIDGE0     148
+#define BRIDGE1     104
+#define DIRTY       175
+#define NONEWS      135
+#define NOCLEAN     152
+#define QUARTERNUM  30
 
 
 static byte *loadBackPict(const char *fileName, bool tomem) {
@@ -83,8 +83,8 @@ static byte *loadBackPict(const char *fileName, bool tomem) {
 
 	for (uint16 i = 0; i < 16; i++) {
 		hipal[i] = ((g_lab->_anim->_diffPalette[i * 3] >> 2) << 8) +
-		           ((g_lab->_anim->_diffPalette[i * 3 + 1] >> 2) << 4) +
-		           ((g_lab->_anim->_diffPalette[i * 3 + 2] >> 2));
+				((g_lab->_anim->_diffPalette[i * 3 + 1] >> 2) << 4) +
+				((g_lab->_anim->_diffPalette[i * 3 + 2] >> 2));
 	}
 
 	g_lab->_anim->_noPalChange = false;
@@ -282,7 +282,6 @@ static void turnPage(bool FromLeft) {
 	}
 }
 
-
 /*****************************************************************************/
 /* Draws the journal from page x.                                            */
 /*****************************************************************************/
@@ -347,7 +346,7 @@ void LabEngine::processJournal() {
 			GadID     = Msg->_code;
 
 			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) ||
-			        ((Class == RAWKEY) && (GadID == 27)))
+				  ((Class == RAWKEY) && (GadID == 27)))
 				return;
 
 			else if (Class == GADGETUP) {
@@ -385,7 +384,7 @@ void LabEngine::doJournal() {
 
 	JBackImage._width = _graphics->_screenWidth;
 	JBackImage._height = _graphics->_screenHeight;
-	JBackImage._imageData   = NULL;
+	JBackImage._imageData = NULL;
 
 	ScreenImage = JBackImage;
 	ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
@@ -558,7 +557,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 			Code      = Msg->_code;
 
 			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) ||
-			        ((Class == RAWKEY) && (Code == 27)))
+				  ((Class == RAWKEY) && (Code == 27)))
 				return;
 
 			else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) {
diff --git a/engines/lab/timing.cpp b/engines/lab/timing.cpp
index ba3dd40..63a2b94 100644
--- a/engines/lab/timing.cpp
+++ b/engines/lab/timing.cpp
@@ -56,7 +56,7 @@ void LabEngine::microDelay(uint32 secs, uint32 micros) {
 void LabEngine::getTime(uint32 *secs, uint32 *micros) {
 	uint32 t = g_system->getMillis();
 
-	*secs   = t / 1000;
+	*secs = t / 1000;
 	*micros = t % 1000;
 }
 
@@ -66,7 +66,7 @@ void LabEngine::getTime(uint32 *secs, uint32 *micros) {
 void LabEngine::addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *timeMicros) {
 	getTime(timeSec, timeMicros);
 
-	(*timeSec)    += sec;
+	(*timeSec) += sec;
 	(*timeMicros) += micros;
 
 	if (*timeMicros >= ONESECOND) {
@@ -80,7 +80,7 @@ void LabEngine::addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *t
 /* time2, returns 0.                                                         */
 /*****************************************************************************/
 void LabEngine::anyTimeDiff(uint32 sec1, uint32 micros1, uint32 sec2, uint32 micros2, uint32 *diffSecs, uint32 *diffMicros) {
-	*diffSecs   = 0;
+	*diffSecs = 0;
 	*diffMicros = 0;
 
 	if (sec1 > sec2)
@@ -89,10 +89,10 @@ void LabEngine::anyTimeDiff(uint32 sec1, uint32 micros1, uint32 sec2, uint32 mic
 		return;
 
 	if (micros1 > micros2) {
-		*diffSecs   = sec2 - sec1 - 1;
+		*diffSecs = sec2 - sec1 - 1;
 		*diffMicros = (ONESECOND - micros1) + micros2;
 	} else {
-		*diffSecs   = sec2 - sec1;
+		*diffSecs = sec2 - sec1;
 		*diffMicros = micros2 - micros1;
 	}
 }


Commit: ae056a767ba8c983b7d38afd2532ba18fd3cb724
    https://github.com/scummvm/scummvm/commit/ae056a767ba8c983b7d38afd2532ba18fd3cb724
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:55+01:00

Commit Message:
LAB: Use doxygen format for function comments

Changed paths:
    engines/lab/anim.cpp
    engines/lab/engine.cpp
    engines/lab/eventman.cpp
    engines/lab/graphics.cpp
    engines/lab/image.cpp
    engines/lab/interface.cpp
    engines/lab/intro.cpp
    engines/lab/map.cpp
    engines/lab/music.cpp
    engines/lab/savegame.cpp
    engines/lab/special.cpp
    engines/lab/tilepuzzle.cpp
    engines/lab/timing.cpp
    engines/lab/transitions.cpp
    engines/lab/utils.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index d8b3b2f..4927b25 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -243,9 +243,9 @@ void Anim::diffNextFrame() {
 	}
 }
 
-/*****************************************************************************/
-/* A separate task launched by readDiff.  Plays the DIFF.                    */
-/*****************************************************************************/
+/**
+ * A separate task launched by readDiff.  Plays the DIFF.
+ */
 void Anim::playDiff(byte *buffer) {
 	_waitSec = 0L;
 	_waitMicros = 0L;
@@ -330,17 +330,17 @@ void Anim::playDiff(byte *buffer) {
 		diffNextFrame();
 }
 
-/*****************************************************************************/
-/* Stops an animation from running.                                          */
-/*****************************************************************************/
+/**
+ * Stops an animation from running.
+ */
 void Anim::stopDiff() {
 	if (_isPlaying && _isAnim)
 		_vm->_graphics->blackScreen();
 }
 
-/*****************************************************************************/
-/* Stops an animation from running.                                          */
-/*****************************************************************************/
+/**
+ * Stops an animation from running.
+ */
 void Anim::stopDiffEnd() {
 	if (_isPlaying) {
 		_stopPlayingEnd = true;
@@ -351,9 +351,9 @@ void Anim::stopDiffEnd() {
 	}
 }
 
-/*****************************************************************************/
-/* Reads in a DIFF file.                                                     */
-/*****************************************************************************/
+/**
+ * Reads in a DIFF file.
+ */
 bool Anim::readDiff(byte *buffer, bool playOnce) {
 	_playOnce = playOnce;
 	playDiff(buffer);
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 3e76e16..6fb4c70 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -86,9 +86,9 @@ static char initcolors[] = { '\x00', '\x00', '\x00', '\x30',
 							 '\x24', '\x24', '\x2c', '\x2c',
 							 '\x2c', '\x08', '\x08', '\x08'};
 
-/******************************************************************************/
-/* Draws the message for the room.                                            */
-/******************************************************************************/
+/**
+ * Draws the message for the room.
+ */
 void LabEngine::drawRoomMessage(uint16 curInv, CloseDataPtr closePtr) {
 	if (_lastTooLong) {
 		_lastTooLong = false;
@@ -124,10 +124,9 @@ void LabEngine::freeScreens() {
 	}
 }
 
-
-/******************************************************************************/
-/* Permanently flips the imagery of a gadget.                                 */
-/******************************************************************************/
+/**
+ * Permanently flips the imagery of a gadget.
+ */
 void LabEngine::perFlipGadget(uint16 gadgetId) {
 	for (GadgetList::iterator gadget = _moveGadgetList.begin(); gadget != _moveGadgetList.end(); ++gadget) {
 		Gadget *topGadget = *gadget;
@@ -147,9 +146,9 @@ void LabEngine::perFlipGadget(uint16 gadgetId) {
 	}
 }
 
-/******************************************************************************/
-/* Eats all the available messages.                                           */
-/******************************************************************************/
+/**
+ * Eats all the available messages.
+ */
 void LabEngine::eatMessages() {
 	IntuiMessage *msg;
 
@@ -158,9 +157,9 @@ void LabEngine::eatMessages() {
 	} while (msg);
 }
 
-/******************************************************************************/
-/* Checks whether the close up is one of the special case closeups.           */
-/******************************************************************************/
+/**
+ * Checks whether the close up is one of the special case closeups.
+ */
 bool LabEngine::doCloseUp(CloseDataPtr closePtr) {
 	if (closePtr == NULL)
 		return false;
@@ -216,9 +215,9 @@ bool LabEngine::doCloseUp(CloseDataPtr closePtr) {
 	return true;
 }
 
-/******************************************************************************/
-/* Gets the current inventory name.                                           */
-/******************************************************************************/
+/**
+ * Gets the current inventory name.
+ */
 const char *LabEngine::getInvName(uint16 curInv) {
 	if (_mainDisplay)
 		return _inventory[curInv]._bitmapName;
@@ -246,9 +245,9 @@ const char *LabEngine::getInvName(uint16 curInv) {
 	return _inventory[curInv]._bitmapName;
 }
 
-/******************************************************************************/
-/* Turns the interface off.                                                   */
-/******************************************************************************/
+/**
+ * Turns the interface off.
+ */
 void LabEngine::interfaceOff() {
 	if (!_interfaceOff) {
 		_event->attachGadgetList(NULL);
@@ -257,9 +256,9 @@ void LabEngine::interfaceOff() {
 	}
 }
 
-/******************************************************************************/
-/* Turns the interface on.                                                    */
-/******************************************************************************/
+/**
+ * Turns the interface on.
+ */
 void LabEngine::interfaceOn() {
 	if (_interfaceOff) {
 		_interfaceOff = false;
@@ -274,9 +273,9 @@ void LabEngine::interfaceOn() {
 		_event->attachGadgetList(&_moveGadgetList);
 }
 
-/******************************************************************************/
-/* If the user hits the "Use" gadget; things that can get used on themselves. */
-/******************************************************************************/
+/**
+ * If the user hits the "Use" gadget; things that can get used on themselves.
+ */
 bool LabEngine::doUse(uint16 curInv) {
 	if (curInv == MAPNUM) {                  /* LAB: Labyrinth specific */
 		drawStaticMessage(kTextUseMap);
@@ -336,9 +335,9 @@ bool LabEngine::doUse(uint16 curInv) {
 	return true;
 }
 
-/******************************************************************************/
-/* Decrements the current inventory number.                                   */
-/******************************************************************************/
+/**
+ * Decrements the current inventory number.
+ */
 void LabEngine::decIncInv(uint16 *curInv, bool decreaseFl) {
 	interfaceOff();
 
@@ -379,9 +378,9 @@ void LabEngine::decIncInv(uint16 *curInv, bool decreaseFl) {
 	}
 }
 
-/******************************************************************************/
-/* The main game loop                                                         */
-/******************************************************************************/
+/**
+ * The main game loop.
+ */
 void LabEngine::mainGameLoop() {
 	uint16 actionMode = 4;
 	uint16 curInv = MAPNUM;
@@ -1075,9 +1074,9 @@ void LabEngine::go() {
 	_music->freeMusic();
 }
 
-/*****************************************************************************/
-/* New code to allow quick(er) return navigation in game.                    */
-/*****************************************************************************/
+/**
+ * New code to allow quick(er) return navigation in game.
+ */
 int LabEngine::followCrumbs() {
 	// NORTH, SOUTH, EAST, WEST
 	static int movement[4][4] = {
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index b840c0a..5b55ed4 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -55,10 +55,10 @@ static byte MouseData[] = {
 #define MOUSE_WIDTH 10
 #define MOUSE_HEIGHT 15
 
-/*****************************************************************************/
-/* Checks whether or not the cords fall within one of the gadgets in a list  */
-/* of gadgets.                                                               */
-/*****************************************************************************/
+/**
+ * Checks whether or not the cords fall within one of the gadgets in a list
+ * of gadgets.
+ */
 Gadget *EventManager::checkGadgetHit(GadgetList *gadgetList, Common::Point pos) {
 	for (GadgetList::iterator gadgetItr = gadgetList->begin(); gadgetItr != gadgetList->end(); ++gadgetItr) {
 		Gadget *gadget = *gadgetItr;
@@ -154,9 +154,9 @@ void EventManager::updateMouse() {
 		_vm->_graphics->screenUpdate();
 }
 
-/*****************************************************************************/
-/* Initializes the mouse.                                                    */
-/*****************************************************************************/
+/**
+ * Initializes the mouse.
+ */
 void EventManager::initMouse() {
 	g_system->setMouseCursor(MouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0);
 	g_system->showMouse(false);
@@ -164,9 +164,9 @@ void EventManager::initMouse() {
 	setMousePos(Common::Point(0, 0));
 }
 
-/*****************************************************************************/
-/* Shows the mouse.                                                          */
-/*****************************************************************************/
+/**
+ * Shows the mouse.
+ */
 void EventManager::mouseShow() {
 	if (_mouseHidden) {
 		processInput();
@@ -176,9 +176,9 @@ void EventManager::mouseShow() {
 	g_system->showMouse(true);
 }
 
-/*****************************************************************************/
-/* Hides the mouse.                                                          */
-/*****************************************************************************/
+/**
+ * Hides the mouse.
+ */
 void EventManager::mouseHide() {
 	if (!_mouseHidden) {
 		_mouseHidden = true;
@@ -187,10 +187,10 @@ void EventManager::mouseHide() {
 	}
 }
 
-/*****************************************************************************/
-/* Gets the current mouse co-ordinates.  NOTE: On IBM version, will scale    */
-/* from virtual to screen co-ordinates automatically.                        */
-/*****************************************************************************/
+/**
+ * Gets the current mouse co-ordinates.  NOTE: On IBM version, will scale
+ * from virtual to screen co-ordinates automatically.
+ */
 Common::Point EventManager::getMousePos() {
 	if (_vm->_isHiRes)
 		return _mousePos;
@@ -198,9 +198,9 @@ Common::Point EventManager::getMousePos() {
 		return Common::Point(_mousePos.x / 2, _mousePos.y);
 }
 
-/*****************************************************************************/
-/* Moves the mouse to new co-ordinates.                                      */
-/*****************************************************************************/
+/**
+ * Moves the mouse to new co-ordinates.
+ */
 void EventManager::setMousePos(Common::Point pos) {
 	if (_vm->_isHiRes)
 		g_system->warpMouse(pos.x, pos.y);
@@ -211,11 +211,11 @@ void EventManager::setMousePos(Common::Point pos) {
 		processInput();
 }
 
-/*****************************************************************************/
-/* Checks whether or not the mouse buttons have been pressed, and the last   */
-/* co-ordinates of the button press.  leftbutton tells whether to check the  */
-/* left or right button.                                                     */
-/*****************************************************************************/
+/**
+ * Checks whether or not the mouse buttons have been pressed, and the last
+ * co-ordinates of the button press.  leftbutton tells whether to check the
+ * left or right button.
+ */
 bool EventManager::mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
 	if (leftbutton) {
 		if (_leftClick) {
@@ -243,9 +243,9 @@ Gadget *EventManager::mouseGadget() {
 	return temp;
 }
 
-/*****************************************************************************/
-/* Checks whether or not a key has been pressed.                             */
-/*****************************************************************************/
+/**
+ * Checks whether or not a key has been pressed.
+ */
 bool EventManager::keyPress(uint16 *keyCode) {
 	if (haveNextChar()) {
 		*keyCode = getNextChar();
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index aa118eb..926dc7c 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -74,9 +74,9 @@ void DisplayMan::loadPict(const char *filename) {
 	delete bitmapFile;
 }
 
-/*****************************************************************************/
-/* Reads in a picture into the dest bitmap.                                  */
-/*****************************************************************************/
+/**
+ * Reads in a picture into the dest bitmap.
+ */
 void DisplayMan::readPict(const char *filename, bool playOnce) {
 	_vm->_anim->stopDiff();
 
@@ -94,9 +94,9 @@ void DisplayMan::readPict(const char *filename, bool playOnce) {
 	_vm->_anim->readDiff(_curBitmap, playOnce);
 }
 
-/*****************************************************************************/
-/* Reads in a picture into buffer memory.                                    */
-/*****************************************************************************/
+/**
+ * Reads in a picture into buffer memory.
+ */
 byte *DisplayMan::readPictToMem(const char *filename, uint16 x, uint16 y) {
 	_vm->_anim->stopDiff();
 
@@ -132,9 +132,9 @@ void DisplayMan::freePict() {
 
 /*----- The flowText routines -----*/
 
-/******************************************************************************/
-/* Extracts the first word from a string.                                     */
-/******************************************************************************/
+/**
+ * Extracts the first word from a string.
+ */
 static void getWord(char *wordBuffer, const char *mainBuffer, uint16 *wordWidth) {
 	uint16 width = 0;
 
@@ -148,10 +148,10 @@ static void getWord(char *wordBuffer, const char *mainBuffer, uint16 *wordWidth)
 	*wordWidth = width;
 }
 
-/******************************************************************************/
-/* Gets a line of text for flowText; makes sure that its length is less than  */
-/* or equal to the maximum width.                                             */
-/******************************************************************************/
+/**
+ * Gets a line of text for flowText; makes sure that its length is less than
+ * or equal to the maximum width.
+ */
 void DisplayMan::getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer, uint16 lineWidth) {
 	uint16 curWidth = 0, wordWidth;
 	char wordBuffer[100];
@@ -181,14 +181,13 @@ void DisplayMan::getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer
 	}
 }
 
-/******************************************************************************/
-/* Dumps a chunk of text to an arbitrary box; flows it within that box and    */
-/* optionally centers it. Returns the number of characters that were          */
-/* processed.                                                                 */
-/*                                                                            */
-/* Note: Every individual word MUST be int16 enough to fit on a line, and     */
-/* each line less than 255 characters.                                        */
-/******************************************************************************/
+/**
+ * Dumps a chunk of text to an arbitrary box; flows it within that box and
+ * optionally centers it. Returns the number of characters that were
+ * processed.
+ * Note: Every individual word MUST be int16 enough to fit on a line, and
+ * each line less than 255 characters.
+ */
 uint32 DisplayMan::flowText(
 			void *font,            /* the TextAttr pointer */
 			int16 spacing,         /* How much vertical spacing between the lines */
@@ -270,9 +269,9 @@ uint32 DisplayMan::flowTextScaled(void *font,      /* the TextAttr pointer */
 					_vm->_utils->vgaScaleX(x2), _vm->_utils->vgaScaleY(y2), str);
 }
 
-/******************************************************************************/
-/* Calls flowText, but flows it to memory.  Same restrictions as flowText.    */
-/******************************************************************************/
+/**
+ * Calls flowText, but flows it to memory.  Same restrictions as flowText.
+ */
 uint32 DisplayMan::flowTextToMem(Image *destIm,
 			void *font,            /* the TextAttr pointer */
 			int16 spacing,         /* How much vertical spacing between the lines */
@@ -334,9 +333,9 @@ int32 DisplayMan::longDrawMessage(const char *str) {
 	return flowTextScaled(_vm->_msgFont, 0, 1, 7, false, true, true, true, 6, 155, 313, 195, str);
 }
 
-/******************************************************************************/
-/* Draws a message to the message box.                                        */
-/******************************************************************************/
+/**
+ * Draws a message to the message box.
+ */
 void DisplayMan::drawMessage(const char *str) {
 	if (_doNotDrawMessage) {
 		_doNotDrawMessage = false;
@@ -362,9 +361,9 @@ void DisplayMan::drawMessage(const char *str) {
 	}
 }
 
-/******************************************************************************/
-/* Draws the control panel display.                                           */
-/******************************************************************************/
+/**
+ * Draws the control panel display.
+ */
 void DisplayMan::drawPanel() {
 	_vm->_event->mouseHide();
 
@@ -415,9 +414,9 @@ void DisplayMan::drawPanel() {
 	_vm->_event->mouseShow();
 }
 
-/******************************************************************************/
-/* Sets up the Labyrinth screens, and opens up the initial windows.           */
-/******************************************************************************/
+/**
+ * Sets up the Labyrinth screens, and opens up the initial windows.
+ */
 bool DisplayMan::setUpScreens() {
 	if (!createScreen(_vm->_isHiRes))
 		return false;
@@ -471,16 +470,16 @@ bool DisplayMan::setUpScreens() {
 	return true;
 }
 
-/*****************************************************************************/
-/* Sets the pen number to use on all the drawing operations.                 */
-/*****************************************************************************/
+/**
+ * Sets the pen number to use on all the drawing operations.
+ */
 void DisplayMan::setAPen(byte pennum) {
 	_curapen = pennum;
 }
 
-/*****************************************************************************/
-/* Fills in a rectangle.                                                     */
-/*****************************************************************************/
+/**
+ * Fills in a rectangle.
+ */
 void DisplayMan::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	int w = x2 - x1 + 1;
 	int h = y2 - y1 + 1;
@@ -511,16 +510,16 @@ void DisplayMan::rectFillScaled(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	rectFill(_vm->_utils->vgaScaleX(x1), _vm->_utils->vgaScaleY(y1), _vm->_utils->vgaScaleX(x2), _vm->_utils->vgaScaleY(y2));
 }
 
-/*****************************************************************************/
-/* Draws a horizontal line.                                                  */
-/*****************************************************************************/
+/**
+ * Draws a horizontal line.
+ */
 void DisplayMan::drawVLine(uint16 x, uint16 y1, uint16 y2) {
 	rectFill(x, y1, x, y2);
 }
 
-/*****************************************************************************/
-/* Draws a vertical line.                                                    */
-/*****************************************************************************/
+/**
+ * Draws a vertical line.
+ */
 void DisplayMan::drawHLine(uint16 x1, uint16 y, uint16 x2) {
 	rectFill(x1, y, x2, y);
 }
@@ -532,9 +531,9 @@ void DisplayMan::screenUpdate() {
 	_vm->_event->processInput();
 }
 
-/*****************************************************************************/
-/* Sets up either a low-res or a high-res 256 color screen.                  */
-/*****************************************************************************/
+/**
+ * Sets up either a low-res or a high-res 256 color screen.
+ */
 bool DisplayMan::createScreen(bool hiRes) {
 	if (hiRes) {
 		_screenWidth  = 640;
@@ -549,10 +548,10 @@ bool DisplayMan::createScreen(bool hiRes) {
 	return true;
 }
 
-/*****************************************************************************/
-/* Converts an Amiga palette (up to 16 colors) to a VGA palette, then sets   */
-/* the VGA palette.                                                          */
-/*****************************************************************************/
+/**
+ * Converts an Amiga palette (up to 16 colors) to a VGA palette, then sets
+ * the VGA palette.
+ */
 void DisplayMan::setAmigaPal(uint16 *pal, uint16 numColors) {
 	byte vgaPal[16 * 3];
 	uint16 vgaIdx = 0;
@@ -570,17 +569,17 @@ void DisplayMan::setAmigaPal(uint16 *pal, uint16 numColors) {
 	_vm->waitTOF();
 }
 
-/*****************************************************************************/
-/* Writes any number of the 256 color registers.                             */
-/* first:    the number of the first color register to write.                */
-/* numreg:   the number of registers to write                                */
-/* buf:      a char pointer which contains the selected color registers.     */
-/*           Each value representing a color register occupies 3 bytes in    */
-/*           the array.  The order is red, green then blue.  The first byte  */
-/*           in the array is the red component of the first element selected.*/
-/*           The length of the buffer is 3 times the number of registers     */
-/*           selected.                                                       */
-/*****************************************************************************/
+/**
+ * Writes any number of the 256 color registers.
+ * first:    the number of the first color register to write.
+ * numreg:   the number of registers to write
+ * buf:      a char pointer which contains the selected color registers.
+ *           Each value representing a color register occupies 3 bytes in
+ *           the array.  The order is red, green then blue.  The first byte
+ *           in the array is the red component of the first element selected.
+ *           The length of the buffer is 3 times the number of registers
+ *           selected.
+ */
 void DisplayMan::writeColorRegs(byte *buf, uint16 first, uint16 numreg) {
 	byte tmp[256 * 3];
 
@@ -598,9 +597,9 @@ void DisplayMan::setPalette(void *cmap, uint16 numcolors) {
 		writeColorRegs((byte *)cmap, 0, numcolors);
 }
 
-/*****************************************************************************/
-/* Returns the base address of the current VGA display.                      */
-/*****************************************************************************/
+/**
+ * Returns the base address of the current VGA display.
+ */
 byte *DisplayMan::getCurrentDrawingBuffer() {
 	if (_currentDisplayBuffer)
 		return _currentDisplayBuffer;
@@ -608,9 +607,9 @@ byte *DisplayMan::getCurrentDrawingBuffer() {
 	return _displayBuffer;
 }
 
-/*****************************************************************************/
-/* Overlays a region on the screen using the desired pen color.              */
-/*****************************************************************************/
+/**
+ * Overlays a region on the screen using the desired pen color.
+ */
 void DisplayMan::overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	int w = x2 - x1 + 1;
 	int h = y2 - y1 + 1;
@@ -645,9 +644,9 @@ void DisplayMan::overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, u
 	}
 }
 
-/*****************************************************************************/
-/* Closes a font and frees all memory associated with it.                    */
-/*****************************************************************************/
+/**
+ * Closes a font and frees all memory associated with it.
+ */
 void DisplayMan::closeFont(TextFont *tf) {
 	if (tf) {
 		if (tf->_data && tf->_dataLength)
@@ -657,9 +656,9 @@ void DisplayMan::closeFont(TextFont *tf) {
 	}
 }
 
-/*****************************************************************************/
-/* Returns the length of a text in the specified font.                       */
-/*****************************************************************************/
+/**
+ * Returns the length of a text in the specified font.
+ */
 uint16 DisplayMan::textLength(TextFont *tf, const char *text, uint16 numchars) {
 	uint16 length = 0;
 
@@ -673,16 +672,16 @@ uint16 DisplayMan::textLength(TextFont *tf, const char *text, uint16 numchars) {
 	return length;
 }
 
-/*****************************************************************************/
-/* Returns the height of a specified font.                                   */
-/*****************************************************************************/
+/**
+ * Returns the height of a specified font.
+ */
 uint16 DisplayMan::textHeight(TextFont *tf) {
 	return (tf) ? tf->_height : 0;
 }
 
-/*****************************************************************************/
-/* Draws the text to the screen.                                             */
-/*****************************************************************************/
+/**
+ * Draws the text to the screen.
+ */
 void DisplayMan::text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numchars) {
 	byte *VGATop, *VGACur, *VGATemp, *VGATempLine, *cdata;
 	uint32 RealOffset, SegmentOffset;
diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp
index ab63e96..29459b1 100644
--- a/engines/lab/image.cpp
+++ b/engines/lab/image.cpp
@@ -33,9 +33,9 @@
 
 namespace Lab {
 
-/*****************************************************************************/
-/* Reads in an image from disk.                                              */
-/*****************************************************************************/
+/**
+ * Reads in an image from disk.
+ */
 Image::Image(Common::File *s) {
 	_width = s->readUint16LE();
 	_height = s->readUint16LE();
@@ -49,9 +49,9 @@ Image::Image(Common::File *s) {
 	s->read(_imageData, size);
 }
 
-/*****************************************************************************/
-/* Blits a piece of one image to another.                                    */
-/*****************************************************************************/
+/**
+ * Blits a piece of one image to another.
+ */
 void Image::blitBitmap(uint16 xs, uint16 ys, Image *imDest,
 	uint16 xd, uint16 yd, uint16 width, uint16 height, byte masked) {
 	int w = width;
@@ -96,23 +96,23 @@ void Image::blitBitmap(uint16 xs, uint16 ys, Image *imDest,
 	}
 }
 
-/*****************************************************************************/
-/* Draws an image to the screen.                                             */
-/*****************************************************************************/
+/**
+ * Draws an image to the screen.
+ */
 void Image::drawImage(uint16 x, uint16 y) {
 	blitBitmap(0, 0, NULL, x, y, _width, _height, false);
 }
 
-/*****************************************************************************/
-/* Draws an image to the screen with transparency.                           */
-/*****************************************************************************/
+/**
+ * Draws an image to the screen with transparency.
+ */
 void Image::drawMaskImage(uint16 x, uint16 y) {
 	blitBitmap(0, 0, NULL, x, y, _width, _height, true);
 }
 
-/*****************************************************************************/
-/* Reads an image from the screen.                                           */
-/*****************************************************************************/
+/**
+ * Reads an image from the screen.
+ */
 void Image::readScreenImage(uint16 x, uint16 y) {
 	int w = _width;
 	int h = _height;
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 4e514ea..ade5f69 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -62,9 +62,9 @@ void freeButtonList(GadgetList *gadgetList) {
 	gadgetList->clear();
 }
 
-/*****************************************************************************/
-/* Draws a gadget list to the screen.                                        */
-/*****************************************************************************/
+/**
+ * Draws a gadget list to the screen.
+ */
 void drawGadgetList(GadgetList *gadgetList) {
 	for (GadgetList::iterator gadget = gadgetList->begin(); gadget != gadgetList->end(); ++gadget) {
 		(*gadget)->_image->drawImage((*gadget)->x, (*gadget)->y);
@@ -74,25 +74,25 @@ void drawGadgetList(GadgetList *gadgetList) {
 	}
 }
 
-/*****************************************************************************/
-/* Dims a gadget, and makes it unavailable for using.                        */
-/*****************************************************************************/
+/**
+ * Dims a gadget, and makes it unavailable for using.
+ */
 void disableGadget(Gadget *curgad, uint16 pencolor) {
 	g_lab->_graphics->overlayRect(pencolor, curgad->x, curgad->y, curgad->x + curgad->_image->_width - 1, curgad->y + curgad->_image->_height - 1);
 	curgad->_flags |= GADGETOFF;
 }
 
-/*****************************************************************************/
-/* Undims a gadget, and makes it available again.                            */
-/*****************************************************************************/
+/**
+ * Undims a gadget, and makes it available again.
+ */
 void enableGadget(Gadget *curgad) {
 	curgad->_image->drawImage(curgad->x, curgad->y);
 	curgad->_flags &= !(GADGETOFF);
 }
 
-/*****************************************************************************/
-/* Make a key press have the right case for a gadget KeyEquiv value.         */
-/*****************************************************************************/
+/**
+ * Make a key press have the right case for a gadget KeyEquiv value.
+ */
 uint16 makeGadgetKeyEquiv(uint16 key) {
 	if (Common::isAlnum(key))
 		key = tolower(key);
@@ -100,10 +100,10 @@ uint16 makeGadgetKeyEquiv(uint16 key) {
 	return key;
 }
 
-/*****************************************************************************/
-/* Checks whether or not the coords fall within one of the gadgets in a list  */
-/* of gadgets.                                                               */
-/*****************************************************************************/
+/**
+ * Checks whether or not the coords fall within one of the gadgets in a list
+ * of gadgets.
+ */
 Gadget *LabEngine::checkNumGadgetHit(GadgetList *gadgetList, uint16 key) {
 	uint16 gkey = key - '0';
 
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 2af4f44..b75a215 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -37,10 +37,10 @@ Intro::Intro(LabEngine *vm) : _vm(vm) {
 	_quitIntro = false;
 }
 
-/******************************************************************************/
-/* Goes through, and responds to all the intuition messages currently in the  */
-/* message queue.                                                             */
-/******************************************************************************/
+/**
+ * Goes through, and responds to all the intuition messages currently in the
+ * message queue.
+ */
 void Intro::introEatMessages() {
 	while (1) {
 		IntuiMessage *msg = _vm->getMsg();
@@ -61,9 +61,9 @@ void Intro::introEatMessages() {
 	}
 }
 
-/*****************************************************************************/
-/* Reads in a picture.                                                       */
-/*****************************************************************************/
+/**
+ * Reads in a picture.
+ */
 void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 	char path[50] = "Lab:rooms/Intro/";
 	strcat(path, filename);
@@ -200,9 +200,9 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 	}	// while(1)
 }
 
-/*****************************************************************************/
-/* Does a one second delay, but checks the music while doing it.             */
-/*****************************************************************************/
+/**
+ * Does a one second delay, but checks the music while doing it.
+ */
 void Intro::musicDelay() {
 	_vm->_music->updateMusic();
 
@@ -231,9 +231,9 @@ void Intro::nReadPict(const char *filename, bool playOnce) {
 	_vm->_graphics->readPict(finalFileName.c_str(), playOnce);
 }
 
-/*****************************************************************************/
-/* Does the introduction sequence for Labyrinth.                             */
-/*****************************************************************************/
+/**
+ * Does the introduction sequence for Labyrinth.
+ */
 void Intro::introSequence() {
 	uint16 palette[16] = {
 		0x0000, 0x0855, 0x0FF9, 0x0EE7,
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 405d7b8..b86e2b6 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -80,9 +80,9 @@ static uint16 mapScaleY(uint16 y) {
 		return ((y - 35) >> 1) - (y >> 6);
 }
 
-/*****************************************************************************/
-/* Loads in the map data.                                                    */
-/*****************************************************************************/
+/**
+ * Loads in the map data.
+ */
 static bool loadMapData() {
 	uint16 counter;
 
@@ -156,9 +156,9 @@ static void freeMapData() {
 	Maps = NULL;
 }
 
-/*****************************************************************************/
-/* Figures out what a room's coordinates should be.                          */
-/*****************************************************************************/
+/**
+ * Figures out what a room's coordinates should be.
+ */
 static void roomCoords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16 *y2) {
 	Image *curRoomImg = NULL;
 
@@ -193,9 +193,9 @@ static void roomCoords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint1
 	}
 }
 
-/*****************************************************************************/
-/* Draws a room to the bitmap.                                               */
-/*****************************************************************************/
+/**
+ * Draws a room to the bitmap.
+ */
 static void drawRoom(uint16 CurRoom, bool drawx) {
 	uint16 x, y, xx, xy, offset;
 	uint32 flags;
@@ -328,9 +328,9 @@ static void drawRoom(uint16 CurRoom, bool drawx) {
 		XMark->drawImage(xx, xy);
 }
 
-/*****************************************************************************/
-/* Checks if a floor has been visitted.                                      */
-/*****************************************************************************/
+/**
+ * Checks if a floor has been visitted.
+ */
 static bool onFloor(uint16 Floor) {
 	for (uint16 i = 1; i <= MaxRooms; i++) {
 		if ((Maps[i].PageNumber == Floor) && g_lab->_roomsFound->in(i) && Maps[i].x)
@@ -340,9 +340,9 @@ static bool onFloor(uint16 Floor) {
 	return false;
 }
 
-/*****************************************************************************/
-/* Figures out which floor, if any, should be gone to if the up arrow is hit */
-/*****************************************************************************/
+/**
+ * Figures out which floor, if any, should be gone to if the up arrow is hit
+ */
 static void getUpFloor(uint16 *Floor, bool *isfloor) {
 	do {
 		*isfloor = true;
@@ -357,10 +357,10 @@ static void getUpFloor(uint16 *Floor, bool *isfloor) {
 	} while ((!onFloor(*Floor)) && (*Floor <= CARNIVAL));
 }
 
-/*****************************************************************************/
-/* Figures out which floor, if any, should be gone to if the down arrow is   */
-/* hit.                                                                      */
-/*****************************************************************************/
+/**
+ * Figures out which floor, if any, should be gone to if the down arrow is
+ * hit.
+ */
 static void getDownFloor(uint16 *Floor, bool *isfloor) {
 	do {
 		*isfloor = true;
@@ -388,9 +388,9 @@ static void getDownFloor(uint16 *Floor, bool *isfloor) {
 	} while ((!onFloor(*Floor)) && *Floor);
 }
 
-/*****************************************************************************/
-/* Draws the map                                                             */
-/*****************************************************************************/
+/**
+ * Draws the map
+ */
 void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein) {
 	char *sptr;
 
@@ -468,9 +468,9 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 	_event->mouseShow();
 }
 
-/*****************************************************************************/
-/* Processes the map.                                                        */
-/*****************************************************************************/
+/**
+ * Processes the map.
+ */
 void LabEngine::processMap(uint16 CurRoom) {
 	uint32 Class, place = 1;
 	uint16 Code, Qualifier, MouseX, MouseY, GadgetID, CurFloor, OldFloor, OldMsg, CurMsg, x1, y1, x2, y2;
@@ -629,9 +629,9 @@ void LabEngine::processMap(uint16 CurRoom) {
 	}
 }
 
-/*****************************************************************************/
-/* Does the map processing.                                                  */
-/*****************************************************************************/
+/**
+ * Does the map processing.
+ */
 void LabEngine::doMap(uint16 CurRoom) {
 	static uint16 AmigaMapPalette[] = {
 		0x0BA8, 0x0C11, 0x0A74, 0x0076,
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 8fd88ff..1c043ef 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -62,10 +62,10 @@ Music::Music(LabEngine *vm) : _vm(vm) {
 	_waitTillFinished = false;
 }
 
-/*****************************************************************************/
-/* Figures out which buffer is currently playing based on messages sent to   */
-/* it from the Audio device.                                                 */
-/*****************************************************************************/
+/**
+ * Figures out which buffer is currently playing based on messages sent to
+ * it from the Audio device.
+ */
 void Music::updateMusic() {
 	_vm->_event->processInput();
 	_vm->_event->updateMouse();
@@ -143,9 +143,9 @@ void Music::fillbuffer(byte *musicBuffer) {
 	}
 }
 
-/*****************************************************************************/
-/* Starts up the music initially.                                            */
-/*****************************************************************************/
+/**
+ * Starts up the music initially.
+ */
 void Music::startMusic(bool restartFl) {
 	if (!_musicOn)
 		return;
@@ -161,9 +161,9 @@ void Music::startMusic(bool restartFl) {
 	updateMusic();
 }
 
-/*****************************************************************************/
-/* Initializes the music buffers.                                            */
-/*****************************************************************************/
+/**
+ * Initializes the music buffers.
+ */
 bool Music::initMusic() {
 	_musicOn = true;
 	_musicPaused = false;
@@ -180,9 +180,9 @@ bool Music::initMusic() {
 	return true;
 }
 
-/*****************************************************************************/
-/* Frees up the music buffers and closes the file.                           */
-/*****************************************************************************/
+/**
+ * Frees up the music buffers and closes the file.
+ */
 void Music::freeMusic() {
 	_musicOn = false;
 
@@ -195,9 +195,9 @@ void Music::freeMusic() {
 	_file = NULL;
 }
 
-/*****************************************************************************/
-/* Pauses the background music.                                              */
-/*****************************************************************************/
+/**
+ * Pauses the background music.
+ */
 void Music::pauseBackMusic() {
 	if (!_musicPaused && _musicOn) {
 		updateMusic();
@@ -210,9 +210,9 @@ void Music::pauseBackMusic() {
 	}
 }
 
-/*****************************************************************************/
-/* Resumes the paused background music.                                      */
-/*****************************************************************************/
+/**
+ * Resumes the paused background music.
+ */
 void Music::resumeBackMusic() {
 	if (_musicPaused) {
 		stopSoundEffect();
@@ -225,9 +225,9 @@ void Music::resumeBackMusic() {
 	}
 }
 
-/*****************************************************************************/
-/* Turns the music on and off.                                               */
-/*****************************************************************************/
+/**
+ * Turns the music on and off.
+ */
 void Music::setMusic(bool on) {
 	stopSoundEffect();
 
@@ -241,9 +241,9 @@ void Music::setMusic(bool on) {
 		_musicOn = on;
 }
 
-/******************************************************************************/
-/* Checks the music that should be playing in a particular room.              */
-/******************************************************************************/
+/**
+ * Checks the music that should be playing in a particular room.
+ */
 void Music::checkRoomMusic() {
 	if ((_lastMusicRoom == _vm->_roomNum) || !_musicOn)
 		return;
@@ -258,9 +258,9 @@ void Music::checkRoomMusic() {
 	_lastMusicRoom = _vm->_roomNum;
 }
 
-/*****************************************************************************/
-/* Changes the background music to something else.                           */
-/*****************************************************************************/
+/**
+ * Changes the background music to something else.
+ */
 void Music::changeMusic(const char *newmusic) {
 	if (!_tFile) {
 		_tFile = _file;
@@ -278,9 +278,9 @@ void Music::changeMusic(const char *newmusic) {
 	setMusic(true);
 }
 
-/*****************************************************************************/
-/* Changes the background music to the original piece playing.               */
-/*****************************************************************************/
+/**
+ * Changes the background music to the original piece playing.
+ */
 void Music::resetMusic() {
 	if (!_tFile)
 		return;
@@ -308,9 +308,9 @@ void Music::resetMusic() {
 	_tFile = 0;
 }
 
-/*****************************************************************************/
-/* Reads in a music file.  Ignores any graphics.                             */
-/*****************************************************************************/
+/**
+ * Reads in a music file.  Ignores any graphics.
+ */
 bool Music::readMusic(const char *filename, bool waitTillFinished) {
 	Common::File *file = _vm->_resource->openDataFile(filename, MKTAG('D', 'I', 'F', 'F'));
 	updateMusic();
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index bf3f8a4..10f52a2 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -113,9 +113,9 @@ bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
 	return true;
 }
 
-/*****************************************************************************/
-/* Writes the game out to disk.                                              */
-/*****************************************************************************/
+/**
+ * Writes the game out to disk.
+ */
 bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc) {
 	uint16 i, j;
 	Common::String fileName = g_lab->generateSaveFileName(slot);
@@ -164,9 +164,9 @@ bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc)
 	return true;
 }
 
-/*****************************************************************************/
-/* Reads the game from disk.                                                 */
-/*****************************************************************************/
+/**
+ * Reads the game from disk.
+ */
 bool loadGame(uint16 *Direction, uint16 *Quarters, int slot) {
 	uint16 i, j;
 	Common::String fileName = g_lab->generateSaveFileName(slot);
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 0d92772..62d45d1 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -92,9 +92,9 @@ static byte *loadBackPict(const char *fileName, bool tomem) {
 	return res;
 }
 
-/*****************************************************************************/
-/* Does the things to properly set up the detective notes.                   */
-/*****************************************************************************/
+/**
+ * Does the things to properly set up the detective notes.
+ */
 void LabEngine::doNotes() {
 	TextFont *noteFont = g_lab->_resource->getFont("P:Note.fon");
 	char *ntext = g_lab->_resource->getText("Lab:Rooms/Notes");
@@ -107,10 +107,10 @@ void LabEngine::doNotes() {
 }
 
 
-/*****************************************************************************/
-/* Does the things to properly set up the old west newspaper.  Assumes that  */
-/* OpenHiRes already called.                                                 */
-/*****************************************************************************/
+/**
+ * Does the things to properly set up the old west newspaper.  Assumes that
+ * OpenHiRes already called.
+ */
 void LabEngine::doWestPaper() {
 	char *ntext;
 	TextFont *paperFont;
@@ -147,9 +147,9 @@ void LabEngine::doWestPaper() {
 	g_lab->_graphics->setPalette(g_lab->_anim->_diffPalette, 256);
 }
 
-/*****************************************************************************/
-/* Loads in the data for the journal.                                        */
-/*****************************************************************************/
+/**
+ * Loads in the data for the journal.
+ */
 static bool loadJournalData() {
 	char filename[20];
 	bool bridge, dirty, news, clean;
@@ -223,9 +223,9 @@ static bool loadJournalData() {
 	return true;
 }
 
-/*****************************************************************************/
-/* Draws the text to the back journal screen to the appropriate Page number  */
-/*****************************************************************************/
+/**
+ * Draws the text to the back journal screen to the appropriate Page number
+ */
 static void drawJournalText() {
 	uint16 DrawingToPage = 1;
 	int32 CharsDrawn    = 0L;
@@ -261,9 +261,9 @@ static void drawJournalText() {
 	lastpage = lastpage || (*CurText == 0);
 }
 
-/*****************************************************************************/
-/* Does the turn page wipe.                                                  */
-/*****************************************************************************/
+/**
+ * Does the turn page wipe.
+ */
 static void turnPage(bool FromLeft) {
 	if (FromLeft) {
 		for (int i = 0; i < g_lab->_graphics->_screenWidth; i += 8) {
@@ -282,9 +282,9 @@ static void turnPage(bool FromLeft) {
 	}
 }
 
-/*****************************************************************************/
-/* Draws the journal from page x.                                            */
-/*****************************************************************************/
+/**
+ * Draws the journal from page x.
+ */
 void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 	_event->mouseHide();
 
@@ -326,9 +326,9 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 	g_lab->_anim->_noPalChange = false;
 }
 
-/*****************************************************************************/
-/* Processes user input.                                                     */
-/*****************************************************************************/
+/**
+ * Processes user input.
+ */
 void LabEngine::processJournal() {
 	IntuiMessage *Msg;
 	uint32 Class;
@@ -368,9 +368,9 @@ void LabEngine::processJournal() {
 	}
 }
 
-/*****************************************************************************/
-/* Does the journal processing.                                              */
-/*****************************************************************************/
+/**
+ * Does the journal processing.
+ */
 void LabEngine::doJournal() {
 	GadgetList journalGadgetList;
 	journalGadgetList.push_back(&BackG);
@@ -449,9 +449,9 @@ bool LabEngine::saveRestoreGame() {
 	return isOK;
 }
 
-/*****************************************************************************/
-/* Draws the text for the monitor.                                           */
-/*****************************************************************************/
+/**
+ * Draws the text for the monitor.
+ */
 void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) {
 	uint16 DrawingToPage = 0, yspacing = 0, numlines, fheight;
 	int32 CharsDrawn    = 0L;
@@ -509,9 +509,9 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
 	_event->mouseShow();
 }
 
-/*****************************************************************************/
-/* Processes user input.                                                     */
-/*****************************************************************************/
+/**
+ * Processes user input.
+ */
 void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	IntuiMessage *Msg;
 	uint32 Class;
@@ -603,9 +603,9 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 	}
 }
 
-/*****************************************************************************/
-/* Does what's necessary for the monitor.                                    */
-/*****************************************************************************/
+/**
+ * Does what's necessary for the monitor.
+ */
 void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	char *ntext;
 
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index 4d95d4c..c6997c5 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -62,9 +62,9 @@ void LabEngine::initTilePuzzle() {
 		_combination[i] = 0;
 }
 
-/*****************************************************************************/
-/* Processes mouse clicks and changes the combination.                       */
-/*****************************************************************************/
+/**
+ * Processes mouse clicks and changes the combination.
+ */
 void LabEngine::mouseTile(Common::Point pos) {
 	Common::Point realPos = _utils->vgaUnscale(pos);
 
@@ -78,9 +78,9 @@ void LabEngine::mouseTile(Common::Point pos) {
 		changeTile(tileX, tileY);
 }
 
-/*****************************************************************************/
-/* Changes the combination number of one of the slots                        */
-/*****************************************************************************/
+/**
+ * Changes the combination number of one of the slots
+ */
 void LabEngine::changeTile(uint16 col, uint16 row) {
 	int16 scrolltype = -1;
 
@@ -147,9 +147,9 @@ void LabEngine::changeTile(uint16 col, uint16 row) {
 	}
 }
 
-/*****************************************************************************/
-/* Processes mouse clicks and changes the combination.                       */
-/*****************************************************************************/
+/**
+ * Processes mouse clicks and changes the combination.
+ */
 void LabEngine::mouseCombination(Common::Point pos) {
 	Common::Point realPos = _utils->vgaUnscale(pos);
 
@@ -173,9 +173,9 @@ void LabEngine::mouseCombination(Common::Point pos) {
 	changeCombination(number);
 }
 
-/*****************************************************************************/
-/* Draws the images of the combination lock to the display bitmap.           */
-/*****************************************************************************/
+/**
+ * Draws the images of the combination lock to the display bitmap.
+ */
 void LabEngine::doTile(bool showsolution) {
 	uint16 row = 0, col = 0, rowm, colm, num;
 	int16 rows, cols;
@@ -215,9 +215,9 @@ void LabEngine::doTile(bool showsolution) {
 	}
 }
 
-/*****************************************************************************/
-/* Reads in a backdrop picture.                                              */
-/*****************************************************************************/
+/**
+ * Reads in a backdrop picture.
+ */
 void LabEngine::showTile(const char *filename, bool showsolution) {
 	uint16 start = showsolution ? 0 : 1;
 
@@ -238,9 +238,9 @@ void LabEngine::showTile(const char *filename, bool showsolution) {
 	_graphics->setPalette(_anim->_diffPalette, 256);
 }
 
-/*****************************************************************************/
-/* Does the scrolling for the tiles on the tile puzzle.                      */
-/*****************************************************************************/
+/**
+ * Does the scrolling for the tiles on the tile puzzle.
+ */
 void LabEngine::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 	int16 dX = 0, dY = 0, dx = 0, dy = 0, sx = 0, sy = 0;
 	uint16 last = 0;
@@ -278,9 +278,9 @@ void LabEngine::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 	}
 }
 
-/*****************************************************************************/
-/* Changes the combination number of one of the slots                        */
-/*****************************************************************************/
+/**
+ * Changes the combination number of one of the slots
+ */
 void LabEngine::changeCombination(uint16 number) {
 	static const int solution[6] = { 0, 4, 0, 8, 7, 2 };
 
@@ -328,17 +328,17 @@ void LabEngine::scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2
 		_graphics->scrollDisplayY(dy, x1, y1, x2, y2);
 }
 
-/*****************************************************************************/
-/* Draws the images of the combination lock to the display bitmap.           */
-/*****************************************************************************/
+/**
+ * Draws the images of the combination lock to the display bitmap.
+ */
 void LabEngine::doCombination() {
 	for (uint16 i = 0; i <= 5; i++)
 		_numberImages[_combination[i]]->drawImage(_utils->vgaScaleX(COMBINATION_X[i]), _utils->vgaScaleY(65));
 }
 
-/*****************************************************************************/
-/* Reads in a backdrop picture.                                              */
-/*****************************************************************************/
+/**
+ * Reads in a backdrop picture.
+ */
 void LabEngine::showCombination(const char *filename) {
 	_anim->_doBlack = true;
 	_anim->_noPalChange = true;
diff --git a/engines/lab/timing.cpp b/engines/lab/timing.cpp
index 63a2b94..1cbe6d3 100644
--- a/engines/lab/timing.cpp
+++ b/engines/lab/timing.cpp
@@ -32,12 +32,11 @@
 
 namespace Lab {
 
-/*****************************************************************************/
-/* Waits for for Secs seconds and Micros microseconds to pass.               */
-/*****************************************************************************/
+/**
+ * Waits for for Secs seconds and Micros microseconds to pass.
+ */
 void LabEngine::microDelay(uint32 secs, uint32 micros) {
 	uint32 waitSecs, waitMicros;
-
 	addCurTime(secs, micros, &waitSecs, &waitMicros);
 
 	while (1) {
@@ -50,9 +49,9 @@ void LabEngine::microDelay(uint32 secs, uint32 micros) {
 	}
 }
 
-/*****************************************************************************/
-/* Gets the current system time.                                             */
-/*****************************************************************************/
+/**
+ * Gets the current system time.
+ */
 void LabEngine::getTime(uint32 *secs, uint32 *micros) {
 	uint32 t = g_system->getMillis();
 
@@ -60,9 +59,9 @@ void LabEngine::getTime(uint32 *secs, uint32 *micros) {
 	*micros = t % 1000;
 }
 
-/*****************************************************************************/
-/* Adds seconds and microseconds to current time to get a new time.          */
-/*****************************************************************************/
+/**
+ * Adds seconds and microseconds to current time to get a new time.
+ */
 void LabEngine::addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *timeMicros) {
 	getTime(timeSec, timeMicros);
 
@@ -75,10 +74,10 @@ void LabEngine::addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *t
 	}
 }
 
-/*****************************************************************************/
-/* Finds the difference between time1 and time2.  If time1 is later than     */
-/* time2, returns 0.                                                         */
-/*****************************************************************************/
+/**
+ * Finds the difference between time1 and time2.  If time1 is later than
+ * time2, returns 0.
+ */
 void LabEngine::anyTimeDiff(uint32 sec1, uint32 micros1, uint32 sec2, uint32 micros2, uint32 *diffSecs, uint32 *diffMicros) {
 	*diffSecs = 0;
 	*diffMicros = 0;
@@ -97,22 +96,21 @@ void LabEngine::anyTimeDiff(uint32 sec1, uint32 micros1, uint32 sec2, uint32 mic
 	}
 }
 
-/*****************************************************************************/
-/* Finds the difference between the current time, and a future time. Returns */
-/* 0 if the future time is actually before the current time.                 */
-/*****************************************************************************/
+/**
+ * Finds the difference between the current time, and a future time. Returns
+ * 0 if the future time is actually before the current time.
+ */
 void LabEngine::timeDiff(uint32 sec, uint32 micros, uint32 *diffSec, uint32 *diffMicros) {
 	uint32 curSec, curMicros;
 	getTime(&curSec, &curMicros);
 	anyTimeDiff(curSec, curMicros, sec, micros, diffSec, diffMicros);
 }
 
-/*****************************************************************************/
-/* Waits for a specified time to occur.                                      */
-/*****************************************************************************/
+/**
+ * Waits for a specified time to occur.
+ */
 void LabEngine::waitForTime(uint32 sec, uint32 micros) {
 	uint32 curSec, curMicros;
-
 	getTime(&curSec, &curMicros);
 
 	if (curSec > sec)
diff --git a/engines/lab/transitions.cpp b/engines/lab/transitions.cpp
index 7090181..6f90718 100644
--- a/engines/lab/transitions.cpp
+++ b/engines/lab/transitions.cpp
@@ -34,9 +34,9 @@
 
 namespace Lab {
 
-/*****************************************************************************/
-/* Scrolls the display to black.                                             */
-/*****************************************************************************/
+/**
+ * Scrolls the display to black.
+ */
 void DisplayMan::doScrollBlack() {
 	byte *tempmem;
 	Image im;
@@ -132,9 +132,9 @@ void DisplayMan::copyPage(uint16 width, uint16 height, uint16 nheight, uint16 st
 	}
 }
 
-/*****************************************************************************/
-/* Scrolls the display to a new picture from a black screen.                 */
-/*****************************************************************************/
+/**
+ * Scrolls the display to a new picture from a black screen.
+ */
 void DisplayMan::doScrollWipe(char *filename) {
 	uint16 startline = 0, onrow = 0;
 
@@ -189,9 +189,9 @@ void DisplayMan::doScrollWipe(char *filename) {
 	_vm->_event->mouseShow();
 }
 
-/*****************************************************************************/
-/* Does the scroll bounce.  Assumes bitmap already in memory.                */
-/*****************************************************************************/
+/**
+ * Does the scroll bounce.  Assumes bitmap already in memory.
+ */
 void DisplayMan::doScrollBounce() {
 	const uint16 *newby, *newby1;
 
@@ -235,9 +235,9 @@ void DisplayMan::doScrollBounce() {
 	_vm->_event->mouseShow();
 }
 
-/*****************************************************************************/
-/* Does the transporter wipe.                                                */
-/*****************************************************************************/
+/**
+ * Does the transporter wipe.
+ */
 void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 	uint16 lastY, curY, linesdone = 0, lineslast;
 	Image imSource, imDest;
@@ -318,9 +318,9 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 	}	// for j
 }
 
-/*****************************************************************************/
-/* Does a certain number of pre-programmed wipes.                            */
-/*****************************************************************************/
+/**
+ * Does a certain number of pre-programmed wipes.
+ */
 void DisplayMan::doTransition(TransitionType transitionType, CloseDataPtr *cPtr, char *filename) {
 	switch (transitionType) {
 	case kTransitionWipe:
@@ -348,9 +348,9 @@ void DisplayMan::doTransition(TransitionType transitionType, CloseDataPtr *cPtr,
 	}
 }
 
-/*****************************************************************************/
-/* Changes the front screen to black.                                        */
-/*****************************************************************************/
+/**
+ * Changes the front screen to black.
+ */
 void DisplayMan::blackScreen() {
 	byte pal[256 * 3];
 	memset(pal, 0, 248 * 3);
@@ -359,18 +359,18 @@ void DisplayMan::blackScreen() {
 	g_system->delayMillis(32);
 }
 
-/*****************************************************************************/
-/* Changes the front screen to white.                                        */
-/*****************************************************************************/
+/**
+ * Changes the front screen to white.
+ */
 void DisplayMan::whiteScreen() {
 	byte pal[256 * 3];
 	memset(pal, 255, 248 * 3);
 	writeColorRegs(pal, 8, 248);
 }
 
-/*****************************************************************************/
-/* Changes the entire screen to black.                                       */
-/*****************************************************************************/
+/**
+ * Changes the entire screen to black.
+*/
 void DisplayMan::blackAllScreen() {
 	byte pal[256 * 3];
 	memset(pal, 0, 256 * 3);
@@ -379,11 +379,11 @@ void DisplayMan::blackAllScreen() {
 	g_system->delayMillis(32);
 }
 
-/*****************************************************************************/
-/* Scrolls the display in the x direction by blitting.                       */
-/* The _tempScrollData variable must be initialized to some memory, or this   */
-/* function will fail.                                                       */
-/*****************************************************************************/
+/**
+ * Scrolls the display in the x direction by blitting.
+ * The _tempScrollData variable must be initialized to some memory, or this
+ * function will fail.
+ */
 void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	Image im;
 
@@ -405,9 +405,9 @@ void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint1
 	rectFill(x1, y1, x1 + dx - 1, y2);
 }
 
-/*****************************************************************************/
-/* Scrolls the display in the y direction by blitting.                       */
-/*****************************************************************************/
+/**
+ * Scrolls the display in the y direction by blitting.
+ */
 void DisplayMan::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	Image im;
 
@@ -429,9 +429,9 @@ void DisplayMan::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint1
 	rectFill(x1, y1, x2, y1 + dy - 1);
 }
 
-/*****************************************************************************/
-/* Does the fading of the Palette on the screen.                             */
-/*****************************************************************************/
+/**
+ * Does the fading of the Palette on the screen.
+ */
 uint16 DisplayMan::fadeNumIn(uint16 num, uint16 res, uint16 counter) {
 	return (num - ((((int32)(15 - counter)) * ((int32)(num - res))) / 15));
 }
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index 041a970..d5d0734 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -36,10 +36,10 @@ Utils::Utils(LabEngine *vm) : _vm(vm) {
 	_dataBytesPerRow = 0;
 }
 
-/*****************************************************************************/
-/* Scales the x co-ordinates to that of the new display.  In the room parser */
-/* file, co-ordinates are set up on a 360x336 display.                       */
-/*****************************************************************************/
+/**
+ * Scales the x co-ordinates to that of the new display.  In the room parser
+ * file, co-ordinates are set up on a 360x336 display.
+ */
 uint16 Utils::scaleX(uint16 x) {
 	if (_vm->_isHiRes)
 		return (uint16)((x * 16) / 9);
@@ -47,10 +47,10 @@ uint16 Utils::scaleX(uint16 x) {
 		return (uint16)((x * 8) / 9);
 }
 
-/*****************************************************************************/
-/* Scales the y co-ordinates to that of the new display.  In the room parser */
-/* file, co-ordinates are set up on a 368x336 display.                       */
-/*****************************************************************************/
+/**
+ * Scales the y co-ordinates to that of the new display.  In the room parser
+ * file, co-ordinates are set up on a 368x336 display.
+ */
 uint16 Utils::scaleY(uint16 y) {
 	if (_vm->_isHiRes)
 		return (y + (y / 14));
@@ -58,9 +58,9 @@ uint16 Utils::scaleY(uint16 y) {
 		return ((y * 10) / 24);
 }
 
-/*****************************************************************************/
-/* Scales the VGA coords to SVGA if necessary; otherwise, returns VGA coords.*/
-/*****************************************************************************/
+/**
+ * Scales the VGA coords to SVGA if necessary; otherwise, returns VGA coords.
+ */
 int16 Utils::vgaScaleX(int16 x) {
 	if (_vm->_isHiRes)
 		return (x * 2);
@@ -68,9 +68,9 @@ int16 Utils::vgaScaleX(int16 x) {
 		return x;
 }
 
-/*****************************************************************************/
-/* Scales the VGA coords to SVGA if necessary; otherwise, returns VGA coords.*/
-/*****************************************************************************/
+/**
+ * Scales the VGA coords to SVGA if necessary; otherwise, returns VGA coords.
+ */
 int16 Utils::vgaScaleY(int16 y) {
 	if (_vm->_isHiRes)
 		return ((y * 12) / 5);
@@ -85,9 +85,9 @@ uint16 Utils::svgaCord(uint16 cord) {
 		return 0;
 }
 
-/*****************************************************************************/
-/* Converts SVGA coords to VGA if necessary, otherwise returns VGA coords.   */
-/*****************************************************************************/
+/**
+ * Converts SVGA coords to VGA if necessary, otherwise returns VGA coords.
+ */
 Common::Point Utils::vgaUnscale(Common::Point pos) {
 	Common::Point result;
 	if (_vm->_isHiRes) {
@@ -100,10 +100,10 @@ Common::Point Utils::vgaUnscale(Common::Point pos) {
 	return result;
 }
 
-/*****************************************************************************/
-/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
-/* is also a byte.                                                           */
-/*****************************************************************************/
+/**
+ * Undiffs a piece of memory when header size is a byte, and copy/skip size
+ * is also a byte.
+ */
 void Utils::unDiffByteByte(byte *dest, byte *diff) {
 	uint16 skip, copy;
 
@@ -130,10 +130,10 @@ void Utils::unDiffByteByte(byte *dest, byte *diff) {
 	}
 }
 
-/*****************************************************************************/
-/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
-/* is a word.                                                                */
-/*****************************************************************************/
+/**
+ * Undiffs a piece of memory when header size is a byte, and copy/skip size
+ * is a word.
+ */
 void Utils::unDiffByteWord(uint16 *dest, uint16 *diff) {
 	uint16 skip, copy;
 
@@ -186,10 +186,10 @@ void Utils::unDiffByteWord(uint16 *dest, uint16 *diff) {
 
 /*------------------------- unDiff Vertical Memory --------------------------*/
 
-/*****************************************************************************/
-/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
-/* is a byte.                                                                */
-/*****************************************************************************/
+/**
+ * Undiffs a piece of memory when header size is a byte, and copy/skip size
+ * is a byte.
+ */
 void Utils::VUnDiffByteByte(byte *dest, byte *diff, uint16 bytesPerRow) {
 	byte *curPtr;
 	uint16 skip, copy;
@@ -224,10 +224,10 @@ void Utils::VUnDiffByteByte(byte *dest, byte *diff, uint16 bytesPerRow) {
 	}
 }
 
-/*****************************************************************************/
-/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
-/* is a word.                                                                */
-/*****************************************************************************/
+/**
+ * Undiffs a piece of memory when header size is a byte, and copy/skip size
+ * is a word.
+ */
 void Utils::VUnDiffByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow) {
 	uint16 *curPtr;
 	uint16 skip, copy;
@@ -264,10 +264,10 @@ void Utils::VUnDiffByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow) {
 	}
 }
 
-/*****************************************************************************/
-/* Undiffs a piece of memory when header size is a byte, and copy/skip size  */
-/* is a long.                                                                */
-/*****************************************************************************/
+/**
+ * Undiffs a piece of memory when header size is a byte, and copy/skip size
+ * is a long.
+ */
 void Utils::VUnDiffByteLong(uint32 *dest, uint32 *diff, uint16 bytesPerRow) {
 	uint32 *_curPtr;
 	uint16 skip, copy;
@@ -307,9 +307,9 @@ void Utils::VUnDiffByteLong(uint32 *dest, uint32 *diff, uint16 bytesPerRow) {
 	}
 }
 
-/*****************************************************************************/
-/* Runlength decodes a chunk of memory.                                      */
-/*****************************************************************************/
+/**
+ * Runlength decodes a chunk of memory.
+ */
 void Utils::runLengthDecode(byte *dest, byte *source) {
 	int8 num;
 	int16 count;
@@ -338,9 +338,9 @@ void Utils::runLengthDecode(byte *dest, byte *source) {
 	}
 }
 
-/*****************************************************************************/
-/* Does a vertical run length decode.                                        */
-/*****************************************************************************/
+/**
+ * Does a vertical run length decode.
+ */
 void Utils::VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow) {
 	int8 num;
 	int16 count;
@@ -379,9 +379,9 @@ void Utils::VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow) {
 	}
 }
 
-/*****************************************************************************/
-/* Does the undiffing between the bitmaps.                                   */
-/*****************************************************************************/
+/**
+ * Does the undiffing between the bitmaps.
+ */
 void Utils::unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesPerRow, bool isV) {
 	diffData++;
 	byte bufType = *diffData;


Commit: 21fc36bfad679426f19e77c4d783ba809038735c
    https://github.com/scummvm/scummvm/commit/21fc36bfad679426f19e77c4d783ba809038735c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:55+01:00

Commit Message:
LAB: Get rid of _isBM

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h
    engines/lab/graphics.cpp
    engines/lab/graphics.h
    engines/lab/transitions.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 4927b25..fef1edf 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -37,7 +37,6 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 	_header = 0;
 	_curBit = 0;
 	_numChunks = 1;
-	_isBM = false;
 	_headerdata._width = 0;
 	_headerdata._height = 0;
 	_headerdata._fps = 0;
@@ -78,7 +77,7 @@ void Anim::readBlock(void *Buffer, uint32 Size, byte **File) {
 	(*File) += Size;
 }
 
-void Anim::diffNextFrame() {
+void Anim::diffNextFrame(bool onlyDiffData) {
 	if (_header == 65535)  /* Already done. */
 		return;
 
@@ -96,7 +95,7 @@ void Anim::diffNextFrame() {
 		if (_curBit >= _numChunks) {
 			_vm->_event->mouseShow();
 
-			if (!_isBM) {
+			if (!onlyDiffData) {
 				if (_headerdata._fps) {
 					_vm->waitForTime(_waitSec, _waitMicros);
 					_vm->addCurTime(0L, _delayMicros, &_waitSec, &_waitMicros);
@@ -110,7 +109,7 @@ void Anim::diffNextFrame() {
 				_donePal = true;
 			}
 
-			if (_isPal && !_noPalChange && !_isBM && !_donePal) {
+			if (_isPal && !_noPalChange && !onlyDiffData && !_donePal) {
 				_vm->_graphics->setPalette(_diffPalette, 256);
 				_isPal = false;
 			}
@@ -147,7 +146,7 @@ void Anim::diffNextFrame() {
 		case 10L:
 			_rawDiffBM._planes[_curBit] = _diffFile;
 
-			if (_isBM)
+			if (onlyDiffData)
 				_diffFile += _size;
 			else {
 				readBlock(DrawBitMap->_planes[_curBit], _size, &_diffFile);
@@ -246,7 +245,7 @@ void Anim::diffNextFrame() {
 /**
  * A separate task launched by readDiff.  Plays the DIFF.
  */
-void Anim::playDiff(byte *buffer) {
+void Anim::playDiff(byte *buffer, bool onlyDiffData) {
 	_waitSec = 0L;
 	_waitMicros = 0L;
 	_delayMicros = 0L;
@@ -325,9 +324,9 @@ void Anim::playDiff(byte *buffer) {
 
 	if (_playOnce) {
 		while (_header != 65535)
-			diffNextFrame();
+			diffNextFrame(onlyDiffData);
 	} else
-		diffNextFrame();
+		diffNextFrame(onlyDiffData);
 }
 
 /**
@@ -354,9 +353,9 @@ void Anim::stopDiffEnd() {
 /**
  * Reads in a DIFF file.
  */
-bool Anim::readDiff(byte *buffer, bool playOnce) {
+bool Anim::readDiff(byte *buffer, bool playOnce, bool onlyDiffData) {
 	_playOnce = playOnce;
-	playDiff(buffer);
+	playDiff(buffer, onlyDiffData);
 	return true;
 }
 
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 121edea..82732f0 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -86,21 +86,20 @@ private:
 	BitMap *DrawBitMap;
 
 	void readBlock(void *Buffer, uint32 Size, byte **File);
-	void playDiff(byte *buffer);
+	void playDiff(byte *buffer, bool onlyDiffData = false);
 
 public:
 	Anim(LabEngine *vm);
 
 	DIFFHeader _headerdata;
 	char _diffPalette[256 * 3];
-	bool _isBM;          /* Just fill in the RawDIFFBM structure */
 	bool _waitForEffect; /* Wait for each sound effect to finish before continuing. */
 	bool _doBlack;       /* Black the screen before new picture  */
 	bool _noPalChange;   /* Don't change the palette.            */
 	BitMap _rawDiffBM;
 
-	bool readDiff(byte *buffer, bool playOnce);
-	void diffNextFrame();
+	bool readDiff(byte *buffer, bool playOnce, bool onlyDiffData = false);
+	void diffNextFrame(bool onlyDiffData = false);
 	void stopDiff();
 	void stopDiffEnd();
 };
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 926dc7c..0d4501e 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -77,7 +77,7 @@ void DisplayMan::loadPict(const char *filename) {
 /**
  * Reads in a picture into the dest bitmap.
  */
-void DisplayMan::readPict(const char *filename, bool playOnce) {
+void DisplayMan::readPict(const char *filename, bool playOnce, bool onlyDiffData) {
 	_vm->_anim->stopDiff();
 
 	loadPict(filename);
@@ -91,7 +91,7 @@ void DisplayMan::readPict(const char *filename, bool playOnce) {
 	_dispBitMap._rows        = _screenHeight;
 	_dispBitMap._flags       = BITMAPF_VIDEO;
 
-	_vm->_anim->readDiff(_curBitmap, playOnce);
+	_vm->_anim->readDiff(_curBitmap, playOnce, onlyDiffData);
 }
 
 /**
diff --git a/engines/lab/graphics.h b/engines/lab/graphics.h
index 9c25295..8798718 100644
--- a/engines/lab/graphics.h
+++ b/engines/lab/graphics.h
@@ -75,7 +75,7 @@ public:
 	virtual ~DisplayMan();
 
 	void loadPict(const char *filename);
-	void readPict(const char *filename, bool playOnce);
+	void readPict(const char *filename, bool playOnce, bool onlyDiffData = false);
 	void freePict();
 	byte *readPictToMem(const char *filename, uint16 x, uint16 y);
 	void doScrollBlack();
diff --git a/engines/lab/transitions.cpp b/engines/lab/transitions.cpp
index 6f90718..c611266 100644
--- a/engines/lab/transitions.cpp
+++ b/engines/lab/transitions.cpp
@@ -147,10 +147,8 @@ void DisplayMan::doScrollWipe(char *filename) {
 		_vm->waitTOF();
 	}
 
-	_vm->_anim->_isBM = true;
-	readPict(filename, true);
+	readPict(filename, true, true);
 	setPalette(_vm->_anim->_diffPalette, 256);
-	_vm->_anim->_isBM = false;
 	byte *mem = _vm->_anim->_rawDiffBM._planes[0];
 
 	_vm->_music->updateMusic();


Commit: 2d0fab7f4c1e4c7f8e88aee6a867a98a8917de86
    https://github.com/scummvm/scummvm/commit/2d0fab7f4c1e4c7f8e88aee6a867a98a8917de86
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:55+01:00

Commit Message:
LAB: Use // for comments

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h
    engines/lab/engine.cpp
    engines/lab/eventman.cpp
    engines/lab/eventman.h
    engines/lab/graphics.cpp
    engines/lab/graphics.h
    engines/lab/interface.cpp
    engines/lab/interface.h
    engines/lab/lab.h
    engines/lab/labfun.h
    engines/lab/labsets.h
    engines/lab/map.cpp
    engines/lab/music.cpp
    engines/lab/music.h
    engines/lab/processroom.cpp
    engines/lab/processroom.h
    engines/lab/resource.h
    engines/lab/savegame.cpp
    engines/lab/special.cpp
    engines/lab/tilepuzzle.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index fef1edf..523bfc0 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -78,7 +78,8 @@ void Anim::readBlock(void *Buffer, uint32 Size, byte **File) {
 }
 
 void Anim::diffNextFrame(bool onlyDiffData) {
-	if (_header == 65535)  /* Already done. */
+	if (_header == 65535)
+		// Already done.
 		return;
 
 	if (_vm->_graphics->_dispBitMap._flags & BITMAPF_VIDEO) {
@@ -127,7 +128,8 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 			if (_vm->_graphics->_dispBitMap._flags & BITMAPF_VIDEO)
 				_vm->_graphics->screenUpdate();
 
-			return; /* done with the next frame. */
+			// done with the next frame.
+			return;
 		}
 
 		_vm->_music->updateMusic();
@@ -231,7 +233,8 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 				return;
 			}
 
-			_frameNum = 4;  /* Random frame number so it never gets back to 2 */
+			// Random frame number so it never gets back to 2
+			_frameNum = 4;
 			_diffFile = _buffer;
 			break;
 
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 82732f0..b5df6e2 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -93,9 +93,9 @@ public:
 
 	DIFFHeader _headerdata;
 	char _diffPalette[256 * 3];
-	bool _waitForEffect; /* Wait for each sound effect to finish before continuing. */
-	bool _doBlack;       /* Black the screen before new picture  */
-	bool _noPalChange;   /* Don't change the palette.            */
+	bool _waitForEffect; // Wait for each sound effect to finish before continuing.
+	bool _doBlack;       // Black the screen before new picture
+	bool _noPalChange;   // Don't change the palette.
 	BitMap _rawDiffBM;
 
 	bool readDiff(byte *buffer, bool playOnce, bool onlyDiffData = false);
@@ -106,6 +106,6 @@ public:
 
 } // End of namespace Lab
 
-#endif /* LAB_DIFF_H */
+#endif // LAB_DIFF_H
 
 
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 6fb4c70..5ea7df8 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -39,10 +39,10 @@
 
 namespace Lab {
 
-/* Global parser data */
+// Global parser data
 bool ispal = false;
 
-/* LAB: Labyrinth specific code for the special puzzles */
+// LAB: Labyrinth specific code for the special puzzles
 #define SPECIALLOCK         100
 #define SPECIALBRICK        101
 #define SPECIALBRICKNOMOUSE 102
@@ -97,7 +97,8 @@ void LabEngine::drawRoomMessage(uint16 curInv, CloseDataPtr closePtr) {
 
 	if (_alternate) {
 		if ((curInv <= _numInv) && _conditions->in(curInv) && _inventory[curInv]._bitmapName) {
-			if ((curInv == LAMPNUM) && _conditions->in(LAMPON))  /* LAB: Labyrinth specific */
+			if ((curInv == LAMPNUM) && _conditions->in(LAMPON))
+				// LAB: Labyrinth specific
 				drawStaticMessage(kTextLampOn);
 			else if (_inventory[curInv]._many > 1) {
 				Common::String roomMessage = Common::String(_inventory[curInv]._name) + "  (" + Common::String::format("%d", _inventory[curInv]._many) + ")";
@@ -277,7 +278,8 @@ void LabEngine::interfaceOn() {
  * If the user hits the "Use" gadget; things that can get used on themselves.
  */
 bool LabEngine::doUse(uint16 curInv) {
-	if (curInv == MAPNUM) {                  /* LAB: Labyrinth specific */
+	if (curInv == MAPNUM) {
+		// LAB: Labyrinth specific
 		drawStaticMessage(kTextUseMap);
 		interfaceOff();
 		_anim->stopDiff();
@@ -287,7 +289,8 @@ bool LabEngine::doUse(uint16 curInv) {
 		_graphics->setPalette(initcolors, 8);
 		_graphics->drawMessage(NULL);
 		_graphics->drawPanel();
-	} else if (curInv == JOURNALNUM) {         /* LAB: Labyrinth specific */
+	} else if (curInv == JOURNALNUM) {
+		// LAB: Labyrinth specific
 		drawStaticMessage(kTextUseJournal);
 		interfaceOff();
 		_anim->stopDiff();
@@ -296,7 +299,8 @@ bool LabEngine::doUse(uint16 curInv) {
 		doJournal();
 		_graphics->drawPanel();
 		_graphics->drawMessage(NULL);
-	} else if (curInv == LAMPNUM) {            /* LAB: Labyrinth specific */
+	} else if (curInv == LAMPNUM) {
+		// LAB: Labyrinth specific
 		interfaceOff();
 
 		if (_conditions->in(LAMPON)) {
@@ -314,19 +318,23 @@ bool LabEngine::doUse(uint16 curInv) {
 
 		_anim->_doBlack = false;
 		_nextFileName = getInvName(curInv);
-	} else if (curInv == BELTNUM) {                    /* LAB: Labyrinth specific */
+	} else if (curInv == BELTNUM) {
+		// LAB: Labyrinth specific
 		if (!_conditions->in(BELTGLOW))
 			_conditions->inclElement(BELTGLOW);
 
 		_anim->_doBlack = false;
 		_nextFileName = getInvName(curInv);
-	} else if (curInv == WHISKEYNUM) {                 /* LAB: Labyrinth specific */
+	} else if (curInv == WHISKEYNUM) {
+		// LAB: Labyrinth specific
 		_conditions->inclElement(USEDHELMET);
 		drawStaticMessage(kTextUseWhiskey);
-	} else if (curInv == PITHHELMETNUM) {              /* LAB: Labyrinth specific */
+	} else if (curInv == PITHHELMETNUM) {
+		// LAB: Labyrinth specific
 		_conditions->inclElement(USEDHELMET);
 		drawStaticMessage(kTextUsePith);
-	} else if (curInv == HELMETNUM) {                  /* LAB: Labyrinth specific */
+	} else if (curInv == HELMETNUM) {
+		// LAB: Labyrinth specific
 		_conditions->inclElement(USEDHELMET);
 		drawStaticMessage(kTextUseHelmet);
 	} else
@@ -411,8 +419,7 @@ void LabEngine::mainGameLoop() {
 
 	perFlipGadget(actionMode);
 
-	/* Set up initial picture. */
-
+	// Set up initial picture.
 	while (1) {
 		_event->processInput(true);
 
@@ -424,7 +431,7 @@ void LabEngine::mainGameLoop() {
 
 			_music->resumeBackMusic();
 
-			/* Sees what kind of close up we're in and does the appropriate stuff, if any. */
+			// Sees what kind of close up we're in and does the appropriate stuff, if any.
 			if (doCloseUp(_cptr)) {
 				_cptr = NULL;
 
@@ -432,27 +439,31 @@ void LabEngine::mainGameLoop() {
 				_graphics->screenUpdate();
 			}
 
-			/* Sets the current picture properly on the screen */
+			// Sets the current picture properly on the screen
 			if (_mainDisplay)
 				_nextFileName = getPictName(&_cptr);
 
 			if (_noUpdateDiff) {
-				_roomsFound->inclElement(_roomNum); /* Potentially entered another room */
+				// Potentially entered another room
+				_roomsFound->inclElement(_roomNum);
 				forceDraw |= (strcmp(_nextFileName, _curFileName) != 0);
 
 				_noUpdateDiff = false;
 				_curFileName = _nextFileName;
 			} else if (strcmp(_nextFileName, _curFileName) != 0) {
 				interfaceOff();
-				_roomsFound->inclElement(_roomNum); /* Potentially entered another room */
+				// Potentially entered another room
+				_roomsFound->inclElement(_roomNum);
 				_curFileName = _nextFileName;
 
 				if (_cptr) {
-					if ((_cptr->_closeUpType == SPECIALLOCK) && _mainDisplay)  /* LAB: Labyrinth specific code */
+					if ((_cptr->_closeUpType == SPECIALLOCK) && _mainDisplay)
+						// LAB: Labyrinth specific code
 						showCombination(_curFileName);
 					else if (((_cptr->_closeUpType == SPECIALBRICK)  ||
 								  (_cptr->_closeUpType == SPECIALBRICKNOMOUSE)) &&
-								  _mainDisplay) /* LAB: Labyrinth specific code */
+								  _mainDisplay)
+						// LAB: Labyrinth specific code
 						showTile(_curFileName, (bool)(_cptr->_closeUpType == SPECIALBRICKNOMOUSE));
 					else
 						_graphics->readPict(_curFileName, false);
@@ -476,11 +487,13 @@ void LabEngine::mainGameLoop() {
 			}
 		}
 
-		_music->updateMusic();  /* Make sure we check the music at least after every message */
+		// Make sure we check the music at least after every message
+		_music->updateMusic();
 		interfaceOn();
 		IntuiMessage *curMsg = getMsg();
 
-		if (curMsg == NULL) { /* Does music load and next animation frame when you've run out of messages */
+		if (curMsg == NULL) {
+			// Does music load and next animation frame when you've run out of messages
 			gotMessage = false;
 			_music->checkRoomMusic();
 			_music->updateMusic();
@@ -556,18 +569,20 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 	_anim->_doBlack = false;
 
 	if ((msgClass == RAWKEY) && (!_graphics->_longWinInFront)) {
-		if (code == 13) { /* The return key */
+		if (code == 13) {
+			// The return key
 			msgClass = MOUSEBUTTONS;
 			Qualifier = IEQUALIFIER_LEFTBUTTON;
 			curPos = _event->getMousePos();
-		} else if (getPlatform() == Common::kPlatformWindows &&
-				(code == 'b' || code == 'B')) {  /* Start bread crumbs */
+		} else if (getPlatform() == Common::kPlatformWindows && (code == 'b' || code == 'B')) {
+			// Start bread crumbs
 			_breadCrumbs[0]._roomNum = 0;
 			_numCrumbs = 0;
 			_droppingCrumbs = true;
 			mayShowCrumbIndicator();
 			_graphics->screenUpdate();
-		} else if (code == 'f' || code == 'F' || code == 'r' || code == 'R') {  /* Follow bread crumbs */
+		} else if (code == 'f' || code == 'F' || code == 'r' || code == 'R') {
+			// Follow bread crumbs
 			if (_droppingCrumbs) {
 				if (_numCrumbs > 0) {
 					_followingCrumbs = true;
@@ -583,7 +598,8 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 						_graphics->_doNotDrawMessage = false;
 
 						_mainDisplay = true;
-						interfaceOn(); /* Sets the correct gadget list */
+						// Sets the correct gadget list
+						interfaceOn();
 						_graphics->drawPanel();
 						drawRoomMessage(curInv, _cptr);
 						_graphics->screenUpdate();
@@ -597,7 +613,8 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 					_graphics->screenUpdate();
 				}
 			}
-		} else if ((code == 315) || (code == 'x') || (code == 'X') || (code == 'q') || (code == 'Q')) {  /* Quit? */
+		} else if ((code == 315) || (code == 'x') || (code == 'X') || (code == 'q') || (code == 'Q')) {
+			// Quit?
 			_graphics->_doNotDrawMessage = false;
 			_graphics->drawMessage("Do you want to quit? (Y/N)");
 			doit = false;
@@ -605,10 +622,12 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			interfaceOff();
 
 			while (1) {
-				_music->updateMusic();  /* Make sure we check the music at least after every message */
+				// Make sure we check the music at least after every message
+				_music->updateMusic();
 				curMsg = getMsg();
 
-				if (curMsg == NULL) { /* Does music load and next animation frame when you've run out of messages */
+				if (curMsg == NULL) {
+					// Does music load and next animation frame when you've run out of messages
 					_music->updateMusic();
 					_anim->diffNextFrame();
 				} else {
@@ -632,9 +651,11 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				forceDraw = true;
 				interfaceOn();
 			}
-		} else if (code == 9) { /* TAB key */
+		} else if (code == 9) {
+			// TAB key
 			msgClass = DELTAMOVE;
-		} else if (code == 27) { /* ESC key */
+		} else if (code == 27) {
+			// ESC key
 			_cptr = NULL;
 		}
 
@@ -667,8 +688,8 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				_alternate = true;
 				_anim->_doBlack = true;
 				_graphics->_doNotDrawMessage = false;
-				interfaceOn(); /* Sets the correct gadget list */
-
+				// Sets the correct gadget list
+				interfaceOn();
 				_mainDisplay = false;
 
 				if (lastInv && _conditions->in(lastInv)) {
@@ -700,7 +721,8 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 			mayShowCrumbIndicator();
 			_graphics->screenUpdate();
-		} else if (gadgetId >= 6) { /* Arrow Gadgets */
+		} else if (gadgetId >= 6) {
+			// Arrow Gadgets
 			_cptr = NULL;
 			hcptr = NULL;
 
@@ -734,7 +756,8 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 					if (oldRoomNum != _roomNum) {
 						drawStaticMessage(kTextGoForward);
-						_roomsFound->inclElement(_roomNum); /* Potentially entered a new room */
+						// Potentially entered a new room
+						_roomsFound->inclElement(_roomNum);
 						_curFileName = " ";
 						forceDraw = true;
 					} else {
@@ -798,7 +821,8 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			_graphics->_doNotDrawMessage = false;
 
 			_mainDisplay = true;
-			interfaceOn(); /* Sets the correct gadget list */
+			// Sets the correct gadget list
+			interfaceOn();
 			_graphics->drawPanel();
 			drawRoomMessage(curInv, _cptr);
 
@@ -833,7 +857,8 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 		} else if (gadgetId == 1) {
 			if (!doUse(curInv)) {
 				uint16 oldActionMode = actionMode;
-				actionMode = 5;  /* Use button */
+				// Use button
+				actionMode = 5;
 
 				if (oldActionMode < 5)
 					perFlipGadget(oldActionMode);
@@ -857,27 +882,31 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				_nextFileName = getInvName(curInv);
 
 			_graphics->screenUpdate();
-		} else if (gadgetId == 3) { /* Left gadget */
+		} else if (gadgetId == 3) {
+			// Left gadget
 			decIncInv(&curInv, true);
 			lastInv = curInv;
 			_graphics->_doNotDrawMessage = false;
 			drawRoomMessage(curInv, _cptr);
 
 			_graphics->screenUpdate();
-		} else if (gadgetId == 4) { /* Right gadget */
+		} else if (gadgetId == 4) {
+			// Right gadget
 			decIncInv(&curInv, false);
 			lastInv = curInv;
 			_graphics->_doNotDrawMessage = false;
 			drawRoomMessage(curInv, _cptr);
 
 			_graphics->screenUpdate();
-		} else if (gadgetId == 5) { /* bread crumbs */
+		} else if (gadgetId == 5) {
+			// bread crumbs
 			_breadCrumbs[0]._roomNum = 0;
 			_numCrumbs = 0;
 			_droppingCrumbs = true;
 			mayShowCrumbIndicator();
 			_graphics->screenUpdate();
-		} else if (gadgetId == 6) { /* follow crumbs */
+		} else if (gadgetId == 6) {
+			// follow crumbs
 			if (_droppingCrumbs) {
 				if (_numCrumbs > 0) {
 					_followingCrumbs = true;
@@ -892,7 +921,8 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 					_graphics->_doNotDrawMessage = false;
 
 					_mainDisplay = true;
-					interfaceOn(); /* Sets the correct gadget list */
+					// Sets the correct gadget list
+					interfaceOn();
 					_graphics->drawPanel();
 					drawRoomMessage(curInv, _cptr);
 					_graphics->screenUpdate();
@@ -913,7 +943,8 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 		doit = false;
 
 		if (_cptr) {
-			if ((_cptr->_closeUpType == SPECIALLOCK) && _mainDisplay) /* LAB: Labyrinth specific code */
+			if ((_cptr->_closeUpType == SPECIALLOCK) && _mainDisplay)
+				// LAB: Labyrinth specific code
 				mouseCombination(curPos);
 			else if ((_cptr->_closeUpType == SPECIALBRICK) && _mainDisplay)
 				mouseTile(curPos);
@@ -927,7 +958,8 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 			hcptr = NULL;
 			eatMessages();
 
-			if (actionMode == 0) { /* Take something. */
+			if (actionMode == 0) {
+				// Take something.
 				if (doActionRule(Common::Point(curPos.x, curPos.y), actionMode, _roomNum, &_cptr))
 					_curFileName = _newFileName;
 				else if (takeItem(curPos.x, curPos.y, &_cptr))
@@ -938,16 +970,16 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 					_curFileName = _newFileName;
 				else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 					drawStaticMessage(kTextNothing);
-			} else if ((actionMode == 1) /* Manipulate an object */  ||
-						  (actionMode == 2) /* Open up a "door" */      ||
-						  (actionMode == 3)) { /* Close a "door" */
+			} else if ((actionMode == 1) || (actionMode == 2) || (actionMode == 3)) {
+				// Manipulate an object, Open up a "door" or Close a "door"
 				if (doActionRule(curPos, actionMode, _roomNum, &_cptr))
 					_curFileName = _newFileName;
 				else if (!doActionRule(curPos, actionMode, 0, &_cptr)) {
 					if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 						drawStaticMessage(kTextNothing);
 				}
-			} else if (actionMode == 4) { /* Look at closeups */
+			} else if (actionMode == 4) {
+				// Look at closeups
 				tempcptr = _cptr;
 				setCurClose(curPos, &tempcptr);
 
@@ -962,7 +994,8 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 						drawStaticMessage(kTextNothing);
 				} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 					drawStaticMessage(kTextNothing);
-			} else if ((actionMode == 5)  && _conditions->in(curInv)) { /* Use an item on something else */
+			} else if ((actionMode == 5)  && _conditions->in(curInv)) {
+				// Use an item on something else
 				if (doOperateRule(curPos.x, curPos.y, curInv, &_cptr)) {
 					_curFileName = _newFileName;
 
@@ -1009,7 +1042,8 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 		_anim->_doBlack = true;
 		_graphics->_doNotDrawMessage = false;
 		_mainDisplay = true;
-		interfaceOn(); /* Sets the correct gadget list */
+		// Sets the correct gadget list
+		interfaceOn();
 
 		if (_alternate) {
 			if (lastInv && _conditions->in(lastInv))
@@ -1046,7 +1080,8 @@ void LabEngine::go() {
 	_event->mouseShow();
 	mainGameLoop();
 
-	if (_quitLab) { /* Won the game */
+	if (_quitLab) {
+		// Won the game
 		_graphics->blackAllScreen();
 		_graphics->readPict("P:End/L2In.1", true);
 
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 5b55ed4..ad56b46 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -114,7 +114,8 @@ EventManager::EventManager(LabEngine *vm) : _vm(vm) {
 }
 
 void EventManager::mouseHandler(int flag, Common::Point pos) {
-	if (flag & 0x02) { /* Left mouse button click */
+	if (flag & 0x02) {
+		// Left mouse button click
 		Gadget *tmp = NULL;
 		if (_screenGadgetList)
 			tmp = checkGadgetHit(_screenGadgetList, _vm->_isHiRes ? pos : Common::Point(pos.x / 2, pos.y));
@@ -125,7 +126,8 @@ void EventManager::mouseHandler(int flag, Common::Point pos) {
 			_leftClick = true;
 	}
 
-	if (flag & 0x08) /* Right mouse button click */
+	if (flag & 0x08)
+		// Right mouse button click
 		_rightClick = true;
 }
 
@@ -263,7 +265,7 @@ bool EventManager::haveNextChar() {
 void EventManager::processInput(bool can_delay) {
 	Common::Event event;
 
-	if (1 /*!g_IgnoreProcessInput*/) {
+	if (1) { //!g_IgnoreProcessInput
 		int flags = 0;
 		while (g_system->getEventManager()->pollEvent(event)) {
 			switch (event.type) {
diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h
index 11d8dfd..f87d7ee 100644
--- a/engines/lab/eventman.h
+++ b/engines/lab/eventman.h
@@ -77,4 +77,4 @@ public:
 
 } // End of namespace Lab
 
-#endif /* LAB_EVENTMAN_H */
+#endif // LAB_EVENTMAN_H
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 0d4501e..3d0bbe1 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -62,9 +62,7 @@ DisplayMan::~DisplayMan() {
 	freePict();
 }
 
-/*---------------------------------------------------------------------------*/
-/*------ From readPict.c.  Reads in pictures and animations from disk. ------*/
-/*---------------------------------------------------------------------------*/
+// From readPict.c.  Reads in pictures and animations from disk.
 
 void DisplayMan::loadPict(const char *filename) {
 	Common::File *bitmapFile = _vm->_resource->openDataFile(filename);
@@ -126,11 +124,9 @@ void DisplayMan::freePict() {
 	_curBitmap = NULL;
 }
 
-/*---------------------------------------------------------------------------*/
-/*------------ Does all the text rendering to the message boxes. ------------*/
-/*---------------------------------------------------------------------------*/
-
-/*----- The flowText routines -----*/
+//---------------------------------------------------------------------------
+//------------ Does all the text rendering to the message boxes. ------------
+//---------------------------------------------------------------------------
 
 /**
  * Extracts the first word from a string.
@@ -189,17 +185,17 @@ void DisplayMan::getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer
  * each line less than 255 characters.
  */
 uint32 DisplayMan::flowText(
-			void *font,            /* the TextAttr pointer */
-			int16 spacing,         /* How much vertical spacing between the lines */
-			byte pencolor,         /* pen number to use for text */
-			byte backpen,          /* the background color */
-			bool fillback,         /* Whether to fill the background */
-			bool centerh,          /* Whether to center the text horizontally */
-			bool centerv,          /* Whether to center the text vertically */
-			bool output,           /* Whether to output any text */
-			uint16 x1, uint16 y1,  /* Cords */
+			void *font,            // the TextAttr pointer
+			int16 spacing,         // How much vertical spacing between the lines
+			byte pencolor,         // pen number to use for text
+			byte backpen,          // the background color
+			bool fillback,         // Whether to fill the background
+			bool centerh,          // Whether to center the text horizontally
+			bool centerv,          // Whether to center the text vertically
+			bool output,           // Whether to output any text
+			uint16 x1, uint16 y1,  // Cords
 			uint16 x2, uint16 y2,
-			const char *str) {     /* The text itself */
+			const char *str) {     // The text itself
 	TextFont *_msgFont = (TextFont *)font;
 	char linebuffer[256];
 	const char *temp;
@@ -254,16 +250,18 @@ uint32 DisplayMan::flowText(
 	return (str - temp);
 }
 
-uint32 DisplayMan::flowTextScaled(void *font,      /* the TextAttr pointer */
-	int16 spacing,                /* How much vertical spacing between the lines */
-	byte penColor,                /* pen number to use for text */
-	byte backPen,                 /* the background color */
-	bool fillBack,                /* Whether to fill the background */
-	bool centerX,                 /* Whether to center the text horizontally */
-	bool centerY,                 /* Whether to center the text vertically */
-	bool output,                  /* Whether to output any text */
-	uint16 x1, uint16 y1,         /* Cords */
-	uint16 x2, uint16 y2, const char *str) {
+uint32 DisplayMan::flowTextScaled(
+	void *font,                // the TextAttr pointer
+	int16 spacing,             // How much vertical spacing between the lines
+	byte penColor,             // pen number to use for text
+	byte backPen,              // the background color
+	bool fillBack,             // Whether to fill the background
+	bool centerX,              // Whether to center the text horizontally
+	bool centerY,              // Whether to center the text vertically
+	bool output,               // Whether to output any text
+	uint16 x1, uint16 y1,      // Cords
+	uint16 x2, uint16 y2,
+	const char *str) {
 	return flowText(font, spacing, penColor, backPen, fillBack, centerX, centerY, output,
 					_vm->_utils->vgaScaleX(x1), _vm->_utils->vgaScaleY(y1),
 					_vm->_utils->vgaScaleX(x2), _vm->_utils->vgaScaleY(y2), str);
@@ -273,17 +271,17 @@ uint32 DisplayMan::flowTextScaled(void *font,      /* the TextAttr pointer */
  * Calls flowText, but flows it to memory.  Same restrictions as flowText.
  */
 uint32 DisplayMan::flowTextToMem(Image *destIm,
-			void *font,            /* the TextAttr pointer */
-			int16 spacing,         /* How much vertical spacing between the lines */
-			byte pencolor,         /* pen number to use for text */
-			byte backpen,          /* the background color */
-			bool fillback,         /* Whether to fill the background */
-			bool centerh,          /* Whether to center the text horizontally */
-			bool centerv,          /* Whether to center the text vertically */
-			bool output,           /* Whether to output any text */
-			uint16 x1, uint16 y1,  /* Cords */
+			void *font,            // the TextAttr pointer
+			int16 spacing,         // How much vertical spacing between the lines
+			byte pencolor,         // pen number to use for text
+			byte backpen,          // the background color
+			bool fillback,         // Whether to fill the background
+			bool centerh,          // Whether to center the text horizontally
+			bool centerv,          // Whether to center the text vertically
+			bool output,           // Whether to output any text
+			uint16 x1, uint16 y1,  // Cords
 			uint16 x2, uint16 y2,
-			const char *str) {     /* The text itself */
+			const char *str) {     // The text itself
 	uint32 res, vgabyte = _screenBytesPerPage;
 	byte *tmp = _currentDisplayBuffer;
 
@@ -298,13 +296,15 @@ uint32 DisplayMan::flowTextToMem(Image *destIm,
 	return res;
 }
 
-/*----- The control panel stuff -----*/
+//----- The control panel stuff -----
 
 void DisplayMan::createBox(uint16 y2) {
-	setAPen(7);                 /* Message box area */
+	// Message box area
+	setAPen(7);
 	rectFillScaled(4, 154, 315, y2 - 2);
 
-	setAPen(0);                 /* Box around message area */
+	// Box around message area
+	setAPen(0);
 	drawHLine(_vm->_utils->vgaScaleX(2), _vm->_utils->vgaScaleY(152), _vm->_utils->vgaScaleX(317));
 	drawVLine(_vm->_utils->vgaScaleX(317), _vm->_utils->vgaScaleY(152), _vm->_utils->vgaScaleY(y2));
 	drawHLine(_vm->_utils->vgaScaleX(2), _vm->_utils->vgaScaleY(y2), _vm->_utils->vgaScaleX(317));
@@ -323,7 +323,8 @@ int32 DisplayMan::longDrawMessage(const char *str) {
 
 	if (!_longWinInFront) {
 		_longWinInFront = true;
-		setAPen(3);                 /* Clear Area */
+		// Clear Area
+		setAPen(3);
 		rectFill(0, _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319), _vm->_utils->vgaScaleY(199));
 	}
 
@@ -367,37 +368,45 @@ void DisplayMan::drawMessage(const char *str) {
 void DisplayMan::drawPanel() {
 	_vm->_event->mouseHide();
 
-	setAPen(3);                 /* Clear Area */
+	// Clear Area
+	setAPen(3);
 	rectFill(0, _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319), _vm->_utils->vgaScaleY(199));
 
-	setAPen(0);                 /* First Line */
+	// First Line
+	setAPen(0);
 	drawHLine(0, _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319));
-	setAPen(5);                 /* Second Line */
+	// Second Line
+	setAPen(5);
 	drawHLine(0, _vm->_utils->vgaScaleY(149) + 1 + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319));
-
-	/* Gadget Separators */
+	// Gadget Separators
 	setAPen(0);
-	drawHLine(0, _vm->_utils->vgaScaleY(170), _vm->_utils->vgaScaleX(319));     /* First black line to separate buttons */
+	// First black line to separate buttons
+	drawHLine(0, _vm->_utils->vgaScaleY(170), _vm->_utils->vgaScaleX(319));
 
 	if (!_vm->_alternate) {
 		setAPen(4);
-		drawHLine(0, _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(319)); /* The horizontal lines under the black one */
+		// The horizontal lines under the black one
+		drawHLine(0, _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(319));
 		drawGadgetList(&_vm->_moveGadgetList);
 	} else {
 		if (_vm->getPlatform() != Common::kPlatformWindows) {
-			drawVLine(_vm->_utils->vgaScaleX(124), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199)); /* Vertical Black lines */
+			// Vertical Black lines
+			drawVLine(_vm->_utils->vgaScaleX(124), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));
 			drawVLine(_vm->_utils->vgaScaleX(194), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));
 		} else {
-			drawVLine(_vm->_utils->vgaScaleX(90), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));  /* Vertical Black lines */
+			// Vertical Black lines
+			drawVLine(_vm->_utils->vgaScaleX(90), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));
 			drawVLine(_vm->_utils->vgaScaleX(160), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));
 			drawVLine(_vm->_utils->vgaScaleX(230), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));
 		}
 
 		setAPen(4);
-		drawHLine(0, _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(122));   /* The horizontal lines under the black one */
+		// The horizontal lines under the black one
+		drawHLine(0, _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(122));
 		drawHLine(_vm->_utils->vgaScaleX(126), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(192));
 		drawHLine(_vm->_utils->vgaScaleX(196), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(319));
-		drawVLine(_vm->_utils->vgaScaleX(1), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198)); /* The vertical high light lines */
+		// The vertical high light lines
+		drawVLine(_vm->_utils->vgaScaleX(1), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
 
 		if (_vm->getPlatform() != Common::kPlatformWindows) {
 			drawVLine(_vm->_utils->vgaScaleX(126), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
@@ -426,7 +435,7 @@ bool DisplayMan::setUpScreens() {
 		_vm->_moveImages[i] = new Image(controlFile);
 	delete controlFile;
 
-	/* Creates the gadgets for the movement control panel */
+	// Creates the gadgets for the movement control panel
 	uint16 y = _vm->_utils->vgaScaleY(173) - _vm->_utils->svgaCord(2);
 
 	// The key mapping was only set for the Windows version.
@@ -726,9 +735,9 @@ void DisplayMan::text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char
 							if (templeft <= 0) {
 								curpage++;
 								VGATemp = (byte *)(VGATop - templeft);
-								/* Set up VGATempLine for next line */
+								// Set up VGATempLine for next line
 								VGATempLine -= _screenBytesPerPage;
-								/* Set up LeftInSegment for next line */
+								// Set up LeftInSegment for next line
 								LeftInSegment += _screenBytesPerPage + templeft;
 								templeft += _screenBytesPerPage;
 							}
diff --git a/engines/lab/graphics.h b/engines/lab/graphics.h
index 8798718..71c8246 100644
--- a/engines/lab/graphics.h
+++ b/engines/lab/graphics.h
@@ -95,43 +95,44 @@ public:
 	void setAPen(byte pennum);
 	void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void rectFillScaled(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-	/* Window text stuff */
-	uint32 flowText(void *font,				/* the TextAttr pointer */
-					int16 spacing,			/* How much vertical spacing between the lines */
-					byte pencolor,			/* pen number to use for text */
-					byte backpen,			/* the background color */
-					bool fillback,			/* Whether to fill the background */
-					bool centerh,			/* Whether to center the text horizontally */
-					bool centerv,			/* Whether to center the text vertically */
-					bool output,			/* Whether to output any text */
-					uint16 x1, uint16 y1,	/* Cords */
-					uint16 x2, uint16 y2,
-					const char *text);		/* The text itself */
-
-	uint32 flowTextScaled(void *font,		/* the TextAttr pointer */
-		int16 spacing,			/* How much vertical spacing between the lines */
-		byte pencolor,			/* pen number to use for text */
-		byte backpen,			/* the background color */
-		bool fillback,			/* Whether to fill the background */
-		bool centerh,			/* Whether to center the text horizontally */
-		bool centerv,			/* Whether to center the text vertically */
-		bool output,			/* Whether to output any text */
-		uint16 x1, uint16 y1,	/* Cords */
-		uint16 x2, uint16 y2,
-		const char *text);		/* The text itself */
+	// Window text stuff
+	uint32 flowText(void *font,	// the TextAttr pointer
+				int16 spacing,				// How much vertical spacing between the lines
+				byte pencolor,				// pen number to use for text
+				byte backpen,					// the background color
+				bool fillback,				// Whether to fill the background
+				bool centerh,					// Whether to center the text horizontally
+				bool centerv,					// Whether to center the text vertically
+				bool output,					// Whether to output any text
+				uint16 x1, uint16 y1,	// Cords
+				uint16 x2, uint16 y2,
+				const char *text);		// The text itself
+
+	uint32 flowTextScaled(
+				void *font,						// the TextAttr pointer
+				int16 spacing,				// How much vertical spacing between the lines
+				byte pencolor,				// pen number to use for text
+				byte backpen,					// the background color
+				bool fillback,				// Whether to fill the background
+				bool centerh,					// Whether to center the text horizontally
+				bool centerv,					// Whether to center the text vertically
+				bool output,					// Whether to output any text
+				uint16 x1, uint16 y1,	// Cords
+				uint16 x2, uint16 y2,
+				const char *text);		// The text itself
 
 	uint32 flowTextToMem(Image *destIm,
-					void *font,				/* the TextAttr pointer */
-					int16 spacing,			/* How much vertical spacing between the lines */
-					byte pencolor,			/* pen number to use for text */
-					byte backpen,			/* the background color */
-					bool fillback,			/* Whether to fill the background */
-					bool centerh,			/* Whether to center the text horizontally */
-					bool centerv,			/* Whether to center the text vertically */
-					bool output,			/* Whether to output any text */
-					uint16 x1, uint16 y1,	/* Cords */
-					uint16 x2, uint16 y2,
-					const char *str);		/* The text itself */
+				void *font,						// the TextAttr pointer
+				int16 spacing,				// How much vertical spacing between the lines
+				byte pencolor,				// pen number to use for text
+				byte backpen,					// the background color
+				bool fillback,				// Whether to fill the background
+				bool centerh,					// Whether to center the text horizontally
+				bool centerv,					// Whether to center the text vertically
+				bool output,					// Whether to output any text
+				uint16 x1, uint16 y1,	// Cords
+				uint16 x2, uint16 y2,
+				const char *str);			// The text itself
 
 	void drawHLine(uint16 x, uint16 y1, uint16 y2);
 	void drawVLine(uint16 x1, uint16 y, uint16 x2);
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index ade5f69..13cbd1e 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -145,15 +145,18 @@ IntuiMessage *LabEngine::getMsg() {
 		IMessage._gadgetID = curgad->_gadgetID;
 		IMessage._qualifier = qualifiers;
 		return &IMessage;
-	} else if (_event->mouseButton(&IMessage._mouseX, &IMessage._mouseY, true)) { /* Left Button */
+	} else if (_event->mouseButton(&IMessage._mouseX, &IMessage._mouseY, true)) {
+		// Left Button
 		IMessage._qualifier = IEQUALIFIER_LEFTBUTTON | qualifiers;
 		IMessage._msgClass = MOUSEBUTTONS;
 		return &IMessage;
-	} else if (_event->mouseButton(&IMessage._mouseX, &IMessage._mouseY, false)) { /* Right Button */
+	} else if (_event->mouseButton(&IMessage._mouseX, &IMessage._mouseY, false)) {
+		// Right Button
 		IMessage._qualifier = IEQUALIFIER_RBUTTON | qualifiers;
 		IMessage._msgClass = MOUSEBUTTONS;
 		return &IMessage;
-	} else if (_event->keyPress(&IMessage._code)) { /* Keyboard key */
+	} else if (_event->keyPress(&IMessage._code)) {
+		// Keyboard key
 		curgad = checkNumGadgetHit(_event->_screenGadgetList, IMessage._code);
 
 		if (curgad) {
diff --git a/engines/lab/interface.h b/engines/lab/interface.h
index 3e0460b..bd9c3c9 100644
--- a/engines/lab/interface.h
+++ b/engines/lab/interface.h
@@ -50,12 +50,12 @@ struct Gadget {
 	Image *_image, *_altImage;
 };
 
-/* Defines for the GadgetFlags portion */
+// Defines for the GadgetFlags portion
 #define GADGETOFF 0x01
 
 typedef Common::List<Gadget *> GadgetList;
 
-/* Defines for the Class variable in IntuiMessage */
+// Defines for the Class variable in IntuiMessage
 #define SIZEVERIFY  0x00000001
 #define NEWSIZE     0x00000002
 #define REFRESHWINDOW   0x00000004
@@ -73,14 +73,14 @@ typedef Common::List<Gadget *> GadgetList;
 #define NEWPREFS    0x00004000
 #define DISKINSERTED    0x00008000
 #define DISKREMOVED 0x00010000
-#define WBENCHMESSAGE   0x00020000  /*  System use only     */
+#define WBENCHMESSAGE   0x00020000  // System use only
 #define ACTIVEWINDOW    0x00040000
 #define INACTIVEWINDOW  0x00080000
 #define DELTAMOVE   0x00100000
 #define VANULLLAKEY  0x00200000
 
 
-/* Defines for the Qualifier variable in IntuiMessage */
+// Defines for the Qualifier variable in IntuiMessage
 #define IEQUALIFIER_LSHIFT      0x0001
 #define IEQUALIFIER_RSHIFT      0x0002
 #define IEQUALIFIER_CAPSLOCK        0x0004
@@ -103,9 +103,9 @@ typedef Common::List<Gadget *> GadgetList;
 #define VKEY_LTARROW    276
 
 
-/*---------------------------------------------------------------------------*/
-/*--------------------------- Function Prototypes ---------------------------*/
-/*---------------------------------------------------------------------------*/
+//---------------------------------------------------------------------------
+//--------------------------- Function Prototypes ---------------------------
+//---------------------------------------------------------------------------
 
 Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt);
 void freeButtonList(GadgetList *gadgetList);
@@ -116,4 +116,4 @@ IntuiMessage *getMsg();
 
 } // End of namespace Lab
 
-#endif /* LAB_INTEFACE_H */
+#endif // LAB_INTEFACE_H
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 7dec75f..6b2efda 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -132,7 +132,8 @@ public:
 
 	const char *_curFileName;
 	const char *_nextFileName;
-	const char *_newFileName;  /* When ProcessRoom.c decides to change the filename of the current picture. */
+	// When ProcessRoom.c decides to change the filename of the current picture.
+	const char *_newFileName;
 	TextFont *_msgFont;
 	GadgetList _moveGadgetList;
 	GadgetList _invGadgetList;
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index e0a3b08..4edb263 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -40,7 +40,7 @@ namespace Lab {
 
 class LabEngine;
 
-/* Direction defines */
+// Direction defines
 #define NORTH   0
 #define SOUTH   1
 #define EAST    2
@@ -53,9 +53,9 @@ struct SaveGameHeader {
 	uint16 _direction;
 };
 
-/*--------------------------*/
-/*----- From saveGame.c ----*/
-/*--------------------------*/
+//--------------------------
+//----- From saveGame.c ----
+//--------------------------
 
 bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc);
 bool loadGame(uint16 *Direction, uint16 *Quarters, int slot);
@@ -63,4 +63,4 @@ bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header);
 
 } // End of namespace Lab
 
-#endif /* LAB_LABFUN_H */
+#endif // LAB_LABFUN_H
diff --git a/engines/lab/labsets.h b/engines/lab/labsets.h
index 647730d..0c1af77 100644
--- a/engines/lab/labsets.h
+++ b/engines/lab/labsets.h
@@ -33,9 +33,9 @@
 
 namespace Lab {
 
-/*---------------------------*/
-/*----- From LabSets.c ------*/
-/*---------------------------*/
+//---------------------------
+//----- From LabSets.c ------
+//---------------------------
 
 class LabEngine;
 
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index b86e2b6..b09ca50 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -415,8 +415,9 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 		}
 	}
 
-	/* Makes sure the X is drawn in corridors */
-	/* NOTE: this here on purpose just in case there's some weird condition, like the surreal maze where there are no rooms */
+	// Makes sure the X is drawn in corridors
+	// NOTE: this here on purpose just in case there's some weird
+	// condition, like the surreal maze where there are no rooms
 	if ((Maps[CurRoom].PageNumber == Floor) && _roomsFound->in(CurRoom) && Maps[CurRoom].x)
 		drawRoom(CurRoom, true);
 
@@ -483,7 +484,8 @@ void LabEngine::processMap(uint16 CurRoom) {
 	CurFloor = Maps[CurRoom].PageNumber;
 
 	while (1) {
-		_music->updateMusic();  /* Make sure we check the music at least after every message */
+		// Make sure we check the music at least after every message
+		_music->updateMusic();
 		Msg = getMsg();
 
 		if (Msg == NULL) {
@@ -526,9 +528,11 @@ void LabEngine::processMap(uint16 CurRoom) {
 				return;
 
 			if (Class == GADGETUP) {
-				if (GadgetID == 0) { /* Quit menu button */
+				if (GadgetID == 0) {
+					// Quit menu button
 					return;
-				} else if (GadgetID == 1) { /* Up arrow */
+				} else if (GadgetID == 1) {
+					// Up arrow
 					OldFloor = CurFloor;
 					getUpFloor(&CurFloor, &drawmap);
 
@@ -538,7 +542,8 @@ void LabEngine::processMap(uint16 CurRoom) {
 						_graphics->fade(true, 0);
 					} else
 						CurFloor = OldFloor;
-				} else if (GadgetID == 2) { /* Down arrow */
+				} else if (GadgetID == 2) {
+					// Down arrow
 					OldFloor = CurFloor;
 					getDownFloor(&CurFloor, &drawmap);
 
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 1c043ef..4bf1502 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -272,9 +272,12 @@ void Music::changeMusic(const char *newmusic) {
 	}
 
 	_file = g_lab->_resource->openDataFile(newmusic);
-	_musicOn = true;   /* turn it off */
+	// turn music off
+	_musicOn = true;
 	setMusic(false);
-	_musicOn = false;  /* turn it back on */
+
+	// turn it back on
+	_musicOn = false;
 	setMusic(true);
 }
 
diff --git a/engines/lab/music.h b/engines/lab/music.h
index 3114817..6d102e7 100644
--- a/engines/lab/music.h
+++ b/engines/lab/music.h
@@ -41,9 +41,9 @@ namespace Lab {
 
 class LabEngine;
 
-/*---------------------------*/
-/*----- From LabMusic.c -----*/
-/*---------------------------*/
+//---------------------------
+//----- From LabMusic.c -----
+//---------------------------
 
 #define MAXBUFFERS         5L
 
@@ -98,4 +98,4 @@ private:
 
 } // End of namespace Lab
 
-#endif /* LAB_MUSIC_H */
+#endif // LAB_MUSIC_H
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index e037522..26e91e5 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -39,12 +39,11 @@
 
 namespace Lab {
 
-/* Global parser data */
 #define NOFILE         "no file"
 
-/*****************************************************************************/
-/* Generates a random number.                                                */
-/*****************************************************************************/
+/**
+ * Generates a random number.
+ */
 uint16 getRandom(uint16 max) {
 	uint32 secs, micros;
 
@@ -52,9 +51,9 @@ uint16 getRandom(uint16 max) {
 	return ((micros + secs) % max);
 }
 
-/*****************************************************************************/
-/* Checks whether all the conditions in a condition list are met.            */
-/*****************************************************************************/
+/**
+ * Checks whether all the conditions in a condition list are met.
+ */
 static bool checkConditions(int16 *condition) {
 	if (condition == NULL)
 		return true;
@@ -73,9 +72,9 @@ static bool checkConditions(int16 *condition) {
 	return res;
 }
 
-/*****************************************************************************/
-/* Gets the current ViewDataPointer.                                         */
-/*****************************************************************************/
+/**
+ * Gets the current ViewDataPointer.
+ */
 ViewData *getViewData(uint16 roomNum, uint16 direction) {
 	if (!g_lab->_rooms[roomNum]._roomMsg)
 		g_lab->_resource->readViews(roomNum);
@@ -92,9 +91,9 @@ ViewData *getViewData(uint16 roomNum, uint16 direction) {
 	return view;
 }
 
-/*****************************************************************************/
-/* Gets an object, if any, from the user's click on the screen.              */
-/*****************************************************************************/
+/**
+ * Gets an object, if any, from the user's click on the screen.
+ */
 static CloseData *getObject(uint16 x, uint16 y, CloseDataPtr lcptr) {
 	if (lcptr == NULL) {
 		lcptr = getViewData(g_lab->_roomNum, g_lab->_direction)->_closeUps;
@@ -113,12 +112,12 @@ static CloseData *getObject(uint16 x, uint16 y, CloseDataPtr lcptr) {
 	return NULL;
 }
 
-/*****************************************************************************/
-/* Goes through the list of closeups to find a match.                        */
-/* NYI: Known bug here.  If there are two objects that have closeups, and    */
-/*      some of the closeups have the same hit boxes, then this returns the  */
-/*      first occurence of the object with the same hit box.                 */
-/*****************************************************************************/
+/**
+ * Goes through the list of closeups to find a match.
+ * NYI: Known bug here.  If there are two objects that have closeups, and
+ *      some of the closeups have the same hit boxes, then this returns the
+ *      first occurence of the object with the same hit box.
+ */
 static CloseDataPtr findCPtrMatch(CloseDataPtr cpmain, CloseDataPtr list) {
 	CloseDataPtr cptr;
 
@@ -139,9 +138,9 @@ static CloseDataPtr findCPtrMatch(CloseDataPtr cpmain, CloseDataPtr list) {
 	return NULL;
 }
 
-/*****************************************************************************/
-/* Returns the current picture name.                                         */
-/*****************************************************************************/
+/**
+ * Returns the current picture name.
+ */
 char *LabEngine::getPictName(CloseDataPtr *lcptr) {
 	ViewData *viewPtr = getViewData(g_lab->_roomNum, g_lab->_direction);
 
@@ -155,9 +154,9 @@ char *LabEngine::getPictName(CloseDataPtr *lcptr) {
 	return viewPtr->_graphicName;
 }
 
-/*****************************************************************************/
-/* Draws the current direction to the screen.                                */
-/*****************************************************************************/
+/**
+ * Draws the current direction to the screen.
+ */
 void LabEngine::drawDirection(CloseDataPtr lcptr) {
 	if (lcptr != NULL && lcptr->_message) {
 		_graphics->drawMessage(lcptr->_message);
@@ -183,9 +182,9 @@ void LabEngine::drawDirection(CloseDataPtr lcptr) {
 	_graphics->drawMessage(message.c_str());
 }
 
-/*****************************************************************************/
-/* process a arrow gadget movement.                                          */
-/*****************************************************************************/
+/**
+ * process a arrow gadget movement.
+ */
 uint16 processArrow(uint16 curDirection, uint16 arrow) {
 	if (arrow == 1) { // Forward
 		uint16 room = 1;
@@ -227,9 +226,9 @@ uint16 processArrow(uint16 curDirection, uint16 arrow) {
 	return curDirection;
 }
 
-/*****************************************************************************/
-/* Sets the current close up data.                                           */
-/*****************************************************************************/
+/**
+ * Sets the current close up data.
+ */
 void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords) {
 	CloseDataPtr lcptr;
 	uint16 x1, y1, x2, y2;
@@ -261,9 +260,9 @@ void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords)
 	}
 }
 
-/*****************************************************************************/
-/* Takes the currently selected item.                                        */
-/*****************************************************************************/
+/**
+ * Takes the currently selected item.
+ */
 bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
 	CloseDataPtr lcptr;
 
@@ -290,9 +289,9 @@ bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
 	return false;
 }
 
-/*****************************************************************************/
-/* Processes the action list.                                                */
-/*****************************************************************************/
+/**
+ * Processes the action list.
+ */
 void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 	while (aptr) {
 		_music->updateMusic();
@@ -327,7 +326,8 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 
 		case LOADDIFF:
 			if (aptr->_data)
-				_graphics->loadPict((char *)aptr->_data);          /* Puts a file into memory */
+				// Puts a file into memory
+				_graphics->loadPict((char *)aptr->_data);
 
 			break;
 
@@ -520,7 +520,8 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 				_anim->_doBlack = (_cptr == NULL);
 			else if (aptr->_param1 == 2)
 				_anim->_doBlack = (_cptr != NULL);
-			else if (aptr->_param1 == 5) { /* inverse the palette */
+			else if (aptr->_param1 == 5) {
+				// inverse the palette
 				for (uint16 idx = (8 * 3); idx < (255 * 3); idx++)
 					_anim->_diffPalette[idx] = 255 - _anim->_diffPalette[idx];
 
@@ -528,16 +529,19 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 				_graphics->setPalette(_anim->_diffPalette, 256);
 				waitTOF();
 				waitTOF();
-			} else if (aptr->_param1 == 4) { /* white the palette */
+			} else if (aptr->_param1 == 4) {
+				// white the palette
 				_graphics->whiteScreen();
 				waitTOF();
 				waitTOF();
-			} else if (aptr->_param1 == 6) { /* Restore the palette */
+			} else if (aptr->_param1 == 6) {
+				// Restore the palette
 				waitTOF();
 				_graphics->setPalette(_anim->_diffPalette, 256);
 				waitTOF();
 				waitTOF();
-			} else if (aptr->_param1 == 7) { /* Quick pause */
+			} else if (aptr->_param1 == 7) {
+				// Quick pause
 				waitTOF();
 				waitTOF();
 				waitTOF();
@@ -563,9 +567,9 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 	_music->_doNotFilestopSoundEffect = false;
 }
 
-/*****************************************************************************/
-/* Does the work for doActionRule.                                           */
-/*****************************************************************************/
+/**
+ * Does the work for doActionRule.
+ */
 static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr lcptr, CloseDataPtr *set, bool allowDefaults) {
 	action++;
 
@@ -595,9 +599,9 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr lcptr, Clo
 	return false;
 }
 
-/*****************************************************************************/
-/* Goes through the rules if an action is taken.                             */
-/*****************************************************************************/
+/**
+ * Goes through the rules if an action is taken.
+ */
 bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *lcptr) {
 	if (roomNum)
 		g_lab->_newFileName = NOFILE;
@@ -618,9 +622,9 @@ bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *
 	return false;
 }
 
-/*****************************************************************************/
-/* Does the work for doActionRule.                                           */
-/*****************************************************************************/
+/**
+ * Does the work for doActionRule.
+ */
 static bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr lcptr, CloseDataPtr *set, bool allowDefaults) {
 	if (lcptr)
 		if (lcptr->_closeUpType > 0) {
@@ -646,9 +650,9 @@ static bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr lcptr, C
 	return false;
 }
 
-/*****************************************************************************/
-/* Goes through the rules if the user tries to operate an item on an object. */
-/*****************************************************************************/
+/**
+ * Goes through the rules if the user tries to operate an item on an object.
+ */
 bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *lcptr) {
 	CloseDataPtr tlcptr;
 
@@ -680,9 +684,9 @@ bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *lcptr) {
 	return false;
 }
 
-/*****************************************************************************/
-/* Goes through the rules if the user tries to go forward.                   */
-/*****************************************************************************/
+/**
+ * Goes through the rules if the user tries to go forward.
+ */
 bool doGoForward(CloseDataPtr *lcptr) {
 	RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;
 
@@ -698,9 +702,9 @@ bool doGoForward(CloseDataPtr *lcptr) {
 	return false;
 }
 
-/*****************************************************************************/
-/* Goes through the rules if the user tries to turn.                         */
-/*****************************************************************************/
+/**
+ * Goes through the rules if the user tries to turn.
+ */
 bool doTurn(uint16 from, uint16 to, CloseDataPtr *lcptr) {
 	from++;
 	to++;
@@ -721,9 +725,9 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *lcptr) {
 	return false;
 }
 
-/*****************************************************************************/
-/* Goes through the rules if the user tries to go to the main view           */
-/*****************************************************************************/
+/**
+ * Goes through the rules if the user tries to go to the main view
+ */
 bool doMainView(CloseDataPtr *lcptr) {
 	RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
diff --git a/engines/lab/processroom.h b/engines/lab/processroom.h
index d69dae1..e4cb84e 100644
--- a/engines/lab/processroom.h
+++ b/engines/lab/processroom.h
@@ -33,7 +33,7 @@
 
 namespace Lab {
 
-	/*------------------------------- Action types ------------------------------*/
+//------------------------------- Action types ------------------------------
 #define PLAYSOUND     1
 #define PLAYSOUNDCONT 2
 #define SHOWDIFF      3
@@ -71,7 +71,7 @@ namespace Lab {
 #define CSHOWMESSAGE 35
 #define PLAYSOUNDB   36
 
-	/* Rule Types */
+// Rule Types
 #define ACTION      1
 #define OPERATE     2
 #define GOFORWARD   3
@@ -80,7 +80,7 @@ namespace Lab {
 #define GOMAINVIEW  6
 #define TURNFROMTO  7
 
-	/*----------------------------- Rule Type Action ----------------------------*/
+//----------------------------- Rule Type Action ----------------------------
 #define TAKE        1
 #define MOVE        2
 #define OPENDOOR    3
@@ -93,8 +93,8 @@ namespace Lab {
 
 typedef struct CloseData {
 	uint16 x1, y1, x2, y2;
-	int16 _closeUpType;          /* if > 0, an object.  If < 0, an item */
-	uint16 _depth;               /* Level of the closeup. */
+	int16 _closeUpType;          // if > 0, an object.  If < 0, an item
+	uint16 _depth;               // Level of the closeup.
 	char *_graphicName;
 	char *_message;
 	CloseData *_nextCloseUp;
@@ -115,7 +115,7 @@ struct Action {
 	int16 _param1;
 	int16 _param2;
 	int16 _param3;
-	byte *_data;            /* Message, or a pointer to array of messages. */
+	byte *_data;            // Message, or a pointer to array of messages.
 	Action *_nextAction;
 };
 
@@ -147,15 +147,15 @@ struct InventoryData {
 	char *_bitmapName;
 };
 
-/* Map Flags */
+// Map Flags
 
-/* Where the doors are; in a corridor, assumed to be left doors */
+// Where the doors are; in a corridor, assumed to be left doors
 #define     NORTHDOOR        1L
 #define     EASTDOOR         2L
 #define     SOUTHDOOR        4L
 #define     WESTDOOR         8L
 
-/* Where the doors are in corridors; M means middle, R means right, B means bottom */
+// Where the doors are in corridors; M means middle, R means right, B means bottom
 #define     NORTHMDOOR      16L
 #define     NORTHRDOOR      32L
 #define     SOUTHMDOOR      64L
@@ -166,7 +166,7 @@ struct InventoryData {
 #define     WESTMDOOR       64L
 #define     WESTBDOOR      128L
 
-/* Special Map ID's */
+// Special Map ID's
 #define     NORMAL           0
 #define     UPARROWROOM      1
 #define     DOWNARROWROOM    2
@@ -203,4 +203,4 @@ bool doMainView(CloseDataPtr *lcptr);
 
 } // End of namespace Lab
 
-#endif /* LAB_PROCESSROOM_H */
+#endif // LAB_PROCESSROOM_H
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index cf7f350..cfba7ab 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -122,4 +122,4 @@ private:
 
 } // End of namespace Lab
 
-#endif /* LAB_RESOURCE_H */
+#endif // LAB_RESOURCE_H
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 10f52a2..5924d88 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -37,13 +37,9 @@
 #include "lab/labfun.h"
 
 namespace Lab {
-
-// Labyrinth of Time ScummVM
 #define SAVEGAME_ID       MKTAG('L', 'O', 'T', 'S')
 #define SAVEGAME_VERSION  1
 
-/*----- The machine independent section of saveGame.c -----*/
-
 void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName) {
 	out->writeUint32BE(SAVEGAME_ID);
 
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 62d45d1..6395ee9 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -335,7 +335,8 @@ void LabEngine::processJournal() {
 	uint16 Qualifier, GadID;
 
 	while (1) {
-		_music->updateMusic();  /* Make sure we check the music at least after every message */
+		// Make sure we check the music at least after every message
+		_music->updateMusic();
 		Msg = getMsg();
 
 		if (Msg == NULL) {
@@ -544,7 +545,8 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 			}
 		}
 
-		_music->updateMusic();  /* Make sure we check the music at least after every message */
+		// Make sure we check the music at least after every message
+		_music->updateMusic();
 		Msg = getMsg();
 
 		if (Msg == NULL) {
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index c6997c5..68f4771 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -140,7 +140,8 @@ void LabEngine::changeTile(uint16 col, uint16 row) {
 		}
 
 		if (check) {
-			_conditions->inclElement(BRICKOPEN);  /* unlocked combination */
+			// unlocked combination
+			_conditions->inclElement(BRICKOPEN);
 			_anim->_doBlack = true;
 			_graphics->readPict("p:Up/BDOpen", true);
 		}


Commit: 0b2bf45a09ba2b5d1fc1593e629118c03b99f38f
    https://github.com/scummvm/scummvm/commit/0b2bf45a09ba2b5d1fc1593e629118c03b99f38f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:55+01:00

Commit Message:
LAB: Simplify the gadget enabling/disabling code

Changed paths:
    engines/lab/eventman.cpp
    engines/lab/interface.cpp
    engines/lab/interface.h



diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index ad56b46..7760ba2 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -63,9 +63,8 @@ Gadget *EventManager::checkGadgetHit(GadgetList *gadgetList, Common::Point pos)
 	for (GadgetList::iterator gadgetItr = gadgetList->begin(); gadgetItr != gadgetList->end(); ++gadgetItr) {
 		Gadget *gadget = *gadgetItr;
 		Common::Rect gadgetRect(gadget->x, gadget->y, gadget->x + gadget->_image->_width - 1, gadget->y + gadget->_image->_height - 1);
-		bool gadgetIsEnabled = !(gadget->_flags & GADGETOFF);
 
-		if (gadgetRect.contains(pos) && gadgetIsEnabled) {
+		if (gadgetRect.contains(pos) && gadget->isEnabled) {
 			if (_vm->_isHiRes) {
 				_hitGadget = gadget;
 			} else {
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 13cbd1e..d041160 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -48,6 +48,7 @@ Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image
 		gptr->_keyEquiv = key;
 		gptr->_image = im;
 		gptr->_altImage = imalt;
+		gptr->isEnabled = true;
 
 		return gptr;
 	} else
@@ -69,7 +70,7 @@ void drawGadgetList(GadgetList *gadgetList) {
 	for (GadgetList::iterator gadget = gadgetList->begin(); gadget != gadgetList->end(); ++gadget) {
 		(*gadget)->_image->drawImage((*gadget)->x, (*gadget)->y);
 
-		if (GADGETOFF & (*gadget)->_flags)
+		if (!(*gadget)->isEnabled)
 			disableGadget((*gadget), 1);
 	}
 }
@@ -79,7 +80,7 @@ void drawGadgetList(GadgetList *gadgetList) {
  */
 void disableGadget(Gadget *curgad, uint16 pencolor) {
 	g_lab->_graphics->overlayRect(pencolor, curgad->x, curgad->y, curgad->x + curgad->_image->_width - 1, curgad->y + curgad->_image->_height - 1);
-	curgad->_flags |= GADGETOFF;
+	curgad->isEnabled = false;
 }
 
 /**
@@ -87,7 +88,7 @@ void disableGadget(Gadget *curgad, uint16 pencolor) {
  */
 void enableGadget(Gadget *curgad) {
 	curgad->_image->drawImage(curgad->x, curgad->y);
-	curgad->_flags &= !(GADGETOFF);
+	curgad->isEnabled = true;
 }
 
 /**
@@ -114,7 +115,7 @@ Gadget *LabEngine::checkNumGadgetHit(GadgetList *gadgetList, uint16 key) {
 		Gadget *gadget = *gadgetItr;
 		if ((gkey - 1 == gadget->_gadgetID || (gkey == 0 && gadget->_gadgetID == 9) ||
 			  (gadget->_keyEquiv != 0 && makeGadgetKeyEquiv(key) == gadget->_keyEquiv))
-			  && !(GADGETOFF & gadget->_flags)) {
+			  && gadget->isEnabled) {
 			_event->mouseHide();
 			gadget->_altImage->drawImage(gadget->x, gadget->y);
 			_event->mouseShow();
diff --git a/engines/lab/interface.h b/engines/lab/interface.h
index bd9c3c9..50e89e3 100644
--- a/engines/lab/interface.h
+++ b/engines/lab/interface.h
@@ -46,13 +46,10 @@ struct IntuiMessage {
 struct Gadget {
 	uint16 x, y, _gadgetID;
 	uint16 _keyEquiv; // if not zero, a key that activates gadget
-	uint32 _flags;
+	bool isEnabled;
 	Image *_image, *_altImage;
 };
 
-// Defines for the GadgetFlags portion
-#define GADGETOFF 0x01
-
 typedef Common::List<Gadget *> GadgetList;
 
 // Defines for the Class variable in IntuiMessage


Commit: 6230fcbeb9e19c1db8bf50dd06fc02ffee925c01
    https://github.com/scummvm/scummvm/commit/6230fcbeb9e19c1db8bf50dd06fc02ffee925c01
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:55+01:00

Commit Message:
LAB: Simplify the journal and map gadget handling

Changed paths:
    engines/lab/eventman.cpp
    engines/lab/eventman.h
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 7760ba2..53361c9 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -94,6 +94,16 @@ void EventManager::attachGadgetList(GadgetList *gadgetList) {
 	_screenGadgetList = gadgetList;
 }
 
+Gadget *EventManager::getGadget(uint16 id) {
+	for (GadgetList::iterator gadgetItr = _screenGadgetList->begin(); gadgetItr != _screenGadgetList->end(); ++gadgetItr) {
+		Gadget *gadget = *gadgetItr;
+		if (gadget->_gadgetID == id)
+			return gadget;
+	}
+
+	return nullptr;
+}
+
 EventManager::EventManager(LabEngine *vm) : _vm(vm) {
 	_leftClick = false;
 	_rightClick = false;
diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h
index f87d7ee..420c7d0 100644
--- a/engines/lab/eventman.h
+++ b/engines/lab/eventman.h
@@ -67,6 +67,7 @@ public:
 	bool mouseButton(uint16 *x, uint16 *y, bool leftButton);
 	Gadget *mouseGadget();
 	void attachGadgetList(GadgetList *gadgetList);
+	Gadget *getGadget(uint16 id);
 	void mouseHandler(int flag, Common::Point pos);
 	bool keyPress(uint16 *keyCode);
 	bool haveNextChar();
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 6b2efda..2604579 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -149,6 +149,8 @@ private:
 	CloseDataPtr _cptr;
 	InventoryData *_inventory;
 	Image *_tiles[16];
+	GadgetList _journalGadgetList;
+	GadgetList _mapGadgetList;
 
 private:
 	bool from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Common::Point tmpPos, uint16 &curInv, IntuiMessage * curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode);
@@ -161,9 +163,12 @@ public:
 	void decIncInv(uint16 *CurInv, bool dec);
 	Gadget *checkNumGadgetHit(GadgetList *gadgetList, uint16 key);
 	IntuiMessage *getMsg();
+	void loadMapData();
 	void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein);
 	void processMap(uint16 CurRoom);
 	void doMap(uint16 CurRoom);
+	void freeMapData();
+	void loadJournalData();
 	void drawJournal(uint16 wipenum, bool needFade);
 	void processJournal();
 	void doJournal();
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index b09ca50..b509039 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -49,15 +49,6 @@ static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge,
 static uint16 MaxRooms;
 static MapData *Maps;
 
-static uint16 MapGadX[3] = {101, 55, 8}, MapGadY[3] = {105, 105, 105};
-
-static Gadget
-	backgadget = { 8, 105, 0, 0, 0L, NULL, NULL },
-	upgadget = { 55, 105, 1, VKEY_UPARROW, 0L, NULL, NULL },
-	downgadget = { 101, 105, 2, VKEY_DNARROW, 0L, NULL, NULL };
-
-static GadgetList *MapGadgetList;
-
 #define LOWERFLOOR     1
 #define MIDDLEFLOOR    2
 #define UPPERFLOOR     3
@@ -83,14 +74,8 @@ static uint16 mapScaleY(uint16 y) {
 /**
  * Loads in the map data.
  */
-static bool loadMapData() {
-	uint16 counter;
-
-	MapGadgetList = new GadgetList();
-	MapGadgetList->push_back(&backgadget);
-	MapGadgetList->push_back(&upgadget);
-	MapGadgetList->push_back(&downgadget);
-
+void LabEngine::loadMapData() {
+	Utils *utils = g_lab->_utils;
 	Common::File *mapImages = g_lab->_resource->openDataFile("P:MapImage");
 
 	Map = new Image(mapImages);
@@ -111,23 +96,12 @@ static bool loadMapData() {
 	Path = new Image(mapImages);
 	Bridge = new Image(mapImages);
 
-	backgadget._image = new Image(mapImages);
-	backgadget._altImage = new Image(mapImages);
-	upgadget._image = new Image(mapImages);
-	upgadget._altImage = new Image(mapImages);
-	downgadget._image = new Image(mapImages);
-	downgadget._altImage = new Image(mapImages);
+	_mapGadgetList.push_back(createButton( 8,  utils->vgaScaleY(105), 0, VKEY_LTARROW, new Image(mapImages), new Image(mapImages)));	// back
+	_mapGadgetList.push_back(createButton( 55, utils->vgaScaleY(105), 1, VKEY_UPARROW, new Image(mapImages), new Image(mapImages)));	// up
+	_mapGadgetList.push_back(createButton(101, utils->vgaScaleY(105), 2, VKEY_DNARROW, new Image(mapImages), new Image(mapImages)));	// down
 
 	delete mapImages;
 
-	counter = 0;
-
-	for (GadgetList::iterator gadget = MapGadgetList->begin(); gadget != MapGadgetList->end(); ++gadget) {
-		(*gadget)->x = g_lab->_utils->vgaScaleX(MapGadX[counter]);
-		(*gadget)->y = g_lab->_utils->vgaScaleY(MapGadY[counter]);
-		counter++;
-	}
-
 	Common::File *mapFile = g_lab->_resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0'));
 	g_lab->_music->updateMusic();
 	if (!g_lab->_music->_doNotFilestopSoundEffect)
@@ -144,13 +118,10 @@ static bool loadMapData() {
 	}
 
 	delete mapFile;
-
-	return true;
 }
 
-static void freeMapData() {
-	MapGadgetList->clear();
-	delete MapGadgetList;
+void LabEngine::freeMapData() {
+	freeButtonList(&_mapGadgetList);
 
 	delete[] Maps;
 	Maps = NULL;
@@ -406,7 +377,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 	_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);
 
 	Map->drawImage(0, 0);
-	drawGadgetList(MapGadgetList);
+	drawGadgetList(&_mapGadgetList);
 
 	for (uint16 i = 1; i <= MaxRooms; i++) {
 		if ((Maps[i].PageNumber == Floor) && _roomsFound->in(i) && Maps[i].x) {
@@ -424,18 +395,21 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 	tempfloor = Floor;
 	getUpFloor(&tempfloor, &noOverlay);
 
+	Gadget *upGadget = _event->getGadget(1);
+	Gadget *downGadget = _event->getGadget(2);
+
 	if (noOverlay)
-		enableGadget(&upgadget);
+		enableGadget(upGadget);
 	else
-		disableGadget(&upgadget, 12);
+		disableGadget(upGadget, 12);
 
 	tempfloor = Floor;
 	getDownFloor(&tempfloor, &noOverlay);
 
 	if (noOverlay)
-		enableGadget(&downgadget);
+		enableGadget(downGadget);
 	else
-		disableGadget(&downgadget, 12);
+		disableGadget(downGadget, 12);
 
 	// Labyrinth specific code
 	if (Floor == LOWERFLOOR) {
@@ -660,9 +634,9 @@ void LabEngine::doMap(uint16 CurRoom) {
 	else if (_direction == WEST)
 		XMark = MapWest;
 
+	_event->attachGadgetList(&_mapGadgetList);
 	drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true);
 	_event->mouseShow();
-	_event->attachGadgetList(MapGadgetList);
 	_graphics->screenUpdate();
 	processMap(CurRoom);
 	_event->attachGadgetList(NULL);
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 6395ee9..5aa8db5 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -51,8 +51,6 @@ static char *journaltext, *journaltexttitle;
 static uint16 JPage = 0;
 static bool lastpage = false;
 static Image JBackImage, ScreenImage;
-static uint16 JGadX[3] = { 80, 144, 194 }, JGadY[3] = { 162, 164, 162 };
-static Gadget ForwardG, CancelG, BackG;
 static bool GotBackImage = false;
 static uint16 monitorPage;
 static const char *TextFileName;
@@ -150,7 +148,7 @@ void LabEngine::doWestPaper() {
 /**
  * Loads in the data for the journal.
  */
-static bool loadJournalData() {
+void LabEngine::loadJournalData() {
 	char filename[20];
 	bool bridge, dirty, news, clean;
 
@@ -187,40 +185,11 @@ static bool loadJournalData() {
 	journaltexttitle = g_lab->_resource->getText("Lab:Rooms/jt");
 
 	Common::File *journalFile = g_lab->_resource->openDataFile("P:JImage");
-
-	BackG._image = new Image(journalFile);
-	BackG._altImage = new Image(journalFile);
-	ForwardG._image = new Image(journalFile);
-	ForwardG._altImage = new Image(journalFile);
-	CancelG._image = new Image(journalFile);
-	CancelG._altImage = new Image(journalFile);
-
+	Utils *utils = g_lab->_utils;
+	_journalGadgetList.push_back(createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile), new Image(journalFile)));	// back
+	_journalGadgetList.push_back(createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile), new Image(journalFile)));	// foward
+	_journalGadgetList.push_back(createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2,            0, new Image(journalFile), new Image(journalFile)));	// cancel
 	delete journalFile;
-
-	BackG._keyEquiv = VKEY_LTARROW;
-	ForwardG._keyEquiv = VKEY_RTARROW;
-
-	uint16 counter = 0;
-
-	GadgetList journalGadgetList;
-	journalGadgetList.push_back(&BackG);
-	journalGadgetList.push_back(&CancelG);
-	journalGadgetList.push_back(&ForwardG);
-
-	for (GadgetList::iterator gadgetIter = journalGadgetList.begin(); gadgetIter != journalGadgetList.end(); ++gadgetIter) {
-		Gadget *gadget = *gadgetIter;
-		gadget->x = g_lab->_utils->vgaScaleX(JGadX[counter]);
-
-		if (counter == 1)
-			gadget->y = g_lab->_utils->vgaScaleY(JGadY[counter]) + g_lab->_utils->svgaCord(1);
-		else
-			gadget->y = g_lab->_utils->vgaScaleY(JGadY[counter]) - g_lab->_utils->svgaCord(1);
-
-		gadget->_gadgetID = counter;
-		counter++;
-	}
-
-	return true;
 }
 
 /**
@@ -302,15 +271,18 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 	else
 		turnPage((bool)(wipenum == 1));
 
+	Gadget *backGadget = _event->getGadget(0);
+	Gadget *forwardGadget = _event->getGadget(1);
+
 	if (JPage == 0)
-		disableGadget(&BackG, 15);
+		disableGadget(backGadget, 15);
 	else
-		enableGadget(&BackG);
+		enableGadget(backGadget);
 
 	if (lastpage)
-		disableGadget(&ForwardG, 15);
+		disableGadget(forwardGadget, 15);
 	else
-		enableGadget(&ForwardG);
+		enableGadget(forwardGadget);
 
 
 	if (needFade)
@@ -373,11 +345,6 @@ void LabEngine::processJournal() {
  * Does the journal processing.
  */
 void LabEngine::doJournal() {
-	GadgetList journalGadgetList;
-	journalGadgetList.push_back(&BackG);
-	journalGadgetList.push_back(&CancelG);
-	journalGadgetList.push_back(&ForwardG);
-
 	_graphics->blackAllScreen();
 
 	lastpage    = false;
@@ -395,13 +362,13 @@ void LabEngine::doJournal() {
 
 	drawJournal(0, true);
 
-	_event->attachGadgetList(&journalGadgetList);
+	_event->attachGadgetList(&_journalGadgetList);
 	_event->mouseShow();
 	processJournal();
 	_event->attachGadgetList(NULL);
 	_graphics->fade(false, 0);
 	_event->mouseHide();
-	journalGadgetList.clear();
+	freeButtonList(&_journalGadgetList);
 
 	ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
 
@@ -445,6 +412,7 @@ bool LabEngine::saveRestoreGame() {
 		}
 	}
 
+	//_event->attachGadgetList(&_moveGadgetList);
 	_graphics->screenUpdate();
 
 	return isOK;


Commit: c4ca8223b73060d8ae38977fe0624ed7a3d920aa
    https://github.com/scummvm/scummvm/commit/c4ca8223b73060d8ae38977fe0624ed7a3d920aa
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:56+01:00

Commit Message:
LAB: Plug a memory leak in freeButtonList()

Changed paths:
    engines/lab/interface.cpp



diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index d041160..dae822b 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -56,8 +56,11 @@ Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image
 }
 
 void freeButtonList(GadgetList *gadgetList) {
-	for (GadgetList::iterator gadget = gadgetList->begin(); gadget != gadgetList->end(); ++gadget) {
-		delete *gadget;
+	for (GadgetList::iterator gadgetIter = gadgetList->begin(); gadgetIter != gadgetList->end(); ++gadgetIter) {
+		Gadget *gadget = *gadgetIter;
+		delete gadget->_image;
+		delete gadget->_altImage;
+		delete gadget;
 	}
 
 	gadgetList->clear();


Commit: 4340295fbfe767d5248390f9f1b154c22127e549
    https://github.com/scummvm/scummvm/commit/4340295fbfe767d5248390f9f1b154c22127e549
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:56+01:00

Commit Message:
LAB: Rename floor defines

Changed paths:
    engines/lab/map.cpp



diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index b509039..8cd0ed9 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -49,13 +49,16 @@ static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge,
 static uint16 MaxRooms;
 static MapData *Maps;
 
-#define LOWERFLOOR     1
-#define MIDDLEFLOOR    2
-#define UPPERFLOOR     3
-#define MEDMAZEFLOOR   4
-#define HEDGEMAZEFLOOR 5
-#define SURMAZEFLOOR   6
-#define CARNIVAL       7
+enum MapFloor {
+	kFloorNone,
+	kFloorLower,
+	kFloorMiddle,
+	kFloorUpper,
+	kFloorMedMaze,
+	kFloorHedgeMaze,
+	kFloorSurMaze,
+	kFloorCarnival
+};
 
 static uint16 mapScaleX(uint16 x) {
 	if (g_lab->_isHiRes)
@@ -165,9 +168,9 @@ static void roomCoords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint1
 }
 
 /**
- * Draws a room to the bitmap.
+ * Draws a room map.
  */
-static void drawRoom(uint16 CurRoom, bool drawx) {
+static void drawRoomMap(uint16 CurRoom, bool drawx) {
 	uint16 x, y, xx, xy, offset;
 	uint32 flags;
 
@@ -318,14 +321,14 @@ static void getUpFloor(uint16 *Floor, bool *isfloor) {
 	do {
 		*isfloor = true;
 
-		if (*Floor < UPPERFLOOR)
+		if (*Floor < kFloorUpper)
 			(*Floor)++;
 		else {
-			*Floor   = CARNIVAL + 1;
+			*Floor   = kFloorCarnival + 1;
 			*isfloor = false;
 			return;
 		}
-	} while ((!onFloor(*Floor)) && (*Floor <= CARNIVAL));
+	} while ((!onFloor(*Floor)) && (*Floor <= kFloorCarnival));
 }
 
 /**
@@ -336,18 +339,18 @@ static void getDownFloor(uint16 *Floor, bool *isfloor) {
 	do {
 		*isfloor = true;
 
-		if ((*Floor == LOWERFLOOR) || (*Floor == 0)) {
+		if ((*Floor == kFloorLower) || (*Floor == 0)) {
 			*Floor   = 0;
 			*isfloor = false;
 			return;
-		} else if (*Floor > UPPERFLOOR) {
+		} else if (*Floor > kFloorUpper) {
 			// Labyrinth specific code
-			if (*Floor == HEDGEMAZEFLOOR)
-				*Floor = UPPERFLOOR;
-			else if ((*Floor == CARNIVAL) || (*Floor == MEDMAZEFLOOR))
-				*Floor = MIDDLEFLOOR;
-			else if (*Floor == SURMAZEFLOOR)
-				*Floor = LOWERFLOOR;
+			if (*Floor == kFloorHedgeMaze)
+				*Floor = kFloorUpper;
+			else if ((*Floor == kFloorCarnival) || (*Floor == kFloorMedMaze))
+				*Floor = kFloorMiddle;
+			else if (*Floor == kFloorSurMaze)
+				*Floor = kFloorLower;
 			else {
 				*Floor = 0;
 				*isfloor = false;
@@ -381,7 +384,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 
 	for (uint16 i = 1; i <= MaxRooms; i++) {
 		if ((Maps[i].PageNumber == Floor) && _roomsFound->in(i) && Maps[i].x) {
-			drawRoom(i, (bool)(i == CurRoom));
+			drawRoomMap(i, (bool)(i == CurRoom));
 			_music->updateMusic();
 		}
 	}
@@ -390,7 +393,7 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 	// NOTE: this here on purpose just in case there's some weird
 	// condition, like the surreal maze where there are no rooms
 	if ((Maps[CurRoom].PageNumber == Floor) && _roomsFound->in(CurRoom) && Maps[CurRoom].x)
-		drawRoom(CurRoom, true);
+		drawRoomMap(CurRoom, true);
 
 	tempfloor = Floor;
 	getUpFloor(&tempfloor, &noOverlay);
@@ -412,24 +415,24 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 		disableGadget(downGadget, 12);
 
 	// Labyrinth specific code
-	if (Floor == LOWERFLOOR) {
-		if (onFloor(SURMAZEFLOOR))
+	if (Floor == kFloorLower) {
+		if (onFloor(kFloorSurMaze))
 			Maze->drawImage(mapScaleX(538), mapScaleY(277));
-	} else if (Floor == MIDDLEFLOOR) {
-		if (onFloor(CARNIVAL))
+	} else if (Floor == kFloorMiddle) {
+		if (onFloor(kFloorCarnival))
 			Maze->drawImage(mapScaleX(358), mapScaleY(72));
 
-		if (onFloor(MEDMAZEFLOOR))
+		if (onFloor(kFloorMedMaze))
 			Maze->drawImage(mapScaleX(557), mapScaleY(325));
-	} else if (Floor == UPPERFLOOR) {
-		if (onFloor(HEDGEMAZEFLOOR))
+	} else if (Floor == kFloorUpper) {
+		if (onFloor(kFloorHedgeMaze))
 			HugeMaze->drawImage(mapScaleX(524), mapScaleY(97));
-	} else if (Floor == SURMAZEFLOOR) {
+	} else if (Floor == kFloorSurMaze) {
 		sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str();
 		_graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr);
 	}
 
-	if (Floor >= LOWERFLOOR && Floor <= CARNIVAL) {
+	if (Floor >= kFloorLower && Floor <= kFloorCarnival) {
 		sptr = (char *)_resource->getStaticText(Floor - 1).c_str();
 		_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 75, 134, 97, sptr);
 	}
@@ -529,34 +532,34 @@ void LabEngine::processMap(uint16 CurRoom) {
 						CurFloor = OldFloor;
 				}
 			} else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) {
-				if ((CurFloor == LOWERFLOOR) && (MouseX >= mapScaleX(538)) && (MouseY >= mapScaleY(277))
+				if ((CurFloor == kFloorLower) && (MouseX >= mapScaleX(538)) && (MouseY >= mapScaleY(277))
 					  && (MouseX <= mapScaleX(633)) && (MouseY <= mapScaleY(352))
-					  && onFloor(SURMAZEFLOOR)) {
-					CurFloor = SURMAZEFLOOR;
+					  && onFloor(kFloorSurMaze)) {
+					CurFloor = kFloorSurMaze;
 
 					_graphics->fade(false, 0);
 					drawMap(CurRoom, CurMsg, CurFloor, false, false);
 					_graphics->fade(true, 0);
-				} else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(358)) && (MouseY >= mapScaleY(71))
+				} else if ((CurFloor == kFloorMiddle) && (MouseX >= mapScaleX(358)) && (MouseY >= mapScaleY(71))
 							  && (MouseX <= mapScaleX(452)) && (MouseY <= mapScaleY(147))
-							  && onFloor(CARNIVAL)) {
-					CurFloor = CARNIVAL;
+							  && onFloor(kFloorCarnival)) {
+					CurFloor = kFloorCarnival;
 
 					_graphics->fade(false, 0);
 					drawMap(CurRoom, CurMsg, CurFloor, false, false);
 					_graphics->fade(true, 0);
-				} else if ((CurFloor == MIDDLEFLOOR) && (MouseX >= mapScaleX(557)) && (MouseY >= mapScaleY(325))
+				} else if ((CurFloor == kFloorMiddle) && (MouseX >= mapScaleX(557)) && (MouseY >= mapScaleY(325))
 						  && (MouseX <= mapScaleX(653)) && (MouseY <= mapScaleY(401))
-						  && onFloor(MEDMAZEFLOOR)) {
-					CurFloor = MEDMAZEFLOOR;
+						  && onFloor(kFloorMedMaze)) {
+					CurFloor = kFloorMedMaze;
 
 					_graphics->fade(false, 0);
 					drawMap(CurRoom, CurMsg, CurFloor, false, false);
 					_graphics->fade(true, 0);
-				} else if ((CurFloor == UPPERFLOOR) && (MouseX >= mapScaleX(524)) && (MouseY >=  mapScaleY(97))
+				} else if ((CurFloor == kFloorUpper) && (MouseX >= mapScaleX(524)) && (MouseY >=  mapScaleY(97))
 						  && (MouseX <= mapScaleX(645)) && (MouseY <= mapScaleY(207))
-						  && onFloor(HEDGEMAZEFLOOR)) {
-					CurFloor = HEDGEMAZEFLOOR;
+						  && onFloor(kFloorHedgeMaze)) {
+					CurFloor = kFloorHedgeMaze;
 
 					_graphics->fade(false, 0);
 					drawMap(CurRoom, CurMsg, CurFloor, false, false);
@@ -586,7 +589,7 @@ void LabEngine::processMap(uint16 CurRoom) {
 							_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr);
 
 							if (Maps[OldMsg].PageNumber == CurFloor)
-								drawRoom(OldMsg, (bool)(OldMsg == CurRoom));
+								drawRoomMap(OldMsg, (bool)(OldMsg == CurRoom));
 
 							roomCoords(CurMsg, &x1, &y1, &x2, &y2);
 							x1 = (x1 + x2) / 2;


Commit: ff6dfee221ac017caeb3c10389766129b0339e5e
    https://github.com/scummvm/scummvm/commit/ff6dfee221ac017caeb3c10389766129b0339e5e
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:56+01:00

Commit Message:
LAB: Initialize the game interface correctly after saving/loading

Changed paths:
    engines/lab/special.cpp



diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 5aa8db5..502520a 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -412,7 +412,8 @@ bool LabEngine::saveRestoreGame() {
 		}
 	}
 
-	//_event->attachGadgetList(&_moveGadgetList);
+	_alternate = false;
+	_mainDisplay = true;
 	_graphics->screenUpdate();
 
 	return isOK;


Commit: c9ca5a0dd02bd83c1ed78a3f387206f69c8ebbab
    https://github.com/scummvm/scummvm/commit/c9ca5a0dd02bd83c1ed78a3f387206f69c8ebbab
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:56+01:00

Commit Message:
LAB: Remove unused return values

Changed paths:
    engines/lab/engine.cpp
    engines/lab/graphics.cpp
    engines/lab/graphics.h



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 5ea7df8..fe334f4 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -1063,11 +1063,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 void LabEngine::go() {
 	_isHiRes = ((getFeatures() & GF_LOWRES) == 0);
-
-	if (!_graphics->setUpScreens()) {
-		_isHiRes = false;
-		_graphics->setUpScreens();
-	}
+	_graphics->setUpScreens();
 
 	_event->initMouse();
 	_msgFont = _resource->getFont("P:AvanteG.12");
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
index 3d0bbe1..efd24b2 100644
--- a/engines/lab/graphics.cpp
+++ b/engines/lab/graphics.cpp
@@ -426,9 +426,8 @@ void DisplayMan::drawPanel() {
 /**
  * Sets up the Labyrinth screens, and opens up the initial windows.
  */
-bool DisplayMan::setUpScreens() {
-	if (!createScreen(_vm->_isHiRes))
-		return false;
+void DisplayMan::setUpScreens() {
+	createScreen(_vm->_isHiRes);
 
 	Common::File *controlFile = _vm->_resource->openDataFile("P:Control");
 	for (uint16 i = 0; i < 20; i++)
@@ -475,8 +474,6 @@ bool DisplayMan::setUpScreens() {
 	}
 
 	delete invFile;
-
-	return true;
 }
 
 /**
@@ -543,7 +540,7 @@ void DisplayMan::screenUpdate() {
 /**
  * Sets up either a low-res or a high-res 256 color screen.
  */
-bool DisplayMan::createScreen(bool hiRes) {
+void DisplayMan::createScreen(bool hiRes) {
 	if (hiRes) {
 		_screenWidth  = 640;
 		_screenHeight = 480;
@@ -553,8 +550,6 @@ bool DisplayMan::createScreen(bool hiRes) {
 	}
 	_screenBytesPerPage = _screenWidth * _screenHeight;
 	_displayBuffer = new byte[_screenBytesPerPage];	// FIXME: Memory leak!
-
-	return true;
 }
 
 /**
diff --git a/engines/lab/graphics.h b/engines/lab/graphics.h
index 71c8246..c2c3e82 100644
--- a/engines/lab/graphics.h
+++ b/engines/lab/graphics.h
@@ -89,7 +89,7 @@ public:
 	void blackAllScreen();
 	void createBox(uint16 y2);
 	void drawPanel();
-	bool setUpScreens();
+	void setUpScreens();
 	int32 longDrawMessage(const char *str);
 	void drawMessage(const char *str);
 	void setAPen(byte pennum);
@@ -137,7 +137,7 @@ public:
 	void drawHLine(uint16 x, uint16 y1, uint16 y2);
 	void drawVLine(uint16 x1, uint16 y, uint16 x2);
 	void screenUpdate();
-	bool createScreen(bool HiRes);
+	void createScreen(bool HiRes);
 	void setAmigaPal(uint16 *pal, uint16 numColors);
 	void writeColorRegs(byte *buf, uint16 first, uint16 numreg);
 	void setPalette(void *cmap, uint16 numcolors);


Commit: 90e221a570bf684dee016a0aaa5e8ca968465390
    https://github.com/scummvm/scummvm/commit/90e221a570bf684dee016a0aaa5e8ca968465390
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:56+01:00

Commit Message:
LAB: Plug a memory leak

Changed paths:
    engines/lab/special.cpp



diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 502520a..cce06e6 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -152,7 +152,7 @@ void LabEngine::loadJournalData() {
 	char filename[20];
 	bool bridge, dirty, news, clean;
 
-	journalFont = g_lab->_resource->getFont("P:Journal.fon");	// FIXME: memory leak
+	journalFont = g_lab->_resource->getFont("P:Journal.fon");
 
 	g_lab->_music->updateMusic();
 
@@ -368,7 +368,9 @@ void LabEngine::doJournal() {
 	_event->attachGadgetList(NULL);
 	_graphics->fade(false, 0);
 	_event->mouseHide();
+
 	freeButtonList(&_journalGadgetList);
+	g_lab->_graphics->closeFont(journalFont);
 
 	ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
 


Commit: 53de3143f636486b89380e3b2ce245e2606b98e0
    https://github.com/scummvm/scummvm/commit/53de3143f636486b89380e3b2ce245e2606b98e0
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:56+01:00

Commit Message:
LAB: Cleanup doGoForward()

Changed paths:
    engines/lab/processroom.cpp



diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 26e91e5..ed28e87 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -690,10 +690,11 @@ bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *lcptr) {
 bool doGoForward(CloseDataPtr *lcptr) {
 	RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;
 
-	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
-		if (((*rule)->_ruleType == GOFORWARD) && ((*rule)->_param1 == (g_lab->_direction + 1))) {
-			if (checkConditions((*rule)->_condition)) {
-				g_lab->doActions((*rule)->_actionList, lcptr);
+	for (RuleList::iterator ruleIter = rules->begin(); ruleIter != rules->end(); ++ruleIter) {
+		Rule *rule = *ruleIter;
+		if ((rule->_ruleType == GOFORWARD) && (rule->_param1 == (g_lab->_direction + 1))) {
+			if (checkConditions(rule->_condition)) {
+				g_lab->doActions(rule->_actionList, lcptr);
 				return true;
 			}
 		}


Commit: 151e27f4b1d5a98a3867c46d770b9b2a41f8905c
    https://github.com/scummvm/scummvm/commit/151e27f4b1d5a98a3867c46d770b9b2a41f8905c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:56+01:00

Commit Message:
LAB: Fix regression in setCurClose(). Fixes closeups

A regression from 78e8896ce7583fbd1feee8e3e9c1aca0f11c2392

Changed paths:
    engines/lab/processroom.h
    engines/lab/special.cpp



diff --git a/engines/lab/processroom.h b/engines/lab/processroom.h
index e4cb84e..fae4c2f 100644
--- a/engines/lab/processroom.h
+++ b/engines/lab/processroom.h
@@ -193,7 +193,7 @@ bool parse(const char *inputFile);
 ViewData *getViewData(uint16 roomNum, uint16 direction);
 void drawDirection(CloseDataPtr lcptr);
 uint16 processArrow(uint16 curDirection, uint16 arrow);
-void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords = false);
+void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords = true);
 bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr);
 bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *lcptr);
 bool doOperateRule(int16 x, int16 y, int16 itemNum, CloseDataPtr *lcptr);
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index cce06e6..5a0348c 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -564,7 +564,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 					testcptr = _cptr;
 					MouseY = 64 + (MouseY / MonGadHeight) * 42;
 					MouseX = 101;
-					setCurClose(Common::Point(MouseX, MouseY), &_cptr, true);
+					setCurClose(Common::Point(MouseX, MouseY), &_cptr, false);
 
 					if (testcptr != _cptr) {
 						lastcptr[depth] = testcptr;


Commit: d2a540ea557f1b0a2f8e1abc00ec82a068855796
    https://github.com/scummvm/scummvm/commit/d2a540ea557f1b0a2f8e1abc00ec82a068855796
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:56+01:00

Commit Message:
LAB: Rename graphics.* to dispman.*

Changed paths:
  A engines/lab/dispman.cpp
  A engines/lab/dispman.h
  R engines/lab/graphics.cpp
  R engines/lab/graphics.h
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/module.mk
    engines/lab/resource.h
    engines/lab/transitions.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
new file mode 100644
index 0000000..a7c71f2
--- /dev/null
+++ b/engines/lab/dispman.cpp
@@ -0,0 +1,768 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#include "lab/lab.h"
+#include "lab/anim.h"
+#include "lab/image.h"
+#include "lab/labfun.h"
+#include "lab/processroom.h"
+#include "lab/resource.h"
+
+namespace Lab {
+
+DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) {
+	_longWinInFront = false;
+	_lastMessageLong = false;
+	_doNotDrawMessage = false;
+
+	_screenBytesPerPage = 65536;
+	_curapen = 0;
+	_curBitmap = nullptr;
+	_displayBuffer = nullptr;
+	_currentDisplayBuffer = nullptr;
+	_tempScrollData = nullptr;
+	FadePalette = nullptr;
+
+	_screenWidth = 0;
+	_screenHeight = 0;
+
+	for (int i = 0; i < 256 * 3; i++)
+		_curvgapal[i] = 0;
+}
+
+DisplayMan::~DisplayMan() {
+	freePict();
+}
+
+// From readPict.c.  Reads in pictures and animations from disk.
+
+void DisplayMan::loadPict(const char *filename) {
+	Common::File *bitmapFile = _vm->_resource->openDataFile(filename);
+	freePict();
+	_curBitmap = new byte[bitmapFile->size()];
+	bitmapFile->read(_curBitmap, bitmapFile->size());
+	delete bitmapFile;
+}
+
+/**
+ * Reads in a picture into the dest bitmap.
+ */
+void DisplayMan::readPict(const char *filename, bool playOnce, bool onlyDiffData) {
+	_vm->_anim->stopDiff();
+
+	loadPict(filename);
+
+	_vm->_music->updateMusic();
+
+	if (!_vm->_music->_doNotFilestopSoundEffect)
+		_vm->_music->stopSoundEffect();
+
+	_dispBitMap._bytesPerRow = _screenWidth;
+	_dispBitMap._rows        = _screenHeight;
+	_dispBitMap._flags       = BITMAPF_VIDEO;
+
+	_vm->_anim->readDiff(_curBitmap, playOnce, onlyDiffData);
+}
+
+/**
+ * Reads in a picture into buffer memory.
+ */
+byte *DisplayMan::readPictToMem(const char *filename, uint16 x, uint16 y) {
+	_vm->_anim->stopDiff();
+
+	loadPict(filename);
+
+	_vm->_music->updateMusic();
+
+	if (!_vm->_music->_doNotFilestopSoundEffect)
+		_vm->_music->stopSoundEffect();
+
+	_dispBitMap._bytesPerRow = x;
+	_dispBitMap._rows = y;
+	_dispBitMap._flags = BITMAPF_NONE;
+	_dispBitMap._planes[0] = _curBitmap;
+	_dispBitMap._planes[1] = _dispBitMap._planes[0] + 0x10000;
+	_dispBitMap._planes[2] = _dispBitMap._planes[1] + 0x10000;
+	_dispBitMap._planes[3] = _dispBitMap._planes[2] + 0x10000;
+	_dispBitMap._planes[4] = _dispBitMap._planes[3] + 0x10000;
+
+	_vm->_anim->readDiff(_curBitmap, true);
+
+	return _curBitmap;
+}
+
+void DisplayMan::freePict() {
+	delete _curBitmap;
+	_curBitmap = NULL;
+}
+
+//---------------------------------------------------------------------------
+//------------ Does all the text rendering to the message boxes. ------------
+//---------------------------------------------------------------------------
+
+/**
+ * Extracts the first word from a string.
+ */
+static void getWord(char *wordBuffer, const char *mainBuffer, uint16 *wordWidth) {
+	uint16 width = 0;
+
+	while ((mainBuffer[width] != ' ') && mainBuffer[width] && (mainBuffer[width] != '\n')) {
+		wordBuffer[width] = mainBuffer[width];
+		width++;
+	}
+
+	wordBuffer[width] = 0;
+
+	*wordWidth = width;
+}
+
+/**
+ * Gets a line of text for flowText; makes sure that its length is less than
+ * or equal to the maximum width.
+ */
+void DisplayMan::getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer, uint16 lineWidth) {
+	uint16 curWidth = 0, wordWidth;
+	char wordBuffer[100];
+	bool doit = true;
+
+	lineWidth += textLength(tf, " ", 1);
+
+	lineBuffer[0] = 0;
+
+	while ((*mainBuffer)[0] && doit) {
+		getWord(wordBuffer, *mainBuffer, &wordWidth);
+		strcat(wordBuffer, " ");
+
+		if ((curWidth + textLength(tf, wordBuffer, wordWidth + 1)) <= lineWidth) {
+			strcat(lineBuffer, wordBuffer);
+			(*mainBuffer) += wordWidth;
+
+			if ((*mainBuffer)[0] == '\n')
+				doit = false;
+
+			if ((*mainBuffer)[0])
+				(*mainBuffer)++;
+
+			curWidth = textLength(tf, lineBuffer, strlen(lineBuffer));
+		} else
+			doit = false;
+	}
+}
+
+/**
+ * Dumps a chunk of text to an arbitrary box; flows it within that box and
+ * optionally centers it. Returns the number of characters that were
+ * processed.
+ * Note: Every individual word MUST be int16 enough to fit on a line, and
+ * each line less than 255 characters.
+ */
+uint32 DisplayMan::flowText(
+			void *font,            // the TextAttr pointer
+			int16 spacing,         // How much vertical spacing between the lines
+			byte pencolor,         // pen number to use for text
+			byte backpen,          // the background color
+			bool fillback,         // Whether to fill the background
+			bool centerh,          // Whether to center the text horizontally
+			bool centerv,          // Whether to center the text vertically
+			bool output,           // Whether to output any text
+			uint16 x1, uint16 y1,  // Cords
+			uint16 x2, uint16 y2,
+			const char *str) {     // The text itself
+	TextFont *_msgFont = (TextFont *)font;
+	char linebuffer[256];
+	const char *temp;
+	uint16 numlines, actlines, fontheight, width;
+	uint16 x, y;
+
+	if (fillback) {
+		setAPen(backpen);
+		rectFill(x1, y1, x2, y2);
+	}
+
+	if (str == NULL)
+		return 0L;
+
+	setAPen(pencolor);
+
+	fontheight = textHeight(_msgFont) + spacing;
+	numlines   = (y2 - y1 + 1) / fontheight;
+	width      = x2 - x1 + 1;
+	y          = y1;
+
+	if (centerv && output) {
+		temp = str;
+		actlines = 0;
+
+		while (temp[0]) {
+			getLine(_msgFont, linebuffer, &temp, width);
+			actlines++;
+		}
+
+		if (actlines <= numlines)
+			y += ((y2 - y1 + 1) - (actlines * fontheight)) / 2;
+	}
+
+	temp = str;
+
+	while (numlines && str[0]) {
+		getLine(_msgFont, linebuffer, &str, width);
+
+		x = x1;
+
+		if (centerh)
+			x += (width - textLength(_msgFont, linebuffer, strlen(linebuffer))) / 2;
+
+		if (output)
+			text(_msgFont, x, y, pencolor, linebuffer, strlen(linebuffer));
+
+		numlines--;
+		y += fontheight;
+	}
+
+	return (str - temp);
+}
+
+uint32 DisplayMan::flowTextScaled(
+	void *font,                // the TextAttr pointer
+	int16 spacing,             // How much vertical spacing between the lines
+	byte penColor,             // pen number to use for text
+	byte backPen,              // the background color
+	bool fillBack,             // Whether to fill the background
+	bool centerX,              // Whether to center the text horizontally
+	bool centerY,              // Whether to center the text vertically
+	bool output,               // Whether to output any text
+	uint16 x1, uint16 y1,      // Cords
+	uint16 x2, uint16 y2,
+	const char *str) {
+	return flowText(font, spacing, penColor, backPen, fillBack, centerX, centerY, output,
+					_vm->_utils->vgaScaleX(x1), _vm->_utils->vgaScaleY(y1),
+					_vm->_utils->vgaScaleX(x2), _vm->_utils->vgaScaleY(y2), str);
+}
+
+/**
+ * Calls flowText, but flows it to memory.  Same restrictions as flowText.
+ */
+uint32 DisplayMan::flowTextToMem(Image *destIm,
+			void *font,            // the TextAttr pointer
+			int16 spacing,         // How much vertical spacing between the lines
+			byte pencolor,         // pen number to use for text
+			byte backpen,          // the background color
+			bool fillback,         // Whether to fill the background
+			bool centerh,          // Whether to center the text horizontally
+			bool centerv,          // Whether to center the text vertically
+			bool output,           // Whether to output any text
+			uint16 x1, uint16 y1,  // Cords
+			uint16 x2, uint16 y2,
+			const char *str) {     // The text itself
+	uint32 res, vgabyte = _screenBytesPerPage;
+	byte *tmp = _currentDisplayBuffer;
+
+	_currentDisplayBuffer = destIm->_imageData;
+	_screenBytesPerPage = (uint32)destIm->_width * (int32)destIm->_height;
+
+	res = flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str);
+
+	_screenBytesPerPage = vgabyte;
+	_currentDisplayBuffer = tmp;
+
+	return res;
+}
+
+//----- The control panel stuff -----
+
+void DisplayMan::createBox(uint16 y2) {
+	// Message box area
+	setAPen(7);
+	rectFillScaled(4, 154, 315, y2 - 2);
+
+	// Box around message area
+	setAPen(0);
+	drawHLine(_vm->_utils->vgaScaleX(2), _vm->_utils->vgaScaleY(152), _vm->_utils->vgaScaleX(317));
+	drawVLine(_vm->_utils->vgaScaleX(317), _vm->_utils->vgaScaleY(152), _vm->_utils->vgaScaleY(y2));
+	drawHLine(_vm->_utils->vgaScaleX(2), _vm->_utils->vgaScaleY(y2), _vm->_utils->vgaScaleX(317));
+	drawVLine(_vm->_utils->vgaScaleX(2), _vm->_utils->vgaScaleY(152), _vm->_utils->vgaScaleY(y2));
+}
+
+int32 DisplayMan::longDrawMessage(const char *str) {
+	char newText[512];
+
+	if (str == NULL)
+		return 0;
+
+	_vm->_event->attachGadgetList(NULL);
+	_vm->_event->mouseHide();
+	strcpy(newText, str);
+
+	if (!_longWinInFront) {
+		_longWinInFront = true;
+		// Clear Area
+		setAPen(3);
+		rectFill(0, _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319), _vm->_utils->vgaScaleY(199));
+	}
+
+	createBox(198);
+	_vm->_event->mouseShow();
+
+	return flowTextScaled(_vm->_msgFont, 0, 1, 7, false, true, true, true, 6, 155, 313, 195, str);
+}
+
+/**
+ * Draws a message to the message box.
+ */
+void DisplayMan::drawMessage(const char *str) {
+	if (_doNotDrawMessage) {
+		_doNotDrawMessage = false;
+		return;
+	}
+
+	if (str) {
+		if ((textLength(_vm->_msgFont, str, strlen(str)) > _vm->_utils->vgaScaleX(306))) {
+			longDrawMessage(str);
+			_lastMessageLong = true;
+		} else {
+			if (_longWinInFront) {
+				_longWinInFront = false;
+				drawPanel();
+			}
+
+			_vm->_event->mouseHide();
+			createBox(168);
+			text(_vm->_msgFont, _vm->_utils->vgaScaleX(7), _vm->_utils->vgaScaleY(155) + _vm->_utils->svgaCord(2), 1, str, strlen(str));
+			_vm->_event->mouseShow();
+			_lastMessageLong = false;
+		}
+	}
+}
+
+/**
+ * Draws the control panel display.
+ */
+void DisplayMan::drawPanel() {
+	_vm->_event->mouseHide();
+
+	// Clear Area
+	setAPen(3);
+	rectFill(0, _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319), _vm->_utils->vgaScaleY(199));
+
+	// First Line
+	setAPen(0);
+	drawHLine(0, _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319));
+	// Second Line
+	setAPen(5);
+	drawHLine(0, _vm->_utils->vgaScaleY(149) + 1 + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319));
+	// Gadget Separators
+	setAPen(0);
+	// First black line to separate buttons
+	drawHLine(0, _vm->_utils->vgaScaleY(170), _vm->_utils->vgaScaleX(319));
+
+	if (!_vm->_alternate) {
+		setAPen(4);
+		// The horizontal lines under the black one
+		drawHLine(0, _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(319));
+		drawGadgetList(&_vm->_moveGadgetList);
+	} else {
+		if (_vm->getPlatform() != Common::kPlatformWindows) {
+			// Vertical Black lines
+			drawVLine(_vm->_utils->vgaScaleX(124), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));
+			drawVLine(_vm->_utils->vgaScaleX(194), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));
+		} else {
+			// Vertical Black lines
+			drawVLine(_vm->_utils->vgaScaleX(90), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));
+			drawVLine(_vm->_utils->vgaScaleX(160), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));
+			drawVLine(_vm->_utils->vgaScaleX(230), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));
+		}
+
+		setAPen(4);
+		// The horizontal lines under the black one
+		drawHLine(0, _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(122));
+		drawHLine(_vm->_utils->vgaScaleX(126), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(192));
+		drawHLine(_vm->_utils->vgaScaleX(196), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(319));
+		// The vertical high light lines
+		drawVLine(_vm->_utils->vgaScaleX(1), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
+
+		if (_vm->getPlatform() != Common::kPlatformWindows) {
+			drawVLine(_vm->_utils->vgaScaleX(126), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
+			drawVLine(_vm->_utils->vgaScaleX(196), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
+		} else {
+			drawVLine(_vm->_utils->vgaScaleX(92), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
+			drawVLine(_vm->_utils->vgaScaleX(162), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
+			drawVLine(_vm->_utils->vgaScaleX(232), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
+		}
+
+		drawGadgetList(&_vm->_invGadgetList);
+	}
+
+	_vm->_event->mouseShow();
+}
+
+/**
+ * Sets up the Labyrinth screens, and opens up the initial windows.
+ */
+void DisplayMan::setUpScreens() {
+	createScreen(_vm->_isHiRes);
+
+	Common::File *controlFile = _vm->_resource->openDataFile("P:Control");
+	for (uint16 i = 0; i < 20; i++)
+		_vm->_moveImages[i] = new Image(controlFile);
+	delete controlFile;
+
+	// Creates the gadgets for the movement control panel
+	uint16 y = _vm->_utils->vgaScaleY(173) - _vm->_utils->svgaCord(2);
+
+	// The key mapping was only set for the Windows version.
+	// It's very convenient to have those shortcut, so I added them
+	// for all versions. (Strangerke)
+	_vm->_moveGadgetList.push_back(createButton(  1, y, 0,          't', _vm->_moveImages[0],  _vm->_moveImages[1]));
+	_vm->_moveGadgetList.push_back(createButton( 33, y, 1,          'm', _vm->_moveImages[2],  _vm->_moveImages[3]));
+	_vm->_moveGadgetList.push_back(createButton( 65, y, 2,          'o', _vm->_moveImages[4],  _vm->_moveImages[5]));
+	_vm->_moveGadgetList.push_back(createButton( 97, y, 3,          'c', _vm->_moveImages[6],  _vm->_moveImages[7]));
+	_vm->_moveGadgetList.push_back(createButton(129, y, 4,          'l', _vm->_moveImages[8],  _vm->_moveImages[9]));
+	_vm->_moveGadgetList.push_back(createButton(161, y, 5,          'i', _vm->_moveImages[12], _vm->_moveImages[13]));
+	_vm->_moveGadgetList.push_back(createButton(193, y, 6, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]));
+	_vm->_moveGadgetList.push_back(createButton(225, y, 7, VKEY_UPARROW, _vm->_moveImages[16], _vm->_moveImages[17]));
+	_vm->_moveGadgetList.push_back(createButton(257, y, 8, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]));
+	_vm->_moveGadgetList.push_back(createButton(289, y, 9,          'p', _vm->_moveImages[10], _vm->_moveImages[11]));
+
+	Common::File *invFile = _vm->_resource->openDataFile("P:Inv");
+	if (_vm->getPlatform() == Common::kPlatformWindows) {
+		for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++)
+			_vm->_invImages[imgIdx] = new Image(invFile);
+	} else {
+		for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++)
+			_vm->_invImages[imgIdx] = new Image(invFile);
+	}
+	_vm->_invGadgetList.push_back(createButton( 24, y, 0,          'm', _vm->_invImages[0],   _vm->_invImages[1]));
+	_vm->_invGadgetList.push_back(createButton( 56, y, 1,          'g', _vm->_invImages[2],   _vm->_invImages[3]));
+	_vm->_invGadgetList.push_back(createButton( 94, y, 2,          'u', _vm->_invImages[4],   _vm->_invImages[5]));
+	_vm->_invGadgetList.push_back(createButton(126, y, 3,          'l', _vm->_moveImages[8],  _vm->_moveImages[9]));
+	_vm->_invGadgetList.push_back(createButton(164, y, 4, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]));
+	_vm->_invGadgetList.push_back(createButton(196, y, 5, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]));
+
+	// The windows version has 2 extra gadgets for breadcrumb trail
+	// TODO: the game is really hard to play without those, maybe we could add something to enable that.
+	if (_vm->getPlatform() == Common::kPlatformWindows) {
+		_vm->_invGadgetList.push_back(createButton(234, y, 6, 'b', _vm->_invImages[6], _vm->_invImages[7]));
+		_vm->_invGadgetList.push_back(createButton(266, y, 7, 'f', _vm->_invImages[8], _vm->_invImages[9]));
+	}
+
+	delete invFile;
+}
+
+/**
+ * Sets the pen number to use on all the drawing operations.
+ */
+void DisplayMan::setAPen(byte pennum) {
+	_curapen = pennum;
+}
+
+/**
+ * Fills in a rectangle.
+ */
+void DisplayMan::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+	int w = x2 - x1 + 1;
+	int h = y2 - y1 + 1;
+
+	if (x1 + w > _screenWidth)
+		w = _screenWidth - x1;
+
+	if (y1 + h > _screenHeight)
+		h = _screenHeight - y1;
+
+	if ((w > 0) && (h > 0)) {
+		char *d = (char *)getCurrentDrawingBuffer() + y1 * _screenWidth + x1;
+
+		while (h-- > 0) {
+			char *dd = d;
+			int ww = w;
+
+			while (ww-- > 0) {
+				*dd++ = _curapen;
+			}
+
+			d += _screenWidth;
+		}
+	}
+}
+
+void DisplayMan::rectFillScaled(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+	rectFill(_vm->_utils->vgaScaleX(x1), _vm->_utils->vgaScaleY(y1), _vm->_utils->vgaScaleX(x2), _vm->_utils->vgaScaleY(y2));
+}
+
+/**
+ * Draws a horizontal line.
+ */
+void DisplayMan::drawVLine(uint16 x, uint16 y1, uint16 y2) {
+	rectFill(x, y1, x, y2);
+}
+
+/**
+ * Draws a vertical line.
+ */
+void DisplayMan::drawHLine(uint16 x1, uint16 y, uint16 x2) {
+	rectFill(x1, y, x2, y);
+}
+
+void DisplayMan::screenUpdate() {
+	g_system->copyRectToScreen(_displayBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight);
+	g_system->updateScreen();
+
+	_vm->_event->processInput();
+}
+
+/**
+ * Sets up either a low-res or a high-res 256 color screen.
+ */
+void DisplayMan::createScreen(bool hiRes) {
+	if (hiRes) {
+		_screenWidth  = 640;
+		_screenHeight = 480;
+	} else {
+		_screenWidth  = 320;
+		_screenHeight = 200;
+	}
+	_screenBytesPerPage = _screenWidth * _screenHeight;
+	_displayBuffer = new byte[_screenBytesPerPage];	// FIXME: Memory leak!
+}
+
+/**
+ * Converts an Amiga palette (up to 16 colors) to a VGA palette, then sets
+ * the VGA palette.
+ */
+void DisplayMan::setAmigaPal(uint16 *pal, uint16 numColors) {
+	byte vgaPal[16 * 3];
+	uint16 vgaIdx = 0;
+
+	if (numColors > 16)
+		numColors = 16;
+
+	for (uint16 i = 0; i < numColors; i++) {
+		vgaPal[vgaIdx++] = (byte)(((pal[i] & 0xf00) >> 8) << 2);
+		vgaPal[vgaIdx++] = (byte)(((pal[i] & 0x0f0) >> 4) << 2);
+		vgaPal[vgaIdx++] = (byte)(((pal[i] & 0x00f)) << 2);
+	}
+
+	writeColorRegs(vgaPal, 0, 16);
+	_vm->waitTOF();
+}
+
+/**
+ * Writes any number of the 256 color registers.
+ * first:    the number of the first color register to write.
+ * numreg:   the number of registers to write
+ * buf:      a char pointer which contains the selected color registers.
+ *           Each value representing a color register occupies 3 bytes in
+ *           the array.  The order is red, green then blue.  The first byte
+ *           in the array is the red component of the first element selected.
+ *           The length of the buffer is 3 times the number of registers
+ *           selected.
+ */
+void DisplayMan::writeColorRegs(byte *buf, uint16 first, uint16 numreg) {
+	byte tmp[256 * 3];
+
+	for (int i = 0; i < 256 * 3; i++) {
+		tmp[i] = buf[i] * 4;
+	}
+
+	g_system->getPaletteManager()->setPalette(tmp, first, numreg);
+
+	memcpy(&(_curvgapal[first * 3]), buf, numreg * 3);
+}
+
+void DisplayMan::setPalette(void *cmap, uint16 numcolors) {
+	if (memcmp(cmap, _curvgapal, numcolors * 3) != 0)
+		writeColorRegs((byte *)cmap, 0, numcolors);
+}
+
+/**
+ * Returns the base address of the current VGA display.
+ */
+byte *DisplayMan::getCurrentDrawingBuffer() {
+	if (_currentDisplayBuffer)
+		return _currentDisplayBuffer;
+
+	return _displayBuffer;
+}
+
+/**
+ * Overlays a region on the screen using the desired pen color.
+ */
+void DisplayMan::overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+	int w = x2 - x1 + 1;
+	int h = y2 - y1 + 1;
+
+	if (x1 + w > _screenWidth)
+		w = _screenWidth - x1;
+
+	if (y1 + h > _screenHeight)
+		h = _screenHeight - y1;
+
+	if ((w > 0) && (h > 0)) {
+		char *d = (char *)getCurrentDrawingBuffer() + y1 * _screenWidth + x1;
+
+		while (h-- > 0) {
+			char *dd = d;
+			int ww = w;
+
+			if (y1 & 1) {
+				dd++;
+				ww--;
+			}
+
+			while (ww > 0) {
+				*dd = pencolor;
+				dd += 2;
+				ww -= 2;
+			}
+
+			d += _screenWidth;
+			y1++;
+		}
+	}
+}
+
+/**
+ * Closes a font and frees all memory associated with it.
+ */
+void DisplayMan::closeFont(TextFont *tf) {
+	if (tf) {
+		if (tf->_data && tf->_dataLength)
+			delete[] tf->_data;
+
+		delete tf;
+	}
+}
+
+/**
+ * Returns the length of a text in the specified font.
+ */
+uint16 DisplayMan::textLength(TextFont *tf, const char *text, uint16 numchars) {
+	uint16 length = 0;
+
+	if (tf) {
+		for (uint16 i = 0; i < numchars; i++) {
+			length += tf->_widths[(uint)*text];
+			text++;
+		}
+	}
+
+	return length;
+}
+
+/**
+ * Returns the height of a specified font.
+ */
+uint16 DisplayMan::textHeight(TextFont *tf) {
+	return (tf) ? tf->_height : 0;
+}
+
+/**
+ * Draws the text to the screen.
+ */
+void DisplayMan::text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numchars) {
+	byte *VGATop, *VGACur, *VGATemp, *VGATempLine, *cdata;
+	uint32 RealOffset, SegmentOffset;
+	int32 templeft, LeftInSegment;
+	uint16 bwidth, mask, curpage, data;
+
+	VGATop = getCurrentDrawingBuffer();
+
+	for (uint16 i = 0; i < numchars; i++) {
+		RealOffset = (_screenWidth * y) + x;
+		curpage    = RealOffset / _screenBytesPerPage;
+		SegmentOffset = RealOffset - (curpage * _screenBytesPerPage);
+		LeftInSegment = _screenBytesPerPage - SegmentOffset;
+		VGACur = VGATop + SegmentOffset;
+
+		if (tf->_widths[(uint)*text]) {
+			cdata = tf->_data + tf->_offsets[(uint)*text];
+			bwidth = *cdata++;
+			VGATemp = VGACur;
+			VGATempLine = VGACur;
+
+			for (uint16 rows = 0; rows < tf->_height; rows++) {
+				VGATemp = VGATempLine;
+				templeft = LeftInSegment;
+
+				for (uint16 cols = 0; cols < bwidth; cols++) {
+					data = *cdata++;
+
+					if (data && (templeft >= 8)) {
+						for (int j = 7; j >= 0; j--) {
+							if ((1 << j) & data)
+								*VGATemp = color;
+							VGATemp++;
+						}
+
+						templeft -= 8;
+					} else if (data) {
+						mask = 0x80;
+						templeft = LeftInSegment;
+
+						for (uint16 counterb = 0; counterb < 8; counterb++) {
+							if (templeft <= 0) {
+								curpage++;
+								VGATemp = (byte *)(VGATop - templeft);
+								// Set up VGATempLine for next line
+								VGATempLine -= _screenBytesPerPage;
+								// Set up LeftInSegment for next line
+								LeftInSegment += _screenBytesPerPage + templeft;
+								templeft += _screenBytesPerPage;
+							}
+
+							if (mask & data)
+								*VGATemp = color;
+
+							VGATemp++;
+
+							mask = mask >> 1;
+							templeft--;
+						}
+					} else {
+						templeft -= 8;
+						VGATemp += 8;
+					}
+				}
+
+				VGATempLine += _screenWidth;
+				LeftInSegment -= _screenWidth;
+
+				if (LeftInSegment <= 0) {
+					curpage++;
+					VGATempLine -= _screenBytesPerPage;
+					LeftInSegment += _screenBytesPerPage;
+				}
+			}
+		}
+
+		x += tf->_widths[(int)*text];
+		text++;
+	}
+}
+} // End of namespace Lab
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
new file mode 100644
index 0000000..bbbbe35
--- /dev/null
+++ b/engines/lab/dispman.h
@@ -0,0 +1,169 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#ifndef LAB_DISPMAN_H
+#define LAB_DISPMAN_H
+
+#include "graphics/palette.h"
+#include "lab/anim.h"
+#include "lab/processroom.h"
+
+namespace Lab {
+
+class LabEngine;
+
+struct TextFont {
+	uint32 _dataLength;
+	uint16 _height;
+	byte _widths[256];
+	uint16 _offsets[256];
+	byte *_data;
+};
+
+enum TransitionType {
+	kTransitionNone,
+	kTransitionWipe,
+	kTransitionScrollWipe,
+	kTransitionScrollBlack,
+	kTransitionScrollBounce,
+	kTransitionTransporter,
+	kTransitionReadFirstFrame,
+	kTransitionReadNextFrame
+};
+
+class DisplayMan {
+private:
+	LabEngine *_vm;
+
+	uint16 fadeNumIn(uint16 num, uint16 res, uint16 counter);
+	uint16 fadeNumOut(uint16 num, uint16 res, uint16 counter);
+
+	byte _curapen;
+	byte *_curBitmap;
+	byte _curvgapal[256 * 3];
+	byte *_tempScrollData;
+
+public:
+	DisplayMan(LabEngine *lab);
+	virtual ~DisplayMan();
+
+	void loadPict(const char *filename);
+	void readPict(const char *filename, bool playOnce, bool onlyDiffData = false);
+	void freePict();
+	byte *readPictToMem(const char *filename, uint16 x, uint16 y);
+	void doScrollBlack();
+	void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem);
+	void doScrollWipe(char *filename);
+	void doScrollBounce();
+	void doTransWipe(CloseDataPtr *cPtr, char *filename);
+	void doTransition(TransitionType transitionType, CloseDataPtr *cPtr, char *filename);
+	void blackScreen();
+	void whiteScreen();
+	void blackAllScreen();
+	void createBox(uint16 y2);
+	void drawPanel();
+	void setUpScreens();
+	int32 longDrawMessage(const char *str);
+	void drawMessage(const char *str);
+	void setAPen(byte pennum);
+	void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void rectFillScaled(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	// Window text stuff
+	uint32 flowText(void *font,	// the TextAttr pointer
+				int16 spacing,				// How much vertical spacing between the lines
+				byte pencolor,				// pen number to use for text
+				byte backpen,					// the background color
+				bool fillback,				// Whether to fill the background
+				bool centerh,					// Whether to center the text horizontally
+				bool centerv,					// Whether to center the text vertically
+				bool output,					// Whether to output any text
+				uint16 x1, uint16 y1,	// Cords
+				uint16 x2, uint16 y2,
+				const char *text);		// The text itself
+
+	uint32 flowTextScaled(
+				void *font,						// the TextAttr pointer
+				int16 spacing,				// How much vertical spacing between the lines
+				byte pencolor,				// pen number to use for text
+				byte backpen,					// the background color
+				bool fillback,				// Whether to fill the background
+				bool centerh,					// Whether to center the text horizontally
+				bool centerv,					// Whether to center the text vertically
+				bool output,					// Whether to output any text
+				uint16 x1, uint16 y1,	// Cords
+				uint16 x2, uint16 y2,
+				const char *text);		// The text itself
+
+	uint32 flowTextToMem(Image *destIm,
+				void *font,						// the TextAttr pointer
+				int16 spacing,				// How much vertical spacing between the lines
+				byte pencolor,				// pen number to use for text
+				byte backpen,					// the background color
+				bool fillback,				// Whether to fill the background
+				bool centerh,					// Whether to center the text horizontally
+				bool centerv,					// Whether to center the text vertically
+				bool output,					// Whether to output any text
+				uint16 x1, uint16 y1,	// Cords
+				uint16 x2, uint16 y2,
+				const char *str);			// The text itself
+
+	void drawHLine(uint16 x, uint16 y1, uint16 y2);
+	void drawVLine(uint16 x1, uint16 y, uint16 x2);
+	void screenUpdate();
+	void createScreen(bool HiRes);
+	void setAmigaPal(uint16 *pal, uint16 numColors);
+	void writeColorRegs(byte *buf, uint16 first, uint16 numreg);
+	void setPalette(void *cmap, uint16 numcolors);
+	void overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	byte *getCurrentDrawingBuffer();
+	void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void fade(bool fadein, uint16 res);
+	void closeFont(TextFont *tf);
+	uint16 textLength(TextFont *tf, const char *text, uint16 numchars);
+	uint16 textHeight(TextFont *tf);
+	void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numchars);
+	void getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer, uint16 lineWidth);
+
+	bool _longWinInFront;
+	bool _lastMessageLong;
+	uint32 _screenBytesPerPage;
+	int _screenWidth;
+	int _screenHeight;
+	byte *_displayBuffer;
+	byte *_currentDisplayBuffer;
+	bool _doNotDrawMessage;
+	uint16 *FadePalette;
+	BitMap _dispBitMap;
+};
+
+} // End of namespace Lab
+
+#endif // LAB_DISPMAN_H
diff --git a/engines/lab/graphics.cpp b/engines/lab/graphics.cpp
deleted file mode 100644
index efd24b2..0000000
--- a/engines/lab/graphics.cpp
+++ /dev/null
@@ -1,769 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "lab/lab.h"
-#include "lab/anim.h"
-#include "lab/image.h"
-#include "lab/labfun.h"
-#include "lab/processroom.h"
-#include "lab/resource.h"
-#include "lab/graphics.h"
-
-namespace Lab {
-
-DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) {
-	_longWinInFront = false;
-	_lastMessageLong = false;
-	_doNotDrawMessage = false;
-
-	_screenBytesPerPage = 65536;
-	_curapen = 0;
-	_curBitmap = nullptr;
-	_displayBuffer = nullptr;
-	_currentDisplayBuffer = nullptr;
-	_tempScrollData = nullptr;
-	FadePalette = nullptr;
-
-	_screenWidth = 0;
-	_screenHeight = 0;
-
-	for (int i = 0; i < 256 * 3; i++)
-		_curvgapal[i] = 0;
-}
-
-DisplayMan::~DisplayMan() {
-	freePict();
-}
-
-// From readPict.c.  Reads in pictures and animations from disk.
-
-void DisplayMan::loadPict(const char *filename) {
-	Common::File *bitmapFile = _vm->_resource->openDataFile(filename);
-	freePict();
-	_curBitmap = new byte[bitmapFile->size()];
-	bitmapFile->read(_curBitmap, bitmapFile->size());
-	delete bitmapFile;
-}
-
-/**
- * Reads in a picture into the dest bitmap.
- */
-void DisplayMan::readPict(const char *filename, bool playOnce, bool onlyDiffData) {
-	_vm->_anim->stopDiff();
-
-	loadPict(filename);
-
-	_vm->_music->updateMusic();
-
-	if (!_vm->_music->_doNotFilestopSoundEffect)
-		_vm->_music->stopSoundEffect();
-
-	_dispBitMap._bytesPerRow = _screenWidth;
-	_dispBitMap._rows        = _screenHeight;
-	_dispBitMap._flags       = BITMAPF_VIDEO;
-
-	_vm->_anim->readDiff(_curBitmap, playOnce, onlyDiffData);
-}
-
-/**
- * Reads in a picture into buffer memory.
- */
-byte *DisplayMan::readPictToMem(const char *filename, uint16 x, uint16 y) {
-	_vm->_anim->stopDiff();
-
-	loadPict(filename);
-
-	_vm->_music->updateMusic();
-
-	if (!_vm->_music->_doNotFilestopSoundEffect)
-		_vm->_music->stopSoundEffect();
-
-	_dispBitMap._bytesPerRow = x;
-	_dispBitMap._rows = y;
-	_dispBitMap._flags = BITMAPF_NONE;
-	_dispBitMap._planes[0] = _curBitmap;
-	_dispBitMap._planes[1] = _dispBitMap._planes[0] + 0x10000;
-	_dispBitMap._planes[2] = _dispBitMap._planes[1] + 0x10000;
-	_dispBitMap._planes[3] = _dispBitMap._planes[2] + 0x10000;
-	_dispBitMap._planes[4] = _dispBitMap._planes[3] + 0x10000;
-
-	_vm->_anim->readDiff(_curBitmap, true);
-
-	return _curBitmap;
-}
-
-void DisplayMan::freePict() {
-	delete _curBitmap;
-	_curBitmap = NULL;
-}
-
-//---------------------------------------------------------------------------
-//------------ Does all the text rendering to the message boxes. ------------
-//---------------------------------------------------------------------------
-
-/**
- * Extracts the first word from a string.
- */
-static void getWord(char *wordBuffer, const char *mainBuffer, uint16 *wordWidth) {
-	uint16 width = 0;
-
-	while ((mainBuffer[width] != ' ') && mainBuffer[width] && (mainBuffer[width] != '\n')) {
-		wordBuffer[width] = mainBuffer[width];
-		width++;
-	}
-
-	wordBuffer[width] = 0;
-
-	*wordWidth = width;
-}
-
-/**
- * Gets a line of text for flowText; makes sure that its length is less than
- * or equal to the maximum width.
- */
-void DisplayMan::getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer, uint16 lineWidth) {
-	uint16 curWidth = 0, wordWidth;
-	char wordBuffer[100];
-	bool doit = true;
-
-	lineWidth += textLength(tf, " ", 1);
-
-	lineBuffer[0] = 0;
-
-	while ((*mainBuffer)[0] && doit) {
-		getWord(wordBuffer, *mainBuffer, &wordWidth);
-		strcat(wordBuffer, " ");
-
-		if ((curWidth + textLength(tf, wordBuffer, wordWidth + 1)) <= lineWidth) {
-			strcat(lineBuffer, wordBuffer);
-			(*mainBuffer) += wordWidth;
-
-			if ((*mainBuffer)[0] == '\n')
-				doit = false;
-
-			if ((*mainBuffer)[0])
-				(*mainBuffer)++;
-
-			curWidth = textLength(tf, lineBuffer, strlen(lineBuffer));
-		} else
-			doit = false;
-	}
-}
-
-/**
- * Dumps a chunk of text to an arbitrary box; flows it within that box and
- * optionally centers it. Returns the number of characters that were
- * processed.
- * Note: Every individual word MUST be int16 enough to fit on a line, and
- * each line less than 255 characters.
- */
-uint32 DisplayMan::flowText(
-			void *font,            // the TextAttr pointer
-			int16 spacing,         // How much vertical spacing between the lines
-			byte pencolor,         // pen number to use for text
-			byte backpen,          // the background color
-			bool fillback,         // Whether to fill the background
-			bool centerh,          // Whether to center the text horizontally
-			bool centerv,          // Whether to center the text vertically
-			bool output,           // Whether to output any text
-			uint16 x1, uint16 y1,  // Cords
-			uint16 x2, uint16 y2,
-			const char *str) {     // The text itself
-	TextFont *_msgFont = (TextFont *)font;
-	char linebuffer[256];
-	const char *temp;
-	uint16 numlines, actlines, fontheight, width;
-	uint16 x, y;
-
-	if (fillback) {
-		setAPen(backpen);
-		rectFill(x1, y1, x2, y2);
-	}
-
-	if (str == NULL)
-		return 0L;
-
-	setAPen(pencolor);
-
-	fontheight = textHeight(_msgFont) + spacing;
-	numlines   = (y2 - y1 + 1) / fontheight;
-	width      = x2 - x1 + 1;
-	y          = y1;
-
-	if (centerv && output) {
-		temp = str;
-		actlines = 0;
-
-		while (temp[0]) {
-			getLine(_msgFont, linebuffer, &temp, width);
-			actlines++;
-		}
-
-		if (actlines <= numlines)
-			y += ((y2 - y1 + 1) - (actlines * fontheight)) / 2;
-	}
-
-	temp = str;
-
-	while (numlines && str[0]) {
-		getLine(_msgFont, linebuffer, &str, width);
-
-		x = x1;
-
-		if (centerh)
-			x += (width - textLength(_msgFont, linebuffer, strlen(linebuffer))) / 2;
-
-		if (output)
-			text(_msgFont, x, y, pencolor, linebuffer, strlen(linebuffer));
-
-		numlines--;
-		y += fontheight;
-	}
-
-	return (str - temp);
-}
-
-uint32 DisplayMan::flowTextScaled(
-	void *font,                // the TextAttr pointer
-	int16 spacing,             // How much vertical spacing between the lines
-	byte penColor,             // pen number to use for text
-	byte backPen,              // the background color
-	bool fillBack,             // Whether to fill the background
-	bool centerX,              // Whether to center the text horizontally
-	bool centerY,              // Whether to center the text vertically
-	bool output,               // Whether to output any text
-	uint16 x1, uint16 y1,      // Cords
-	uint16 x2, uint16 y2,
-	const char *str) {
-	return flowText(font, spacing, penColor, backPen, fillBack, centerX, centerY, output,
-					_vm->_utils->vgaScaleX(x1), _vm->_utils->vgaScaleY(y1),
-					_vm->_utils->vgaScaleX(x2), _vm->_utils->vgaScaleY(y2), str);
-}
-
-/**
- * Calls flowText, but flows it to memory.  Same restrictions as flowText.
- */
-uint32 DisplayMan::flowTextToMem(Image *destIm,
-			void *font,            // the TextAttr pointer
-			int16 spacing,         // How much vertical spacing between the lines
-			byte pencolor,         // pen number to use for text
-			byte backpen,          // the background color
-			bool fillback,         // Whether to fill the background
-			bool centerh,          // Whether to center the text horizontally
-			bool centerv,          // Whether to center the text vertically
-			bool output,           // Whether to output any text
-			uint16 x1, uint16 y1,  // Cords
-			uint16 x2, uint16 y2,
-			const char *str) {     // The text itself
-	uint32 res, vgabyte = _screenBytesPerPage;
-	byte *tmp = _currentDisplayBuffer;
-
-	_currentDisplayBuffer = destIm->_imageData;
-	_screenBytesPerPage = (uint32)destIm->_width * (int32)destIm->_height;
-
-	res = flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str);
-
-	_screenBytesPerPage = vgabyte;
-	_currentDisplayBuffer = tmp;
-
-	return res;
-}
-
-//----- The control panel stuff -----
-
-void DisplayMan::createBox(uint16 y2) {
-	// Message box area
-	setAPen(7);
-	rectFillScaled(4, 154, 315, y2 - 2);
-
-	// Box around message area
-	setAPen(0);
-	drawHLine(_vm->_utils->vgaScaleX(2), _vm->_utils->vgaScaleY(152), _vm->_utils->vgaScaleX(317));
-	drawVLine(_vm->_utils->vgaScaleX(317), _vm->_utils->vgaScaleY(152), _vm->_utils->vgaScaleY(y2));
-	drawHLine(_vm->_utils->vgaScaleX(2), _vm->_utils->vgaScaleY(y2), _vm->_utils->vgaScaleX(317));
-	drawVLine(_vm->_utils->vgaScaleX(2), _vm->_utils->vgaScaleY(152), _vm->_utils->vgaScaleY(y2));
-}
-
-int32 DisplayMan::longDrawMessage(const char *str) {
-	char newText[512];
-
-	if (str == NULL)
-		return 0;
-
-	_vm->_event->attachGadgetList(NULL);
-	_vm->_event->mouseHide();
-	strcpy(newText, str);
-
-	if (!_longWinInFront) {
-		_longWinInFront = true;
-		// Clear Area
-		setAPen(3);
-		rectFill(0, _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319), _vm->_utils->vgaScaleY(199));
-	}
-
-	createBox(198);
-	_vm->_event->mouseShow();
-
-	return flowTextScaled(_vm->_msgFont, 0, 1, 7, false, true, true, true, 6, 155, 313, 195, str);
-}
-
-/**
- * Draws a message to the message box.
- */
-void DisplayMan::drawMessage(const char *str) {
-	if (_doNotDrawMessage) {
-		_doNotDrawMessage = false;
-		return;
-	}
-
-	if (str) {
-		if ((textLength(_vm->_msgFont, str, strlen(str)) > _vm->_utils->vgaScaleX(306))) {
-			longDrawMessage(str);
-			_lastMessageLong = true;
-		} else {
-			if (_longWinInFront) {
-				_longWinInFront = false;
-				drawPanel();
-			}
-
-			_vm->_event->mouseHide();
-			createBox(168);
-			text(_vm->_msgFont, _vm->_utils->vgaScaleX(7), _vm->_utils->vgaScaleY(155) + _vm->_utils->svgaCord(2), 1, str, strlen(str));
-			_vm->_event->mouseShow();
-			_lastMessageLong = false;
-		}
-	}
-}
-
-/**
- * Draws the control panel display.
- */
-void DisplayMan::drawPanel() {
-	_vm->_event->mouseHide();
-
-	// Clear Area
-	setAPen(3);
-	rectFill(0, _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319), _vm->_utils->vgaScaleY(199));
-
-	// First Line
-	setAPen(0);
-	drawHLine(0, _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319));
-	// Second Line
-	setAPen(5);
-	drawHLine(0, _vm->_utils->vgaScaleY(149) + 1 + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319));
-	// Gadget Separators
-	setAPen(0);
-	// First black line to separate buttons
-	drawHLine(0, _vm->_utils->vgaScaleY(170), _vm->_utils->vgaScaleX(319));
-
-	if (!_vm->_alternate) {
-		setAPen(4);
-		// The horizontal lines under the black one
-		drawHLine(0, _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(319));
-		drawGadgetList(&_vm->_moveGadgetList);
-	} else {
-		if (_vm->getPlatform() != Common::kPlatformWindows) {
-			// Vertical Black lines
-			drawVLine(_vm->_utils->vgaScaleX(124), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));
-			drawVLine(_vm->_utils->vgaScaleX(194), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));
-		} else {
-			// Vertical Black lines
-			drawVLine(_vm->_utils->vgaScaleX(90), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));
-			drawVLine(_vm->_utils->vgaScaleX(160), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));
-			drawVLine(_vm->_utils->vgaScaleX(230), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));
-		}
-
-		setAPen(4);
-		// The horizontal lines under the black one
-		drawHLine(0, _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(122));
-		drawHLine(_vm->_utils->vgaScaleX(126), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(192));
-		drawHLine(_vm->_utils->vgaScaleX(196), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(319));
-		// The vertical high light lines
-		drawVLine(_vm->_utils->vgaScaleX(1), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
-
-		if (_vm->getPlatform() != Common::kPlatformWindows) {
-			drawVLine(_vm->_utils->vgaScaleX(126), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
-			drawVLine(_vm->_utils->vgaScaleX(196), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
-		} else {
-			drawVLine(_vm->_utils->vgaScaleX(92), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
-			drawVLine(_vm->_utils->vgaScaleX(162), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
-			drawVLine(_vm->_utils->vgaScaleX(232), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
-		}
-
-		drawGadgetList(&_vm->_invGadgetList);
-	}
-
-	_vm->_event->mouseShow();
-}
-
-/**
- * Sets up the Labyrinth screens, and opens up the initial windows.
- */
-void DisplayMan::setUpScreens() {
-	createScreen(_vm->_isHiRes);
-
-	Common::File *controlFile = _vm->_resource->openDataFile("P:Control");
-	for (uint16 i = 0; i < 20; i++)
-		_vm->_moveImages[i] = new Image(controlFile);
-	delete controlFile;
-
-	// Creates the gadgets for the movement control panel
-	uint16 y = _vm->_utils->vgaScaleY(173) - _vm->_utils->svgaCord(2);
-
-	// The key mapping was only set for the Windows version.
-	// It's very convenient to have those shortcut, so I added them
-	// for all versions. (Strangerke)
-	_vm->_moveGadgetList.push_back(createButton(  1, y, 0,          't', _vm->_moveImages[0],  _vm->_moveImages[1]));
-	_vm->_moveGadgetList.push_back(createButton( 33, y, 1,          'm', _vm->_moveImages[2],  _vm->_moveImages[3]));
-	_vm->_moveGadgetList.push_back(createButton( 65, y, 2,          'o', _vm->_moveImages[4],  _vm->_moveImages[5]));
-	_vm->_moveGadgetList.push_back(createButton( 97, y, 3,          'c', _vm->_moveImages[6],  _vm->_moveImages[7]));
-	_vm->_moveGadgetList.push_back(createButton(129, y, 4,          'l', _vm->_moveImages[8],  _vm->_moveImages[9]));
-	_vm->_moveGadgetList.push_back(createButton(161, y, 5,          'i', _vm->_moveImages[12], _vm->_moveImages[13]));
-	_vm->_moveGadgetList.push_back(createButton(193, y, 6, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]));
-	_vm->_moveGadgetList.push_back(createButton(225, y, 7, VKEY_UPARROW, _vm->_moveImages[16], _vm->_moveImages[17]));
-	_vm->_moveGadgetList.push_back(createButton(257, y, 8, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]));
-	_vm->_moveGadgetList.push_back(createButton(289, y, 9,          'p', _vm->_moveImages[10], _vm->_moveImages[11]));
-
-	Common::File *invFile = _vm->_resource->openDataFile("P:Inv");
-	if (_vm->getPlatform() == Common::kPlatformWindows) {
-		for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++)
-			_vm->_invImages[imgIdx] = new Image(invFile);
-	} else {
-		for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++)
-			_vm->_invImages[imgIdx] = new Image(invFile);
-	}
-	_vm->_invGadgetList.push_back(createButton( 24, y, 0,          'm', _vm->_invImages[0],   _vm->_invImages[1]));
-	_vm->_invGadgetList.push_back(createButton( 56, y, 1,          'g', _vm->_invImages[2],   _vm->_invImages[3]));
-	_vm->_invGadgetList.push_back(createButton( 94, y, 2,          'u', _vm->_invImages[4],   _vm->_invImages[5]));
-	_vm->_invGadgetList.push_back(createButton(126, y, 3,          'l', _vm->_moveImages[8],  _vm->_moveImages[9]));
-	_vm->_invGadgetList.push_back(createButton(164, y, 4, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]));
-	_vm->_invGadgetList.push_back(createButton(196, y, 5, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]));
-
-	// The windows version has 2 extra gadgets for breadcrumb trail
-	// TODO: the game is really hard to play without those, maybe we could add something to enable that.
-	if (_vm->getPlatform() == Common::kPlatformWindows) {
-		_vm->_invGadgetList.push_back(createButton(234, y, 6, 'b', _vm->_invImages[6], _vm->_invImages[7]));
-		_vm->_invGadgetList.push_back(createButton(266, y, 7, 'f', _vm->_invImages[8], _vm->_invImages[9]));
-	}
-
-	delete invFile;
-}
-
-/**
- * Sets the pen number to use on all the drawing operations.
- */
-void DisplayMan::setAPen(byte pennum) {
-	_curapen = pennum;
-}
-
-/**
- * Fills in a rectangle.
- */
-void DisplayMan::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	int w = x2 - x1 + 1;
-	int h = y2 - y1 + 1;
-
-	if (x1 + w > _screenWidth)
-		w = _screenWidth - x1;
-
-	if (y1 + h > _screenHeight)
-		h = _screenHeight - y1;
-
-	if ((w > 0) && (h > 0)) {
-		char *d = (char *)getCurrentDrawingBuffer() + y1 * _screenWidth + x1;
-
-		while (h-- > 0) {
-			char *dd = d;
-			int ww = w;
-
-			while (ww-- > 0) {
-				*dd++ = _curapen;
-			}
-
-			d += _screenWidth;
-		}
-	}
-}
-
-void DisplayMan::rectFillScaled(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	rectFill(_vm->_utils->vgaScaleX(x1), _vm->_utils->vgaScaleY(y1), _vm->_utils->vgaScaleX(x2), _vm->_utils->vgaScaleY(y2));
-}
-
-/**
- * Draws a horizontal line.
- */
-void DisplayMan::drawVLine(uint16 x, uint16 y1, uint16 y2) {
-	rectFill(x, y1, x, y2);
-}
-
-/**
- * Draws a vertical line.
- */
-void DisplayMan::drawHLine(uint16 x1, uint16 y, uint16 x2) {
-	rectFill(x1, y, x2, y);
-}
-
-void DisplayMan::screenUpdate() {
-	g_system->copyRectToScreen(_displayBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight);
-	g_system->updateScreen();
-
-	_vm->_event->processInput();
-}
-
-/**
- * Sets up either a low-res or a high-res 256 color screen.
- */
-void DisplayMan::createScreen(bool hiRes) {
-	if (hiRes) {
-		_screenWidth  = 640;
-		_screenHeight = 480;
-	} else {
-		_screenWidth  = 320;
-		_screenHeight = 200;
-	}
-	_screenBytesPerPage = _screenWidth * _screenHeight;
-	_displayBuffer = new byte[_screenBytesPerPage];	// FIXME: Memory leak!
-}
-
-/**
- * Converts an Amiga palette (up to 16 colors) to a VGA palette, then sets
- * the VGA palette.
- */
-void DisplayMan::setAmigaPal(uint16 *pal, uint16 numColors) {
-	byte vgaPal[16 * 3];
-	uint16 vgaIdx = 0;
-
-	if (numColors > 16)
-		numColors = 16;
-
-	for (uint16 i = 0; i < numColors; i++) {
-		vgaPal[vgaIdx++] = (byte)(((pal[i] & 0xf00) >> 8) << 2);
-		vgaPal[vgaIdx++] = (byte)(((pal[i] & 0x0f0) >> 4) << 2);
-		vgaPal[vgaIdx++] = (byte)(((pal[i] & 0x00f)) << 2);
-	}
-
-	writeColorRegs(vgaPal, 0, 16);
-	_vm->waitTOF();
-}
-
-/**
- * Writes any number of the 256 color registers.
- * first:    the number of the first color register to write.
- * numreg:   the number of registers to write
- * buf:      a char pointer which contains the selected color registers.
- *           Each value representing a color register occupies 3 bytes in
- *           the array.  The order is red, green then blue.  The first byte
- *           in the array is the red component of the first element selected.
- *           The length of the buffer is 3 times the number of registers
- *           selected.
- */
-void DisplayMan::writeColorRegs(byte *buf, uint16 first, uint16 numreg) {
-	byte tmp[256 * 3];
-
-	for (int i = 0; i < 256 * 3; i++) {
-		tmp[i] = buf[i] * 4;
-	}
-
-	g_system->getPaletteManager()->setPalette(tmp, first, numreg);
-
-	memcpy(&(_curvgapal[first * 3]), buf, numreg * 3);
-}
-
-void DisplayMan::setPalette(void *cmap, uint16 numcolors) {
-	if (memcmp(cmap, _curvgapal, numcolors * 3) != 0)
-		writeColorRegs((byte *)cmap, 0, numcolors);
-}
-
-/**
- * Returns the base address of the current VGA display.
- */
-byte *DisplayMan::getCurrentDrawingBuffer() {
-	if (_currentDisplayBuffer)
-		return _currentDisplayBuffer;
-
-	return _displayBuffer;
-}
-
-/**
- * Overlays a region on the screen using the desired pen color.
- */
-void DisplayMan::overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	int w = x2 - x1 + 1;
-	int h = y2 - y1 + 1;
-
-	if (x1 + w > _screenWidth)
-		w = _screenWidth - x1;
-
-	if (y1 + h > _screenHeight)
-		h = _screenHeight - y1;
-
-	if ((w > 0) && (h > 0)) {
-		char *d = (char *)getCurrentDrawingBuffer() + y1 * _screenWidth + x1;
-
-		while (h-- > 0) {
-			char *dd = d;
-			int ww = w;
-
-			if (y1 & 1) {
-				dd++;
-				ww--;
-			}
-
-			while (ww > 0) {
-				*dd = pencolor;
-				dd += 2;
-				ww -= 2;
-			}
-
-			d += _screenWidth;
-			y1++;
-		}
-	}
-}
-
-/**
- * Closes a font and frees all memory associated with it.
- */
-void DisplayMan::closeFont(TextFont *tf) {
-	if (tf) {
-		if (tf->_data && tf->_dataLength)
-			delete[] tf->_data;
-
-		delete tf;
-	}
-}
-
-/**
- * Returns the length of a text in the specified font.
- */
-uint16 DisplayMan::textLength(TextFont *tf, const char *text, uint16 numchars) {
-	uint16 length = 0;
-
-	if (tf) {
-		for (uint16 i = 0; i < numchars; i++) {
-			length += tf->_widths[(uint)*text];
-			text++;
-		}
-	}
-
-	return length;
-}
-
-/**
- * Returns the height of a specified font.
- */
-uint16 DisplayMan::textHeight(TextFont *tf) {
-	return (tf) ? tf->_height : 0;
-}
-
-/**
- * Draws the text to the screen.
- */
-void DisplayMan::text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numchars) {
-	byte *VGATop, *VGACur, *VGATemp, *VGATempLine, *cdata;
-	uint32 RealOffset, SegmentOffset;
-	int32 templeft, LeftInSegment;
-	uint16 bwidth, mask, curpage, data;
-
-	VGATop = getCurrentDrawingBuffer();
-
-	for (uint16 i = 0; i < numchars; i++) {
-		RealOffset = (_screenWidth * y) + x;
-		curpage    = RealOffset / _screenBytesPerPage;
-		SegmentOffset = RealOffset - (curpage * _screenBytesPerPage);
-		LeftInSegment = _screenBytesPerPage - SegmentOffset;
-		VGACur = VGATop + SegmentOffset;
-
-		if (tf->_widths[(uint)*text]) {
-			cdata = tf->_data + tf->_offsets[(uint)*text];
-			bwidth = *cdata++;
-			VGATemp = VGACur;
-			VGATempLine = VGACur;
-
-			for (uint16 rows = 0; rows < tf->_height; rows++) {
-				VGATemp = VGATempLine;
-				templeft = LeftInSegment;
-
-				for (uint16 cols = 0; cols < bwidth; cols++) {
-					data = *cdata++;
-
-					if (data && (templeft >= 8)) {
-						for (int j = 7; j >= 0; j--) {
-							if ((1 << j) & data)
-								*VGATemp = color;
-							VGATemp++;
-						}
-
-						templeft -= 8;
-					} else if (data) {
-						mask = 0x80;
-						templeft = LeftInSegment;
-
-						for (uint16 counterb = 0; counterb < 8; counterb++) {
-							if (templeft <= 0) {
-								curpage++;
-								VGATemp = (byte *)(VGATop - templeft);
-								// Set up VGATempLine for next line
-								VGATempLine -= _screenBytesPerPage;
-								// Set up LeftInSegment for next line
-								LeftInSegment += _screenBytesPerPage + templeft;
-								templeft += _screenBytesPerPage;
-							}
-
-							if (mask & data)
-								*VGATemp = color;
-
-							VGATemp++;
-
-							mask = mask >> 1;
-							templeft--;
-						}
-					} else {
-						templeft -= 8;
-						VGATemp += 8;
-					}
-				}
-
-				VGATempLine += _screenWidth;
-				LeftInSegment -= _screenWidth;
-
-				if (LeftInSegment <= 0) {
-					curpage++;
-					VGATempLine -= _screenBytesPerPage;
-					LeftInSegment += _screenBytesPerPage;
-				}
-			}
-		}
-
-		x += tf->_widths[(int)*text];
-		text++;
-	}
-}
-} // End of namespace Lab
diff --git a/engines/lab/graphics.h b/engines/lab/graphics.h
deleted file mode 100644
index c2c3e82..0000000
--- a/engines/lab/graphics.h
+++ /dev/null
@@ -1,169 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#ifndef LAB_GRAPHICS_H
-#define LAB_GRAPHICS_H
-
-#include "graphics/palette.h"
-#include "lab/anim.h"
-#include "lab/processroom.h"
-
-namespace Lab {
-
-class LabEngine;
-
-struct TextFont {
-	uint32 _dataLength;
-	uint16 _height;
-	byte _widths[256];
-	uint16 _offsets[256];
-	byte *_data;
-};
-
-enum TransitionType {
-	kTransitionNone,
-	kTransitionWipe,
-	kTransitionScrollWipe,
-	kTransitionScrollBlack,
-	kTransitionScrollBounce,
-	kTransitionTransporter,
-	kTransitionReadFirstFrame,
-	kTransitionReadNextFrame
-};
-
-class DisplayMan {
-private:
-	LabEngine *_vm;
-
-	uint16 fadeNumIn(uint16 num, uint16 res, uint16 counter);
-	uint16 fadeNumOut(uint16 num, uint16 res, uint16 counter);
-
-	byte _curapen;
-	byte *_curBitmap;
-	byte _curvgapal[256 * 3];
-	byte *_tempScrollData;
-
-public:
-	DisplayMan(LabEngine *lab);
-	virtual ~DisplayMan();
-
-	void loadPict(const char *filename);
-	void readPict(const char *filename, bool playOnce, bool onlyDiffData = false);
-	void freePict();
-	byte *readPictToMem(const char *filename, uint16 x, uint16 y);
-	void doScrollBlack();
-	void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem);
-	void doScrollWipe(char *filename);
-	void doScrollBounce();
-	void doTransWipe(CloseDataPtr *cPtr, char *filename);
-	void doTransition(TransitionType transitionType, CloseDataPtr *cPtr, char *filename);
-	void blackScreen();
-	void whiteScreen();
-	void blackAllScreen();
-	void createBox(uint16 y2);
-	void drawPanel();
-	void setUpScreens();
-	int32 longDrawMessage(const char *str);
-	void drawMessage(const char *str);
-	void setAPen(byte pennum);
-	void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-	void rectFillScaled(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-	// Window text stuff
-	uint32 flowText(void *font,	// the TextAttr pointer
-				int16 spacing,				// How much vertical spacing between the lines
-				byte pencolor,				// pen number to use for text
-				byte backpen,					// the background color
-				bool fillback,				// Whether to fill the background
-				bool centerh,					// Whether to center the text horizontally
-				bool centerv,					// Whether to center the text vertically
-				bool output,					// Whether to output any text
-				uint16 x1, uint16 y1,	// Cords
-				uint16 x2, uint16 y2,
-				const char *text);		// The text itself
-
-	uint32 flowTextScaled(
-				void *font,						// the TextAttr pointer
-				int16 spacing,				// How much vertical spacing between the lines
-				byte pencolor,				// pen number to use for text
-				byte backpen,					// the background color
-				bool fillback,				// Whether to fill the background
-				bool centerh,					// Whether to center the text horizontally
-				bool centerv,					// Whether to center the text vertically
-				bool output,					// Whether to output any text
-				uint16 x1, uint16 y1,	// Cords
-				uint16 x2, uint16 y2,
-				const char *text);		// The text itself
-
-	uint32 flowTextToMem(Image *destIm,
-				void *font,						// the TextAttr pointer
-				int16 spacing,				// How much vertical spacing between the lines
-				byte pencolor,				// pen number to use for text
-				byte backpen,					// the background color
-				bool fillback,				// Whether to fill the background
-				bool centerh,					// Whether to center the text horizontally
-				bool centerv,					// Whether to center the text vertically
-				bool output,					// Whether to output any text
-				uint16 x1, uint16 y1,	// Cords
-				uint16 x2, uint16 y2,
-				const char *str);			// The text itself
-
-	void drawHLine(uint16 x, uint16 y1, uint16 y2);
-	void drawVLine(uint16 x1, uint16 y, uint16 x2);
-	void screenUpdate();
-	void createScreen(bool HiRes);
-	void setAmigaPal(uint16 *pal, uint16 numColors);
-	void writeColorRegs(byte *buf, uint16 first, uint16 numreg);
-	void setPalette(void *cmap, uint16 numcolors);
-	void overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-	byte *getCurrentDrawingBuffer();
-	void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-	void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-	void fade(bool fadein, uint16 res);
-	void closeFont(TextFont *tf);
-	uint16 textLength(TextFont *tf, const char *text, uint16 numchars);
-	uint16 textHeight(TextFont *tf);
-	void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numchars);
-	void getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer, uint16 lineWidth);
-
-	bool _longWinInFront;
-	bool _lastMessageLong;
-	uint32 _screenBytesPerPage;
-	int _screenWidth;
-	int _screenHeight;
-	byte *_displayBuffer;
-	byte *_currentDisplayBuffer;
-	bool _doNotDrawMessage;
-	uint16 *FadePalette;
-	BitMap _dispBitMap;
-};
-
-} // End of namespace Lab
-
-#endif // LAB_GRAPHICS_H
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index d1de3e1..a5ae97c 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -45,7 +45,6 @@
 #include "lab/labfun.h"
 #include "lab/resource.h"
 #include "lab/anim.h"
-#include "lab/graphics.h"
 
 namespace Lab {
 
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 2604579..110e470 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -42,7 +42,6 @@
 #include "lab/music.h"
 #include "lab/resource.h"
 #include "lab/anim.h"
-#include "lab/graphics.h"
 #include "lab/labsets.h"
 #include "lab/utils.h"
 
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index f4cb284..0d05de2 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -3,9 +3,9 @@ MODULE := engines/lab
 MODULE_OBJS := \
 	anim.o \
 	detection.o \
+	dispman.o \
 	engine.o \
 	eventman.o \
-	graphics.o \
 	image.o \
 	interface.o \
 	intro.o \
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index cfba7ab..c51e744 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -32,7 +32,7 @@
 #define LAB_RESOURCE_H
 
 #include "lab/labfun.h"
-#include "lab/graphics.h"
+#include "lab/dispman.h"
 
 namespace Lab {
 
diff --git a/engines/lab/transitions.cpp b/engines/lab/transitions.cpp
index c611266..53749e8 100644
--- a/engines/lab/transitions.cpp
+++ b/engines/lab/transitions.cpp
@@ -30,7 +30,6 @@
 
 #include "lab/lab.h"
 #include "lab/processroom.h"
-#include "lab/graphics.h"
 
 namespace Lab {
 


Commit: eccb8527497e7f50d2de9c026e1c4c194096bc5f
    https://github.com/scummvm/scummvm/commit/eccb8527497e7f50d2de9c026e1c4c194096bc5f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:56+01:00

Commit Message:
LAB: Removed unnecessary includes

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h
    engines/lab/detection.cpp
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/engine.cpp
    engines/lab/eventman.cpp
    engines/lab/image.cpp
    engines/lab/interface.cpp
    engines/lab/intro.cpp
    engines/lab/intro.h
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/labsets.cpp
    engines/lab/map.cpp
    engines/lab/music.cpp
    engines/lab/music.h
    engines/lab/processroom.cpp
    engines/lab/resource.cpp
    engines/lab/resource.h
    engines/lab/savegame.cpp
    engines/lab/special.cpp
    engines/lab/transitions.cpp
    engines/lab/utils.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 523bfc0..5391957 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -28,7 +28,6 @@
  *
  */
 
-#include "common/endian.h"
 #include "lab/lab.h"
 
 namespace Lab {
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index b5df6e2..91bc0d7 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -31,8 +31,6 @@
 #ifndef LAB_DIFF_H
 #define LAB_DIFF_H
 
-#include "common/file.h"
-
 namespace Lab {
 
 class LabEngine;
@@ -107,5 +105,3 @@ public:
 } // End of namespace Lab
 
 #endif // LAB_DIFF_H
-
-
diff --git a/engines/lab/detection.cpp b/engines/lab/detection.cpp
index 67890da..18d73ce 100644
--- a/engines/lab/detection.cpp
+++ b/engines/lab/detection.cpp
@@ -30,15 +30,7 @@
 
 #include "engines/advancedDetector.h"
 
-#include "common/str-array.h"
-#include "common/savefile.h"
-
-#include "base/plugins.h"
-
-#include "graphics/surface.h"
-
 #include "lab/lab.h"
-#include "lab/labfun.h"
 
 static const PlainGameDescriptor lab_setting[] = {
 	{ "lab", "Labyrith of Time" },
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index a7c71f2..eb26f81 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -28,12 +28,8 @@
  *
  */
 
+#include "graphics/palette.h"
 #include "lab/lab.h"
-#include "lab/anim.h"
-#include "lab/image.h"
-#include "lab/labfun.h"
-#include "lab/processroom.h"
-#include "lab/resource.h"
 
 namespace Lab {
 
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index bbbbe35..01d1def 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -31,7 +31,6 @@
 #ifndef LAB_DISPMAN_H
 #define LAB_DISPMAN_H
 
-#include "graphics/palette.h"
 #include "lab/anim.h"
 #include "lab/processroom.h"
 
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index fe334f4..4ef3436 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -29,13 +29,7 @@
  */
 
 #include "lab/lab.h"
-#include "lab/labfun.h"
-#include "lab/anim.h"
-#include "lab/image.h"
 #include "lab/intro.h"
-#include "lab/processroom.h"
-#include "lab/interface.h"
-#include "lab/resource.h"
 
 namespace Lab {
 
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 53361c9..c68149f 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -29,8 +29,6 @@
  */
 
 #include "lab/lab.h"
-#include "lab/image.h"
-#include "lab/interface.h"
 
 namespace Lab {
 
diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp
index 29459b1..f4ad015 100644
--- a/engines/lab/image.cpp
+++ b/engines/lab/image.cpp
@@ -29,7 +29,6 @@
  */
 
 #include "lab/lab.h"
-#include "lab/image.h"
 
 namespace Lab {
 
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index dae822b..286ff7f 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -29,10 +29,6 @@
  */
 
 #include "lab/lab.h"
-#include "lab/labfun.h"
-#include "lab/image.h"
-#include "lab/interface.h"
-#include "common/util.h"
 
 namespace Lab {
 
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index b75a215..71c5fc8 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -30,7 +30,6 @@
 
 #include "lab/lab.h"
 #include "lab/intro.h"
-#include "lab/anim.h"
 
 namespace Lab {
 Intro::Intro(LabEngine *vm) : _vm(vm) {
diff --git a/engines/lab/intro.h b/engines/lab/intro.h
index c532bdf..323859c 100644
--- a/engines/lab/intro.h
+++ b/engines/lab/intro.h
@@ -31,8 +31,6 @@
 #ifndef LAB_INTRO_H
 #define LAB_INTRO_H
 
-#include "lab/intro.h"
-
 namespace Lab {
 
 class Intro {
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index a5ae97c..4252033 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -28,23 +28,12 @@
  *
  */
 
-#include "common/config-manager.h"
 #include "common/debug-channels.h"
-#include "common/scummsys.h"
-#include "common/error.h"
-#include "common/fs.h"
-#include "common/rect.h"
 
-#include "engines/dialogs.h"
-#include "engines/engine.h"
 #include "engines/util.h"
 #include "gui/message.h"
-#include "engines/advancedDetector.h"
 
 #include "lab/lab.h"
-#include "lab/labfun.h"
-#include "lab/resource.h"
-#include "lab/anim.h"
 
 namespace Lab {
 
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 110e470..93f3796 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -31,8 +31,6 @@
 #ifndef LAB_H
 #define LAB_H
 
-#include "common/array.h"
-#include "common/events.h"
 #include "common/system.h"
 
 #include "engines/engine.h"
diff --git a/engines/lab/labsets.cpp b/engines/lab/labsets.cpp
index f09f669..2b860ad 100644
--- a/engines/lab/labsets.cpp
+++ b/engines/lab/labsets.cpp
@@ -29,8 +29,6 @@
  */
 
 #include "lab/lab.h"
-#include "lab/labfun.h"
-#include "lab/resource.h"
 
 namespace Lab {
 
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 8cd0ed9..4406fae 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -29,12 +29,6 @@
  */
 
 #include "lab/lab.h"
-#include "lab/labfun.h"
-#include "lab/anim.h"
-#include "lab/image.h"
-#include "lab/processroom.h"
-#include "lab/resource.h"
-#include "lab/interface.h"
 
 namespace Lab {
 
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 4bf1502..d1031a0 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -28,10 +28,8 @@
  *
  */
 
-#include "audio/mixer.h"
+#include "audio/decoders/raw.h"
 
-#include "lab/labfun.h"
-#include "lab/music.h"
 #include "lab/lab.h"
 
 namespace Lab {
diff --git a/engines/lab/music.h b/engines/lab/music.h
index 6d102e7..d257d27 100644
--- a/engines/lab/music.h
+++ b/engines/lab/music.h
@@ -31,11 +31,8 @@
 #ifndef LAB_MUSIC_H
 #define LAB_MUSIC_H
 
-#include "common/events.h"
-
 #include "audio/mixer.h"
 #include "audio/audiostream.h"
-#include "audio/decoders/raw.h"
 
 namespace Lab {
 
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index ed28e87..e541aa0 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -31,11 +31,6 @@
 #include "gui/message.h"
 
 #include "lab/lab.h"
-#include "lab/labfun.h"
-#include "lab/processroom.h"
-#include "lab/resource.h"
-#include "lab/anim.h"
-#include "lab/interface.h"
 
 namespace Lab {
 
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index de1e9dc..b49afa0 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -29,7 +29,6 @@
  */
 
 #include "lab/lab.h"
-#include "lab/resource.h"
 
 namespace Lab {
 
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index c51e744..1c733d8 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -31,7 +31,6 @@
 #ifndef LAB_RESOURCE_H
 #define LAB_RESOURCE_H
 
-#include "lab/labfun.h"
 #include "lab/dispman.h"
 
 namespace Lab {
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 5924d88..986e910 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -28,13 +28,9 @@
  *
  */
 
-#include "common/savefile.h"
-
-#include "graphics/surface.h"
 #include "graphics/thumbnail.h"
 
 #include "lab/lab.h"
-#include "lab/labfun.h"
 
 namespace Lab {
 #define SAVEGAME_ID       MKTAG('L', 'O', 'T', 'S')
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 5a0348c..ee454bf 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -34,12 +34,6 @@
 #include "gui/saveload.h"
 
 #include "lab/lab.h"
-#include "lab/labfun.h"
-#include "lab/image.h"
-#include "lab/processroom.h"
-#include "lab/interface.h"
-#include "lab/anim.h"
-#include "lab/resource.h"
 
 namespace Lab {
 
diff --git a/engines/lab/transitions.cpp b/engines/lab/transitions.cpp
index 53749e8..14753fb 100644
--- a/engines/lab/transitions.cpp
+++ b/engines/lab/transitions.cpp
@@ -29,7 +29,6 @@
  */
 
 #include "lab/lab.h"
-#include "lab/processroom.h"
 
 namespace Lab {
 
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index d5d0734..198e1ab 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -29,7 +29,6 @@
  */
 
 #include "lab/lab.h"
-#include "lab/utils.h"
 
 namespace Lab {
 Utils::Utils(LabEngine *vm) : _vm(vm) {


Commit: d8e01fe23a569e60e9cacf7b29fa69e7cab03eb5
    https://github.com/scummvm/scummvm/commit/d8e01fe23a569e60e9cacf7b29fa69e7cab03eb5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:56+01:00

Commit Message:
LAB: Reduce header dependency from music.h

Changed paths:
    engines/lab/anim.cpp
    engines/lab/dispman.cpp
    engines/lab/engine.cpp
    engines/lab/intro.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/music.cpp
    engines/lab/processroom.cpp
    engines/lab/resource.cpp
    engines/lab/special.cpp
    engines/lab/transitions.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 5391957..d4abc34 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -29,6 +29,7 @@
  */
 
 #include "lab/lab.h"
+#include "lab/music.h"
 
 namespace Lab {
 
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index eb26f81..75e61b4 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -29,7 +29,9 @@
  */
 
 #include "graphics/palette.h"
+
 #include "lab/lab.h"
+#include "lab/music.h"
 
 namespace Lab {
 
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 4ef3436..2b51e34 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -30,6 +30,8 @@
 
 #include "lab/lab.h"
 #include "lab/intro.h"
+#include "lab/music.h"
+
 
 namespace Lab {
 
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 71c5fc8..47dc671 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -30,6 +30,7 @@
 
 #include "lab/lab.h"
 #include "lab/intro.h"
+#include "lab/music.h"
 
 namespace Lab {
 Intro::Intro(LabEngine *vm) : _vm(vm) {
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 4252033..9ff8ce5 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -34,6 +34,7 @@
 #include "gui/message.h"
 
 #include "lab/lab.h"
+#include "lab/music.h"
 
 namespace Lab {
 
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 93f3796..52a8df9 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -37,7 +37,7 @@
 #include "lab/labfun.h"
 #include "lab/interface.h"
 #include "lab/eventman.h"
-#include "lab/music.h"
+//#include "lab/music.h"
 #include "lab/resource.h"
 #include "lab/anim.h"
 #include "lab/labsets.h"
@@ -47,6 +47,8 @@ struct ADGameDescription;
 
 namespace Lab {
 
+class Music;
+
 enum GameFeatures {
 	GF_LOWRES = 1 << 0,
 	GF_WINDOWS_TRIAL = 1 << 1
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 4406fae..6d09a99 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -29,6 +29,7 @@
  */
 
 #include "lab/lab.h"
+#include "lab/music.h"
 
 namespace Lab {
 
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index d1031a0..de4ac8e 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -31,6 +31,7 @@
 #include "audio/decoders/raw.h"
 
 #include "lab/lab.h"
+#include "lab/music.h"
 
 namespace Lab {
 
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index e541aa0..8876740 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -31,6 +31,7 @@
 #include "gui/message.h"
 
 #include "lab/lab.h"
+#include "lab/music.h"
 
 namespace Lab {
 
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index b49afa0..d21efaf 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -29,6 +29,7 @@
  */
 
 #include "lab/lab.h"
+#include "lab/music.h"
 
 namespace Lab {
 
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index ee454bf..f9eb0db 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -34,6 +34,7 @@
 #include "gui/saveload.h"
 
 #include "lab/lab.h"
+#include "lab/music.h"
 
 namespace Lab {
 
diff --git a/engines/lab/transitions.cpp b/engines/lab/transitions.cpp
index 14753fb..aad9b3d 100644
--- a/engines/lab/transitions.cpp
+++ b/engines/lab/transitions.cpp
@@ -29,6 +29,7 @@
  */
 
 #include "lab/lab.h"
+#include "lab/music.h"
 
 namespace Lab {
 


Commit: 8e9798a0bce3fb6fac55a85c7f9e54176d4cbc85
    https://github.com/scummvm/scummvm/commit/8e9798a0bce3fb6fac55a85c7f9e54176d4cbc85
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:57+01:00

Commit Message:
LAB: Reduce header intra-dependency. Reduced image.h dependency

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/engine.cpp
    engines/lab/eventman.cpp
    engines/lab/image.cpp
    engines/lab/interface.cpp
    engines/lab/interface.h
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/labfun.h
    engines/lab/map.cpp
    engines/lab/resource.h
    engines/lab/special.cpp
    engines/lab/tilepuzzle.cpp
    engines/lab/transitions.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 75e61b4..42007a4 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -32,6 +32,7 @@
 
 #include "lab/lab.h"
 #include "lab/music.h"
+#include "lab/image.h"
 
 namespace Lab {
 
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index 01d1def..a04d142 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -31,12 +31,10 @@
 #ifndef LAB_DISPMAN_H
 #define LAB_DISPMAN_H
 
-#include "lab/anim.h"
-#include "lab/processroom.h"
-
 namespace Lab {
 
 class LabEngine;
+class Image;
 
 struct TextFont {
 	uint32 _dataLength;
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 2b51e34..f8658a4 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -31,7 +31,7 @@
 #include "lab/lab.h"
 #include "lab/intro.h"
 #include "lab/music.h"
-
+#include "lab/image.h"
 
 namespace Lab {
 
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index c68149f..edc2588 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -29,6 +29,7 @@
  */
 
 #include "lab/lab.h"
+#include "lab/image.h"
 
 namespace Lab {
 
diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp
index f4ad015..29459b1 100644
--- a/engines/lab/image.cpp
+++ b/engines/lab/image.cpp
@@ -29,6 +29,7 @@
  */
 
 #include "lab/lab.h"
+#include "lab/image.h"
 
 namespace Lab {
 
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 286ff7f..f536c22 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -29,6 +29,7 @@
  */
 
 #include "lab/lab.h"
+#include "lab/image.h"
 
 namespace Lab {
 
diff --git a/engines/lab/interface.h b/engines/lab/interface.h
index 50e89e3..c4b2341 100644
--- a/engines/lab/interface.h
+++ b/engines/lab/interface.h
@@ -28,14 +28,13 @@
  *
  */
 
-#include "common/keyboard.h"
-#include "lab/image.h"
-
 #ifndef LAB_INTEFACE_H
 #define LAB_INTEFACE_H
 
 namespace Lab {
 
+class Image;
+
 struct IntuiMessage {
 	uint32 _msgClass;
 	uint16 _code, _qualifier, _mouseX, _mouseY, _gadgetID;
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 9ff8ce5..6b328e1 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -35,6 +35,7 @@
 
 #include "lab/lab.h"
 #include "lab/music.h"
+#include "lab/image.h"
 
 namespace Lab {
 
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 52a8df9..0290a36 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -32,12 +32,15 @@
 #define LAB_H
 
 #include "common/system.h"
+#include "common/events.h"
 
 #include "engines/engine.h"
+#include "lab/anim.h"
 #include "lab/labfun.h"
+#include "lab/processroom.h"
 #include "lab/interface.h"
 #include "lab/eventman.h"
-//#include "lab/music.h"
+#include "lab/dispman.h"
 #include "lab/resource.h"
 #include "lab/anim.h"
 #include "lab/labsets.h"
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 4edb263..08f7cda 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -31,7 +31,6 @@
 #ifndef LAB_LABFUN_H
 #define LAB_LABFUN_H
 
-#include "common/events.h"
 #include "common/file.h"
 #include "common/savefile.h"
 #include "engines/savestate.h"
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 6d09a99..8a0bec4 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -30,6 +30,7 @@
 
 #include "lab/lab.h"
 #include "lab/music.h"
+#include "lab/image.h"
 
 namespace Lab {
 
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index 1c733d8..89303e1 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -31,8 +31,6 @@
 #ifndef LAB_RESOURCE_H
 #define LAB_RESOURCE_H
 
-#include "lab/dispman.h"
-
 namespace Lab {
 
 enum StaticText {
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index f9eb0db..8b1e426 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -35,6 +35,7 @@
 
 #include "lab/lab.h"
 #include "lab/music.h"
+#include "lab/image.h"
 
 namespace Lab {
 
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index 68f4771..7afb7c0 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -30,6 +30,7 @@
 
 #include "lab/lab.h"
 #include "gui/message.h"
+#include "lab/image.h"
 
 namespace Lab {
 
diff --git a/engines/lab/transitions.cpp b/engines/lab/transitions.cpp
index aad9b3d..5b2ef2b 100644
--- a/engines/lab/transitions.cpp
+++ b/engines/lab/transitions.cpp
@@ -30,6 +30,7 @@
 
 #include "lab/lab.h"
 #include "lab/music.h"
+#include "lab/image.h"
 
 namespace Lab {
 


Commit: d2cf293e4abb19f2e15b7a69931a2723bcdbeaad
    https://github.com/scummvm/scummvm/commit/d2cf293e4abb19f2e15b7a69931a2723bcdbeaad
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:57+01:00

Commit Message:
LAB: More intra-header dependency reduction

Changed paths:
    engines/lab/lab.h
    engines/lab/labfun.h



diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 0290a36..b8a5ad4 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -33,6 +33,9 @@
 
 #include "common/system.h"
 #include "common/events.h"
+#include "common/file.h"
+#include "common/savefile.h"
+#include "engines/savestate.h"
 
 #include "engines/engine.h"
 #include "lab/anim.h"
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 08f7cda..9307dea 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -31,10 +31,6 @@
 #ifndef LAB_LABFUN_H
 #define LAB_LABFUN_H
 
-#include "common/file.h"
-#include "common/savefile.h"
-#include "engines/savestate.h"
-
 namespace Lab {
 
 class LabEngine;


Commit: a53045626db463327ba87301f271d62f7ac16b40
    https://github.com/scummvm/scummvm/commit/a53045626db463327ba87301f271d62f7ac16b40
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:57+01:00

Commit Message:
LAB: Moved direction defines to lab.h

Changed paths:
    engines/lab/lab.h
    engines/lab/labfun.h



diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index b8a5ad4..d50261e 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -77,6 +77,12 @@ struct CrumbData {
 
 #define MAX_CRUMBS          128
 
+// Direction defines
+#define NORTH   0
+#define SOUTH   1
+#define EAST    2
+#define WEST    3
+
 class LabEngine : public Engine {
 public:
 	LabEngine(OSystem *syst, const ADGameDescription *gameDesc);
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
index 9307dea..d8595af 100644
--- a/engines/lab/labfun.h
+++ b/engines/lab/labfun.h
@@ -35,12 +35,6 @@ namespace Lab {
 
 class LabEngine;
 
-// Direction defines
-#define NORTH   0
-#define SOUTH   1
-#define EAST    2
-#define WEST    3
-
 struct SaveGameHeader {
 	byte _version;
 	SaveStateDescriptor _descr;


Commit: bb80b6d46b2661b6184a048025428aab3858b417
    https://github.com/scummvm/scummvm/commit/bb80b6d46b2661b6184a048025428aab3858b417
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:57+01:00

Commit Message:
LAB: Rename labfun.h to savegame.h

Changed paths:
  A engines/lab/savegame.h
  R engines/lab/labfun.h
    engines/lab/lab.h



diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index d50261e..f9e8a0a 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -39,7 +39,7 @@
 
 #include "engines/engine.h"
 #include "lab/anim.h"
-#include "lab/labfun.h"
+#include "lab/savegame.h"
 #include "lab/processroom.h"
 #include "lab/interface.h"
 #include "lab/eventman.h"
diff --git a/engines/lab/labfun.h b/engines/lab/labfun.h
deleted file mode 100644
index d8595af..0000000
--- a/engines/lab/labfun.h
+++ /dev/null
@@ -1,55 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#ifndef LAB_LABFUN_H
-#define LAB_LABFUN_H
-
-namespace Lab {
-
-class LabEngine;
-
-struct SaveGameHeader {
-	byte _version;
-	SaveStateDescriptor _descr;
-	uint16 _roomNumber;
-	uint16 _direction;
-};
-
-//--------------------------
-//----- From saveGame.c ----
-//--------------------------
-
-bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc);
-bool loadGame(uint16 *Direction, uint16 *Quarters, int slot);
-bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header);
-
-} // End of namespace Lab
-
-#endif // LAB_LABFUN_H
diff --git a/engines/lab/savegame.h b/engines/lab/savegame.h
new file mode 100644
index 0000000..82f93e7
--- /dev/null
+++ b/engines/lab/savegame.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.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#ifndef LAB_SAVEGAME_H
+#define LAB_SAVEGAME_H
+
+namespace Lab {
+
+class LabEngine;
+
+struct SaveGameHeader {
+	byte _version;
+	SaveStateDescriptor _descr;
+	uint16 _roomNumber;
+	uint16 _direction;
+};
+
+bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc);
+bool loadGame(uint16 *Direction, uint16 *Quarters, int slot);
+bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header);
+
+} // End of namespace Lab
+
+#endif // LAB_SAVEGAME_H


Commit: b1585b2c62c1d45ef22e5f08a1a434ec78c2fd3e
    https://github.com/scummvm/scummvm/commit/b1585b2c62c1d45ef22e5f08a1a434ec78c2fd3e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:57+01:00

Commit Message:
LAB: Reduced header dependency: savegame.h

Changed paths:
    engines/lab/detection.cpp
    engines/lab/lab.h
    engines/lab/savegame.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/detection.cpp b/engines/lab/detection.cpp
index 18d73ce..afdf5a1 100644
--- a/engines/lab/detection.cpp
+++ b/engines/lab/detection.cpp
@@ -31,6 +31,7 @@
 #include "engines/advancedDetector.h"
 
 #include "lab/lab.h"
+#include "lab/savegame.h"
 
 static const PlainGameDescriptor lab_setting[] = {
 	{ "lab", "Labyrith of Time" },
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index f9e8a0a..4242780 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -39,7 +39,6 @@
 
 #include "engines/engine.h"
 #include "lab/anim.h"
-#include "lab/savegame.h"
 #include "lab/processroom.h"
 #include "lab/interface.h"
 #include "lab/eventman.h"
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 986e910..c9cb831 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -31,6 +31,7 @@
 #include "graphics/thumbnail.h"
 
 #include "lab/lab.h"
+#include "lab/savegame.h"
 
 namespace Lab {
 #define SAVEGAME_ID       MKTAG('L', 'O', 'T', 'S')
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 8b1e426..11af40a 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -36,6 +36,7 @@
 #include "lab/lab.h"
 #include "lab/music.h"
 #include "lab/image.h"
+#include "lab/savegame.h"
 
 namespace Lab {
 


Commit: 5fad5cece3704f8e4267da4610a014017d32db1d
    https://github.com/scummvm/scummvm/commit/5fad5cece3704f8e4267da4610a014017d32db1d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:57+01:00

Commit Message:
LAB: Reduced header dependency: labsets.h, utils.h

Changed paths:
    engines/lab/anim.cpp
    engines/lab/dispman.cpp
    engines/lab/engine.cpp
    engines/lab/interface.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/labsets.cpp
    engines/lab/map.cpp
    engines/lab/processroom.cpp
    engines/lab/savegame.cpp
    engines/lab/special.cpp
    engines/lab/tilepuzzle.cpp
    engines/lab/transitions.cpp
    engines/lab/utils.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index d4abc34..db8e8c6 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -30,6 +30,7 @@
 
 #include "lab/lab.h"
 #include "lab/music.h"
+#include "lab/utils.h"
 
 namespace Lab {
 
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 42007a4..b80ef07 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -33,6 +33,7 @@
 #include "lab/lab.h"
 #include "lab/music.h"
 #include "lab/image.h"
+#include "lab/utils.h"
 
 namespace Lab {
 
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index f8658a4..13f3ae6 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -29,9 +29,11 @@
  */
 
 #include "lab/lab.h"
+#include "lab/image.h"
 #include "lab/intro.h"
+#include "lab/labsets.h"
 #include "lab/music.h"
-#include "lab/image.h"
+#include "lab/utils.h"
 
 namespace Lab {
 
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index f536c22..62b0f80 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -30,6 +30,7 @@
 
 #include "lab/lab.h"
 #include "lab/image.h"
+#include "lab/utils.h"
 
 namespace Lab {
 
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 6b328e1..04a6898 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -36,6 +36,7 @@
 #include "lab/lab.h"
 #include "lab/music.h"
 #include "lab/image.h"
+#include "lab/utils.h"
 
 namespace Lab {
 
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 4242780..7e5f33e 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -44,15 +44,14 @@
 #include "lab/eventman.h"
 #include "lab/dispman.h"
 #include "lab/resource.h"
-#include "lab/anim.h"
-#include "lab/labsets.h"
-#include "lab/utils.h"
 
 struct ADGameDescription;
 
 namespace Lab {
 
 class Music;
+class Utils;
+class LargeSet;
 
 enum GameFeatures {
 	GF_LOWRES = 1 << 0,
diff --git a/engines/lab/labsets.cpp b/engines/lab/labsets.cpp
index 2b860ad..ca37a39 100644
--- a/engines/lab/labsets.cpp
+++ b/engines/lab/labsets.cpp
@@ -29,6 +29,7 @@
  */
 
 #include "lab/lab.h"
+#include "lab/labsets.h"
 
 namespace Lab {
 
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 8a0bec4..7bcfd80 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -29,8 +29,10 @@
  */
 
 #include "lab/lab.h"
+#include "lab/labsets.h"
 #include "lab/music.h"
 #include "lab/image.h"
+#include "lab/utils.h"
 
 namespace Lab {
 
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 8876740..472c0e4 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -31,7 +31,9 @@
 #include "gui/message.h"
 
 #include "lab/lab.h"
+#include "lab/labsets.h"
 #include "lab/music.h"
+#include "lab/utils.h"
 
 namespace Lab {
 
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index c9cb831..244f119 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -31,6 +31,7 @@
 #include "graphics/thumbnail.h"
 
 #include "lab/lab.h"
+#include "lab/labsets.h"
 #include "lab/savegame.h"
 
 namespace Lab {
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 11af40a..274e987 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -34,9 +34,11 @@
 #include "gui/saveload.h"
 
 #include "lab/lab.h"
+#include "lab/labsets.h"
 #include "lab/music.h"
 #include "lab/image.h"
 #include "lab/savegame.h"
+#include "lab/utils.h"
 
 namespace Lab {
 
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index 7afb7c0..f989b1a 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -28,9 +28,12 @@
  *
  */
 
-#include "lab/lab.h"
 #include "gui/message.h"
+
+#include "lab/lab.h"
+#include "lab/labsets.h"
 #include "lab/image.h"
+#include "lab/utils.h"
 
 namespace Lab {
 
diff --git a/engines/lab/transitions.cpp b/engines/lab/transitions.cpp
index 5b2ef2b..89ce54f 100644
--- a/engines/lab/transitions.cpp
+++ b/engines/lab/transitions.cpp
@@ -31,6 +31,7 @@
 #include "lab/lab.h"
 #include "lab/music.h"
 #include "lab/image.h"
+#include "lab/utils.h"
 
 namespace Lab {
 
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index 198e1ab..d5d0734 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -29,6 +29,7 @@
  */
 
 #include "lab/lab.h"
+#include "lab/utils.h"
 
 namespace Lab {
 Utils::Utils(LabEngine *vm) : _vm(vm) {


Commit: 9a9b752c0e0e14d35e99cd5475bfa2138fff4d4a
    https://github.com/scummvm/scummvm/commit/9a9b752c0e0e14d35e99cd5475bfa2138fff4d4a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:57+01:00

Commit Message:
LAB: More header dependency redux

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/engine.cpp
    engines/lab/image.cpp
    engines/lab/image.h
    engines/lab/intro.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/labsets.cpp
    engines/lab/map.cpp
    engines/lab/music.cpp
    engines/lab/music.h
    engines/lab/processroom.cpp
    engines/lab/resource.cpp
    engines/lab/savegame.cpp
    engines/lab/savegame.h
    engines/lab/special.cpp
    engines/lab/tilepuzzle.cpp
    engines/lab/utils.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index b80ef07..ee9d5bc 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -33,6 +33,7 @@
 #include "lab/lab.h"
 #include "lab/music.h"
 #include "lab/image.h"
+#include "lab/resource.h"
 #include "lab/utils.h"
 
 namespace Lab {
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 13f3ae6..2759f8a 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -29,10 +29,12 @@
  */
 
 #include "lab/lab.h"
+
 #include "lab/image.h"
 #include "lab/intro.h"
 #include "lab/labsets.h"
 #include "lab/music.h"
+#include "lab/resource.h"
 #include "lab/utils.h"
 
 namespace Lab {
diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp
index 29459b1..2fac5a6 100644
--- a/engines/lab/image.cpp
+++ b/engines/lab/image.cpp
@@ -28,6 +28,8 @@
  *
  */
 
+#include "common/file.h"
+
 #include "lab/lab.h"
 #include "lab/image.h"
 
diff --git a/engines/lab/image.h b/engines/lab/image.h
index 7f2c1ed..0e2f831 100644
--- a/engines/lab/image.h
+++ b/engines/lab/image.h
@@ -31,6 +31,10 @@
 #ifndef LAB_IMAGE_H
 #define LAB_IMAGE_H
 
+namespace Common {
+	class File;
+}
+
 namespace Lab {
 
 class Image {
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 47dc671..8e5986f 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -29,8 +29,10 @@
  */
 
 #include "lab/lab.h"
+
 #include "lab/intro.h"
 #include "lab/music.h"
+#include "lab/resource.h"
 
 namespace Lab {
 Intro::Intro(LabEngine *vm) : _vm(vm) {
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 04a6898..5ce053a 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -29,13 +29,16 @@
  */
 
 #include "common/debug-channels.h"
+#include "common/error.h"
 
 #include "engines/util.h"
 #include "gui/message.h"
 
 #include "lab/lab.h"
+
 #include "lab/music.h"
 #include "lab/image.h"
+#include "lab/resource.h"
 #include "lab/utils.h"
 
 namespace Lab {
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 7e5f33e..7aaa548 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -33,9 +33,6 @@
 
 #include "common/system.h"
 #include "common/events.h"
-#include "common/file.h"
-#include "common/savefile.h"
-#include "engines/savestate.h"
 
 #include "engines/engine.h"
 #include "lab/anim.h"
@@ -43,15 +40,15 @@
 #include "lab/interface.h"
 #include "lab/eventman.h"
 #include "lab/dispman.h"
-#include "lab/resource.h"
 
 struct ADGameDescription;
 
 namespace Lab {
 
+class LargeSet;
 class Music;
+class Resource;
 class Utils;
-class LargeSet;
 
 enum GameFeatures {
 	GF_LOWRES = 1 << 0,
diff --git a/engines/lab/labsets.cpp b/engines/lab/labsets.cpp
index ca37a39..b19755e 100644
--- a/engines/lab/labsets.cpp
+++ b/engines/lab/labsets.cpp
@@ -28,8 +28,12 @@
  *
  */
 
+#include "common/file.h"
+
 #include "lab/lab.h"
+
 #include "lab/labsets.h"
+#include "lab/resource.h"
 
 namespace Lab {
 
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 7bcfd80..accd56d 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -29,9 +29,11 @@
  */
 
 #include "lab/lab.h"
+
+#include "lab/image.h"
 #include "lab/labsets.h"
 #include "lab/music.h"
-#include "lab/image.h"
+#include "lab/resource.h"
 #include "lab/utils.h"
 
 namespace Lab {
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index de4ac8e..722ec99 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -31,7 +31,9 @@
 #include "audio/decoders/raw.h"
 
 #include "lab/lab.h"
+
 #include "lab/music.h"
+#include "lab/resource.h"
 
 namespace Lab {
 
diff --git a/engines/lab/music.h b/engines/lab/music.h
index d257d27..5efd2e3 100644
--- a/engines/lab/music.h
+++ b/engines/lab/music.h
@@ -31,6 +31,7 @@
 #ifndef LAB_MUSIC_H
 #define LAB_MUSIC_H
 
+#include "common/file.h"
 #include "audio/mixer.h"
 #include "audio/audiostream.h"
 
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 472c0e4..4df7e20 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -31,8 +31,10 @@
 #include "gui/message.h"
 
 #include "lab/lab.h"
+
 #include "lab/labsets.h"
 #include "lab/music.h"
+#include "lab/resource.h"
 #include "lab/utils.h"
 
 namespace Lab {
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index d21efaf..65b1478 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -29,7 +29,9 @@
  */
 
 #include "lab/lab.h"
+
 #include "lab/music.h"
+#include "lab/resource.h"
 
 namespace Lab {
 
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 244f119..1393278 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -29,6 +29,7 @@
  */
 
 #include "graphics/thumbnail.h"
+#include "engines/savestate.h"
 
 #include "lab/lab.h"
 #include "lab/labsets.h"
diff --git a/engines/lab/savegame.h b/engines/lab/savegame.h
index 82f93e7..608da99 100644
--- a/engines/lab/savegame.h
+++ b/engines/lab/savegame.h
@@ -31,6 +31,8 @@
 #ifndef LAB_SAVEGAME_H
 #define LAB_SAVEGAME_H
 
+#include "common/savefile.h"
+
 namespace Lab {
 
 class LabEngine;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 274e987..55825a7 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -34,9 +34,11 @@
 #include "gui/saveload.h"
 
 #include "lab/lab.h"
+
+#include "lab/image.h"
 #include "lab/labsets.h"
 #include "lab/music.h"
-#include "lab/image.h"
+#include "lab/resource.h"
 #include "lab/savegame.h"
 #include "lab/utils.h"
 
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index f989b1a..bf435be 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -31,8 +31,10 @@
 #include "gui/message.h"
 
 #include "lab/lab.h"
-#include "lab/labsets.h"
+
 #include "lab/image.h"
+#include "lab/labsets.h"
+#include "lab/resource.h"
 #include "lab/utils.h"
 
 namespace Lab {
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index d5d0734..b552a40 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -28,6 +28,8 @@
  *
  */
 
+#include "common/file.h"
+
 #include "lab/lab.h"
 #include "lab/utils.h"
 


Commit: 66f2935a2282521f77062ad42d3308699f087cb5
    https://github.com/scummvm/scummvm/commit/66f2935a2282521f77062ad42d3308699f087cb5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:57+01:00

Commit Message:
LAB: Reduced header dependency: dispman.h, eventman.h

Changed paths:
    engines/lab/anim.cpp
    engines/lab/dispman.cpp
    engines/lab/engine.cpp
    engines/lab/eventman.cpp
    engines/lab/image.cpp
    engines/lab/interface.cpp
    engines/lab/intro.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/music.cpp
    engines/lab/processroom.cpp
    engines/lab/resource.cpp
    engines/lab/savegame.cpp
    engines/lab/special.cpp
    engines/lab/tilepuzzle.cpp
    engines/lab/transitions.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index db8e8c6..7411dcb 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -29,6 +29,9 @@
  */
 
 #include "lab/lab.h"
+
+#include "lab/dispman.h"
+#include "lab/eventman.h"
 #include "lab/music.h"
 #include "lab/utils.h"
 
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index ee9d5bc..f78e55d 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -31,6 +31,9 @@
 #include "graphics/palette.h"
 
 #include "lab/lab.h"
+
+#include "lab/dispman.h"
+#include "lab/eventman.h"
 #include "lab/music.h"
 #include "lab/image.h"
 #include "lab/resource.h"
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 2759f8a..af6d4c4 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -30,6 +30,8 @@
 
 #include "lab/lab.h"
 
+#include "lab/dispman.h"
+#include "lab/eventman.h"
 #include "lab/image.h"
 #include "lab/intro.h"
 #include "lab/labsets.h"
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index edc2588..176f008 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -29,6 +29,9 @@
  */
 
 #include "lab/lab.h"
+
+#include "lab/dispman.h"
+#include "lab/eventman.h"
 #include "lab/image.h"
 
 namespace Lab {
diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp
index 2fac5a6..20c893d 100644
--- a/engines/lab/image.cpp
+++ b/engines/lab/image.cpp
@@ -31,6 +31,8 @@
 #include "common/file.h"
 
 #include "lab/lab.h"
+
+#include "lab/dispman.h"
 #include "lab/image.h"
 
 namespace Lab {
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 62b0f80..d56f485 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -29,6 +29,9 @@
  */
 
 #include "lab/lab.h"
+
+#include "lab/dispman.h"
+#include "lab/eventman.h"
 #include "lab/image.h"
 #include "lab/utils.h"
 
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 8e5986f..89e030c 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -30,6 +30,7 @@
 
 #include "lab/lab.h"
 
+#include "lab/dispman.h"
 #include "lab/intro.h"
 #include "lab/music.h"
 #include "lab/resource.h"
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 5ce053a..dc77acb 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -36,8 +36,10 @@
 
 #include "lab/lab.h"
 
-#include "lab/music.h"
+#include "lab/dispman.h"
+#include "lab/eventman.h"
 #include "lab/image.h"
+#include "lab/music.h"
 #include "lab/resource.h"
 #include "lab/utils.h"
 
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 7aaa548..4d9cb7b 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -38,16 +38,18 @@
 #include "lab/anim.h"
 #include "lab/processroom.h"
 #include "lab/interface.h"
-#include "lab/eventman.h"
-#include "lab/dispman.h"
+//#include "lab/eventman.h"
 
 struct ADGameDescription;
 
 namespace Lab {
 
+class DisplayMan;
+class EventManager;
 class LargeSet;
 class Music;
 class Resource;
+struct TextFont;
 class Utils;
 
 enum GameFeatures {
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index accd56d..2176391 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -30,6 +30,8 @@
 
 #include "lab/lab.h"
 
+#include "lab/dispman.h"
+#include "lab/eventman.h"
 #include "lab/image.h"
 #include "lab/labsets.h"
 #include "lab/music.h"
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 722ec99..66963da 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -32,6 +32,7 @@
 
 #include "lab/lab.h"
 
+#include "lab/eventman.h"
 #include "lab/music.h"
 #include "lab/resource.h"
 
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 4df7e20..894bdea 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -32,6 +32,7 @@
 
 #include "lab/lab.h"
 
+#include "lab/dispman.h"
 #include "lab/labsets.h"
 #include "lab/music.h"
 #include "lab/resource.h"
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 65b1478..6f5964f 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -30,6 +30,7 @@
 
 #include "lab/lab.h"
 
+#include "lab/dispman.h"
 #include "lab/music.h"
 #include "lab/resource.h"
 
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 1393278..1e2c8af 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -32,6 +32,8 @@
 #include "engines/savestate.h"
 
 #include "lab/lab.h"
+
+#include "lab/dispman.h"
 #include "lab/labsets.h"
 #include "lab/savegame.h"
 
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 55825a7..690dc29 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -35,6 +35,8 @@
 
 #include "lab/lab.h"
 
+#include "lab/dispman.h"
+#include "lab/eventman.h"
 #include "lab/image.h"
 #include "lab/labsets.h"
 #include "lab/music.h"
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index bf435be..c4e5da9 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -28,10 +28,13 @@
  *
  */
 
+#include "common/file.h"
+
 #include "gui/message.h"
 
 #include "lab/lab.h"
 
+#include "lab/dispman.h"
 #include "lab/image.h"
 #include "lab/labsets.h"
 #include "lab/resource.h"
diff --git a/engines/lab/transitions.cpp b/engines/lab/transitions.cpp
index 89ce54f..cc0efb2 100644
--- a/engines/lab/transitions.cpp
+++ b/engines/lab/transitions.cpp
@@ -29,8 +29,11 @@
  */
 
 #include "lab/lab.h"
-#include "lab/music.h"
+
+#include "lab/dispman.h"
+#include "lab/eventman.h"
 #include "lab/image.h"
+#include "lab/music.h"
 #include "lab/utils.h"
 
 namespace Lab {


Commit: 9015cf72a326e5bac2eeb311b257690a01d4bc26
    https://github.com/scummvm/scummvm/commit/9015cf72a326e5bac2eeb311b257690a01d4bc26
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:57+01:00

Commit Message:
LAB: Reduced header dependency: interface.h

Changed paths:
    engines/lab/anim.cpp
    engines/lab/dispman.cpp
    engines/lab/engine.cpp
    engines/lab/eventman.cpp
    engines/lab/interface.cpp
    engines/lab/intro.cpp
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 7411dcb..ac1ab3e 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -30,6 +30,7 @@
 
 #include "lab/lab.h"
 
+#include "lab/anim.h"
 #include "lab/dispman.h"
 #include "lab/eventman.h"
 #include "lab/music.h"
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index f78e55d..d3ad191 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -32,8 +32,10 @@
 
 #include "lab/lab.h"
 
+#include "lab/anim.h"
 #include "lab/dispman.h"
 #include "lab/eventman.h"
+#include "lab/interface.h"
 #include "lab/music.h"
 #include "lab/image.h"
 #include "lab/resource.h"
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index af6d4c4..a22c19f 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -33,6 +33,7 @@
 #include "lab/dispman.h"
 #include "lab/eventman.h"
 #include "lab/image.h"
+#include "lab/interface.h"
 #include "lab/intro.h"
 #include "lab/labsets.h"
 #include "lab/music.h"
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 176f008..967a6f0 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -33,6 +33,7 @@
 #include "lab/dispman.h"
 #include "lab/eventman.h"
 #include "lab/image.h"
+#include "lab/interface.h"
 
 namespace Lab {
 
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index d56f485..41f7e37 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -33,6 +33,7 @@
 #include "lab/dispman.h"
 #include "lab/eventman.h"
 #include "lab/image.h"
+#include "lab/interface.h"
 #include "lab/utils.h"
 
 namespace Lab {
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 89e030c..df575bd 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -31,6 +31,7 @@
 #include "lab/lab.h"
 
 #include "lab/dispman.h"
+#include "lab/interface.h"
 #include "lab/intro.h"
 #include "lab/music.h"
 #include "lab/resource.h"
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 4d9cb7b..4031fe6 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -37,15 +37,17 @@
 #include "engines/engine.h"
 #include "lab/anim.h"
 #include "lab/processroom.h"
-#include "lab/interface.h"
-//#include "lab/eventman.h"
 
 struct ADGameDescription;
 
 namespace Lab {
 
+class Anim;
 class DisplayMan;
 class EventManager;
+struct Gadget;
+class Image;
+struct IntuiMessage;
 class LargeSet;
 class Music;
 class Resource;
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 2176391..cec9c4c 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -33,6 +33,7 @@
 #include "lab/dispman.h"
 #include "lab/eventman.h"
 #include "lab/image.h"
+#include "lab/interface.h"
 #include "lab/labsets.h"
 #include "lab/music.h"
 #include "lab/resource.h"
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 690dc29..24db6ce 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -38,6 +38,7 @@
 #include "lab/dispman.h"
 #include "lab/eventman.h"
 #include "lab/image.h"
+#include "lab/interface.h"
 #include "lab/labsets.h"
 #include "lab/music.h"
 #include "lab/resource.h"


Commit: cf020db741294c54dab66a0ed652bdee565d44d5
    https://github.com/scummvm/scummvm/commit/cf020db741294c54dab66a0ed652bdee565d44d5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:58+01:00

Commit Message:
LAB: Converted DisplayMan::_dispBitMap to a pointer.

Changed paths:
    engines/lab/anim.cpp
    engines/lab/dispman.cpp
    engines/lab/dispman.h



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index ac1ab3e..5f77974 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -71,7 +71,7 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 	_doBlack = false;
 	_diffWidth = 0;
 	_diffHeight = 0;
-	DrawBitMap = &_vm->_graphics->_dispBitMap;
+	DrawBitMap = _vm->_graphics->_dispBitMap;
 
 	for (int i = 0; i < 3 * 256; i++)
 		_diffPalette[i] = 0;
@@ -87,12 +87,12 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 		// Already done.
 		return;
 
-	if (_vm->_graphics->_dispBitMap._flags & BITMAPF_VIDEO) {
-		_vm->_graphics->_dispBitMap._planes[0] = _vm->_graphics->getCurrentDrawingBuffer();
-		_vm->_graphics->_dispBitMap._planes[1] = _vm->_graphics->_dispBitMap._planes[0] + 0x10000;
-		_vm->_graphics->_dispBitMap._planes[2] = _vm->_graphics->_dispBitMap._planes[1] + 0x10000;
-		_vm->_graphics->_dispBitMap._planes[3] = _vm->_graphics->_dispBitMap._planes[2] + 0x10000;
-		_vm->_graphics->_dispBitMap._planes[4] = _vm->_graphics->_dispBitMap._planes[3] + 0x10000;
+	if (_vm->_graphics->_dispBitMap->_flags & BITMAPF_VIDEO) {
+		_vm->_graphics->_dispBitMap->_planes[0] = _vm->_graphics->getCurrentDrawingBuffer();
+		_vm->_graphics->_dispBitMap->_planes[1] = _vm->_graphics->_dispBitMap->_planes[0] + 0x10000;
+		_vm->_graphics->_dispBitMap->_planes[2] = _vm->_graphics->_dispBitMap->_planes[1] + 0x10000;
+		_vm->_graphics->_dispBitMap->_planes[3] = _vm->_graphics->_dispBitMap->_planes[2] + 0x10000;
+		_vm->_graphics->_dispBitMap->_planes[4] = _vm->_graphics->_dispBitMap->_planes[3] + 0x10000;
 	}
 
 	_vm->_event->mouseHide();
@@ -130,7 +130,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 			_isAnim = (_frameNum >= 3) && (!_playOnce);
 			_curBit = 0;
 
-			if (_vm->_graphics->_dispBitMap._flags & BITMAPF_VIDEO)
+			if (_vm->_graphics->_dispBitMap->_flags & BITMAPF_VIDEO)
 				_vm->_graphics->screenUpdate();
 
 			// done with the next frame.
@@ -177,13 +177,13 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 			break;
 
 		case 20L:
-			_vm->_utils->unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap._planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, false);
+			_vm->_utils->unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, false);
 			_curBit++;
 			_diffFile += _size;
 			break;
 
 		case 21L:
-			_vm->_utils->unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap._planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, true);
+			_vm->_utils->unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, true);
 			_curBit++;
 			_diffFile += _size;
 			break;
@@ -224,7 +224,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 						_vm->_music->updateMusic();
 						_vm->waitTOF();
 
-						if (_vm->_graphics->_dispBitMap._flags & BITMAPF_VIDEO)
+						if (_vm->_graphics->_dispBitMap->_flags & BITMAPF_VIDEO)
 							didTOF = true;
 					}
 				}
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index d3ad191..df42f17 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -61,10 +61,13 @@ DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) {
 
 	for (int i = 0; i < 256 * 3; i++)
 		_curvgapal[i] = 0;
+
+	_dispBitMap = new BitMap;
 }
 
 DisplayMan::~DisplayMan() {
 	freePict();
+	delete _dispBitMap;
 }
 
 // From readPict.c.  Reads in pictures and animations from disk.
@@ -90,9 +93,9 @@ void DisplayMan::readPict(const char *filename, bool playOnce, bool onlyDiffData
 	if (!_vm->_music->_doNotFilestopSoundEffect)
 		_vm->_music->stopSoundEffect();
 
-	_dispBitMap._bytesPerRow = _screenWidth;
-	_dispBitMap._rows        = _screenHeight;
-	_dispBitMap._flags       = BITMAPF_VIDEO;
+	_dispBitMap->_bytesPerRow = _screenWidth;
+	_dispBitMap->_rows        = _screenHeight;
+	_dispBitMap->_flags       = BITMAPF_VIDEO;
 
 	_vm->_anim->readDiff(_curBitmap, playOnce, onlyDiffData);
 }
@@ -110,14 +113,14 @@ byte *DisplayMan::readPictToMem(const char *filename, uint16 x, uint16 y) {
 	if (!_vm->_music->_doNotFilestopSoundEffect)
 		_vm->_music->stopSoundEffect();
 
-	_dispBitMap._bytesPerRow = x;
-	_dispBitMap._rows = y;
-	_dispBitMap._flags = BITMAPF_NONE;
-	_dispBitMap._planes[0] = _curBitmap;
-	_dispBitMap._planes[1] = _dispBitMap._planes[0] + 0x10000;
-	_dispBitMap._planes[2] = _dispBitMap._planes[1] + 0x10000;
-	_dispBitMap._planes[3] = _dispBitMap._planes[2] + 0x10000;
-	_dispBitMap._planes[4] = _dispBitMap._planes[3] + 0x10000;
+	_dispBitMap->_bytesPerRow = x;
+	_dispBitMap->_rows = y;
+	_dispBitMap->_flags = BITMAPF_NONE;
+	_dispBitMap->_planes[0] = _curBitmap;
+	_dispBitMap->_planes[1] = _dispBitMap->_planes[0] + 0x10000;
+	_dispBitMap->_planes[2] = _dispBitMap->_planes[1] + 0x10000;
+	_dispBitMap->_planes[3] = _dispBitMap->_planes[2] + 0x10000;
+	_dispBitMap->_planes[4] = _dispBitMap->_planes[3] + 0x10000;
 
 	_vm->_anim->readDiff(_curBitmap, true);
 
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index a04d142..5ce4923 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -33,6 +33,7 @@
 
 namespace Lab {
 
+struct BitMap;
 class LabEngine;
 class Image;
 
@@ -158,7 +159,7 @@ public:
 	byte *_currentDisplayBuffer;
 	bool _doNotDrawMessage;
 	uint16 *FadePalette;
-	BitMap _dispBitMap;
+	BitMap *_dispBitMap;
 };
 
 } // End of namespace Lab


Commit: 9af853b6ab7c998910d2212206fab1a14c8b5818
    https://github.com/scummvm/scummvm/commit/9af853b6ab7c998910d2212206fab1a14c8b5818
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:58+01:00

Commit Message:
LAB: Reduced last reducable header: anim.h

Changed paths:
    engines/lab/engine.cpp
    engines/lab/intro.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/music.cpp
    engines/lab/processroom.cpp
    engines/lab/special.cpp
    engines/lab/tilepuzzle.cpp
    engines/lab/transitions.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index a22c19f..b7f69e4 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -30,6 +30,7 @@
 
 #include "lab/lab.h"
 
+#include "lab/anim.h"
 #include "lab/dispman.h"
 #include "lab/eventman.h"
 #include "lab/image.h"
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index df575bd..4518a27 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -30,6 +30,7 @@
 
 #include "lab/lab.h"
 
+#include "lab/anim.h"
 #include "lab/dispman.h"
 #include "lab/interface.h"
 #include "lab/intro.h"
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index dc77acb..ff4a290 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -36,6 +36,7 @@
 
 #include "lab/lab.h"
 
+#include "lab/anim.h"
 #include "lab/dispman.h"
 #include "lab/eventman.h"
 #include "lab/image.h"
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 4031fe6..fb23bcc 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -35,7 +35,6 @@
 #include "common/events.h"
 
 #include "engines/engine.h"
-#include "lab/anim.h"
 #include "lab/processroom.h"
 
 struct ADGameDescription;
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 66963da..feddea5 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -32,6 +32,7 @@
 
 #include "lab/lab.h"
 
+#include "lab/anim.h"
 #include "lab/eventman.h"
 #include "lab/music.h"
 #include "lab/resource.h"
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 894bdea..7f01970 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -32,6 +32,7 @@
 
 #include "lab/lab.h"
 
+#include "lab/anim.h"
 #include "lab/dispman.h"
 #include "lab/labsets.h"
 #include "lab/music.h"
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 24db6ce..3578a65 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -35,6 +35,7 @@
 
 #include "lab/lab.h"
 
+#include "lab/anim.h"
 #include "lab/dispman.h"
 #include "lab/eventman.h"
 #include "lab/image.h"
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index c4e5da9..db30277 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -34,6 +34,7 @@
 
 #include "lab/lab.h"
 
+#include "lab/anim.h"
 #include "lab/dispman.h"
 #include "lab/image.h"
 #include "lab/labsets.h"
diff --git a/engines/lab/transitions.cpp b/engines/lab/transitions.cpp
index cc0efb2..b2f07fc 100644
--- a/engines/lab/transitions.cpp
+++ b/engines/lab/transitions.cpp
@@ -30,6 +30,7 @@
 
 #include "lab/lab.h"
 
+#include "lab/anim.h"
 #include "lab/dispman.h"
 #include "lab/eventman.h"
 #include "lab/image.h"


Commit: c062dee369216f9ce5573e8a98334aef25a72117
    https://github.com/scummvm/scummvm/commit/c062dee369216f9ce5573e8a98334aef25a72117
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:58+01:00

Commit Message:
LAB: Optimized dependency on common headers

Changed paths:
    engines/lab/eventman.cpp
    engines/lab/interface.cpp
    engines/lab/lab.h



diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 967a6f0..967596c 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -28,6 +28,8 @@
  *
  */
 
+#include "common/events.h"
+
 #include "lab/lab.h"
 
 #include "lab/dispman.h"
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 41f7e37..0ccbd48 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -28,6 +28,8 @@
  *
  */
 
+#include "common/events.h"
+
 #include "lab/lab.h"
 
 #include "lab/dispman.h"
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index fb23bcc..2fd60c7 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -32,7 +32,7 @@
 #define LAB_H
 
 #include "common/system.h"
-#include "common/events.h"
+#include "common/rect.h"
 
 #include "engines/engine.h"
 #include "lab/processroom.h"


Commit: e5f753749fc55beb0d48180d1d649fc81412182c
    https://github.com/scummvm/scummvm/commit/e5f753749fc55beb0d48180d1d649fc81412182c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:58+01:00

Commit Message:
LAB: Reduced dependency on processroom.h. Yay!

Changed paths:
    engines/lab/engine.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/processroom.cpp
    engines/lab/processroom.h
    engines/lab/resource.cpp
    engines/lab/resource.h
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index b7f69e4..46e60dc 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -38,6 +38,7 @@
 #include "lab/intro.h"
 #include "lab/labsets.h"
 #include "lab/music.h"
+#include "lab/processroom.h"
 #include "lab/resource.h"
 #include "lab/utils.h"
 
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index ff4a290..4bf9aa3 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -41,6 +41,7 @@
 #include "lab/eventman.h"
 #include "lab/image.h"
 #include "lab/music.h"
+#include "lab/processroom.h"
 #include "lab/resource.h"
 #include "lab/utils.h"
 
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 2fd60c7..2cbea65 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -35,21 +35,25 @@
 #include "common/rect.h"
 
 #include "engines/engine.h"
-#include "lab/processroom.h"
 
 struct ADGameDescription;
 
 namespace Lab {
 
+struct Action;
 class Anim;
+struct CloseData;
 class DisplayMan;
 class EventManager;
 struct Gadget;
 class Image;
 struct IntuiMessage;
+struct InventoryData;
 class LargeSet;
 class Music;
 class Resource;
+struct RoomData;
+struct Rule;
 struct TextFont;
 class Utils;
 
@@ -75,6 +79,9 @@ struct CrumbData {
 
 #define MAX_CRUMBS          128
 
+typedef CloseData *CloseDataPtr;
+typedef Common::List<Rule *> RuleList;
+
 // Direction defines
 #define NORTH   0
 #define SOUTH   1
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index cec9c4c..af61c85 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -36,6 +36,7 @@
 #include "lab/interface.h"
 #include "lab/labsets.h"
 #include "lab/music.h"
+#include "lab/processroom.h"
 #include "lab/resource.h"
 #include "lab/utils.h"
 
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 7f01970..31a4cdd 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -36,6 +36,7 @@
 #include "lab/dispman.h"
 #include "lab/labsets.h"
 #include "lab/music.h"
+#include "lab/processroom.h"
 #include "lab/resource.h"
 #include "lab/utils.h"
 
diff --git a/engines/lab/processroom.h b/engines/lab/processroom.h
index fae4c2f..cf2f8df 100644
--- a/engines/lab/processroom.h
+++ b/engines/lab/processroom.h
@@ -101,8 +101,6 @@ typedef struct CloseData {
 	CloseData *_subCloseUps;
 } CloseData;
 
-typedef CloseData *CloseDataPtr;
-
 struct ViewData {
 	int16 *_condition;
 	char *_graphicName;
@@ -128,8 +126,6 @@ struct Rule {
 	Rule *_nextRule;
 };
 
-typedef Common::List<Rule *> RuleList;
-
 struct RoomData {
 	uint16 _northDoor;
 	uint16 _southDoor;
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 6f5964f..281f9a2 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -32,6 +32,7 @@
 
 #include "lab/dispman.h"
 #include "lab/music.h"
+#include "lab/processroom.h"
 #include "lab/resource.h"
 
 namespace Lab {
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index 89303e1..2273d79 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -33,6 +33,8 @@
 
 namespace Lab {
 
+struct ViewData;
+
 enum StaticText {
 	kTextLowerFloor,
 	kTextMiddleFloor,
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 3578a65..8bb57ad 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -42,6 +42,7 @@
 #include "lab/interface.h"
 #include "lab/labsets.h"
 #include "lab/music.h"
+#include "lab/processroom.h"
 #include "lab/resource.h"
 #include "lab/savegame.h"
 #include "lab/utils.h"


Commit: c1fc1687fc4fb271871a9c02c4cb3ffe2c00d158
    https://github.com/scummvm/scummvm/commit/c1fc1687fc4fb271871a9c02c4cb3ffe2c00d158
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:58+01:00

Commit Message:
LAB: Code naming standards

Changed paths:
    engines/lab/engine.cpp
    engines/lab/lab.h



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 46e60dc..57383ec 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -560,16 +560,17 @@ void LabEngine::mainGameLoop() {
 	}
 }
 
-bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Common::Point tmpPos, uint16 &curInv, IntuiMessage *curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode) {
+bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Common::Point tmpPos,
+			uint16 &curInv, IntuiMessage *curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode) {
 	uint32 msgClass = tmpClass;
 	Common::Point curPos = tmpPos;
 
 	uint16 oldDirection = 0;
 	uint16 lastInv = MAPNUM;
 	CloseDataPtr oldcptr, tempcptr, hcptr = nullptr;
-	ViewData *VPtr;
+	ViewData *vptr;
 	bool doit;
-	uint16 NewDir;
+	uint16 newDir;
 
 	_anim->_doBlack = false;
 
@@ -577,7 +578,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 		if (code == 13) {
 			// The return key
 			msgClass = MOUSEBUTTONS;
-			Qualifier = IEQUALIFIER_LEFTBUTTON;
+			qualifier = IEQUALIFIER_LEFTBUTTON;
 			curPos = _event->getMousePos();
 		} else if (getPlatform() == Common::kPlatformWindows && (code == 'b' || code == 'B')) {
 			// Start bread crumbs
@@ -669,8 +670,8 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 	if (_graphics->_longWinInFront) {
 		if ((msgClass == RAWKEY) || ((msgClass == MOUSEBUTTONS) &&
-			  ((IEQUALIFIER_LEFTBUTTON & Qualifier) ||
-				(IEQUALIFIER_RBUTTON & Qualifier)))) {
+			  ((IEQUALIFIER_LEFTBUTTON & qualifier) ||
+				(IEQUALIFIER_RBUTTON & qualifier)))) {
 			_graphics->_longWinInFront = false;
 			_graphics->_doNotDrawMessage = false;
 			_graphics->drawPanel();
@@ -741,10 +742,10 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 				oldDirection = _direction;
 
-				NewDir = processArrow(_direction, gadgetId - 6);
-				doTurn(_direction, NewDir, &_cptr);
+				newDir = processArrow(_direction, gadgetId - 6);
+				doTurn(_direction, newDir, &_cptr);
 				_anim->_doBlack = true;
-				_direction = NewDir;
+				_direction = newDir;
 				forceDraw = true;
 
 				mayShowCrumbIndicator();
@@ -941,7 +942,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 				}
 			}
 		}
-	} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier) && _mainDisplay) {
+	} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier) && _mainDisplay) {
 		interfaceOff();
 		_mainDisplay = true;
 
@@ -1014,8 +1015,8 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 		mayShowCrumbIndicator();
 		_graphics->screenUpdate();
 	} else if (msgClass == DELTAMOVE) {
-		VPtr = getViewData(_roomNum, _direction);
-		oldcptr = VPtr->_closeUps;
+		vptr = getViewData(_roomNum, _direction);
+		oldcptr = vptr->_closeUps;
 
 		if (hcptr == NULL) {
 			tempcptr = _cptr;
@@ -1041,7 +1042,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Comm
 
 		if (hcptr)
 			_event->setMousePos(Common::Point(_utils->scaleX((hcptr->x1 + hcptr->x2) / 2), _utils->scaleY((hcptr->y1 + hcptr->y2) / 2)));
-	} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) {
+	} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & qualifier)) {
 		eatMessages();
 		_alternate = !_alternate;
 		_anim->_doBlack = true;
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 2cbea65..a1a5bb0 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -169,7 +169,8 @@ private:
 	GadgetList _mapGadgetList;
 
 private:
-	bool from_crumbs(uint32 tmpClass, uint16 code, uint16 Qualifier, Common::Point tmpPos, uint16 &curInv, IntuiMessage * curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode);
+	bool from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Common::Point tmpPos,
+			uint16 &curInv, IntuiMessage *curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode);
 
 public:
 	void waitTOF();


Commit: 23bbd70aac37e36f6863da3326704e10fdcfb1a9
    https://github.com/scummvm/scummvm/commit/23bbd70aac37e36f6863da3326704e10fdcfb1a9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:58+01:00

Commit Message:
LAB: Reduced variables scope

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 57383ec..0b353b5 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -44,9 +44,6 @@
 
 namespace Lab {
 
-// Global parser data
-bool ispal = false;
-
 // LAB: Labyrinth specific code for the special puzzles
 #define SPECIALLOCK         100
 #define SPECIALBRICK        101
@@ -89,7 +86,7 @@ static char initcolors[] = { '\x00', '\x00', '\x00', '\x30',
 							 '\x10', '\x14', '\x14', '\x14',
 							 '\x20', '\x20', '\x20', '\x24',
 							 '\x24', '\x24', '\x2c', '\x2c',
-							 '\x2c', '\x08', '\x08', '\x08'};
+							 '\x2c', '\x08', '\x08', '\x08' };
 
 /**
  * Draws the message for the room.
@@ -567,10 +564,8 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Comm
 
 	uint16 oldDirection = 0;
 	uint16 lastInv = MAPNUM;
-	CloseDataPtr oldcptr, tempcptr, hcptr = nullptr;
-	ViewData *vptr;
+	CloseDataPtr hcptr = nullptr;
 	bool doit;
-	uint16 newDir;
 
 	_anim->_doBlack = false;
 
@@ -742,7 +737,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Comm
 
 				oldDirection = _direction;
 
-				newDir = processArrow(_direction, gadgetId - 6);
+				uint16 newDir = processArrow(_direction, gadgetId - 6);
 				doTurn(_direction, newDir, &_cptr);
 				_anim->_doBlack = true;
 				_direction = newDir;
@@ -986,7 +981,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Comm
 				}
 			} else if (actionMode == 4) {
 				// Look at closeups
-				tempcptr = _cptr;
+				CloseDataPtr tempcptr = _cptr;
 				setCurClose(curPos, &tempcptr);
 
 				if (_cptr == tempcptr) {
@@ -1015,11 +1010,11 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Comm
 		mayShowCrumbIndicator();
 		_graphics->screenUpdate();
 	} else if (msgClass == DELTAMOVE) {
-		vptr = getViewData(_roomNum, _direction);
-		oldcptr = vptr->_closeUps;
+		ViewData *vptr = getViewData(_roomNum, _direction);
+		CloseDataPtr oldcptr = vptr->_closeUps;
 
 		if (hcptr == NULL) {
-			tempcptr = _cptr;
+			CloseDataPtr tempcptr = _cptr;
 			setCurClose(curPos, &tempcptr);
 
 			if ((tempcptr == NULL) || (tempcptr == _cptr)) {


Commit: f137e1af151e0c3838bd5182022e5293468da03f
    https://github.com/scummvm/scummvm/commit/f137e1af151e0c3838bd5182022e5293468da03f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:58+01:00

Commit Message:
LAB: Use a local buffer for moving tiles in the tile puzzle

This fixes the crash when a tile is moved

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/lab.h
    engines/lab/tilepuzzle.cpp
    engines/lab/transitions.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index df42f17..199c9e04 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -53,7 +53,6 @@ DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) {
 	_curBitmap = nullptr;
 	_displayBuffer = nullptr;
 	_currentDisplayBuffer = nullptr;
-	_tempScrollData = nullptr;
 	FadePalette = nullptr;
 
 	_screenWidth = 0;
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index 5ce4923..dbeeefc 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -66,7 +66,6 @@ private:
 	byte _curapen;
 	byte *_curBitmap;
 	byte _curvgapal[256 * 3];
-	byte *_tempScrollData;
 
 public:
 	DisplayMan(LabEngine *lab);
@@ -141,8 +140,8 @@ public:
 	void setPalette(void *cmap, uint16 numcolors);
 	void overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	byte *getCurrentDrawingBuffer();
-	void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-	void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer);
+	void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer);
 	void fade(bool fadein, uint16 res);
 	void closeFont(TextFont *tf);
 	uint16 textLength(TextFont *tf, const char *text, uint16 numchars);
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index a1a5bb0..ac27c94 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -219,7 +219,7 @@ private:
 	void showTile(const char *filename, bool showsolution);
 	void doTileScroll(uint16 col, uint16 row, uint16 scrolltype);
 	void changeCombination(uint16 number);
-	void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer);
 	void doCombination();
 	void showCombination(const char *filename);
 	void initTilePuzzle();
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index db30277..652c633 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -281,19 +281,23 @@ void LabEngine::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 	uint16 x1 = _utils->vgaScaleX(100) + (col * _utils->vgaScaleX(30)) + dx;
 	uint16 y1 = _utils->vgaScaleY(25) + (row * _utils->vgaScaleY(25)) + dy;
 
+	byte *buffer = new byte[_tiles[1]->_width * _tiles[1]->_height * 2L];
+
 	for (uint16 i = 0; i < last; i++) {
 		waitTOF();
-		scrollRaster(dX, dY, x1, y1, x1 + _utils->vgaScaleX(28) + sx, y1 + _utils->vgaScaleY(23) + sy);
+		scrollRaster(dX, dY, x1, y1, x1 + _utils->vgaScaleX(28) + sx, y1 + _utils->vgaScaleY(23) + sy, buffer);
 		x1 += dX;
 		y1 += dY;
 	}
+
+	delete[] buffer;
 }
 
 /**
  * Changes the combination number of one of the slots
  */
 void LabEngine::changeCombination(uint16 number) {
-	static const int solution[6] = { 0, 4, 0, 8, 7, 2 };
+	const int solution[6] = { 0, 4, 0, 8, 7, 2 };
 
 	Image display;
 	uint16 combnum;
@@ -310,6 +314,8 @@ void LabEngine::changeCombination(uint16 number) {
 	display._width     = _graphics->_screenWidth;
 	display._height    = _graphics->_screenHeight;
 
+	byte *buffer = new byte[_tiles[1]->_width * _tiles[1]->_height * 2L];
+
 	for (uint16 i = 1; i <= (_numberImages[combnum]->_height / 2); i++) {
 		if (_isHiRes) {
 			if (i & 1)
@@ -318,10 +324,12 @@ void LabEngine::changeCombination(uint16 number) {
 			waitTOF();
 
 		display._imageData = _graphics->getCurrentDrawingBuffer();
-		_graphics->scrollDisplayY(2, _utils->vgaScaleX(COMBINATION_X[number]), _utils->vgaScaleY(65), _utils->vgaScaleX(COMBINATION_X[number]) + (_numberImages[combnum])->_width - 1, _utils->vgaScaleY(65) + (_numberImages[combnum])->_height);
+		_graphics->scrollDisplayY(2, _utils->vgaScaleX(COMBINATION_X[number]), _utils->vgaScaleY(65), _utils->vgaScaleX(COMBINATION_X[number]) + (_numberImages[combnum])->_width - 1, _utils->vgaScaleY(65) + (_numberImages[combnum])->_height, buffer);
 		_numberImages[combnum]->blitBitmap(0, (_numberImages[combnum])->_height - (2 * i), &(display), _utils->vgaScaleX(COMBINATION_X[number]), _utils->vgaScaleY(65), (_numberImages[combnum])->_width, 2, false);
 	}
 
+	delete[] buffer;
+
 	for (uint16 i = 0; i < 6; i++)
 		unlocked &= (_combination[i] == solution[i]);
 
@@ -331,12 +339,12 @@ void LabEngine::changeCombination(uint16 number) {
 		_conditions->exclElement(COMBINATIONUNLOCKED);
 }
 
-void LabEngine::scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+void LabEngine::scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer) {
 	if (dx)
-		_graphics->scrollDisplayX(dx, x1, y1, x2, y2);
+		_graphics->scrollDisplayX(dx, x1, y1, x2, y2, buffer);
 
 	if (dy)
-		_graphics->scrollDisplayY(dy, x1, y1, x2, y2);
+		_graphics->scrollDisplayY(dy, x1, y1, x2, y2, buffer);
 }
 
 /**
diff --git a/engines/lab/transitions.cpp b/engines/lab/transitions.cpp
index b2f07fc..7c0b99d 100644
--- a/engines/lab/transitions.cpp
+++ b/engines/lab/transitions.cpp
@@ -387,10 +387,10 @@ void DisplayMan::blackAllScreen() {
  * The _tempScrollData variable must be initialized to some memory, or this
  * function will fail.
  */
-void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer) {
 	Image im;
 
-	im._imageData = _tempScrollData;
+	im._imageData = buffer;
 
 	if (x1 > x2)
 		SWAP<uint16>(x1, x2);
@@ -411,10 +411,10 @@ void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint1
 /**
  * Scrolls the display in the y direction by blitting.
  */
-void DisplayMan::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+void DisplayMan::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer) {
 	Image im;
 
-	im._imageData = _tempScrollData;
+	im._imageData = buffer;
 
 	if (x1 > x2)
 		SWAP<uint16>(x1, x2);


Commit: 23f73c32440b8ff638920f214e3d8f0a75aafd70
    https://github.com/scummvm/scummvm/commit/23f73c32440b8ff638920f214e3d8f0a75aafd70
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:58+01:00

Commit Message:
LAB: Fix regression when scrolling tiles

A regression of 28991ed1224ed3d0dbaf345a065a0bf79fa70ea9

Changed paths:
    engines/lab/transitions.cpp



diff --git a/engines/lab/transitions.cpp b/engines/lab/transitions.cpp
index 7c0b99d..df3c777 100644
--- a/engines/lab/transitions.cpp
+++ b/engines/lab/transitions.cpp
@@ -398,14 +398,25 @@ void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint1
 	if (y1 > y2)
 		SWAP<uint16>(y1, y2);
 
-	im._width = x2 - x1 + 1 - dx;
-	im._height = y2 - y1 + 1;
+	if (dx > 0) {
+		im._width = x2 - x1 + 1 - dx;
+		im._height = y2 - y1 + 1;
 
-	im.readScreenImage(x1, y1);
-	im.drawImage(x1 + dx, y1);
+		im.readScreenImage(x1, y1);
+		im.drawImage(x1 + dx, y1);
 
-	setAPen(0);
-	rectFill(x1, y1, x1 + dx - 1, y2);
+		setAPen(0);
+		rectFill(x1, y1, x1 + dx - 1, y2);
+	} else if (dx < 0) {
+		im._width = x2 - x1 + 1 + dx;
+		im._height = y2 - y1 + 1;
+
+		im.readScreenImage(x1 - dx, y1);
+		im.drawImage(x1, y1);
+
+		setAPen(0);
+		rectFill(x2 + dx + 1, y1, x2, y2);
+	}
 }
 
 /**
@@ -422,14 +433,25 @@ void DisplayMan::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint1
 	if (y1 > y2)
 		SWAP<uint16>(y1, y2);
 
-	im._width = x2 - x1 + 1;
-	im._height = y2 - y1 + 1 - dy;
+	if (dy > 0) {
+		im._width = x2 - x1 + 1;
+		im._height = y2 - y1 + 1 - dy;
 
-	im.readScreenImage(x1, y1);
-	im.drawImage(x1, y1 + dy);
+		im.readScreenImage(x1, y1);
+		im.drawImage(x1, y1 + dy);
 
-	setAPen(0);
-	rectFill(x1, y1, x2, y1 + dy - 1);
+		setAPen(0);
+		rectFill(x1, y1, x2, y1 + dy - 1);
+	} else if (dy < 0) {
+		im._width = x2 - x1 + 1;
+		im._height = y2 - y1 + 1 + dy;
+
+		im.readScreenImage(x1, y1 - dy);
+		im.drawImage(x1, y1);
+
+		setAPen(0);
+		rectFill(x1, y2 + dy + 1, x2, y2);
+	}
 }
 
 /**


Commit: c42629674bc58f46a27a91c3c8325f68ed9f222c
    https://github.com/scummvm/scummvm/commit/c42629674bc58f46a27a91c3c8325f68ed9f222c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:58+01:00

Commit Message:
LAB: Code naming, reduced variable scope

Changed paths:
    engines/lab/eventman.cpp
    engines/lab/intro.cpp
    engines/lab/map.cpp



diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 967596c..2b39397 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -39,7 +39,7 @@
 
 namespace Lab {
 
-static byte MouseData[] = {
+static byte mouseData[] = {
 	1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
 	1, 7, 1, 0, 0, 0, 0, 0, 0, 0,
 	1, 7, 7, 1, 0, 0, 0, 0, 0, 0,
@@ -174,7 +174,7 @@ void EventManager::updateMouse() {
  * Initializes the mouse.
  */
 void EventManager::initMouse() {
-	g_system->setMouseCursor(MouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0);
+	g_system->setMouseCursor(mouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0);
 	g_system->showMouse(false);
 
 	setMousePos(Common::Point(0, 0));
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 4518a27..d0406bc 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -38,6 +38,7 @@
 #include "lab/resource.h"
 
 namespace Lab {
+
 Intro::Intro(LabEngine *vm) : _vm(vm) {
 	_quitIntro = false;
 }
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index af61c85..bc95304 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -137,10 +137,10 @@ void LabEngine::freeMapData() {
 /**
  * Figures out what a room's coordinates should be.
  */
-static void roomCoords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16 *y2) {
+static void roomCoords(uint16 curRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16 *y2) {
 	Image *curRoomImg = NULL;
 
-	switch (Maps[CurRoom].SpecialID) {
+	switch (Maps[curRoom].SpecialID) {
 	case NORMAL:
 	case UPARROWROOM:
 	case DOWNARROWROOM:
@@ -160,8 +160,8 @@ static void roomCoords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint1
 		break;
 	}
 
-	*x1 = mapScaleX(Maps[CurRoom].x);
-	*y1 = mapScaleY(Maps[CurRoom].y);
+	*x1 = mapScaleX(Maps[curRoom].x);
+	*y1 = mapScaleY(Maps[curRoom].y);
 	*x2 = *x1;
 	*y2 = *y1;
 
@@ -174,21 +174,21 @@ static void roomCoords(uint16 CurRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint1
 /**
  * Draws a room map.
  */
-static void drawRoomMap(uint16 CurRoom, bool drawx) {
+static void drawRoomMap(uint16 curRoom, bool drawx) {
 	uint16 x, y, xx, xy, offset;
 	uint32 flags;
 
-	x = mapScaleX(Maps[CurRoom].x);
-	y = mapScaleY(Maps[CurRoom].y);
-	flags = Maps[CurRoom].MapFlags;
+	x = mapScaleX(Maps[curRoom].x);
+	y = mapScaleY(Maps[curRoom].y);
+	flags = Maps[curRoom].MapFlags;
 
-	switch (Maps[CurRoom].SpecialID) {
+	switch (Maps[curRoom].SpecialID) {
 	case NORMAL:
 	case UPARROWROOM:
 	case DOWNARROWROOM:
-		if (Maps[CurRoom].SpecialID == NORMAL)
+		if (Maps[curRoom].SpecialID == NORMAL)
 			Room->drawImage(x, y);
-		else if (Maps[CurRoom].SpecialID == DOWNARROWROOM)
+		else if (Maps[curRoom].SpecialID == DOWNARROWROOM)
 			DownArrowRoom->drawImage(x, y);
 		else
 			UpArrowRoom->drawImage(x, y);
@@ -309,9 +309,9 @@ static void drawRoomMap(uint16 CurRoom, bool drawx) {
 /**
  * Checks if a floor has been visitted.
  */
-static bool onFloor(uint16 Floor) {
+static bool onFloor(uint16 flr) {
 	for (uint16 i = 1; i <= MaxRooms; i++) {
-		if ((Maps[i].PageNumber == Floor) && g_lab->_roomsFound->in(i) && Maps[i].x)
+		if ((Maps[i].PageNumber == flr) && g_lab->_roomsFound->in(i) && Maps[i].x)
 			return true;
 	}
 
@@ -321,60 +321,52 @@ static bool onFloor(uint16 Floor) {
 /**
  * Figures out which floor, if any, should be gone to if the up arrow is hit
  */
-static void getUpFloor(uint16 *Floor, bool *isfloor) {
+static bool getUpFloor(uint16 *flr) {
 	do {
-		*isfloor = true;
-
-		if (*Floor < kFloorUpper)
-			(*Floor)++;
+		if (*flr < kFloorUpper)
+			(*flr)++;
 		else {
-			*Floor   = kFloorCarnival + 1;
-			*isfloor = false;
-			return;
+			*flr   = kFloorCarnival + 1;
+			return false;
 		}
-	} while ((!onFloor(*Floor)) && (*Floor <= kFloorCarnival));
+	} while ((!onFloor(*flr)) && (*flr <= kFloorCarnival));
+
+	return true;
 }
 
 /**
  * Figures out which floor, if any, should be gone to if the down arrow is
  * hit.
  */
-static void getDownFloor(uint16 *Floor, bool *isfloor) {
+static bool getDownFloor(uint16 *flr) {
 	do {
-		*isfloor = true;
-
-		if ((*Floor == kFloorLower) || (*Floor == 0)) {
-			*Floor   = 0;
-			*isfloor = false;
-			return;
-		} else if (*Floor > kFloorUpper) {
+		if ((*flr == kFloorLower) || (*flr == 0)) {
+			*flr   = 0;
+			return false;
+		} else if (*flr > kFloorUpper) {
 			// Labyrinth specific code
-			if (*Floor == kFloorHedgeMaze)
-				*Floor = kFloorUpper;
-			else if ((*Floor == kFloorCarnival) || (*Floor == kFloorMedMaze))
-				*Floor = kFloorMiddle;
-			else if (*Floor == kFloorSurMaze)
-				*Floor = kFloorLower;
+			if (*flr == kFloorHedgeMaze)
+				*flr = kFloorUpper;
+			else if ((*flr == kFloorCarnival) || (*flr == kFloorMedMaze))
+				*flr = kFloorMiddle;
+			else if (*flr == kFloorSurMaze)
+				*flr = kFloorLower;
 			else {
-				*Floor = 0;
-				*isfloor = false;
-				return;
+				*flr = 0;
+				return false;
 			}
 		} else
-			(*Floor)--;
+			(*flr)--;
 
-	} while ((!onFloor(*Floor)) && *Floor);
+	} while ((!onFloor(*flr)) && *flr);
+
+	return true;
 }
 
 /**
  * Draws the map
  */
-void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein) {
-	char *sptr;
-
-	uint16 tempfloor;
-	bool noOverlay;
-
+void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 flr, bool fadeout, bool fadein) {
 	_event->mouseHide();
 
 	if (fadeout)
@@ -387,8 +379,8 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 	drawGadgetList(&_mapGadgetList);
 
 	for (uint16 i = 1; i <= MaxRooms; i++) {
-		if ((Maps[i].PageNumber == Floor) && _roomsFound->in(i) && Maps[i].x) {
-			drawRoomMap(i, (bool)(i == CurRoom));
+		if ((Maps[i].PageNumber == flr) && _roomsFound->in(i) && Maps[i].x) {
+			drawRoomMap(i, (bool)(i == curRoom));
 			_music->updateMusic();
 		}
 	}
@@ -396,11 +388,12 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 	// Makes sure the X is drawn in corridors
 	// NOTE: this here on purpose just in case there's some weird
 	// condition, like the surreal maze where there are no rooms
-	if ((Maps[CurRoom].PageNumber == Floor) && _roomsFound->in(CurRoom) && Maps[CurRoom].x)
-		drawRoomMap(CurRoom, true);
+	if ((Maps[curRoom].PageNumber == flr) && _roomsFound->in(curRoom) && Maps[curRoom].x)
+		drawRoomMap(curRoom, true);
+
+	uint16 tempfloor = flr;
 
-	tempfloor = Floor;
-	getUpFloor(&tempfloor, &noOverlay);
+	bool noOverlay = getUpFloor(&tempfloor);
 
 	Gadget *upGadget = _event->getGadget(1);
 	Gadget *downGadget = _event->getGadget(2);
@@ -410,38 +403,40 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 	else
 		disableGadget(upGadget, 12);
 
-	tempfloor = Floor;
-	getDownFloor(&tempfloor, &noOverlay);
+	tempfloor = flr;
+	noOverlay = getDownFloor(&tempfloor);
 
 	if (noOverlay)
 		enableGadget(downGadget);
 	else
 		disableGadget(downGadget, 12);
 
+	char *sptr;
+
 	// Labyrinth specific code
-	if (Floor == kFloorLower) {
+	if (flr == kFloorLower) {
 		if (onFloor(kFloorSurMaze))
 			Maze->drawImage(mapScaleX(538), mapScaleY(277));
-	} else if (Floor == kFloorMiddle) {
+	} else if (flr == kFloorMiddle) {
 		if (onFloor(kFloorCarnival))
 			Maze->drawImage(mapScaleX(358), mapScaleY(72));
 
 		if (onFloor(kFloorMedMaze))
 			Maze->drawImage(mapScaleX(557), mapScaleY(325));
-	} else if (Floor == kFloorUpper) {
+	} else if (flr == kFloorUpper) {
 		if (onFloor(kFloorHedgeMaze))
 			HugeMaze->drawImage(mapScaleX(524), mapScaleY(97));
-	} else if (Floor == kFloorSurMaze) {
+	} else if (flr == kFloorSurMaze) {
 		sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str();
 		_graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr);
 	}
 
-	if (Floor >= kFloorLower && Floor <= kFloorCarnival) {
-		sptr = (char *)_resource->getStaticText(Floor - 1).c_str();
+	if (flr >= kFloorLower && flr <= kFloorCarnival) {
+		sptr = (char *)_resource->getStaticText(flr - 1).c_str();
 		_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 75, 134, 97, sptr);
 	}
 
-	if ((sptr = _rooms[CurMsg]._roomMsg))
+	if ((sptr = _rooms[curMsg]._roomMsg))
 		_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr);
 
 	if (fadein)
@@ -453,25 +448,22 @@ void LabEngine::drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeou
 /**
  * Processes the map.
  */
-void LabEngine::processMap(uint16 CurRoom) {
-	uint32 Class, place = 1;
-	uint16 Code, Qualifier, MouseX, MouseY, GadgetID, CurFloor, OldFloor, OldMsg, CurMsg, x1, y1, x2, y2;
-	char *sptr;
-	byte newcolor[3];
-	bool drawmap;
-	IntuiMessage *Msg;
+void LabEngine::processMap(uint16 curRoom) {
+	uint32 place = 1;
 
-	CurMsg   = CurRoom;
-	CurFloor = Maps[CurRoom].PageNumber;
+	uint16 curMsg   = curRoom;
+	uint16 curFloor = Maps[curRoom].PageNumber;
 
 	while (1) {
 		// Make sure we check the music at least after every message
 		_music->updateMusic();
-		Msg = getMsg();
+		IntuiMessage *msg = getMsg();
 
-		if (Msg == NULL) {
+		if (msg == NULL) {
 			_music->updateMusic();
 
+			byte newcolor[3];
+
 			if (place <= 14) {
 				newcolor[0] = 14 << 2;
 				newcolor[1] = place << 2;
@@ -498,108 +490,110 @@ void LabEngine::processMap(uint16 CurRoom) {
 				place = 1;
 
 		} else {
-			Class     = Msg->_msgClass;
-			Code      = Msg->_code;
-			GadgetID  = Msg->_gadgetID;
-			Qualifier = Msg->_qualifier;
-			MouseX    = Msg->_mouseX;
-			MouseY    = Msg->_mouseY;
-
-			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) || ((Class == RAWKEY) && (Code == 27)))
+			uint32 msgClass  = msg->_msgClass;
+			uint16 msgCode   = msg->_code;
+			uint16 gadgetID  = msg->_gadgetID;
+			uint16 qualifier = msg->_qualifier;
+			uint16 mouseX    = msg->_mouseX;
+			uint16 mouseY    = msg->_mouseY;
+
+			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & qualifier)) || ((msgClass == RAWKEY) && (msgCode == 27)))
 				return;
 
-			if (Class == GADGETUP) {
-				if (GadgetID == 0) {
+			if (msgClass == GADGETUP) {
+				if (gadgetID == 0) {
 					// Quit menu button
 					return;
-				} else if (GadgetID == 1) {
+				} else if (gadgetID == 1) {
 					// Up arrow
-					OldFloor = CurFloor;
-					getUpFloor(&CurFloor, &drawmap);
+					uint16 oldFloor = curFloor;
+					bool drawmap = getUpFloor(&curFloor);
 
 					if (drawmap) {
 						_graphics->fade(false, 0);
-						drawMap(CurRoom, CurMsg, CurFloor, false, false);
+						drawMap(curRoom, curMsg, curFloor, false, false);
 						_graphics->fade(true, 0);
 					} else
-						CurFloor = OldFloor;
-				} else if (GadgetID == 2) {
+						curFloor = oldFloor;
+				} else if (gadgetID == 2) {
 					// Down arrow
-					OldFloor = CurFloor;
-					getDownFloor(&CurFloor, &drawmap);
+					uint16 oldFloor = curFloor;
+					bool drawmap = getDownFloor(&curFloor);
 
 					if (drawmap) {
 						_graphics->fade(false, 0);
-						drawMap(CurRoom, CurMsg, CurFloor, false, false);
+						drawMap(curRoom, curMsg, curFloor, false, false);
 						_graphics->fade(true, 0);
 					} else
-						CurFloor = OldFloor;
+						curFloor = oldFloor;
 				}
-			} else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) {
-				if ((CurFloor == kFloorLower) && (MouseX >= mapScaleX(538)) && (MouseY >= mapScaleY(277))
-					  && (MouseX <= mapScaleX(633)) && (MouseY <= mapScaleY(352))
+			} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) {
+				if ((curFloor == kFloorLower) && (mouseX >= mapScaleX(538)) && (mouseY >= mapScaleY(277))
+					  && (mouseX <= mapScaleX(633)) && (mouseY <= mapScaleY(352))
 					  && onFloor(kFloorSurMaze)) {
-					CurFloor = kFloorSurMaze;
+					curFloor = kFloorSurMaze;
 
 					_graphics->fade(false, 0);
-					drawMap(CurRoom, CurMsg, CurFloor, false, false);
+					drawMap(curRoom, curMsg, curFloor, false, false);
 					_graphics->fade(true, 0);
-				} else if ((CurFloor == kFloorMiddle) && (MouseX >= mapScaleX(358)) && (MouseY >= mapScaleY(71))
-							  && (MouseX <= mapScaleX(452)) && (MouseY <= mapScaleY(147))
+				} else if ((curFloor == kFloorMiddle) && (mouseX >= mapScaleX(358)) && (mouseY >= mapScaleY(71))
+							  && (mouseX <= mapScaleX(452)) && (mouseY <= mapScaleY(147))
 							  && onFloor(kFloorCarnival)) {
-					CurFloor = kFloorCarnival;
+					curFloor = kFloorCarnival;
 
 					_graphics->fade(false, 0);
-					drawMap(CurRoom, CurMsg, CurFloor, false, false);
+					drawMap(curRoom, curMsg, curFloor, false, false);
 					_graphics->fade(true, 0);
-				} else if ((CurFloor == kFloorMiddle) && (MouseX >= mapScaleX(557)) && (MouseY >= mapScaleY(325))
-						  && (MouseX <= mapScaleX(653)) && (MouseY <= mapScaleY(401))
+				} else if ((curFloor == kFloorMiddle) && (mouseX >= mapScaleX(557)) && (mouseY >= mapScaleY(325))
+						  && (mouseX <= mapScaleX(653)) && (mouseY <= mapScaleY(401))
 						  && onFloor(kFloorMedMaze)) {
-					CurFloor = kFloorMedMaze;
+					curFloor = kFloorMedMaze;
 
 					_graphics->fade(false, 0);
-					drawMap(CurRoom, CurMsg, CurFloor, false, false);
+					drawMap(curRoom, curMsg, curFloor, false, false);
 					_graphics->fade(true, 0);
-				} else if ((CurFloor == kFloorUpper) && (MouseX >= mapScaleX(524)) && (MouseY >=  mapScaleY(97))
-						  && (MouseX <= mapScaleX(645)) && (MouseY <= mapScaleY(207))
+				} else if ((curFloor == kFloorUpper) && (mouseX >= mapScaleX(524)) && (mouseY >=  mapScaleY(97))
+						  && (mouseX <= mapScaleX(645)) && (mouseY <= mapScaleY(207))
 						  && onFloor(kFloorHedgeMaze)) {
-					CurFloor = kFloorHedgeMaze;
+					curFloor = kFloorHedgeMaze;
 
 					_graphics->fade(false, 0);
-					drawMap(CurRoom, CurMsg, CurFloor, false, false);
+					drawMap(curRoom, curMsg, curFloor, false, false);
 					_graphics->fade(true, 0);
-				} else if (MouseX > mapScaleX(314)) {
-					OldMsg = CurMsg;
+				} else if (mouseX > mapScaleX(314)) {
+					uint16 oldMsg = curMsg;
+					uint16 x1, y1, x2, y2;
 
 					for (uint16 i = 1; i <= MaxRooms; i++) {
 						roomCoords(i, &x1, &y1, &x2, &y2);
 
-						if ((Maps[i].PageNumber == CurFloor)
+						if ((Maps[i].PageNumber == curFloor)
 							  && _roomsFound->in(i)
-							  && (MouseX >= x1) && (MouseX <= x2)
-							  && (MouseY >= y1) && (MouseY <= y2)) {
-							CurMsg = i;
+							  && (mouseX >= x1) && (mouseX <= x2)
+							  && (mouseY >= y1) && (mouseY <= y2)) {
+							curMsg = i;
 						}
 					}
 
-					if (OldMsg != CurMsg) {
-						if (_rooms[CurMsg]._roomMsg == nullptr)
-							_resource->readViews(CurMsg);
+					if (oldMsg != curMsg) {
+						if (_rooms[curMsg]._roomMsg == nullptr)
+							_resource->readViews(curMsg);
 
-						if ((sptr = _rooms[CurMsg]._roomMsg)) {
+						char *sptr;
+						if ((sptr = _rooms[curMsg]._roomMsg)) {
 							_event->mouseHide();
 							_graphics->setAPen(3);
 							_graphics->rectFillScaled(13, 148, 135, 186);
 							_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr);
 
-							if (Maps[OldMsg].PageNumber == CurFloor)
-								drawRoomMap(OldMsg, (bool)(OldMsg == CurRoom));
+							if (Maps[oldMsg].PageNumber == curFloor)
+								drawRoomMap(oldMsg, (bool)(oldMsg == curRoom));
 
-							roomCoords(CurMsg, &x1, &y1, &x2, &y2);
+							roomCoords(curMsg, &x1, &y1, &x2, &y2);
 							x1 = (x1 + x2) / 2;
 							y1 = (y1 + y2) / 2;
 
-							if ((CurMsg != CurRoom) && (Maps[CurMsg].PageNumber == CurFloor)) {
+							if ((curMsg != curRoom) && (Maps[curMsg].PageNumber == curFloor)) {
 								_graphics->setAPen(1);
 								_graphics->rectFill(x1 - 1, y1, x1, y1);
 							}
@@ -618,15 +612,15 @@ void LabEngine::processMap(uint16 CurRoom) {
 /**
  * Does the map processing.
  */
-void LabEngine::doMap(uint16 CurRoom) {
-	static uint16 AmigaMapPalette[] = {
+void LabEngine::doMap(uint16 curRoom) {
+	static uint16 amigaMapPalette[] = {
 		0x0BA8, 0x0C11, 0x0A74, 0x0076,
 		0x0A96, 0x0DCB, 0x0CCA, 0x0222,
 		0x0444, 0x0555, 0x0777, 0x0999,
 		0x0AAA, 0x0ED0, 0x0EEE, 0x0694
 	};
 
-	_graphics->FadePalette = AmigaMapPalette;
+	_graphics->FadePalette = amigaMapPalette;
 
 	_music->updateMusic();
 	loadMapData();
@@ -642,10 +636,10 @@ void LabEngine::doMap(uint16 CurRoom) {
 		XMark = MapWest;
 
 	_event->attachGadgetList(&_mapGadgetList);
-	drawMap(CurRoom, CurRoom, Maps[CurRoom].PageNumber, false, true);
+	drawMap(curRoom, curRoom, Maps[curRoom].PageNumber, false, true);
 	_event->mouseShow();
 	_graphics->screenUpdate();
-	processMap(CurRoom);
+	processMap(curRoom);
 	_event->attachGadgetList(NULL);
 	_graphics->fade(false, 0);
 	_graphics->blackAllScreen();


Commit: 0af299d3c78d59de20fe5ad41169f755fda297f4
    https://github.com/scummvm/scummvm/commit/0af299d3c78d59de20fe5ad41169f755fda297f4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:33:58+01:00

Commit Message:
LAB: Move saveRestoreGame() to saveload.cpp

Changed paths:
    engines/lab/lab.h
    engines/lab/savegame.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index ac27c94..3e545cc 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -70,6 +70,8 @@ enum GameFeatures {
 #define UPSCROLL       3
 #define DOWNSCROLL     4
 
+#define QUARTERNUM  30
+
 typedef Common::List<Gadget *> GadgetList;
 
 struct CrumbData {
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 1e2c8af..0f0c772 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -28,6 +28,11 @@
  *
  */
 
+#include "common/translation.h"
+
+#include "gui/message.h"
+#include "gui/saveload.h"
+
 #include "graphics/thumbnail.h"
 #include "engines/savestate.h"
 
@@ -35,9 +40,12 @@
 
 #include "lab/dispman.h"
 #include "lab/labsets.h"
+#include "lab/music.h"
+#include "lab/processroom.h"
 #include "lab/savegame.h"
 
 namespace Lab {
+
 #define SAVEGAME_ID       MKTAG('L', 'O', 'T', 'S')
 #define SAVEGAME_VERSION  1
 
@@ -216,5 +224,46 @@ bool loadGame(uint16 *Direction, uint16 *Quarters, int slot) {
 	return true;
 }
 
+bool LabEngine::saveRestoreGame() {
+	bool isOK = false;
+
+	//g_lab->showMainMenu();
+
+	// The original had one screen for saving/loading. We have two.
+	// Ask the user which screen to use.
+	GUI::MessageDialog saveOrLoad(_("Would you like to save or restore a game?"), _("Save"), _("Restore"));
+
+	int choice = saveOrLoad.runModal();
+	if (choice == GUI::kMessageOK) {
+		// Save
+		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
+		int slot = dialog->runModalWithCurrentTarget();
+		if (slot >= 0) {
+			Common::String desc = dialog->getResultString();
+
+			if (desc.empty()) {
+				// create our own description for the saved game, the user didn't enter it
+				desc = dialog->createDefaultSaveDescription(slot);
+			}
+
+			isOK = saveGame(_direction, _inventory[QUARTERNUM]._many, slot, desc);
+		}
+	} else {
+		// Restore
+		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
+		int slot = dialog->runModalWithCurrentTarget();
+		if (slot >= 0) {
+			isOK = loadGame(&_direction, &(_inventory[QUARTERNUM]._many), slot);
+			if (isOK)
+				_music->resetMusic();
+		}
+	}
+
+	_alternate = false;
+	_mainDisplay = true;
+	_graphics->screenUpdate();
+
+	return isOK;
+}
 
 } // End of namespace Lab
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 8bb57ad..63b8109 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -28,11 +28,6 @@
  *
  */
 
-#include "common/translation.h"
-
-#include "gui/message.h"
-#include "gui/saveload.h"
-
 #include "lab/lab.h"
 
 #include "lab/anim.h"
@@ -44,7 +39,6 @@
 #include "lab/music.h"
 #include "lab/processroom.h"
 #include "lab/resource.h"
-#include "lab/savegame.h"
 #include "lab/utils.h"
 
 namespace Lab {
@@ -71,7 +65,6 @@ Image *MonButton;
 #define DIRTY       175
 #define NONEWS      135
 #define NOCLEAN     152
-#define QUARTERNUM  30
 
 
 static byte *loadBackPict(const char *fileName, bool tomem) {
@@ -385,48 +378,6 @@ void LabEngine::doJournal() {
 	_graphics->blackScreen();
 }
 
-bool LabEngine::saveRestoreGame() {
-	bool isOK = false;
-
-	//g_lab->showMainMenu();
-
-	// The original had one screen for saving/loading. We have two.
-	// Ask the user which screen to use.
-	GUI::MessageDialog saveOrLoad(_("Would you like to save or restore a game?"), _("Save"), _("Restore"));
-
-	int choice = saveOrLoad.runModal();
-	if (choice == GUI::kMessageOK) {
-		// Save
-		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
-		int slot = dialog->runModalWithCurrentTarget();
-		if (slot >= 0) {
-			Common::String desc = dialog->getResultString();
-
-			if (desc.empty()) {
-				// create our own description for the saved game, the user didn't enter it
-				desc = dialog->createDefaultSaveDescription(slot);
-			}
-
-			isOK = saveGame(_direction, _inventory[QUARTERNUM]._many, slot, desc);
-		}
-	} else {
-		// Restore
-		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
-		int slot = dialog->runModalWithCurrentTarget();
-		if (slot >= 0) {
-			isOK = loadGame(&_direction, &(_inventory[QUARTERNUM]._many), slot);
-			if (isOK)
-				_music->resetMusic();
-		}
-	}
-
-	_alternate = false;
-	_mainDisplay = true;
-	_graphics->screenUpdate();
-
-	return isOK;
-}
-
 /**
  * Draws the text for the monitor.
  */


Commit: 199fa254f9be4d7cb4395b871755557024926b9d
    https://github.com/scummvm/scummvm/commit/199fa254f9be4d7cb4395b871755557024926b9d
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:59+01:00

Commit Message:
LAB: Rename CloseDataPtr pointers, some refactoring

Changed paths:
    engines/lab/dispman.h
    engines/lab/engine.cpp
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/processroom.cpp
    engines/lab/processroom.h
    engines/lab/resource.cpp
    engines/lab/savegame.cpp
    engines/lab/special.cpp
    engines/lab/transitions.cpp
    engines/lab/utils.cpp
    engines/lab/utils.h



diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index dbeeefc..5b6217b 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -79,8 +79,8 @@ public:
 	void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem);
 	void doScrollWipe(char *filename);
 	void doScrollBounce();
-	void doTransWipe(CloseDataPtr *cPtr, char *filename);
-	void doTransition(TransitionType transitionType, CloseDataPtr *cPtr, char *filename);
+	void doTransWipe(CloseDataPtr *closePtrList, char *filename);
+	void doTransition(TransitionType transitionType, CloseDataPtr *closePtrList, char *filename);
 	void blackScreen();
 	void whiteScreen();
 	void blackAllScreen();
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 0b353b5..5f6f9f9 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -164,7 +164,7 @@ void LabEngine::eatMessages() {
  * Checks whether the close up is one of the special case closeups.
  */
 bool LabEngine::doCloseUp(CloseDataPtr closePtr) {
-	if (closePtr == NULL)
+	if (!closePtr)
 		return false;
 
 	int monltmargin, monrtmargin, montopmargin, lutertmargin;
@@ -253,7 +253,7 @@ const char *LabEngine::getInvName(uint16 curInv) {
  */
 void LabEngine::interfaceOff() {
 	if (!_interfaceOff) {
-		_event->attachGadgetList(NULL);
+		_event->attachGadgetList(nullptr);
 		_event->mouseHide();
 		_interfaceOff = true;
 	}
@@ -286,10 +286,10 @@ bool LabEngine::doUse(uint16 curInv) {
 		interfaceOff();
 		_anim->stopDiff();
 		_curFileName = " ";
-		_cptr = NULL;
+		_closeDataPtr = nullptr;
 		doMap(_roomNum);
 		_graphics->setPalette(initcolors, 8);
-		_graphics->drawMessage(NULL);
+		_graphics->drawMessage(nullptr);
 		_graphics->drawPanel();
 	} else if (curInv == JOURNALNUM) {
 		// LAB: Labyrinth specific
@@ -297,10 +297,10 @@ bool LabEngine::doUse(uint16 curInv) {
 		interfaceOff();
 		_anim->stopDiff();
 		_curFileName = " ";
-		_cptr = NULL;
+		_closeDataPtr = nullptr;
 		doJournal();
 		_graphics->drawPanel();
-		_graphics->drawMessage(NULL);
+		_graphics->drawMessage(nullptr);
 	} else if (curInv == LAMPNUM) {
 		// LAB: Labyrinth specific
 		interfaceOff();
@@ -400,7 +400,7 @@ void LabEngine::mainGameLoop() {
 
 	_graphics->setPalette(initcolors, 8);
 
-	_cptr    = NULL;
+	_closeDataPtr = nullptr;
 	_roomNum = 1;
 	_direction = NORTH;
 
@@ -434,16 +434,15 @@ void LabEngine::mainGameLoop() {
 			_music->resumeBackMusic();
 
 			// Sees what kind of close up we're in and does the appropriate stuff, if any.
-			if (doCloseUp(_cptr)) {
-				_cptr = NULL;
-
+			if (doCloseUp(_closeDataPtr)) {
+				_closeDataPtr = nullptr;
 				mayShowCrumbIndicator();
 				_graphics->screenUpdate();
 			}
 
 			// Sets the current picture properly on the screen
 			if (_mainDisplay)
-				_nextFileName = getPictName(&_cptr);
+				_nextFileName = getPictName(&_closeDataPtr);
 
 			if (_noUpdateDiff) {
 				// Potentially entered another room
@@ -458,21 +457,21 @@ void LabEngine::mainGameLoop() {
 				_roomsFound->inclElement(_roomNum);
 				_curFileName = _nextFileName;
 
-				if (_cptr) {
-					if ((_cptr->_closeUpType == SPECIALLOCK) && _mainDisplay)
+				if (_closeDataPtr) {
+					if ((_closeDataPtr->_closeUpType == SPECIALLOCK) && _mainDisplay)
 						// LAB: Labyrinth specific code
 						showCombination(_curFileName);
-					else if (((_cptr->_closeUpType == SPECIALBRICK)  ||
-								  (_cptr->_closeUpType == SPECIALBRICKNOMOUSE)) &&
+					else if (((_closeDataPtr->_closeUpType == SPECIALBRICK)  ||
+								  (_closeDataPtr->_closeUpType == SPECIALBRICKNOMOUSE)) &&
 								  _mainDisplay)
 						// LAB: Labyrinth specific code
-						showTile(_curFileName, (bool)(_cptr->_closeUpType == SPECIALBRICKNOMOUSE));
+						showTile(_curFileName, (bool)(_closeDataPtr->_closeUpType == SPECIALBRICKNOMOUSE));
 					else
 						_graphics->readPict(_curFileName, false);
 				} else
 					_graphics->readPict(_curFileName, false);
 
-				drawRoomMessage(curInv, _cptr);
+				drawRoomMessage(curInv, _closeDataPtr);
 				forceDraw = false;
 
 				mayShowCrumbIndicator();
@@ -483,7 +482,7 @@ void LabEngine::mainGameLoop() {
 			}
 
 			if (forceDraw) {
-				drawRoomMessage(curInv, _cptr);
+				drawRoomMessage(curInv, _closeDataPtr);
 				forceDraw = false;
 				_graphics->screenUpdate();
 			}
@@ -494,7 +493,7 @@ void LabEngine::mainGameLoop() {
 		interfaceOn();
 		IntuiMessage *curMsg = getMsg();
 
-		if (curMsg == NULL) {
+		if (!curMsg) {
 			// Does music load and next animation frame when you've run out of messages
 			gotMessage = false;
 			_music->checkRoomMusic();
@@ -516,7 +515,7 @@ void LabEngine::mainGameLoop() {
 					gotMessage = true;
 					mayShowCrumbIndicator();
 					_graphics->screenUpdate();
-					if (!from_crumbs(GADGETUP, code, 0, _event->updateAndGetMousePos(), curInv, curMsg, forceDraw, code, actionMode))
+					if (!fromCrumbs(GADGETUP, code, 0, _event->updateAndGetMousePos(), curInv, curMsg, forceDraw, code, actionMode))
 						break;
 				}
 			}
@@ -531,7 +530,7 @@ void LabEngine::mainGameLoop() {
 			curPos.y  = curMsg->_mouseY;
 
 			_followingCrumbs = false;
-			if (!from_crumbs(curMsg->_msgClass, curMsg->_code, curMsg->_qualifier, curPos, curInv, curMsg, forceDraw, curMsg->_gadgetID, actionMode))
+			if (!fromCrumbs(curMsg->_msgClass, curMsg->_code, curMsg->_qualifier, curPos, curInv, curMsg, forceDraw, curMsg->_gadgetID, actionMode))
 				break;
 		}
 	}
@@ -557,14 +556,14 @@ void LabEngine::mainGameLoop() {
 	}
 }
 
-bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Common::Point tmpPos,
+bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Common::Point tmpPos,
 			uint16 &curInv, IntuiMessage *curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode) {
 	uint32 msgClass = tmpClass;
 	Common::Point curPos = tmpPos;
 
 	uint16 oldDirection = 0;
 	uint16 lastInv = MAPNUM;
-	CloseDataPtr hcptr = nullptr;
+	CloseDataPtr wrkClosePtr = nullptr;
 	bool doit;
 
 	_anim->_doBlack = false;
@@ -602,7 +601,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Comm
 						// Sets the correct gadget list
 						interfaceOn();
 						_graphics->drawPanel();
-						drawRoomMessage(curInv, _cptr);
+						drawRoomMessage(curInv, _closeDataPtr);
 						_graphics->screenUpdate();
 					}
 				} else {
@@ -627,7 +626,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Comm
 				_music->updateMusic();
 				curMsg = getMsg();
 
-				if (curMsg == NULL) {
+				if (!curMsg) {
 					// Does music load and next animation frame when you've run out of messages
 					_music->updateMusic();
 					_anim->diffNextFrame();
@@ -657,7 +656,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Comm
 			msgClass = DELTAMOVE;
 		} else if (code == 27) {
 			// ESC key
-			_cptr = NULL;
+			_closeDataPtr = nullptr;
 		}
 
 		eatMessages();
@@ -670,17 +669,17 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Comm
 			_graphics->_longWinInFront = false;
 			_graphics->_doNotDrawMessage = false;
 			_graphics->drawPanel();
-			drawRoomMessage(curInv, _cptr);
+			drawRoomMessage(curInv, _closeDataPtr);
 			_graphics->screenUpdate();
 		}
 	} else if ((msgClass == GADGETUP) && !_alternate) {
 		if (gadgetId <= 5) {
-			if ((actionMode == 4) && (gadgetId == 4) && (_cptr != NULL)) {
-				doMainView(&_cptr);
+			if ((actionMode == 4) && (gadgetId == 4) && _closeDataPtr) {
+				doMainView(&_closeDataPtr);
 
 				_anim->_doBlack = true;
-				hcptr = NULL;
-				_cptr = NULL;
+				wrkClosePtr = nullptr;
+				_closeDataPtr = nullptr;
 				mayShowCrumbIndicator();
 				_graphics->screenUpdate();
 			} else if (gadgetId == 5) {
@@ -700,7 +699,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Comm
 					decIncInv(&curInv, false);
 
 				_graphics->drawPanel();
-				drawRoomMessage(curInv, _cptr);
+				drawRoomMessage(curInv, _closeDataPtr);
 
 				mayShowCrumbIndicator();
 				_graphics->screenUpdate();
@@ -724,8 +723,8 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Comm
 			_graphics->screenUpdate();
 		} else if (gadgetId >= 6) {
 			// Arrow Gadgets
-			_cptr = NULL;
-			hcptr = NULL;
+			_closeDataPtr = nullptr;
+			wrkClosePtr = nullptr;
 
 			if ((gadgetId == 6) || (gadgetId == 8)) {
 				if (gadgetId == 6)
@@ -738,7 +737,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Comm
 				oldDirection = _direction;
 
 				uint16 newDir = processArrow(_direction, gadgetId - 6);
-				doTurn(_direction, newDir, &_cptr);
+				doTurn(_direction, newDir, &_closeDataPtr);
 				_anim->_doBlack = true;
 				_direction = newDir;
 				forceDraw = true;
@@ -748,7 +747,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Comm
 			} else if (gadgetId == 7) {
 				uint16 oldRoomNum = _roomNum;
 
-				if (doGoForward(&_cptr)) {
+				if (doGoForward(&_closeDataPtr)) {
 					if (oldRoomNum == _roomNum)
 						_anim->_doBlack = true;
 				} else {
@@ -825,7 +824,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Comm
 			// Sets the correct gadget list
 			interfaceOn();
 			_graphics->drawPanel();
-			drawRoomMessage(curInv, _cptr);
+			drawRoomMessage(curInv, _closeDataPtr);
 
 			_graphics->screenUpdate();
 		}
@@ -838,8 +837,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Comm
 			_curFileName = " ";
 
 			doit = !saveRestoreGame();
-			_cptr = NULL;
-
+			_closeDataPtr = nullptr;
 			_mainDisplay = true;
 
 			curInv = MAPNUM;
@@ -888,7 +886,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Comm
 			decIncInv(&curInv, true);
 			lastInv = curInv;
 			_graphics->_doNotDrawMessage = false;
-			drawRoomMessage(curInv, _cptr);
+			drawRoomMessage(curInv, _closeDataPtr);
 
 			_graphics->screenUpdate();
 		} else if (gadgetId == 4) {
@@ -896,7 +894,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Comm
 			decIncInv(&curInv, false);
 			lastInv = curInv;
 			_graphics->_doNotDrawMessage = false;
-			drawRoomMessage(curInv, _cptr);
+			drawRoomMessage(curInv, _closeDataPtr);
 
 			_graphics->screenUpdate();
 		} else if (gadgetId == 5) {
@@ -925,7 +923,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Comm
 					// Sets the correct gadget list
 					interfaceOn();
 					_graphics->drawPanel();
-					drawRoomMessage(curInv, _cptr);
+					drawRoomMessage(curInv, _closeDataPtr);
 					_graphics->screenUpdate();
 				} else {
 					_breadCrumbs[0]._roomNum = 0;
@@ -943,11 +941,11 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Comm
 
 		doit = false;
 
-		if (_cptr) {
-			if ((_cptr->_closeUpType == SPECIALLOCK) && _mainDisplay)
+		if (_closeDataPtr) {
+			if ((_closeDataPtr->_closeUpType == SPECIALLOCK) && _mainDisplay)
 				// LAB: Labyrinth specific code
 				mouseCombination(curPos);
-			else if ((_cptr->_closeUpType == SPECIALBRICK) && _mainDisplay)
+			else if ((_closeDataPtr->_closeUpType == SPECIALBRICK) && _mainDisplay)
 				mouseTile(curPos);
 			else
 				doit = true;
@@ -956,48 +954,48 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Comm
 
 
 		if (doit) {
-			hcptr = NULL;
+			wrkClosePtr = nullptr;
 			eatMessages();
 
 			if (actionMode == 0) {
 				// Take something.
-				if (doActionRule(Common::Point(curPos.x, curPos.y), actionMode, _roomNum, &_cptr))
+				if (doActionRule(Common::Point(curPos.x, curPos.y), actionMode, _roomNum, &_closeDataPtr))
 					_curFileName = _newFileName;
-				else if (takeItem(curPos.x, curPos.y, &_cptr))
+				else if (takeItem(curPos.x, curPos.y, &_closeDataPtr))
 					drawStaticMessage(kTextTakeItem);
-				else if (doActionRule(curPos, TAKEDEF - 1, _roomNum, &_cptr))
+				else if (doActionRule(curPos, TAKEDEF - 1, _roomNum, &_closeDataPtr))
 					_curFileName = _newFileName;
-				else if (doActionRule(curPos, TAKE - 1, 0, &_cptr))
+				else if (doActionRule(curPos, TAKE - 1, 0, &_closeDataPtr))
 					_curFileName = _newFileName;
 				else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 					drawStaticMessage(kTextNothing);
 			} else if ((actionMode == 1) || (actionMode == 2) || (actionMode == 3)) {
 				// Manipulate an object, Open up a "door" or Close a "door"
-				if (doActionRule(curPos, actionMode, _roomNum, &_cptr))
+				if (doActionRule(curPos, actionMode, _roomNum, &_closeDataPtr))
 					_curFileName = _newFileName;
-				else if (!doActionRule(curPos, actionMode, 0, &_cptr)) {
+				else if (!doActionRule(curPos, actionMode, 0, &_closeDataPtr)) {
 					if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 						drawStaticMessage(kTextNothing);
 				}
 			} else if (actionMode == 4) {
 				// Look at closeups
-				CloseDataPtr tempcptr = _cptr;
-				setCurClose(curPos, &tempcptr);
+				CloseDataPtr tmpClosePtr = _closeDataPtr;
+				setCurrentClose(curPos, &tmpClosePtr);
 
-				if (_cptr == tempcptr) {
+				if (_closeDataPtr == tmpClosePtr) {
 					if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 						drawStaticMessage(kTextNothing);
-				} else if (tempcptr->_graphicName) {
-					if (*(tempcptr->_graphicName)) {
+				} else if (tmpClosePtr->_graphicName) {
+					if (*(tmpClosePtr->_graphicName)) {
 						_anim->_doBlack = true;
-						_cptr = tempcptr;
+						_closeDataPtr = tmpClosePtr;
 					} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 						drawStaticMessage(kTextNothing);
 				} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 					drawStaticMessage(kTextNothing);
 			} else if ((actionMode == 5)  && _conditions->in(curInv)) {
 				// Use an item on something else
-				if (doOperateRule(curPos.x, curPos.y, curInv, &_cptr)) {
+				if (doOperateRule(curPos, curInv, &_closeDataPtr)) {
 					_curFileName = _newFileName;
 
 					if (!_conditions->in(curInv))
@@ -1011,32 +1009,32 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Comm
 		_graphics->screenUpdate();
 	} else if (msgClass == DELTAMOVE) {
 		ViewData *vptr = getViewData(_roomNum, _direction);
-		CloseDataPtr oldcptr = vptr->_closeUps;
+		CloseDataPtr oldClosePtr = vptr->_closeUps;
 
-		if (hcptr == NULL) {
-			CloseDataPtr tempcptr = _cptr;
-			setCurClose(curPos, &tempcptr);
+		if (!wrkClosePtr) {
+			CloseDataPtr tmpClosePtr = _closeDataPtr;
+			setCurrentClose(curPos, &tmpClosePtr);
 
-			if ((tempcptr == NULL) || (tempcptr == _cptr)) {
-				if (_cptr == NULL)
-					hcptr = oldcptr;
+			if (!tmpClosePtr || (tmpClosePtr == _closeDataPtr)) {
+				if (!_closeDataPtr)
+					wrkClosePtr = oldClosePtr;
 				else
-					hcptr = _cptr->_subCloseUps;
+					wrkClosePtr = _closeDataPtr->_subCloseUps;
 			} else
-				hcptr = tempcptr->_nextCloseUp;
+				wrkClosePtr = tmpClosePtr->_nextCloseUp;
 		} else
-			hcptr = hcptr->_nextCloseUp;
+			wrkClosePtr = wrkClosePtr->_nextCloseUp;
 
 
-		if (hcptr == NULL) {
-			if (_cptr == NULL)
-				hcptr = oldcptr;
+		if (!wrkClosePtr) {
+			if (!_closeDataPtr)
+				wrkClosePtr = oldClosePtr;
 			else
-				hcptr = _cptr->_subCloseUps;
+				wrkClosePtr = _closeDataPtr->_subCloseUps;
 		}
 
-		if (hcptr)
-			_event->setMousePos(Common::Point(_utils->scaleX((hcptr->x1 + hcptr->x2) / 2), _utils->scaleY((hcptr->y1 + hcptr->y2) / 2)));
+		if (wrkClosePtr)
+			_event->setMousePos(Common::Point(_utils->scaleX((wrkClosePtr->_x1 + wrkClosePtr->_x2) / 2), _utils->scaleY((wrkClosePtr->_y1 + wrkClosePtr->_y2) / 2)));
 	} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & qualifier)) {
 		eatMessages();
 		_alternate = !_alternate;
@@ -1054,7 +1052,7 @@ bool LabEngine::from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Comm
 		}
 
 		_graphics->drawPanel();
-		drawRoomMessage(curInv, _cptr);
+		drawRoomMessage(curInv, _closeDataPtr);
 
 		mayShowCrumbIndicator();
 		_graphics->screenUpdate();
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 3e545cc..a490ad7 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -164,19 +164,19 @@ public:
 private:
 	int _lastWaitTOFTicks;
 	bool _lastTooLong;
-	CloseDataPtr _cptr;
+	CloseDataPtr _closeDataPtr;
 	InventoryData *_inventory;
 	Image *_tiles[16];
 	GadgetList _journalGadgetList;
 	GadgetList _mapGadgetList;
 
 private:
-	bool from_crumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Common::Point tmpPos,
+	bool fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Common::Point tmpPos,
 			uint16 &curInv, IntuiMessage *curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode);
 
 public:
 	void waitTOF();
-	void drawRoomMessage(uint16 CurInv, CloseDataPtr cptr);
+	void drawRoomMessage(uint16 curInv, CloseDataPtr closePtr);
 	void interfaceOff();
 	void interfaceOn();
 	void decIncInv(uint16 *CurInv, bool dec);
@@ -198,17 +198,17 @@ public:
 	void doWestPaper();
 	void eatMessages();
 	void drawStaticMessage(byte index);
-	void drawDirection(CloseDataPtr lcPtr);
+	void drawDirection(CloseDataPtr closePtr);
 	int followCrumbs();
 
 	void changeVolume(int delta);
-	char *getPictName(CloseDataPtr *lcptr);
+	char *getPictName(CloseDataPtr *closePtrList);
 
 private:
 	// engine.cpp
 	void freeScreens();
 	void perFlipGadget(uint16 gadID);
-	bool doCloseUp(CloseDataPtr cptr);
+	bool doCloseUp(CloseDataPtr closePtr);
 	void mainGameLoop();
 	bool doUse(uint16 curInv);
 	void mayShowCrumbIndicator();
@@ -229,7 +229,7 @@ private:
 	bool saveRestoreGame();
 
 public:
-	void doActions(Action *aPtr, CloseDataPtr *lcptr);
+	void doActions(Action *actionList, CloseDataPtr *closePtrList);
 
 };
 
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index bc95304..6bf77c4 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -117,11 +117,11 @@ void LabEngine::loadMapData() {
 	MaxRooms = mapFile->readUint16LE();
 	Maps = new MapData[MaxRooms];	// will be freed when the user exits the map
 	for (int i = 0; i < MaxRooms; i++) {
-		Maps[i].x = mapFile->readUint16LE();
-		Maps[i].y = mapFile->readUint16LE();
-		Maps[i].PageNumber = mapFile->readUint16LE();
-		Maps[i].SpecialID = mapFile->readUint16LE();
-		Maps[i].MapFlags = mapFile->readUint32LE();
+		Maps[i]._x = mapFile->readUint16LE();
+		Maps[i]._y = mapFile->readUint16LE();
+		Maps[i]._pageNumber = mapFile->readUint16LE();
+		Maps[i]._specialID = mapFile->readUint16LE();
+		Maps[i]._mapFlags = mapFile->readUint32LE();
 	}
 
 	delete mapFile;
@@ -140,7 +140,7 @@ void LabEngine::freeMapData() {
 static void roomCoords(uint16 curRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16 *y2) {
 	Image *curRoomImg = NULL;
 
-	switch (Maps[curRoom].SpecialID) {
+	switch (Maps[curRoom]._specialID) {
 	case NORMAL:
 	case UPARROWROOM:
 	case DOWNARROWROOM:
@@ -160,8 +160,8 @@ static void roomCoords(uint16 curRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint1
 		break;
 	}
 
-	*x1 = mapScaleX(Maps[curRoom].x);
-	*y1 = mapScaleY(Maps[curRoom].y);
+	*x1 = mapScaleX(Maps[curRoom]._x);
+	*y1 = mapScaleY(Maps[curRoom]._y);
 	*x2 = *x1;
 	*y2 = *y1;
 
@@ -178,17 +178,17 @@ static void drawRoomMap(uint16 curRoom, bool drawx) {
 	uint16 x, y, xx, xy, offset;
 	uint32 flags;
 
-	x = mapScaleX(Maps[curRoom].x);
-	y = mapScaleY(Maps[curRoom].y);
-	flags = Maps[curRoom].MapFlags;
+	x = mapScaleX(Maps[curRoom]._x);
+	y = mapScaleY(Maps[curRoom]._y);
+	flags = Maps[curRoom]._mapFlags;
 
-	switch (Maps[curRoom].SpecialID) {
+	switch (Maps[curRoom]._specialID) {
 	case NORMAL:
 	case UPARROWROOM:
 	case DOWNARROWROOM:
-		if (Maps[curRoom].SpecialID == NORMAL)
+		if (Maps[curRoom]._specialID == NORMAL)
 			Room->drawImage(x, y);
-		else if (Maps[curRoom].SpecialID == DOWNARROWROOM)
+		else if (Maps[curRoom]._specialID == DOWNARROWROOM)
 			DownArrowRoom->drawImage(x, y);
 		else
 			UpArrowRoom->drawImage(x, y);
@@ -311,7 +311,7 @@ static void drawRoomMap(uint16 curRoom, bool drawx) {
  */
 static bool onFloor(uint16 flr) {
 	for (uint16 i = 1; i <= MaxRooms; i++) {
-		if ((Maps[i].PageNumber == flr) && g_lab->_roomsFound->in(i) && Maps[i].x)
+		if ((Maps[i]._pageNumber == flr) && g_lab->_roomsFound->in(i) && Maps[i]._x)
 			return true;
 	}
 
@@ -379,7 +379,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 flr, bool fadeout,
 	drawGadgetList(&_mapGadgetList);
 
 	for (uint16 i = 1; i <= MaxRooms; i++) {
-		if ((Maps[i].PageNumber == flr) && _roomsFound->in(i) && Maps[i].x) {
+		if ((Maps[i]._pageNumber == flr) && _roomsFound->in(i) && Maps[i]._x) {
 			drawRoomMap(i, (bool)(i == curRoom));
 			_music->updateMusic();
 		}
@@ -388,7 +388,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 flr, bool fadeout,
 	// Makes sure the X is drawn in corridors
 	// NOTE: this here on purpose just in case there's some weird
 	// condition, like the surreal maze where there are no rooms
-	if ((Maps[curRoom].PageNumber == flr) && _roomsFound->in(curRoom) && Maps[curRoom].x)
+	if ((Maps[curRoom]._pageNumber == flr) && _roomsFound->in(curRoom) && Maps[curRoom]._x)
 		drawRoomMap(curRoom, true);
 
 	uint16 tempfloor = flr;
@@ -452,7 +452,7 @@ void LabEngine::processMap(uint16 curRoom) {
 	uint32 place = 1;
 
 	uint16 curMsg   = curRoom;
-	uint16 curFloor = Maps[curRoom].PageNumber;
+	uint16 curFloor = Maps[curRoom]._pageNumber;
 
 	while (1) {
 		// Make sure we check the music at least after every message
@@ -567,7 +567,7 @@ void LabEngine::processMap(uint16 curRoom) {
 					for (uint16 i = 1; i <= MaxRooms; i++) {
 						roomCoords(i, &x1, &y1, &x2, &y2);
 
-						if ((Maps[i].PageNumber == curFloor)
+						if ((Maps[i]._pageNumber == curFloor)
 							  && _roomsFound->in(i)
 							  && (mouseX >= x1) && (mouseX <= x2)
 							  && (mouseY >= y1) && (mouseY <= y2)) {
@@ -586,14 +586,14 @@ void LabEngine::processMap(uint16 curRoom) {
 							_graphics->rectFillScaled(13, 148, 135, 186);
 							_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr);
 
-							if (Maps[oldMsg].PageNumber == curFloor)
+							if (Maps[oldMsg]._pageNumber == curFloor)
 								drawRoomMap(oldMsg, (bool)(oldMsg == curRoom));
 
 							roomCoords(curMsg, &x1, &y1, &x2, &y2);
 							x1 = (x1 + x2) / 2;
 							y1 = (y1 + y2) / 2;
 
-							if ((curMsg != curRoom) && (Maps[curMsg].PageNumber == curFloor)) {
+							if ((curMsg != curRoom) && (Maps[curMsg]._pageNumber == curFloor)) {
 								_graphics->setAPen(1);
 								_graphics->rectFill(x1 - 1, y1, x1, y1);
 							}
@@ -636,7 +636,7 @@ void LabEngine::doMap(uint16 curRoom) {
 		XMark = MapWest;
 
 	_event->attachGadgetList(&_mapGadgetList);
-	drawMap(curRoom, curRoom, Maps[curRoom].PageNumber, false, true);
+	drawMap(curRoom, curRoom, Maps[curRoom]._pageNumber, false, true);
 	_event->mouseShow();
 	_graphics->screenUpdate();
 	processMap(curRoom);
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 31a4cdd..be03a0d 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -45,20 +45,10 @@ namespace Lab {
 #define NOFILE         "no file"
 
 /**
- * Generates a random number.
- */
-uint16 getRandom(uint16 max) {
-	uint32 secs, micros;
-
-	g_lab->getTime(&secs, &micros);
-	return ((micros + secs) % max);
-}
-
-/**
  * Checks whether all the conditions in a condition list are met.
  */
 static bool checkConditions(int16 *condition) {
-	if (condition == NULL)
+	if (!condition)
 		return true;
 
 	if (condition[0] == 0)
@@ -97,61 +87,60 @@ ViewData *getViewData(uint16 roomNum, uint16 direction) {
 /**
  * Gets an object, if any, from the user's click on the screen.
  */
-static CloseData *getObject(uint16 x, uint16 y, CloseDataPtr lcptr) {
-	if (lcptr == NULL) {
-		lcptr = getViewData(g_lab->_roomNum, g_lab->_direction)->_closeUps;
-	} else {
-		lcptr = lcptr->_subCloseUps;
-	}
+static CloseData *getObject(Common::Point pos, CloseDataPtr closePtr) {
+	if (closePtr == nullptr)
+		closePtr = getViewData(g_lab->_roomNum, g_lab->_direction)->_closeUps;
+	else
+		closePtr = closePtr->_subCloseUps;
 
-	while (lcptr != NULL) {
-		if ((x >= g_lab->_utils->scaleX(lcptr->x1)) && (y >= g_lab->_utils->scaleY(lcptr->y1)) &&
-			  (x <= g_lab->_utils->scaleX(lcptr->x2)) && (y <= g_lab->_utils->scaleY(lcptr->y2)))
-			return lcptr;
+	while (closePtr) {
+		if ((pos.x >= g_lab->_utils->scaleX(closePtr->_x1)) && (pos.y >= g_lab->_utils->scaleY(closePtr->_y1)) &&
+			  (pos.x <= g_lab->_utils->scaleX(closePtr->_x2)) && (pos.y <= g_lab->_utils->scaleY(closePtr->_y2)))
+			return closePtr;
 
-		lcptr = lcptr->_nextCloseUp;
+		closePtr = closePtr->_nextCloseUp;
 	}
 
-	return NULL;
+	return nullptr;
 }
 
 /**
  * Goes through the list of closeups to find a match.
  * NYI: Known bug here.  If there are two objects that have closeups, and
  *      some of the closeups have the same hit boxes, then this returns the
- *      first occurence of the object with the same hit box.
+ *      first occurrence of the object with the same hit box.
  */
-static CloseDataPtr findCPtrMatch(CloseDataPtr cpmain, CloseDataPtr list) {
-	CloseDataPtr cptr;
+static CloseDataPtr findClosePtrMatch(CloseDataPtr closePtr, CloseDataPtr closePtrList) {
+	CloseDataPtr resClosePtr;
 
-	while (list) {
-		if ((cpmain->x1 == list->x1) && (cpmain->x2 == list->x2) &&
-			  (cpmain->y1 == list->y1) && (cpmain->y2 == list->y2) &&
-			  (cpmain->_depth == list->_depth))
-			return list;
+	while (closePtrList) {
+		if ((closePtr->_x1 == closePtrList->_x1) && (closePtr->_x2 == closePtrList->_x2) &&
+			  (closePtr->_y1 == closePtrList->_y1) && (closePtr->_y2 == closePtrList->_y2) &&
+			  (closePtr->_depth == closePtrList->_depth))
+			return closePtrList;
 
-		cptr = findCPtrMatch(cpmain, list->_subCloseUps);
+		resClosePtr = findClosePtrMatch(closePtr, closePtrList->_subCloseUps);
 
-		if (cptr)
-			return cptr;
+		if (resClosePtr)
+			return resClosePtr;
 		else
-			list = list->_nextCloseUp;
+			closePtrList = closePtrList->_nextCloseUp;
 	}
 
-	return NULL;
+	return nullptr;
 }
 
 /**
  * Returns the current picture name.
  */
-char *LabEngine::getPictName(CloseDataPtr *lcptr) {
-	ViewData *viewPtr = getViewData(g_lab->_roomNum, g_lab->_direction);
+char *LabEngine::getPictName(CloseDataPtr *closePtrList) {
+	ViewData *viewPtr = getViewData(_roomNum, _direction);
 
-	if (*lcptr != NULL) {
-		*lcptr = findCPtrMatch(*lcptr, viewPtr->_closeUps);
+	if (*closePtrList) {
+		*closePtrList = findClosePtrMatch(*closePtrList, viewPtr->_closeUps);
 
-		if (*lcptr)
-			return (*lcptr)->_graphicName;
+		if (*closePtrList)
+			return (*closePtrList)->_graphicName;
 	}
 
 	return viewPtr->_graphicName;
@@ -160,9 +149,9 @@ char *LabEngine::getPictName(CloseDataPtr *lcptr) {
 /**
  * Draws the current direction to the screen.
  */
-void LabEngine::drawDirection(CloseDataPtr lcptr) {
-	if (lcptr != NULL && lcptr->_message) {
-		_graphics->drawMessage(lcptr->_message);
+void LabEngine::drawDirection(CloseDataPtr closePtr) {
+	if (closePtr && closePtr->_message) {
+		_graphics->drawMessage(closePtr->_message);
 		return;
 	}
 
@@ -232,61 +221,53 @@ uint16 processArrow(uint16 curDirection, uint16 arrow) {
 /**
  * Sets the current close up data.
  */
-void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords) {
-	CloseDataPtr lcptr;
-	uint16 x1, y1, x2, y2;
+void setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, bool useAbsoluteCoords) {
+	CloseDataPtr closePtr;
 
-	if (*cptr == NULL) {
-		lcptr = getViewData(g_lab->_roomNum, g_lab->_direction)->_closeUps;
-	} else
-		lcptr = (*cptr)->_subCloseUps;
-
-	while (lcptr != NULL) {
-		if (!useAbsoluteCoords) {
-			x1 = lcptr->x1;
-			y1 = lcptr->y1;
-			x2 = lcptr->x2;
-			y2 = lcptr->y2;
-		} else {
-			x1 = g_lab->_utils->scaleX(lcptr->x1);
-			y1 = g_lab->_utils->scaleY(lcptr->y1);
-			x2 = g_lab->_utils->scaleX(lcptr->x2);
-			y2 = g_lab->_utils->scaleY(lcptr->y2);
-		}
+	if (!*closePtrList)
+		closePtr = getViewData(g_lab->_roomNum, g_lab->_direction)->_closeUps;
+	else
+		closePtr = (*closePtrList)->_subCloseUps;
+
+	Common::Rect target;
+	while (closePtr) {
+		if (!useAbsoluteCoords)
+			target = Common::Rect(closePtr->_x1, closePtr->_y1, closePtr->_x2, closePtr->_y2);
+		else
+			target = Common::Rect(g_lab->_utils->scaleX(closePtr->_x1), g_lab->_utils->scaleY(closePtr->_y1), g_lab->_utils->scaleX(closePtr->_x2), g_lab->_utils->scaleY(closePtr->_y2));
 
-		if (pos.x >= x1 && pos.y >= y1 && pos.x <= x2 && pos.y <= y2 && lcptr->_graphicName) {
-			*cptr = lcptr;
+		if (target.contains(pos) && closePtr->_graphicName) {
+			*closePtrList = closePtr;
 			return;
 		}
 
-		lcptr = lcptr->_nextCloseUp;
+		closePtr = closePtr->_nextCloseUp;
 	}
 }
 
 /**
  * Takes the currently selected item.
  */
-bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
-	CloseDataPtr lcptr;
+bool takeItem(uint16 x, uint16 y, CloseDataPtr *closePtrList) {
+	CloseDataPtr closePtr;
 
-	if (*cptr == NULL) {
-		lcptr = getViewData(g_lab->_roomNum, g_lab->_direction)->_closeUps;
-	} else if ((*cptr)->_closeUpType < 0) {
-		g_lab->_conditions->inclElement(abs((*cptr)->_closeUpType));
+	if (!*closePtrList) {
+		closePtr = getViewData(g_lab->_roomNum, g_lab->_direction)->_closeUps;
+	} else if ((*closePtrList)->_closeUpType < 0) {
+		g_lab->_conditions->inclElement(abs((*closePtrList)->_closeUpType));
 		return true;
 	} else
-		lcptr = (*cptr)->_subCloseUps;
+		closePtr = (*closePtrList)->_subCloseUps;
 
-
-	while (lcptr != NULL) {
-		if ((x >= g_lab->_utils->scaleX(lcptr->x1)) && (y >= g_lab->_utils->scaleY(lcptr->y1)) &&
-			  (x <= g_lab->_utils->scaleX(lcptr->x2)) && (y <= g_lab->_utils->scaleY(lcptr->y2)) &&
-			  (lcptr->_closeUpType < 0)) {
-			g_lab->_conditions->inclElement(abs(lcptr->_closeUpType));
+	while (closePtr) {
+		if ((x >= g_lab->_utils->scaleX(closePtr->_x1)) && (y >= g_lab->_utils->scaleY(closePtr->_y1)) &&
+			  (x <= g_lab->_utils->scaleX(closePtr->_x2)) && (y <= g_lab->_utils->scaleY(closePtr->_y2)) &&
+			  (closePtr->_closeUpType < 0)) {
+			g_lab->_conditions->inclElement(abs(closePtr->_closeUpType));
 			return true;
 		}
 
-		lcptr = lcptr->_nextCloseUp;
+		closePtr = closePtr->_nextCloseUp;
 	}
 
 	return false;
@@ -295,47 +276,47 @@ bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr) {
 /**
  * Processes the action list.
  */
-void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
-	while (aptr) {
+void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
+	while (actionList) {
 		_music->updateMusic();
 
-		switch (aptr->_actionType) {
+		switch (actionList->_actionType) {
 		case PLAYSOUND:
 			_music->_loopSoundEffect = false;
 			_music->_waitTillFinished = true;
-			_music->readMusic((char *)aptr->_data, true);
+			_music->readMusic((char *)actionList->_data, true);
 			_music->_waitTillFinished = false;
 			break;
 
 		case PLAYSOUNDB:
 			_music->_loopSoundEffect = false;
 			_music->_waitTillFinished = false;
-			_music->readMusic((char *)aptr->_data, false);
+			_music->readMusic((char *)actionList->_data, false);
 			break;
 
 		case PLAYSOUNDCONT:
 			_music->_doNotFilestopSoundEffect = true;
 			_music->_loopSoundEffect = true;
-			_music->readMusic((char *)aptr->_data, _music->_waitTillFinished);
+			_music->readMusic((char *)actionList->_data, _music->_waitTillFinished);
 			break;
 
 		case SHOWDIFF:
-			_graphics->readPict((char *)aptr->_data, true);
+			_graphics->readPict((char *)actionList->_data, true);
 			break;
 
 		case SHOWDIFFCONT:
-			_graphics->readPict((char *)aptr->_data, false);
+			_graphics->readPict((char *)actionList->_data, false);
 			break;
 
 		case LOADDIFF:
-			if (aptr->_data)
+			if (actionList->_data)
 				// Puts a file into memory
-				_graphics->loadPict((char *)aptr->_data);
+				_graphics->loadPict((char *)actionList->_data);
 
 			break;
 
 		case TRANSITION:
-			_graphics->doTransition((TransitionType)aptr->_param1, lcptr, (char *)aptr->_data);
+			_graphics->doTransition((TransitionType)actionList->_param1, closePtrList, (char *)actionList->_data);
 			break;
 
 		case NOUPDATE:
@@ -348,92 +329,93 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			break;
 
 		case SHOWCURPICT: {
-				char *test = getPictName(lcptr);
+			char *test = getPictName(closePtrList);
 
-				if (strcmp(test, _curFileName) != 0) {
-					_curFileName = test;
-					_graphics->readPict(_curFileName, true);
-				}
+			if (strcmp(test, _curFileName) != 0) {
+				_curFileName = test;
+				_graphics->readPict(_curFileName, true);
+			}
 			}
 			break;
 
 		case SETELEMENT:
-			_conditions->inclElement(aptr->_param1);
+			_conditions->inclElement(actionList->_param1);
 			break;
 
 		case UNSETELEMENT:
-			_conditions->exclElement(aptr->_param1);
+			_conditions->exclElement(actionList->_param1);
 			break;
 
 		case SHOWMESSAGE:
 			_graphics->_doNotDrawMessage = false;
 
 			if (_graphics->_longWinInFront)
-				_graphics->longDrawMessage((char *)aptr->_data);
+				_graphics->longDrawMessage((char *)actionList->_data);
 			else
-				_graphics->drawMessage((char *)aptr->_data);
+				_graphics->drawMessage((char *)actionList->_data);
 
 			_graphics->_doNotDrawMessage = true;
 			break;
 
 		case CSHOWMESSAGE:
-			if (*lcptr == NULL) {
+			if (!*closePtrList) {
 				_graphics->_doNotDrawMessage = false;
-				_graphics->drawMessage((char *)aptr->_data);
+				_graphics->drawMessage((char *)actionList->_data);
 				_graphics->_doNotDrawMessage = true;
 			}
 
 			break;
 
 		case SHOWMESSAGES: {
-				char **str = (char **)aptr->_data;
+				char **str = (char **)actionList->_data;
 				_graphics->_doNotDrawMessage = false;
-				_graphics->drawMessage(str[getRandom(aptr->_param1)]);
+				_graphics->drawMessage(str[_utils->getRandom(actionList->_param1)]);
 				_graphics->_doNotDrawMessage = true;
 			}
 			break;
 
 		case SETPOSITION:
-			if (aptr->_param1 & 0x8000) {
+			if (actionList->_param1 & 0x8000) {
 				// This is a Wyrmkeep Windows trial version, thus stop at this
 				// point, since we can't check for game payment status
-				_graphics->readPict(getPictName(lcptr), true);
-				aptr = NULL;
+				_graphics->readPict(getPictName(closePtrList), true);
+				actionList = nullptr;
 				GUI::MessageDialog trialMessage("This is the end of the trial version. You can play the full game using the original interpreter from Wyrmkeep");
 				trialMessage.runModal();
 				continue;
 			}
 
-			_roomNum   = aptr->_param1;
-			_direction = aptr->_param2 - 1;
-			*lcptr      = NULL;
+			_roomNum   = actionList->_param1;
+			_direction = actionList->_param2 - 1;
+			*closePtrList = nullptr;
 			_anim->_doBlack = true;
 			break;
 
 		case SETCLOSEUP: {
-				CloseDataPtr tlcptr = getObject(g_lab->_utils->scaleX(aptr->_param1), g_lab->_utils->scaleY(aptr->_param2), *lcptr);
+			Common::Point curPos = Common::Point(g_lab->_utils->scaleX(actionList->_param1), g_lab->_utils->scaleY(actionList->_param2));
+				CloseDataPtr tmpClosePtr = getObject(curPos, *closePtrList);
 
-				if (tlcptr)
-					*lcptr = tlcptr;
+				if (tmpClosePtr)
+					*closePtrList = tmpClosePtr;
 			}
 			break;
 
 		case MAINVIEW:
-			*lcptr = NULL;
+			*closePtrList = nullptr;
 			break;
 
 		case SUBINV:
-			if (_inventory[aptr->_param1]._many)
-				(_inventory[aptr->_param1]._many)--;
+			if (_inventory[actionList->_param1]._many)
+				(_inventory[actionList->_param1]._many)--;
 
-			if (_inventory[aptr->_param1]._many == 0)
-				_conditions->exclElement(aptr->_param1);
+			if (_inventory[actionList->_param1]._many == 0)
+				_conditions->exclElement(actionList->_param1);
 
 			break;
 
 		case ADDINV:
-			(_inventory[aptr->_param1]._many) += aptr->_param2;
-			_conditions->inclElement(aptr->_param1);
+			(_inventory[actionList->_param1]._many) += actionList->_param2;
+			_conditions->inclElement(actionList->_param1);
 			break;
 
 		case SHOWDIR:
@@ -442,8 +424,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 
 		case WAITSECS: {
 				uint32 startSecs, startMicros, curSecs, curMicros;
-
-				addCurTime(aptr->_param1, 0, &startSecs, &startMicros);
+				addCurTime(actionList->_param1, 0, &startSecs, &startMicros);
 
 				_graphics->screenUpdate();
 
@@ -467,7 +448,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			break;
 
 		case CHANGEMUSIC:
-			_music->changeMusic((const char *)aptr->_data);
+			_music->changeMusic((const char *)actionList->_data);
 			_music->setMusicReset(false);
 			break;
 
@@ -517,13 +498,13 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			break;
 
 		case SPECIALCMD:
-			if (aptr->_param1 == 0)
+			if (actionList->_param1 == 0)
 				_anim->_doBlack = true;
-			else if (aptr->_param1 == 1)
-				_anim->_doBlack = (_cptr == NULL);
-			else if (aptr->_param1 == 2)
-				_anim->_doBlack = (_cptr != NULL);
-			else if (aptr->_param1 == 5) {
+			else if (actionList->_param1 == 1)
+				_anim->_doBlack = (_closeDataPtr == nullptr);
+			else if (actionList->_param1 == 2)
+				_anim->_doBlack = (_closeDataPtr != nullptr);
+			else if (actionList->_param1 == 5) {
 				// inverse the palette
 				for (uint16 idx = (8 * 3); idx < (255 * 3); idx++)
 					_anim->_diffPalette[idx] = 255 - _anim->_diffPalette[idx];
@@ -532,18 +513,18 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 				_graphics->setPalette(_anim->_diffPalette, 256);
 				waitTOF();
 				waitTOF();
-			} else if (aptr->_param1 == 4) {
+			} else if (actionList->_param1 == 4) {
 				// white the palette
 				_graphics->whiteScreen();
 				waitTOF();
 				waitTOF();
-			} else if (aptr->_param1 == 6) {
+			} else if (actionList->_param1 == 6) {
 				// Restore the palette
 				waitTOF();
 				_graphics->setPalette(_anim->_diffPalette, 256);
 				waitTOF();
 				waitTOF();
-			} else if (aptr->_param1 == 7) {
+			} else if (actionList->_param1 == 7) {
 				// Quick pause
 				waitTOF();
 				waitTOF();
@@ -553,7 +534,7 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 			break;
 		}
 
-		aptr = aptr->_nextAction;
+		actionList = actionList->_nextAction;
 	}
 
 	if (_music->_loopSoundEffect) {
@@ -573,13 +554,13 @@ void LabEngine::doActions(Action *aptr, CloseDataPtr *lcptr) {
 /**
  * Does the work for doActionRule.
  */
-static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr lcptr, CloseDataPtr *set, bool allowDefaults) {
+static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults) {
 	action++;
 
-	if (lcptr) {
+	if (closePtr) {
 		RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;
 
-		if ((rules == NULL) && (roomNum == 0)) {
+		if (!rules && (roomNum == 0)) {
 			g_lab->_resource->readViews(roomNum);
 			rules = g_lab->_rooms[roomNum]._rules;
 		}
@@ -587,11 +568,11 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr lcptr, Clo
 		for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 			if (((*rule)->_ruleType == ACTION) &&
 				(((*rule)->_param1 == action) || (((*rule)->_param1 == 0) && allowDefaults))) {
-				if ((((*rule)->_param2 == lcptr->_closeUpType) ||
+				if ((((*rule)->_param2 == closePtr->_closeUpType) ||
 					  (((*rule)->_param2 == 0) && allowDefaults)) ||
-					  ((action == 1) && ((*rule)->_param2 == (-lcptr->_closeUpType)))) {
+					  ((action == 1) && ((*rule)->_param2 == (-closePtr->_closeUpType)))) {
 					if (checkConditions((*rule)->_condition)) {
-						g_lab->doActions((*rule)->_actionList, set);
+						g_lab->doActions((*rule)->_actionList, setCloseList);
 						return true;
 					}
 				}
@@ -605,21 +586,21 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr lcptr, Clo
 /**
  * Goes through the rules if an action is taken.
  */
-bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *lcptr) {
+bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *closePtrList) {
 	if (roomNum)
 		g_lab->_newFileName = NOFILE;
 	else
 		g_lab->_newFileName = g_lab->_curFileName;
 
-	CloseDataPtr tlcptr = getObject(pos.x, pos.y, *lcptr);
+	CloseDataPtr curClosePtr = getObject(pos, *closePtrList);
 
-	if (doActionRuleSub(action, roomNum, tlcptr, lcptr, false))
+	if (doActionRuleSub(action, roomNum, curClosePtr, closePtrList, false))
 		return true;
-	else if (doActionRuleSub(action, roomNum, *lcptr, lcptr, false))
+	else if (doActionRuleSub(action, roomNum, *closePtrList, closePtrList, false))
 		return true;
-	else if (doActionRuleSub(action, roomNum, tlcptr, lcptr, true))
+	else if (doActionRuleSub(action, roomNum, curClosePtr, closePtrList, true))
 		return true;
-	else if (doActionRuleSub(action, roomNum, *lcptr, lcptr, true))
+	else if (doActionRuleSub(action, roomNum, *closePtrList, closePtrList, true))
 		return true;
 
 	return false;
@@ -628,12 +609,12 @@ bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *
 /**
  * Does the work for doActionRule.
  */
-static bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr lcptr, CloseDataPtr *set, bool allowDefaults) {
-	if (lcptr)
-		if (lcptr->_closeUpType > 0) {
+static bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults) {
+	if (closePtr)
+		if (closePtr->_closeUpType > 0) {
 			RuleList *rules = g_lab->_rooms[roomNum]._rules;
 
-			if ((rules == NULL) && (roomNum == 0)) {
+			if (!rules && (roomNum == 0)) {
 				g_lab->_resource->readViews(roomNum);
 				rules = g_lab->_rooms[roomNum]._rules;
 			}
@@ -641,9 +622,9 @@ static bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr lcptr, C
 			for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 				if (((*rule)->_ruleType == OPERATE) &&
 					  (((*rule)->_param1 == itemNum) || (((*rule)->_param1 == 0) && allowDefaults)) &&
-						(((*rule)->_param2 == lcptr->_closeUpType) || (((*rule)->_param2 == 0) && allowDefaults))) {
+						(((*rule)->_param2 == closePtr->_closeUpType) || (((*rule)->_param2 == 0) && allowDefaults))) {
 					if (checkConditions((*rule)->_condition)) {
-						g_lab->doActions((*rule)->_actionList, set);
+						g_lab->doActions((*rule)->_actionList, setCloseList);
 						return true;
 					}
 				}
@@ -656,31 +637,28 @@ static bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr lcptr, C
 /**
  * Goes through the rules if the user tries to operate an item on an object.
  */
-bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *lcptr) {
-	CloseDataPtr tlcptr;
-
+bool doOperateRule(Common::Point pos, int16 ItemNum, CloseDataPtr *closePtrList) {
 	g_lab->_newFileName = NOFILE;
+	CloseDataPtr closePtr = getObject(pos, *closePtrList);
 
-	tlcptr = getObject(x, y, *lcptr);
-
-	if (doOperateRuleSub(ItemNum, g_lab->_roomNum, tlcptr, lcptr, false))
+	if (doOperateRuleSub(ItemNum, g_lab->_roomNum, closePtr, closePtrList, false))
 		return true;
-	else if (doOperateRuleSub(ItemNum, g_lab->_roomNum, *lcptr, lcptr, false))
+	else if (doOperateRuleSub(ItemNum, g_lab->_roomNum, *closePtrList, closePtrList, false))
 		return true;
-	else if (doOperateRuleSub(ItemNum, g_lab->_roomNum, tlcptr, lcptr, true))
+	else if (doOperateRuleSub(ItemNum, g_lab->_roomNum, closePtr, closePtrList, true))
 		return true;
-	else if (doOperateRuleSub(ItemNum, g_lab->_roomNum, *lcptr, lcptr, true))
+	else if (doOperateRuleSub(ItemNum, g_lab->_roomNum, *closePtrList, closePtrList, true))
 		return true;
 	else {
 		g_lab->_newFileName = g_lab->_curFileName;
 
-		if (doOperateRuleSub(ItemNum, 0, tlcptr, lcptr, false))
+		if (doOperateRuleSub(ItemNum, 0, closePtr, closePtrList, false))
 			return true;
-		else if (doOperateRuleSub(ItemNum, 0, *lcptr, lcptr, false))
+		else if (doOperateRuleSub(ItemNum, 0, *closePtrList, closePtrList, false))
 			return true;
-		else if (doOperateRuleSub(ItemNum, 0, tlcptr, lcptr, true))
+		else if (doOperateRuleSub(ItemNum, 0, closePtr, closePtrList, true))
 			return true;
-		else if (doOperateRuleSub(ItemNum, 0, *lcptr, lcptr, true))
+		else if (doOperateRuleSub(ItemNum, 0, *closePtrList, closePtrList, true))
 			return true;
 	}
 
@@ -690,14 +668,14 @@ bool doOperateRule(int16 x, int16 y, int16 ItemNum, CloseDataPtr *lcptr) {
 /**
  * Goes through the rules if the user tries to go forward.
  */
-bool doGoForward(CloseDataPtr *lcptr) {
+bool doGoForward(CloseDataPtr *closePtrList) {
 	RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;
 
 	for (RuleList::iterator ruleIter = rules->begin(); ruleIter != rules->end(); ++ruleIter) {
 		Rule *rule = *ruleIter;
 		if ((rule->_ruleType == GOFORWARD) && (rule->_param1 == (g_lab->_direction + 1))) {
 			if (checkConditions(rule->_condition)) {
-				g_lab->doActions(rule->_actionList, lcptr);
+				g_lab->doActions(rule->_actionList, closePtrList);
 				return true;
 			}
 		}
@@ -709,7 +687,7 @@ bool doGoForward(CloseDataPtr *lcptr) {
 /**
  * Goes through the rules if the user tries to turn.
  */
-bool doTurn(uint16 from, uint16 to, CloseDataPtr *lcptr) {
+bool doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList) {
 	from++;
 	to++;
 
@@ -720,7 +698,7 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *lcptr) {
 			  (((*rule)->_ruleType == TURNFROMTO) &&
 			  ((*rule)->_param1 == from) && ((*rule)->_param2 == to))) {
 			if (checkConditions((*rule)->_condition)) {
-				g_lab->doActions((*rule)->_actionList, lcptr);
+				g_lab->doActions((*rule)->_actionList, closePtrList);
 				return true;
 			}
 		}
@@ -732,12 +710,12 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *lcptr) {
 /**
  * Goes through the rules if the user tries to go to the main view
  */
-bool doMainView(CloseDataPtr *lcptr) {
+bool doMainView(CloseDataPtr *closePtrList) {
 	RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 		if ((*rule)->_ruleType == GOMAINVIEW) {
 			if (checkConditions((*rule)->_condition)) {
-				g_lab->doActions((*rule)->_actionList, lcptr);
+				g_lab->doActions((*rule)->_actionList, closePtrList);
 				return true;
 			}
 		}
diff --git a/engines/lab/processroom.h b/engines/lab/processroom.h
index cf2f8df..20b6946 100644
--- a/engines/lab/processroom.h
+++ b/engines/lab/processroom.h
@@ -92,7 +92,7 @@ namespace Lab {
 #endif
 
 typedef struct CloseData {
-	uint16 x1, y1, x2, y2;
+	uint16 _x1, _y1, _x2, _y2;
 	int16 _closeUpType;          // if > 0, an object.  If < 0, an item
 	uint16 _depth;               // Level of the closeup.
 	char *_graphicName;
@@ -177,8 +177,8 @@ struct InventoryData {
 #define     MULTIMAZEF3     11
 
 struct MapData {
-	uint16 x, y, PageNumber, SpecialID;
-	uint32 MapFlags;
+	uint16 _x, _y, _pageNumber, _specialID;
+	uint32 _mapFlags;
 };
 
 #if defined(WIN32)
@@ -187,15 +187,14 @@ struct MapData {
 
 bool parse(const char *inputFile);
 ViewData *getViewData(uint16 roomNum, uint16 direction);
-void drawDirection(CloseDataPtr lcptr);
 uint16 processArrow(uint16 curDirection, uint16 arrow);
-void setCurClose(Common::Point pos, CloseDataPtr *cptr, bool useAbsoluteCoords = true);
-bool takeItem(uint16 x, uint16 y, CloseDataPtr *cptr);
-bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *lcptr);
-bool doOperateRule(int16 x, int16 y, int16 itemNum, CloseDataPtr *lcptr);
-bool doGoForward(CloseDataPtr *lcptr);
-bool doTurn(uint16 from, uint16 to, CloseDataPtr *lcptr);
-bool doMainView(CloseDataPtr *lcptr);
+void setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, bool useAbsoluteCoords = true);
+bool takeItem(uint16 x, uint16 y, CloseDataPtr *closePtrList);
+bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *closePtrList);
+bool doOperateRule(Common::Point pos, int16 itemNum, CloseDataPtr *closePtrList);
+bool doGoForward(CloseDataPtr *closePtrList);
+bool doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList);
+bool doMainView(CloseDataPtr *closePtrList);
 
 } // End of namespace Lab
 
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 281f9a2..1d9a1ae 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -301,10 +301,10 @@ CloseData *Resource::readCloseUps(uint16 depth, Common::File *file) {
 				head = closeup;
 			if (prev)
 				prev->_nextCloseUp = closeup;
-			closeup->x1 = file->readUint16LE();
-			closeup->y1 = file->readUint16LE();
-			closeup->x2 = file->readUint16LE();
-			closeup->y2 = file->readUint16LE();
+			closeup->_x1 = file->readUint16LE();
+			closeup->_y1 = file->readUint16LE();
+			closeup->_x2 = file->readUint16LE();
+			closeup->_y2 = file->readUint16LE();
 			closeup->_closeUpType = file->readSint16LE();
 			closeup->_depth = depth;
 			closeup->_graphicName = readString(file);
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 0f0c772..686b537 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -131,8 +131,8 @@ bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc)
 		return false;
 
 	// Load scene pic
-	CloseDataPtr cPtr = nullptr;
-	g_lab->_graphics->readPict(g_lab->getPictName(&cPtr), true);
+	CloseDataPtr closePtr = nullptr;
+	g_lab->_graphics->readPict(g_lab->getPictName(&closePtr), true);
 
 	writeSaveGameHeader(file, desc);
 	file->writeUint16LE(g_lab->_roomNum);
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 63b8109..d015c4e 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -442,24 +442,24 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
  * Processes user input.
  */
 void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	IntuiMessage *Msg;
-	uint32 Class;
-	uint16 Qualifier, Code, MouseX, MouseY;
+	IntuiMessage *msg;
+	uint32 msgClass;
+	uint16 qualifier, code, mouseX, mouseY;
 	const char *Test = " ", *StartFileName = TextFileName;
-	CloseDataPtr startcptr = _cptr, testcptr, lastcptr[10];
+	CloseDataPtr startClosePtr = _closeDataPtr, lastClosePtr[10];
 	uint16 depth = 0;
 
-	lastcptr[0] = _cptr;
+	lastClosePtr[0] = _closeDataPtr;
 
 	while (1) {
 		if (isinteractive) {
-			if (_cptr == NULL)
-				_cptr = startcptr;
+			if (_closeDataPtr == NULL)
+				_closeDataPtr = startClosePtr;
 
-			if (_cptr == startcptr)
+			if (_closeDataPtr == startClosePtr)
 				Test = StartFileName;
 			else
-				Test = _cptr->_graphicName;
+				Test = _closeDataPtr->_graphicName;
 
 			if (strcmp(Test, TextFileName)) {
 				monitorPage      = 0;
@@ -475,42 +475,42 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 
 		// Make sure we check the music at least after every message
 		_music->updateMusic();
-		Msg = getMsg();
+		msg = getMsg();
 
-		if (Msg == NULL) {
+		if (msg == NULL) {
 			_music->updateMusic();
 		} else {
-			Class     = Msg->_msgClass;
-			Qualifier = Msg->_qualifier;
-			MouseX    = Msg->_mouseX;
-			MouseY    = Msg->_mouseY;
-			Code      = Msg->_code;
-
-			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) ||
-				  ((Class == RAWKEY) && (Code == 27)))
+			msgClass     = msg->_msgClass;
+			qualifier = msg->_qualifier;
+			mouseX    = msg->_mouseX;
+			mouseY    = msg->_mouseY;
+			code      = msg->_code;
+
+			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & qualifier)) ||
+				  ((msgClass == RAWKEY) && (code == 27)))
 				return;
 
-			else if ((Class == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & Qualifier)) {
-				if ((MouseY >= g_lab->_utils->vgaScaleY(171)) && (MouseY <= g_lab->_utils->vgaScaleY(200))) {
-					if ((MouseX >= g_lab->_utils->vgaScaleX(259)) && (MouseX <= g_lab->_utils->vgaScaleX(289))) {
+			else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) {
+				if ((mouseY >= g_lab->_utils->vgaScaleY(171)) && (mouseY <= g_lab->_utils->vgaScaleY(200))) {
+					if ((mouseX >= g_lab->_utils->vgaScaleX(259)) && (mouseX <= g_lab->_utils->vgaScaleX(289))) {
 						if (!lastpage) {
 							monitorPage += 1;
 							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
 						}
-					} else if ((MouseX >= g_lab->_utils->vgaScaleX(0)) && (MouseX <= g_lab->_utils->vgaScaleX(31))) {
+					} else if ((mouseX >= g_lab->_utils->vgaScaleX(0)) && (mouseX <= g_lab->_utils->vgaScaleX(31))) {
 						return;
-					} else if ((MouseX >= g_lab->_utils->vgaScaleX(290)) && (MouseX <= g_lab->_utils->vgaScaleX(320))) {
+					} else if ((mouseX >= g_lab->_utils->vgaScaleX(290)) && (mouseX <= g_lab->_utils->vgaScaleX(320))) {
 						if (monitorPage >= 1) {
 							monitorPage -= 1;
 							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
 						}
-					} else if ((MouseX >= g_lab->_utils->vgaScaleX(31)) && (MouseX <= g_lab->_utils->vgaScaleX(59))) {
+					} else if ((mouseX >= g_lab->_utils->vgaScaleX(31)) && (mouseX <= g_lab->_utils->vgaScaleX(59))) {
 						if (isinteractive) {
 							monitorPage = 0;
 
 							if (depth) {
 								depth--;
-								_cptr = lastcptr[depth];
+								_closeDataPtr = lastClosePtr[depth];
 							}
 						} else if (monitorPage > 0) {
 							monitorPage = 0;
@@ -518,13 +518,13 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 						}
 					}
 				} else if (isinteractive) {
-					testcptr = _cptr;
-					MouseY = 64 + (MouseY / MonGadHeight) * 42;
-					MouseX = 101;
-					setCurClose(Common::Point(MouseX, MouseY), &_cptr, false);
+					CloseDataPtr tmpClosePtr = _closeDataPtr;
+					mouseY = 64 + (mouseY / MonGadHeight) * 42;
+					mouseX = 101;
+					setCurrentClose(Common::Point(mouseX, mouseY), &_closeDataPtr, false);
 
-					if (testcptr != _cptr) {
-						lastcptr[depth] = testcptr;
+					if (tmpClosePtr != _closeDataPtr) {
+						lastClosePtr[depth] = tmpClosePtr;
 						depth++;
 					}
 				}
diff --git a/engines/lab/transitions.cpp b/engines/lab/transitions.cpp
index df3c777..d70da5c 100644
--- a/engines/lab/transitions.cpp
+++ b/engines/lab/transitions.cpp
@@ -241,7 +241,7 @@ void DisplayMan::doScrollBounce() {
 /**
  * Does the transporter wipe.
  */
-void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
+void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, char *filename) {
 	uint16 lastY, curY, linesdone = 0, lineslast;
 	Image imSource, imDest;
 
@@ -277,11 +277,11 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 	}	// for j
 
 	if (filename == NULL)
-		_vm->_curFileName = _vm->getPictName(cPtr);
+		_vm->_curFileName = _vm->getPictName(closePtrList);
 	else if (filename[0] > ' ')
 		_vm->_curFileName = filename;
 	else
-		_vm->_curFileName = _vm->getPictName(cPtr);
+		_vm->_curFileName = _vm->getPictName(closePtrList);
 
 	byte *BitMapMem = readPictToMem(_vm->_curFileName, _screenWidth, lastY + 5);
 	setPalette(_vm->_anim->_diffPalette, 256);
@@ -324,11 +324,11 @@ void DisplayMan::doTransWipe(CloseDataPtr *cPtr, char *filename) {
 /**
  * Does a certain number of pre-programmed wipes.
  */
-void DisplayMan::doTransition(TransitionType transitionType, CloseDataPtr *cPtr, char *filename) {
+void DisplayMan::doTransition(TransitionType transitionType, CloseDataPtr *closePtrList, char *filename) {
 	switch (transitionType) {
 	case kTransitionWipe:
 	case kTransitionTransporter:
-		doTransWipe(cPtr, filename);
+		doTransWipe(closePtrList, filename);
 		break;
 	case kTransitionScrollWipe:
 		doScrollWipe(filename);
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index b552a40..c7f19cf 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -411,4 +411,14 @@ void Utils::unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesPerRo
 void Utils::setBytesPerRow(int num) {
 	_dataBytesPerRow = num;
 }
+
+/**
+ * Generates a random number.
+ */
+uint16 Utils::getRandom(uint16 max) {
+	uint32 secs, micros;
+
+	g_lab->getTime(&secs, &micros);
+	return ((micros + secs) % max);
+}
 } // End of namespace Lab
diff --git a/engines/lab/utils.h b/engines/lab/utils.h
index 4414736..59a0d4b 100644
--- a/engines/lab/utils.h
+++ b/engines/lab/utils.h
@@ -57,6 +57,7 @@ public:
 	void runLengthDecode(byte *dest, byte *source);
 	void VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow);
 	void setBytesPerRow(int num);
+	uint16 getRandom(uint16 max);
 };
 
 


Commit: 72c08cfc8c3d9f19e21592206995578b90345f8a
    https://github.com/scummvm/scummvm/commit/72c08cfc8c3d9f19e21592206995578b90345f8a
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:59+01:00

Commit Message:
LAB: Move mapScale functions to the utility class

Changed paths:
    engines/lab/map.cpp
    engines/lab/utils.cpp
    engines/lab/utils.h



diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 6bf77c4..544627c 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -64,20 +64,6 @@ enum MapFloor {
 	kFloorCarnival
 };
 
-static uint16 mapScaleX(uint16 x) {
-	if (g_lab->_isHiRes)
-		return (x - 45);
-	else
-		return ((x - 45) >> 1);
-}
-
-static uint16 mapScaleY(uint16 y) {
-	if (g_lab->_isHiRes)
-		return y;
-	else
-		return ((y - 35) >> 1) - (y >> 6);
-}
-
 /**
  * Loads in the map data.
  */
@@ -160,8 +146,8 @@ static void roomCoords(uint16 curRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint1
 		break;
 	}
 
-	*x1 = mapScaleX(Maps[curRoom]._x);
-	*y1 = mapScaleY(Maps[curRoom]._y);
+	*x1 = g_lab->_utils->mapScaleX(Maps[curRoom]._x);
+	*y1 = g_lab->_utils->mapScaleY(Maps[curRoom]._y);
 	*x2 = *x1;
 	*y2 = *y1;
 
@@ -178,8 +164,8 @@ static void drawRoomMap(uint16 curRoom, bool drawx) {
 	uint16 x, y, xx, xy, offset;
 	uint32 flags;
 
-	x = mapScaleX(Maps[curRoom]._x);
-	y = mapScaleY(Maps[curRoom]._y);
+	x = g_lab->_utils->mapScaleX(Maps[curRoom]._x);
+	y = g_lab->_utils->mapScaleY(Maps[curRoom]._y);
 	flags = Maps[curRoom]._mapFlags;
 
 	switch (Maps[curRoom]._specialID) {
@@ -416,19 +402,19 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 flr, bool fadeout,
 	// Labyrinth specific code
 	if (flr == kFloorLower) {
 		if (onFloor(kFloorSurMaze))
-			Maze->drawImage(mapScaleX(538), mapScaleY(277));
+			Maze->drawImage(_utils->mapScaleX(538), _utils->mapScaleY(277));
 	} else if (flr == kFloorMiddle) {
 		if (onFloor(kFloorCarnival))
-			Maze->drawImage(mapScaleX(358), mapScaleY(72));
+			Maze->drawImage(_utils->mapScaleX(358), _utils->mapScaleY(72));
 
 		if (onFloor(kFloorMedMaze))
-			Maze->drawImage(mapScaleX(557), mapScaleY(325));
+			Maze->drawImage(_utils->mapScaleX(557), _utils->mapScaleY(325));
 	} else if (flr == kFloorUpper) {
 		if (onFloor(kFloorHedgeMaze))
-			HugeMaze->drawImage(mapScaleX(524), mapScaleY(97));
+			HugeMaze->drawImage(_utils->mapScaleX(524), _utils->mapScaleY(97));
 	} else if (flr == kFloorSurMaze) {
 		sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str();
-		_graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, mapScaleX(360), 0, mapScaleX(660), mapScaleY(450), sptr);
+		_graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, _utils->mapScaleX(360), 0, _utils->mapScaleX(660), _utils->mapScaleY(450), sptr);
 	}
 
 	if (flr >= kFloorLower && flr <= kFloorCarnival) {
@@ -528,39 +514,39 @@ void LabEngine::processMap(uint16 curRoom) {
 						curFloor = oldFloor;
 				}
 			} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) {
-				if ((curFloor == kFloorLower) && (mouseX >= mapScaleX(538)) && (mouseY >= mapScaleY(277))
-					  && (mouseX <= mapScaleX(633)) && (mouseY <= mapScaleY(352))
+				if ((curFloor == kFloorLower) && (mouseX >= _utils->mapScaleX(538)) && (mouseY >= _utils->mapScaleY(277))
+					  && (mouseX <= _utils->mapScaleX(633)) && (mouseY <= _utils->mapScaleY(352))
 					  && onFloor(kFloorSurMaze)) {
 					curFloor = kFloorSurMaze;
 
 					_graphics->fade(false, 0);
 					drawMap(curRoom, curMsg, curFloor, false, false);
 					_graphics->fade(true, 0);
-				} else if ((curFloor == kFloorMiddle) && (mouseX >= mapScaleX(358)) && (mouseY >= mapScaleY(71))
-							  && (mouseX <= mapScaleX(452)) && (mouseY <= mapScaleY(147))
+				} else if ((curFloor == kFloorMiddle) && (mouseX >= _utils->mapScaleX(358)) && (mouseY >= _utils->mapScaleY(71))
+							  && (mouseX <= _utils->mapScaleX(452)) && (mouseY <= _utils->mapScaleY(147))
 							  && onFloor(kFloorCarnival)) {
 					curFloor = kFloorCarnival;
 
 					_graphics->fade(false, 0);
 					drawMap(curRoom, curMsg, curFloor, false, false);
 					_graphics->fade(true, 0);
-				} else if ((curFloor == kFloorMiddle) && (mouseX >= mapScaleX(557)) && (mouseY >= mapScaleY(325))
-						  && (mouseX <= mapScaleX(653)) && (mouseY <= mapScaleY(401))
+				} else if ((curFloor == kFloorMiddle) && (mouseX >= _utils->mapScaleX(557)) && (mouseY >= _utils->mapScaleY(325))
+						  && (mouseX <= _utils->mapScaleX(653)) && (mouseY <= _utils->mapScaleY(401))
 						  && onFloor(kFloorMedMaze)) {
 					curFloor = kFloorMedMaze;
 
 					_graphics->fade(false, 0);
 					drawMap(curRoom, curMsg, curFloor, false, false);
 					_graphics->fade(true, 0);
-				} else if ((curFloor == kFloorUpper) && (mouseX >= mapScaleX(524)) && (mouseY >=  mapScaleY(97))
-						  && (mouseX <= mapScaleX(645)) && (mouseY <= mapScaleY(207))
+				} else if ((curFloor == kFloorUpper) && (mouseX >= _utils->mapScaleX(524)) && (mouseY >=  _utils->mapScaleY(97))
+						  && (mouseX <= _utils->mapScaleX(645)) && (mouseY <= _utils->mapScaleY(207))
 						  && onFloor(kFloorHedgeMaze)) {
 					curFloor = kFloorHedgeMaze;
 
 					_graphics->fade(false, 0);
 					drawMap(curRoom, curMsg, curFloor, false, false);
 					_graphics->fade(true, 0);
-				} else if (mouseX > mapScaleX(314)) {
+				} else if (mouseX > _utils->mapScaleX(314)) {
 					uint16 oldMsg = curMsg;
 					uint16 x1, y1, x2, y2;
 
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index c7f19cf..a9429de 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -418,7 +418,22 @@ void Utils::setBytesPerRow(int num) {
 uint16 Utils::getRandom(uint16 max) {
 	uint32 secs, micros;
 
-	g_lab->getTime(&secs, &micros);
+	_vm->getTime(&secs, &micros);
 	return ((micros + secs) % max);
 }
+
+uint16 Utils::mapScaleX(uint16 x) {
+	if (_vm->_isHiRes)
+		return (x - 45);
+	else
+		return ((x - 45) >> 1);
+}
+
+uint16 Utils::mapScaleY(uint16 y) {
+	if (_vm->_isHiRes)
+		return y;
+	else
+		return ((y - 35) >> 1) - (y >> 6);
+}
+
 } // End of namespace Lab
diff --git a/engines/lab/utils.h b/engines/lab/utils.h
index 59a0d4b..ac036ad 100644
--- a/engines/lab/utils.h
+++ b/engines/lab/utils.h
@@ -52,6 +52,8 @@ public:
 	int16 vgaScaleX(int16 x);
 	int16 vgaScaleY(int16 y);
 	uint16 svgaCord(uint16 cord);
+	uint16 mapScaleX(uint16 x);
+	uint16 mapScaleY(uint16 y);
 	Common::Point vgaUnscale(Common::Point pos);
 	void unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesperrow, bool isV);
 	void runLengthDecode(byte *dest, byte *source);


Commit: 1e9ee6ef4a6fca9f268cf642a239f88a5cc1ec84
    https://github.com/scummvm/scummvm/commit/1e9ee6ef4a6fca9f268cf642a239f88a5cc1ec84
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:59+01:00

Commit Message:
LAB: Some refactoring and renaming in map.cpp

Changed paths:
    engines/lab/lab.h
    engines/lab/map.cpp



diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index a490ad7..8f3e00f 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -225,8 +225,8 @@ private:
 	void doCombination();
 	void showCombination(const char *filename);
 	void initTilePuzzle();
-
 	bool saveRestoreGame();
+	Common::Rect roomCoords(uint16 curRoom);
 
 public:
 	void doActions(Action *actionList, CloseDataPtr *closePtrList);
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 544627c..2bf261d 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -123,8 +123,8 @@ void LabEngine::freeMapData() {
 /**
  * Figures out what a room's coordinates should be.
  */
-static void roomCoords(uint16 curRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint16 *y2) {
-	Image *curRoomImg = NULL;
+Common::Rect LabEngine::roomCoords(uint16 curRoom) {
+	Image *curRoomImg = nullptr;
 
 	switch (Maps[curRoom]._specialID) {
 	case NORMAL:
@@ -146,27 +146,28 @@ static void roomCoords(uint16 curRoom, uint16 *x1, uint16 *y1, uint16 *x2, uint1
 		break;
 	}
 
-	*x1 = g_lab->_utils->mapScaleX(Maps[curRoom]._x);
-	*y1 = g_lab->_utils->mapScaleY(Maps[curRoom]._y);
-	*x2 = *x1;
-	*y2 = *y1;
+	int x1 = _utils->mapScaleX(Maps[curRoom]._x);
+	int y1 = _utils->mapScaleY(Maps[curRoom]._y);
+	int x2 = x1;
+	int y2 = y1;
 
 	if (curRoomImg) {
-		*x2 += curRoomImg->_width;
-		*y2 += curRoomImg->_height;
+		x2 += curRoomImg->_width;
+		y2 += curRoomImg->_height;
 	}
+
+	return Common::Rect(x1, y1, x2, y2);
 }
 
 /**
  * Draws a room map.
  */
-static void drawRoomMap(uint16 curRoom, bool drawx) {
-	uint16 x, y, xx, xy, offset;
-	uint32 flags;
+static void drawRoomMap(uint16 curRoom, bool drawMarkFl) {
+	uint16 drawX, drawY, offset;
 
-	x = g_lab->_utils->mapScaleX(Maps[curRoom]._x);
-	y = g_lab->_utils->mapScaleY(Maps[curRoom]._y);
-	flags = Maps[curRoom]._mapFlags;
+	uint16 x = g_lab->_utils->mapScaleX(Maps[curRoom]._x);
+	uint16 y = g_lab->_utils->mapScaleY(Maps[curRoom]._y);
+	uint32 flags = Maps[curRoom]._mapFlags;
 
 	switch (Maps[curRoom]._specialID) {
 	case NORMAL:
@@ -195,16 +196,16 @@ static void drawRoomMap(uint16 curRoom, bool drawx) {
 		if (WESTDOOR & flags)
 			Path->drawImage(x - Path->_width, y + offset);
 
-		xx = x + (Room->_width - XMark->_width) / 2;
-		xy = y + (Room->_height - XMark->_height) / 2;
+		drawX = x + (Room->_width - XMark->_width) / 2;
+		drawY = y + (Room->_height - XMark->_height) / 2;
 
 		break;
 
 	case BRIDGEROOM:
 		Bridge->drawImage(x, y);
 
-		xx = x + (Bridge->_width - XMark->_width) / 2;
-		xy = y + (Bridge->_height - XMark->_height) / 2;
+		drawX = x + (Bridge->_width - XMark->_width) / 2;
+		drawY = y + (Bridge->_height - XMark->_height) / 2;
 
 		break;
 
@@ -241,8 +242,8 @@ static void drawRoomMap(uint16 curRoom, bool drawx) {
 		if (WESTMDOOR & flags)
 			Path->drawImage(x - Path->_width, y - offset - Path->_height + VRoom->_height);
 
-		xx = x + (VRoom->_width - XMark->_width) / 2;
-		xy = y + (VRoom->_height - XMark->_height) / 2;
+		drawX = x + (VRoom->_width - XMark->_width) / 2;
+		drawY = y + (VRoom->_height - XMark->_height) / 2;
 
 		break;
 
@@ -279,8 +280,8 @@ static void drawRoomMap(uint16 curRoom, bool drawx) {
 		if (WESTDOOR & flags)
 			Path->drawImage(x - Path->_width, y + offset);
 
-		xx = x + (HRoom->_width - XMark->_width) / 2;
-		xy = y + (HRoom->_height - XMark->_height) / 2;
+		drawX = x + (HRoom->_width - XMark->_width) / 2;
+		drawY = y + (HRoom->_height - XMark->_height) / 2;
 
 		break;
 
@@ -288,12 +289,12 @@ static void drawRoomMap(uint16 curRoom, bool drawx) {
 		return;
 	}
 
-	if (drawx)
-		XMark->drawImage(xx, xy);
+	if (drawMarkFl)
+		XMark->drawImage(drawX, drawY);
 }
 
 /**
- * Checks if a floor has been visitted.
+ * Checks if a floor has been visited.
  */
 static bool onFloor(uint16 flr) {
 	for (uint16 i = 1; i <= MaxRooms; i++) {
@@ -548,15 +549,13 @@ void LabEngine::processMap(uint16 curRoom) {
 					_graphics->fade(true, 0);
 				} else if (mouseX > _utils->mapScaleX(314)) {
 					uint16 oldMsg = curMsg;
-					uint16 x1, y1, x2, y2;
+					Common::Rect curCoords;
 
 					for (uint16 i = 1; i <= MaxRooms; i++) {
-						roomCoords(i, &x1, &y1, &x2, &y2);
+						curCoords = roomCoords(i);
 
 						if ((Maps[i]._pageNumber == curFloor)
-							  && _roomsFound->in(i)
-							  && (mouseX >= x1) && (mouseX <= x2)
-							  && (mouseY >= y1) && (mouseY <= y2)) {
+							  && _roomsFound->in(i) && curCoords.contains(Common::Point(mouseX, mouseY))) {
 							curMsg = i;
 						}
 					}
@@ -575,13 +574,15 @@ void LabEngine::processMap(uint16 curRoom) {
 							if (Maps[oldMsg]._pageNumber == curFloor)
 								drawRoomMap(oldMsg, (bool)(oldMsg == curRoom));
 
-							roomCoords(curMsg, &x1, &y1, &x2, &y2);
-							x1 = (x1 + x2) / 2;
-							y1 = (y1 + y2) / 2;
+							curCoords = roomCoords(curMsg);
+							int right = (curCoords.left + curCoords.right) / 2;
+							int left = right - 1;
+							int top, bottom;
+							top = bottom = (curCoords.top + curCoords.bottom) / 2;
 
 							if ((curMsg != curRoom) && (Maps[curMsg]._pageNumber == curFloor)) {
 								_graphics->setAPen(1);
-								_graphics->rectFill(x1 - 1, y1, x1, y1);
+								_graphics->rectFill(left, top, right, bottom);
 							}
 
 							_event->mouseShow();


Commit: 2d90f8a08daf6a6b89ce2c4dd2ac11c03c4c4532
    https://github.com/scummvm/scummvm/commit/2d90f8a08daf6a6b89ce2c4dd2ac11c03c4c4532
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:59+01:00

Commit Message:
LAB: Move map function to LabEngine class, some renaming

Changed paths:
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/map.cpp



diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 4bf9aa3..7a80f64 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -78,6 +78,7 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_highestCondition = 0;
 	_crumbSecs = 0;
 	_crumbMicros = 0;
+	_maxRooms = 0;
 
 	_event = nullptr;
 	_resource = nullptr;
@@ -110,6 +111,23 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_msgFont = nullptr;
 	_inventory = nullptr;
 
+	_imgMap = nullptr;
+	_imgRoom = nullptr;
+	_imgUpArrowRoom = nullptr;
+	_imgDownArrowRoom = nullptr;
+	_imgBridge = nullptr;
+	_imgHRoom = nullptr;
+	_imgVRoom = nullptr;
+	_imgMaze = nullptr;
+	_imgHugeMaze = nullptr;
+	_imgPath = nullptr;
+	_imgMapNorth = nullptr;
+	_imgMapEast = nullptr;
+	_imgMapSouth = nullptr;
+	_imgMapWest = nullptr;
+	_imgXMark = nullptr;
+	_maps = nullptr;
+
 	initTilePuzzle();
 
 	//const Common::FSNode gameDataDir(ConfMan.get("path"));
@@ -130,6 +148,22 @@ LabEngine::~LabEngine() {
 	delete _graphics;
 	delete[] _rooms;
 	delete _utils;
+	delete _imgMap;
+	delete _imgRoom;
+	delete _imgUpArrowRoom;
+	delete _imgDownArrowRoom;
+	delete _imgBridge;
+	delete _imgHRoom;
+	delete _imgVRoom;
+	delete _imgMaze;
+	delete _imgHugeMaze;
+	delete _imgPath;
+	delete _imgMapNorth;
+	delete _imgMapEast;
+	delete _imgMapSouth;
+	delete _imgMapWest;
+	delete _imgXMark;
+	delete _maps;
 
 	for (int i = 0; i < 16; i++)
 		delete _tiles[i];
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 8f3e00f..4170f09 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -40,21 +40,22 @@ struct ADGameDescription;
 
 namespace Lab {
 
+struct MapData;
 struct Action;
-class Anim;
 struct CloseData;
-class DisplayMan;
-class EventManager;
 struct Gadget;
-class Image;
 struct IntuiMessage;
 struct InventoryData;
-class LargeSet;
-class Music;
-class Resource;
 struct RoomData;
 struct Rule;
 struct TextFont;
+class Anim;
+class DisplayMan;
+class EventManager;
+class Image;
+class LargeSet;
+class Music;
+class Resource;
 class Utils;
 
 enum GameFeatures {
@@ -169,6 +170,11 @@ private:
 	Image *_tiles[16];
 	GadgetList _journalGadgetList;
 	GadgetList _mapGadgetList;
+	Image *_imgMap, *_imgRoom, *_imgUpArrowRoom, *_imgDownArrowRoom, *_imgBridge;
+	Image *_imgHRoom, *_imgVRoom, *_imgMaze, *_imgHugeMaze, *_imgPath, *_imgMapNorth;
+	Image *_imgMapEast, *_imgMapSouth, *_imgMapWest, *_imgXMark;
+	uint16 _maxRooms;
+	MapData *_maps;
 
 private:
 	bool fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Common::Point tmpPos,
@@ -183,9 +189,9 @@ public:
 	Gadget *checkNumGadgetHit(GadgetList *gadgetList, uint16 key);
 	IntuiMessage *getMsg();
 	void loadMapData();
-	void drawMap(uint16 CurRoom, uint16 CurMsg, uint16 Floor, bool fadeout, bool fadein);
-	void processMap(uint16 CurRoom);
-	void doMap(uint16 CurRoom);
+	void drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fadeOut, bool fadeIn);
+	void processMap(uint16 curRoom);
+	void doMap(uint16 curRoom);
 	void freeMapData();
 	void loadJournalData();
 	void drawJournal(uint16 wipenum, bool needFade);
@@ -227,6 +233,10 @@ private:
 	void initTilePuzzle();
 	bool saveRestoreGame();
 	Common::Rect roomCoords(uint16 curRoom);
+	void drawRoomMap(uint16 curRoom, bool drawMarkFl);
+	bool onFloor(uint16 floorNum);
+	bool getUpFloor(uint16 *floorNum);
+	bool getDownFloor(uint16 *floorNum);
 
 public:
 	void doActions(Action *actionList, CloseDataPtr *closePtrList);
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 2bf261d..c6b2277 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -46,13 +46,6 @@ namespace Lab {
 /*------------------------------ The Map stuff ------------------------------*/
 /*---------------------------------------------------------------------------*/
 
-static Image *Map, *Room, *UpArrowRoom, *DownArrowRoom, *Bridge,
-			 *HRoom, *VRoom, *Maze, *HugeMaze, *Path, *MapNorth,
-			 *MapEast, *MapSouth, *MapWest, *XMark;
-
-static uint16 MaxRooms;
-static MapData *Maps;
-
 enum MapFloor {
 	kFloorNone,
 	kFloorLower,
@@ -68,46 +61,43 @@ enum MapFloor {
  * Loads in the map data.
  */
 void LabEngine::loadMapData() {
-	Utils *utils = g_lab->_utils;
-	Common::File *mapImages = g_lab->_resource->openDataFile("P:MapImage");
-
-	Map = new Image(mapImages);
-
-	Room = new Image(mapImages);
-	UpArrowRoom = new Image(mapImages);
-	DownArrowRoom = new Image(mapImages);
-	HRoom = new Image(mapImages);
-	VRoom = new Image(mapImages);
-	Maze = new Image(mapImages);
-	HugeMaze = new Image(mapImages);
-
-	MapNorth = new Image(mapImages);
-	MapEast = new Image(mapImages);
-	MapSouth = new Image(mapImages);
-	MapWest = new Image(mapImages);
-
-	Path = new Image(mapImages);
-	Bridge = new Image(mapImages);
-
-	_mapGadgetList.push_back(createButton( 8,  utils->vgaScaleY(105), 0, VKEY_LTARROW, new Image(mapImages), new Image(mapImages)));	// back
-	_mapGadgetList.push_back(createButton( 55, utils->vgaScaleY(105), 1, VKEY_UPARROW, new Image(mapImages), new Image(mapImages)));	// up
-	_mapGadgetList.push_back(createButton(101, utils->vgaScaleY(105), 2, VKEY_DNARROW, new Image(mapImages), new Image(mapImages)));	// down
+	Common::File *mapImages = _resource->openDataFile("P:MapImage");
+
+	_imgMap = new Image(mapImages);
+	_imgRoom = new Image(mapImages);
+	_imgUpArrowRoom = new Image(mapImages);
+	_imgDownArrowRoom = new Image(mapImages);
+	_imgHRoom = new Image(mapImages);
+	_imgVRoom = new Image(mapImages);
+	_imgMaze = new Image(mapImages);
+	_imgHugeMaze = new Image(mapImages);
+
+	_imgMapNorth = new Image(mapImages);
+	_imgMapEast = new Image(mapImages);
+	_imgMapSouth = new Image(mapImages);
+	_imgMapWest = new Image(mapImages);
+	_imgPath = new Image(mapImages);
+	_imgBridge = new Image(mapImages);
+
+	_mapGadgetList.push_back(createButton( 8,  _utils->vgaScaleY(105), 0, VKEY_LTARROW, new Image(mapImages), new Image(mapImages)));	// back
+	_mapGadgetList.push_back(createButton( 55, _utils->vgaScaleY(105), 1, VKEY_UPARROW, new Image(mapImages), new Image(mapImages)));	// up
+	_mapGadgetList.push_back(createButton(101, _utils->vgaScaleY(105), 2, VKEY_DNARROW, new Image(mapImages), new Image(mapImages)));	// down
 
 	delete mapImages;
 
-	Common::File *mapFile = g_lab->_resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0'));
-	g_lab->_music->updateMusic();
-	if (!g_lab->_music->_doNotFilestopSoundEffect)
-		g_lab->_music->stopSoundEffect();
-
-	MaxRooms = mapFile->readUint16LE();
-	Maps = new MapData[MaxRooms];	// will be freed when the user exits the map
-	for (int i = 0; i < MaxRooms; i++) {
-		Maps[i]._x = mapFile->readUint16LE();
-		Maps[i]._y = mapFile->readUint16LE();
-		Maps[i]._pageNumber = mapFile->readUint16LE();
-		Maps[i]._specialID = mapFile->readUint16LE();
-		Maps[i]._mapFlags = mapFile->readUint32LE();
+	Common::File *mapFile = _resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0'));
+	_music->updateMusic();
+	if (!_music->_doNotFilestopSoundEffect)
+		_music->stopSoundEffect();
+
+	_maxRooms = mapFile->readUint16LE();
+	_maps = new MapData[_maxRooms];	// will be freed when the user exits the map
+	for (int i = 0; i < _maxRooms; i++) {
+		_maps[i]._x = mapFile->readUint16LE();
+		_maps[i]._y = mapFile->readUint16LE();
+		_maps[i]._pageNumber = mapFile->readUint16LE();
+		_maps[i]._specialID = mapFile->readUint16LE();
+		_maps[i]._mapFlags = mapFile->readUint32LE();
 	}
 
 	delete mapFile;
@@ -116,8 +106,40 @@ void LabEngine::loadMapData() {
 void LabEngine::freeMapData() {
 	freeButtonList(&_mapGadgetList);
 
-	delete[] Maps;
-	Maps = NULL;
+	delete[] _maps;
+	delete _imgMap;
+	delete _imgRoom;
+	delete _imgUpArrowRoom;
+	delete _imgDownArrowRoom;
+	delete _imgBridge;
+	delete _imgHRoom;
+	delete _imgVRoom;
+	delete _imgMaze;
+	delete _imgHugeMaze;
+	delete _imgPath;
+	delete _imgMapNorth;
+	delete _imgMapEast;
+	delete _imgMapSouth;
+	delete _imgMapWest;
+	delete _imgXMark;
+	delete _maps;
+
+	_imgMap = nullptr;
+	_imgRoom = nullptr;
+	_imgUpArrowRoom = nullptr;
+	_imgDownArrowRoom = nullptr;
+	_imgBridge = nullptr;
+	_imgHRoom = nullptr;
+	_imgVRoom = nullptr;
+	_imgMaze = nullptr;
+	_imgHugeMaze = nullptr;
+	_imgPath = nullptr;
+	_imgMapNorth = nullptr;
+	_imgMapEast = nullptr;
+	_imgMapSouth = nullptr;
+	_imgMapWest = nullptr;
+	_imgXMark = nullptr;
+	_maps = nullptr;
 }
 
 /**
@@ -126,28 +148,28 @@ void LabEngine::freeMapData() {
 Common::Rect LabEngine::roomCoords(uint16 curRoom) {
 	Image *curRoomImg = nullptr;
 
-	switch (Maps[curRoom]._specialID) {
+	switch (_maps[curRoom]._specialID) {
 	case NORMAL:
 	case UPARROWROOM:
 	case DOWNARROWROOM:
-		curRoomImg = Room;
+		curRoomImg = _imgRoom;
 		break;
 	case BRIDGEROOM:
-		curRoomImg = Bridge;
+		curRoomImg = _imgBridge;
 		break;
 	case VCORRIDOR:
-		curRoomImg = VRoom;
+		curRoomImg = _imgVRoom;
 		break;
 	case HCORRIDOR:
-		curRoomImg = HRoom;
+		curRoomImg = _imgHRoom;
 		break;
 	default:
 		// Some rooms (like the map) do not have an image
 		break;
 	}
 
-	int x1 = _utils->mapScaleX(Maps[curRoom]._x);
-	int y1 = _utils->mapScaleY(Maps[curRoom]._y);
+	int x1 = _utils->mapScaleX(_maps[curRoom]._x);
+	int y1 = _utils->mapScaleY(_maps[curRoom]._y);
 	int x2 = x1;
 	int y2 = y1;
 
@@ -162,126 +184,126 @@ Common::Rect LabEngine::roomCoords(uint16 curRoom) {
 /**
  * Draws a room map.
  */
-static void drawRoomMap(uint16 curRoom, bool drawMarkFl) {
+void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) {
 	uint16 drawX, drawY, offset;
 
-	uint16 x = g_lab->_utils->mapScaleX(Maps[curRoom]._x);
-	uint16 y = g_lab->_utils->mapScaleY(Maps[curRoom]._y);
-	uint32 flags = Maps[curRoom]._mapFlags;
+	uint16 x = _utils->mapScaleX(_maps[curRoom]._x);
+	uint16 y = _utils->mapScaleY(_maps[curRoom]._y);
+	uint32 flags = _maps[curRoom]._mapFlags;
 
-	switch (Maps[curRoom]._specialID) {
+	switch (_maps[curRoom]._specialID) {
 	case NORMAL:
 	case UPARROWROOM:
 	case DOWNARROWROOM:
-		if (Maps[curRoom]._specialID == NORMAL)
-			Room->drawImage(x, y);
-		else if (Maps[curRoom]._specialID == DOWNARROWROOM)
-			DownArrowRoom->drawImage(x, y);
+		if (_maps[curRoom]._specialID == NORMAL)
+			_imgRoom->drawImage(x, y);
+		else if (_maps[curRoom]._specialID == DOWNARROWROOM)
+			_imgDownArrowRoom->drawImage(x, y);
 		else
-			UpArrowRoom->drawImage(x, y);
+			_imgUpArrowRoom->drawImage(x, y);
 
-		offset = (Room->_width - Path->_width) / 2;
+		offset = (_imgRoom->_width - _imgPath->_width) / 2;
 
-		if ((NORTHDOOR & flags) && (y >= Path->_height))
-			Path->drawImage(x + offset, y - Path->_height);
+		if ((NORTHDOOR & flags) && (y >= _imgPath->_height))
+			_imgPath->drawImage(x + offset, y - _imgPath->_height);
 
 		if (SOUTHDOOR & flags)
-			Path->drawImage(x + offset, y + Room->_height);
+			_imgPath->drawImage(x + offset, y + _imgRoom->_height);
 
-		offset = (Room->_height - Path->_height) / 2;
+		offset = (_imgRoom->_height - _imgPath->_height) / 2;
 
 		if (EASTDOOR & flags)
-			Path->drawImage(x + Room->_width, y + offset);
+			_imgPath->drawImage(x + _imgRoom->_width, y + offset);
 
 		if (WESTDOOR & flags)
-			Path->drawImage(x - Path->_width, y + offset);
+			_imgPath->drawImage(x - _imgPath->_width, y + offset);
 
-		drawX = x + (Room->_width - XMark->_width) / 2;
-		drawY = y + (Room->_height - XMark->_height) / 2;
+		drawX = x + (_imgRoom->_width - _imgXMark->_width) / 2;
+		drawY = y + (_imgRoom->_height - _imgXMark->_height) / 2;
 
 		break;
 
 	case BRIDGEROOM:
-		Bridge->drawImage(x, y);
+		_imgBridge->drawImage(x, y);
 
-		drawX = x + (Bridge->_width - XMark->_width) / 2;
-		drawY = y + (Bridge->_height - XMark->_height) / 2;
+		drawX = x + (_imgBridge->_width - _imgXMark->_width) / 2;
+		drawY = y + (_imgBridge->_height - _imgXMark->_height) / 2;
 
 		break;
 
 	case VCORRIDOR:
-		VRoom->drawImage(x, y);
+		_imgVRoom->drawImage(x, y);
 
-		offset = (VRoom->_width - Path->_width) / 2;
+		offset = (_imgVRoom->_width - _imgPath->_width) / 2;
 
 		if (NORTHDOOR & flags)
-			Path->drawImage(x + offset, y - Path->_height);
+			_imgPath->drawImage(x + offset, y - _imgPath->_height);
 
 		if (SOUTHDOOR & flags)
-			Path->drawImage(x + offset, y + VRoom->_height);
+			_imgPath->drawImage(x + offset, y + _imgVRoom->_height);
 
-		offset = (Room->_height - Path->_height) / 2;
+		offset = (_imgRoom->_height - _imgPath->_height) / 2;
 
 		if (EASTDOOR & flags)
-			Path->drawImage(x + VRoom->_width, y + offset);
+			_imgPath->drawImage(x + _imgVRoom->_width, y + offset);
 
 		if (WESTDOOR & flags)
-			Path->drawImage(x - Path->_width, y + offset);
+			_imgPath->drawImage(x - _imgPath->_width, y + offset);
 
 		if (EASTBDOOR & flags)
-			Path->drawImage(x + VRoom->_width, y - offset - Path->_height + VRoom->_height);
+			_imgPath->drawImage(x + _imgVRoom->_width, y - offset - _imgPath->_height + _imgVRoom->_height);
 
 		if (WESTBDOOR & flags)
-			Path->drawImage(x - Path->_width, y - offset - Path->_height + VRoom->_height);
+			_imgPath->drawImage(x - _imgPath->_width, y - offset - _imgPath->_height + _imgVRoom->_height);
 
-		offset = (VRoom->_height - Path->_height) / 2;
+		offset = (_imgVRoom->_height - _imgPath->_height) / 2;
 
 		if (EASTMDOOR & flags)
-			Path->drawImage(x + VRoom->_width, y - offset - Path->_height + VRoom->_height);
+			_imgPath->drawImage(x + _imgVRoom->_width, y - offset - _imgPath->_height + _imgVRoom->_height);
 
 		if (WESTMDOOR & flags)
-			Path->drawImage(x - Path->_width, y - offset - Path->_height + VRoom->_height);
+			_imgPath->drawImage(x - _imgPath->_width, y - offset - _imgPath->_height + _imgVRoom->_height);
 
-		drawX = x + (VRoom->_width - XMark->_width) / 2;
-		drawY = y + (VRoom->_height - XMark->_height) / 2;
+		drawX = x + (_imgVRoom->_width - _imgXMark->_width) / 2;
+		drawY = y + (_imgVRoom->_height - _imgXMark->_height) / 2;
 
 		break;
 
 	case HCORRIDOR:
-		HRoom->drawImage(x, y);
+		_imgHRoom->drawImage(x, y);
 
-		offset = (Room->_width - Path->_width) / 2;
+		offset = (_imgRoom->_width - _imgPath->_width) / 2;
 
 		if (NORTHDOOR & flags)
-			Path->drawImage(x + offset, y - Path->_height);
+			_imgPath->drawImage(x + offset, y - _imgPath->_height);
 
 		if (SOUTHDOOR & flags)
-			Path->drawImage(x + offset, y + Room->_height);
+			_imgPath->drawImage(x + offset, y + _imgRoom->_height);
 
 		if (NORTHRDOOR & flags)
-			Path->drawImage(x - offset - Path->_width + HRoom->_width, y - Path->_height);
+			_imgPath->drawImage(x - offset - _imgPath->_width + _imgHRoom->_width, y - _imgPath->_height);
 
 		if (SOUTHRDOOR & flags)
-			Path->drawImage(x - offset - Path->_width + HRoom->_width, y + Room->_height);
+			_imgPath->drawImage(x - offset - _imgPath->_width + _imgHRoom->_width, y + _imgRoom->_height);
 
-		offset = (HRoom->_width - Path->_width) / 2;
+		offset = (_imgHRoom->_width - _imgPath->_width) / 2;
 
 		if (NORTHMDOOR & flags)
-			Path->drawImage(x - offset - Path->_width + HRoom->_width, y - Path->_height);
+			_imgPath->drawImage(x - offset - _imgPath->_width + _imgHRoom->_width, y - _imgPath->_height);
 
 		if (SOUTHMDOOR & flags)
-			Path->drawImage(x - offset - Path->_width + HRoom->_width, y + Room->_height);
+			_imgPath->drawImage(x - offset - _imgPath->_width + _imgHRoom->_width, y + _imgRoom->_height);
 
-		offset = (Room->_height - Path->_height) / 2;
+		offset = (_imgRoom->_height - _imgPath->_height) / 2;
 
 		if (EASTDOOR & flags)
-			Path->drawImage(x + HRoom->_width, y + offset);
+			_imgPath->drawImage(x + _imgHRoom->_width, y + offset);
 
 		if (WESTDOOR & flags)
-			Path->drawImage(x - Path->_width, y + offset);
+			_imgPath->drawImage(x - _imgPath->_width, y + offset);
 
-		drawX = x + (HRoom->_width - XMark->_width) / 2;
-		drawY = y + (HRoom->_height - XMark->_height) / 2;
+		drawX = x + (_imgHRoom->_width - _imgXMark->_width) / 2;
+		drawY = y + (_imgHRoom->_height - _imgXMark->_height) / 2;
 
 		break;
 
@@ -290,15 +312,15 @@ static void drawRoomMap(uint16 curRoom, bool drawMarkFl) {
 	}
 
 	if (drawMarkFl)
-		XMark->drawImage(drawX, drawY);
+		_imgXMark->drawImage(drawX, drawY);
 }
 
 /**
  * Checks if a floor has been visited.
  */
-static bool onFloor(uint16 flr) {
-	for (uint16 i = 1; i <= MaxRooms; i++) {
-		if ((Maps[i]._pageNumber == flr) && g_lab->_roomsFound->in(i) && Maps[i]._x)
+bool LabEngine::onFloor(uint16 floorNum) {
+	for (uint16 i = 1; i <= _maxRooms; i++) {
+		if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x)
 			return true;
 	}
 
@@ -308,15 +330,15 @@ static bool onFloor(uint16 flr) {
 /**
  * Figures out which floor, if any, should be gone to if the up arrow is hit
  */
-static bool getUpFloor(uint16 *flr) {
+bool LabEngine::getUpFloor(uint16 *floorNum) {
 	do {
-		if (*flr < kFloorUpper)
-			(*flr)++;
+		if (*floorNum < kFloorUpper)
+			(*floorNum)++;
 		else {
-			*flr   = kFloorCarnival + 1;
+			*floorNum   = kFloorCarnival + 1;
 			return false;
 		}
-	} while ((!onFloor(*flr)) && (*flr <= kFloorCarnival));
+	} while ((!onFloor(*floorNum)) && (*floorNum <= kFloorCarnival));
 
 	return true;
 }
@@ -325,27 +347,27 @@ static bool getUpFloor(uint16 *flr) {
  * Figures out which floor, if any, should be gone to if the down arrow is
  * hit.
  */
-static bool getDownFloor(uint16 *flr) {
+bool LabEngine::getDownFloor(uint16 *floorNum) {
 	do {
-		if ((*flr == kFloorLower) || (*flr == 0)) {
-			*flr   = 0;
+		if ((*floorNum == kFloorLower) || (*floorNum == kFloorNone)) {
+			*floorNum = kFloorNone;
 			return false;
-		} else if (*flr > kFloorUpper) {
+		} else if (*floorNum > kFloorUpper) {
 			// Labyrinth specific code
-			if (*flr == kFloorHedgeMaze)
-				*flr = kFloorUpper;
-			else if ((*flr == kFloorCarnival) || (*flr == kFloorMedMaze))
-				*flr = kFloorMiddle;
-			else if (*flr == kFloorSurMaze)
-				*flr = kFloorLower;
+			if (*floorNum == kFloorHedgeMaze)
+				*floorNum = kFloorUpper;
+			else if ((*floorNum == kFloorCarnival) || (*floorNum == kFloorMedMaze))
+				*floorNum = kFloorMiddle;
+			else if (*floorNum == kFloorSurMaze)
+				*floorNum = kFloorLower;
 			else {
-				*flr = 0;
+				*floorNum = kFloorNone;
 				return false;
 			}
 		} else
-			(*flr)--;
+			(*floorNum)--;
 
-	} while ((!onFloor(*flr)) && *flr);
+	} while ((!onFloor(*floorNum)) && (*floorNum != kFloorNone));
 
 	return true;
 }
@@ -353,20 +375,20 @@ static bool getDownFloor(uint16 *flr) {
 /**
  * Draws the map
  */
-void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 flr, bool fadeout, bool fadein) {
+void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fadeOut, bool fadeIn) {
 	_event->mouseHide();
 
-	if (fadeout)
+	if (fadeOut)
 		_graphics->fade(false, 0);
 
 	_graphics->setAPen(0);
 	_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);
 
-	Map->drawImage(0, 0);
+	_imgMap->drawImage(0, 0);
 	drawGadgetList(&_mapGadgetList);
 
-	for (uint16 i = 1; i <= MaxRooms; i++) {
-		if ((Maps[i]._pageNumber == flr) && _roomsFound->in(i) && Maps[i]._x) {
+	for (uint16 i = 1; i <= _maxRooms; i++) {
+		if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x) {
 			drawRoomMap(i, (bool)(i == curRoom));
 			_music->updateMusic();
 		}
@@ -375,11 +397,10 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 flr, bool fadeout,
 	// Makes sure the X is drawn in corridors
 	// NOTE: this here on purpose just in case there's some weird
 	// condition, like the surreal maze where there are no rooms
-	if ((Maps[curRoom]._pageNumber == flr) && _roomsFound->in(curRoom) && Maps[curRoom]._x)
+	if ((_maps[curRoom]._pageNumber == floorNum) && _roomsFound->in(curRoom) && _maps[curRoom]._x)
 		drawRoomMap(curRoom, true);
 
-	uint16 tempfloor = flr;
-
+	uint16 tempfloor = floorNum;
 	bool noOverlay = getUpFloor(&tempfloor);
 
 	Gadget *upGadget = _event->getGadget(1);
@@ -390,7 +411,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 flr, bool fadeout,
 	else
 		disableGadget(upGadget, 12);
 
-	tempfloor = flr;
+	tempfloor = floorNum;
 	noOverlay = getDownFloor(&tempfloor);
 
 	if (noOverlay)
@@ -398,35 +419,33 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 flr, bool fadeout,
 	else
 		disableGadget(downGadget, 12);
 
-	char *sptr;
-
 	// Labyrinth specific code
-	if (flr == kFloorLower) {
+	if (floorNum == kFloorLower) {
 		if (onFloor(kFloorSurMaze))
-			Maze->drawImage(_utils->mapScaleX(538), _utils->mapScaleY(277));
-	} else if (flr == kFloorMiddle) {
+			_imgMaze->drawImage(_utils->mapScaleX(538), _utils->mapScaleY(277));
+	} else if (floorNum == kFloorMiddle) {
 		if (onFloor(kFloorCarnival))
-			Maze->drawImage(_utils->mapScaleX(358), _utils->mapScaleY(72));
+			_imgMaze->drawImage(_utils->mapScaleX(358), _utils->mapScaleY(72));
 
 		if (onFloor(kFloorMedMaze))
-			Maze->drawImage(_utils->mapScaleX(557), _utils->mapScaleY(325));
-	} else if (flr == kFloorUpper) {
+			_imgMaze->drawImage(_utils->mapScaleX(557), _utils->mapScaleY(325));
+	} else if (floorNum == kFloorUpper) {
 		if (onFloor(kFloorHedgeMaze))
-			HugeMaze->drawImage(_utils->mapScaleX(524), _utils->mapScaleY(97));
-	} else if (flr == kFloorSurMaze) {
-		sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str();
+			_imgHugeMaze->drawImage(_utils->mapScaleX(524), _utils->mapScaleY(97));
+	} else if (floorNum == kFloorSurMaze) {
+		char *sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str();
 		_graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, _utils->mapScaleX(360), 0, _utils->mapScaleX(660), _utils->mapScaleY(450), sptr);
 	}
 
-	if (flr >= kFloorLower && flr <= kFloorCarnival) {
-		sptr = (char *)_resource->getStaticText(flr - 1).c_str();
+	if ((floorNum >= kFloorLower) && (floorNum <= kFloorCarnival)) {
+		char *sptr = (char *)_resource->getStaticText(floorNum - 1).c_str();
 		_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 75, 134, 97, sptr);
 	}
 
-	if ((sptr = _rooms[curMsg]._roomMsg))
-		_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr);
+	if (_rooms[curMsg]._roomMsg)
+		_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, _rooms[curMsg]._roomMsg);
 
-	if (fadein)
+	if (fadeIn)
 		_graphics->fade(true, 0);
 
 	_event->mouseShow();
@@ -437,16 +456,15 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 flr, bool fadeout,
  */
 void LabEngine::processMap(uint16 curRoom) {
 	uint32 place = 1;
-
-	uint16 curMsg   = curRoom;
-	uint16 curFloor = Maps[curRoom]._pageNumber;
+	uint16 curMsg = curRoom;
+	uint16 curFloor = _maps[curRoom]._pageNumber;
 
 	while (1) {
 		// Make sure we check the music at least after every message
 		_music->updateMusic();
 		IntuiMessage *msg = getMsg();
 
-		if (msg == NULL) {
+		if (!msg) {
 			_music->updateMusic();
 
 			byte newcolor[3];
@@ -551,10 +569,10 @@ void LabEngine::processMap(uint16 curRoom) {
 					uint16 oldMsg = curMsg;
 					Common::Rect curCoords;
 
-					for (uint16 i = 1; i <= MaxRooms; i++) {
+					for (uint16 i = 1; i <= _maxRooms; i++) {
 						curCoords = roomCoords(i);
 
-						if ((Maps[i]._pageNumber == curFloor)
+						if ((_maps[i]._pageNumber == curFloor)
 							  && _roomsFound->in(i) && curCoords.contains(Common::Point(mouseX, mouseY))) {
 							curMsg = i;
 						}
@@ -571,7 +589,7 @@ void LabEngine::processMap(uint16 curRoom) {
 							_graphics->rectFillScaled(13, 148, 135, 186);
 							_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr);
 
-							if (Maps[oldMsg]._pageNumber == curFloor)
+							if (_maps[oldMsg]._pageNumber == curFloor)
 								drawRoomMap(oldMsg, (bool)(oldMsg == curRoom));
 
 							curCoords = roomCoords(curMsg);
@@ -580,7 +598,7 @@ void LabEngine::processMap(uint16 curRoom) {
 							int top, bottom;
 							top = bottom = (curCoords.top + curCoords.bottom) / 2;
 
-							if ((curMsg != curRoom) && (Maps[curMsg]._pageNumber == curFloor)) {
+							if ((curMsg != curRoom) && (_maps[curMsg]._pageNumber == curFloor)) {
 								_graphics->setAPen(1);
 								_graphics->rectFill(left, top, right, bottom);
 							}
@@ -614,20 +632,20 @@ void LabEngine::doMap(uint16 curRoom) {
 	_graphics->blackAllScreen();
 
 	if (_direction == NORTH)
-		XMark = MapNorth;
+		_imgXMark = _imgMapNorth;
 	else if (_direction == SOUTH)
-		XMark = MapSouth;
+		_imgXMark = _imgMapSouth;
 	else if (_direction == EAST)
-		XMark = MapEast;
+		_imgXMark = _imgMapEast;
 	else if (_direction == WEST)
-		XMark = MapWest;
+		_imgXMark = _imgMapWest;
 
 	_event->attachGadgetList(&_mapGadgetList);
-	drawMap(curRoom, curRoom, Maps[curRoom]._pageNumber, false, true);
+	drawMap(curRoom, curRoom, _maps[curRoom]._pageNumber, false, true);
 	_event->mouseShow();
 	_graphics->screenUpdate();
 	processMap(curRoom);
-	_event->attachGadgetList(NULL);
+	_event->attachGadgetList(nullptr);
 	_graphics->fade(false, 0);
 	_graphics->blackAllScreen();
 	_event->mouseHide();


Commit: 4a9286ef2784f7fb73de3f5ce2d8f972b3da9237
    https://github.com/scummvm/scummvm/commit/4a9286ef2784f7fb73de3f5ce2d8f972b3da9237
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:59+01:00

Commit Message:
LAB: Move getWord to DisplayMan

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 199c9e04..13ffd07 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -138,7 +138,7 @@ void DisplayMan::freePict() {
 /**
  * Extracts the first word from a string.
  */
-static void getWord(char *wordBuffer, const char *mainBuffer, uint16 *wordWidth) {
+void DisplayMan::getWord(char *wordBuffer, const char *mainBuffer, uint16 *wordWidth) {
 	uint16 width = 0;
 
 	while ((mainBuffer[width] != ' ') && mainBuffer[width] && (mainBuffer[width] != '\n')) {
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index 5b6217b..5938198 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -62,6 +62,7 @@ private:
 
 	uint16 fadeNumIn(uint16 num, uint16 res, uint16 counter);
 	uint16 fadeNumOut(uint16 num, uint16 res, uint16 counter);
+	void getWord(char *wordBuffer, const char *mainBuffer, uint16 *wordWidth);
 
 	byte _curapen;
 	byte *_curBitmap;


Commit: 8e88d3102541683595865b0c9bac59a854c6cdba
    https://github.com/scummvm/scummvm/commit/8e88d3102541683595865b0c9bac59a854c6cdba
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:59+01:00

Commit Message:
LAB: Move processroom functions to LabEngine

Changed paths:
    engines/lab/engine.cpp
    engines/lab/lab.h
    engines/lab/processroom.cpp
    engines/lab/processroom.h



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 5f6f9f9..4cfdd45 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -980,7 +980,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 			} else if (actionMode == 4) {
 				// Look at closeups
 				CloseDataPtr tmpClosePtr = _closeDataPtr;
-				setCurrentClose(curPos, &tmpClosePtr);
+				setCurrentClose(curPos, &tmpClosePtr, true);
 
 				if (_closeDataPtr == tmpClosePtr) {
 					if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
@@ -1013,7 +1013,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 
 		if (!wrkClosePtr) {
 			CloseDataPtr tmpClosePtr = _closeDataPtr;
-			setCurrentClose(curPos, &tmpClosePtr);
+			setCurrentClose(curPos, &tmpClosePtr, true);
 
 			if (!tmpClosePtr || (tmpClosePtr == _closeDataPtr)) {
 				if (!_closeDataPtr)
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 4170f09..b407f31 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -49,6 +49,8 @@ struct InventoryData;
 struct RoomData;
 struct Rule;
 struct TextFont;
+struct ViewData;
+
 class Anim;
 class DisplayMan;
 class EventManager;
@@ -237,6 +239,20 @@ private:
 	bool onFloor(uint16 floorNum);
 	bool getUpFloor(uint16 *floorNum);
 	bool getDownFloor(uint16 *floorNum);
+	bool checkConditions(int16 *condition);
+	ViewData *getViewData(uint16 roomNum, uint16 direction);
+	CloseData *getObject(Common::Point pos, CloseDataPtr closePtr);
+	CloseDataPtr findClosePtrMatch(CloseDataPtr closePtr, CloseDataPtr closePtrList);
+	uint16 processArrow(uint16 curDirection, uint16 arrow);
+	void setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, bool useAbsoluteCoords);
+	bool takeItem(uint16 x, uint16 y, CloseDataPtr *closePtrList);
+	bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults);
+	bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *closePtrList);
+	bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults);
+	bool doOperateRule(Common::Point pos, int16 ItemNum, CloseDataPtr *closePtrList);
+	bool doGoForward(CloseDataPtr *closePtrList);
+	bool doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList);
+	bool doMainView(CloseDataPtr *closePtrList);
 
 public:
 	void doActions(Action *actionList, CloseDataPtr *closePtrList);
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index be03a0d..49287ae 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -47,7 +47,7 @@ namespace Lab {
 /**
  * Checks whether all the conditions in a condition list are met.
  */
-static bool checkConditions(int16 *condition) {
+bool LabEngine::checkConditions(int16 *condition) {
 	if (!condition)
 		return true;
 
@@ -55,10 +55,10 @@ static bool checkConditions(int16 *condition) {
 		return true;
 
 	int counter = 1;
-	bool res = g_lab->_conditions->in(condition[0]);
+	bool res = _conditions->in(condition[0]);
 
 	while (condition[counter] && res) {
-		res = g_lab->_conditions->in(condition[counter]);
+		res = _conditions->in(condition[counter]);
 		counter++;
 	}
 
@@ -68,11 +68,11 @@ static bool checkConditions(int16 *condition) {
 /**
  * Gets the current ViewDataPointer.
  */
-ViewData *getViewData(uint16 roomNum, uint16 direction) {
-	if (!g_lab->_rooms[roomNum]._roomMsg)
-		g_lab->_resource->readViews(roomNum);
+ViewData *LabEngine::getViewData(uint16 roomNum, uint16 direction) {
+	if (!_rooms[roomNum]._roomMsg)
+		_resource->readViews(roomNum);
 
-	ViewData *view = g_lab->_rooms[roomNum]._view[direction];
+	ViewData *view = _rooms[roomNum]._view[direction];
 
 	do {
 		if (checkConditions(view->_condition))
@@ -87,18 +87,19 @@ ViewData *getViewData(uint16 roomNum, uint16 direction) {
 /**
  * Gets an object, if any, from the user's click on the screen.
  */
-static CloseData *getObject(Common::Point pos, CloseDataPtr closePtr) {
-	if (closePtr == nullptr)
-		closePtr = getViewData(g_lab->_roomNum, g_lab->_direction)->_closeUps;
+CloseData *LabEngine::getObject(Common::Point pos, CloseDataPtr closePtr) {
+	CloseDataPtr wrkClosePtr;
+	if (!closePtr)
+		wrkClosePtr = getViewData(_roomNum, _direction)->_closeUps;
 	else
-		closePtr = closePtr->_subCloseUps;
+		wrkClosePtr = closePtr->_subCloseUps;
 
-	while (closePtr) {
-		if ((pos.x >= g_lab->_utils->scaleX(closePtr->_x1)) && (pos.y >= g_lab->_utils->scaleY(closePtr->_y1)) &&
-			  (pos.x <= g_lab->_utils->scaleX(closePtr->_x2)) && (pos.y <= g_lab->_utils->scaleY(closePtr->_y2)))
-			return closePtr;
+	while (wrkClosePtr) {
+		if ((pos.x >= _utils->scaleX(wrkClosePtr->_x1)) && (pos.y >= _utils->scaleY(wrkClosePtr->_y1)) &&
+			  (pos.x <= _utils->scaleX(wrkClosePtr->_x2)) && (pos.y <= _utils->scaleY(wrkClosePtr->_y2)))
+			return wrkClosePtr;
 
-		closePtr = closePtr->_nextCloseUp;
+		wrkClosePtr = wrkClosePtr->_nextCloseUp;
 	}
 
 	return nullptr;
@@ -110,7 +111,7 @@ static CloseData *getObject(Common::Point pos, CloseDataPtr closePtr) {
  *      some of the closeups have the same hit boxes, then this returns the
  *      first occurrence of the object with the same hit box.
  */
-static CloseDataPtr findClosePtrMatch(CloseDataPtr closePtr, CloseDataPtr closePtrList) {
+CloseDataPtr LabEngine::findClosePtrMatch(CloseDataPtr closePtr, CloseDataPtr closePtrList) {
 	CloseDataPtr resClosePtr;
 
 	while (closePtrList) {
@@ -177,21 +178,21 @@ void LabEngine::drawDirection(CloseDataPtr closePtr) {
 /**
  * process a arrow gadget movement.
  */
-uint16 processArrow(uint16 curDirection, uint16 arrow) {
+uint16 LabEngine::processArrow(uint16 curDirection, uint16 arrow) {
 	if (arrow == 1) { // Forward
 		uint16 room = 1;
 
 		if (curDirection == NORTH)
-			room = g_lab->_rooms[g_lab->_roomNum]._northDoor;
+			room = _rooms[_roomNum]._northDoor;
 		else if (curDirection == SOUTH)
-			room = g_lab->_rooms[g_lab->_roomNum]._southDoor;
+			room = _rooms[_roomNum]._southDoor;
 		else if (curDirection == EAST)
-			room = g_lab->_rooms[g_lab->_roomNum]._eastDoor;
+			room = _rooms[_roomNum]._eastDoor;
 		else if (curDirection == WEST)
-			room = g_lab->_rooms[g_lab->_roomNum]._westDoor;
+			room = _rooms[_roomNum]._westDoor;
 
 		if (room != 0)
-			g_lab->_roomNum = room;
+			_roomNum = room;
 
 		return curDirection;
 	} else if (arrow == 0) { // Left
@@ -221,11 +222,11 @@ uint16 processArrow(uint16 curDirection, uint16 arrow) {
 /**
  * Sets the current close up data.
  */
-void setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, bool useAbsoluteCoords) {
+void LabEngine::setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, bool useAbsoluteCoords) {
 	CloseDataPtr closePtr;
 
 	if (!*closePtrList)
-		closePtr = getViewData(g_lab->_roomNum, g_lab->_direction)->_closeUps;
+		closePtr = getViewData(_roomNum, _direction)->_closeUps;
 	else
 		closePtr = (*closePtrList)->_subCloseUps;
 
@@ -234,7 +235,7 @@ void setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, bool useAbso
 		if (!useAbsoluteCoords)
 			target = Common::Rect(closePtr->_x1, closePtr->_y1, closePtr->_x2, closePtr->_y2);
 		else
-			target = Common::Rect(g_lab->_utils->scaleX(closePtr->_x1), g_lab->_utils->scaleY(closePtr->_y1), g_lab->_utils->scaleX(closePtr->_x2), g_lab->_utils->scaleY(closePtr->_y2));
+			target = Common::Rect(_utils->scaleX(closePtr->_x1), _utils->scaleY(closePtr->_y1), _utils->scaleX(closePtr->_x2), _utils->scaleY(closePtr->_y2));
 
 		if (target.contains(pos) && closePtr->_graphicName) {
 			*closePtrList = closePtr;
@@ -248,22 +249,22 @@ void setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, bool useAbso
 /**
  * Takes the currently selected item.
  */
-bool takeItem(uint16 x, uint16 y, CloseDataPtr *closePtrList) {
+bool LabEngine::takeItem(uint16 x, uint16 y, CloseDataPtr *closePtrList) {
 	CloseDataPtr closePtr;
 
 	if (!*closePtrList) {
-		closePtr = getViewData(g_lab->_roomNum, g_lab->_direction)->_closeUps;
+		closePtr = getViewData(_roomNum, _direction)->_closeUps;
 	} else if ((*closePtrList)->_closeUpType < 0) {
-		g_lab->_conditions->inclElement(abs((*closePtrList)->_closeUpType));
+		_conditions->inclElement(abs((*closePtrList)->_closeUpType));
 		return true;
 	} else
 		closePtr = (*closePtrList)->_subCloseUps;
 
 	while (closePtr) {
-		if ((x >= g_lab->_utils->scaleX(closePtr->_x1)) && (y >= g_lab->_utils->scaleY(closePtr->_y1)) &&
-			  (x <= g_lab->_utils->scaleX(closePtr->_x2)) && (y <= g_lab->_utils->scaleY(closePtr->_y2)) &&
+		if ((x >= _utils->scaleX(closePtr->_x1)) && (y >= _utils->scaleY(closePtr->_y1)) &&
+			  (x <= _utils->scaleX(closePtr->_x2)) && (y <= _utils->scaleY(closePtr->_y2)) &&
 			  (closePtr->_closeUpType < 0)) {
-			g_lab->_conditions->inclElement(abs(closePtr->_closeUpType));
+			_conditions->inclElement(abs(closePtr->_closeUpType));
 			return true;
 		}
 
@@ -392,7 +393,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			break;
 
 		case SETCLOSEUP: {
-			Common::Point curPos = Common::Point(g_lab->_utils->scaleX(actionList->_param1), g_lab->_utils->scaleY(actionList->_param2));
+			Common::Point curPos = Common::Point(_utils->scaleX(actionList->_param1), _utils->scaleY(actionList->_param2));
 				CloseDataPtr tmpClosePtr = getObject(curPos, *closePtrList);
 
 				if (tmpClosePtr)
@@ -494,7 +495,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			break;
 
 		case RESETBUFFER:
-			g_lab->_graphics->freePict();
+			_graphics->freePict();
 			break;
 
 		case SPECIALCMD:
@@ -554,15 +555,15 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 /**
  * Does the work for doActionRule.
  */
-static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults) {
+bool LabEngine::doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults) {
 	action++;
 
 	if (closePtr) {
-		RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;
+		RuleList *rules = _rooms[_roomNum]._rules;
 
 		if (!rules && (roomNum == 0)) {
-			g_lab->_resource->readViews(roomNum);
-			rules = g_lab->_rooms[roomNum]._rules;
+			_resource->readViews(roomNum);
+			rules = _rooms[roomNum]._rules;
 		}
 
 		for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
@@ -572,7 +573,7 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr closePtr,
 					  (((*rule)->_param2 == 0) && allowDefaults)) ||
 					  ((action == 1) && ((*rule)->_param2 == (-closePtr->_closeUpType)))) {
 					if (checkConditions((*rule)->_condition)) {
-						g_lab->doActions((*rule)->_actionList, setCloseList);
+						doActions((*rule)->_actionList, setCloseList);
 						return true;
 					}
 				}
@@ -586,11 +587,11 @@ static bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr closePtr,
 /**
  * Goes through the rules if an action is taken.
  */
-bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *closePtrList) {
+bool LabEngine::doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *closePtrList) {
 	if (roomNum)
-		g_lab->_newFileName = NOFILE;
+		_newFileName = NOFILE;
 	else
-		g_lab->_newFileName = g_lab->_curFileName;
+		_newFileName = _curFileName;
 
 	CloseDataPtr curClosePtr = getObject(pos, *closePtrList);
 
@@ -609,14 +610,14 @@ bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *
 /**
  * Does the work for doActionRule.
  */
-static bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults) {
+bool LabEngine::doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults) {
 	if (closePtr)
 		if (closePtr->_closeUpType > 0) {
-			RuleList *rules = g_lab->_rooms[roomNum]._rules;
+			RuleList *rules = _rooms[roomNum]._rules;
 
 			if (!rules && (roomNum == 0)) {
-				g_lab->_resource->readViews(roomNum);
-				rules = g_lab->_rooms[roomNum]._rules;
+				_resource->readViews(roomNum);
+				rules = _rooms[roomNum]._rules;
 			}
 
 			for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
@@ -624,7 +625,7 @@ static bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr closePtr
 					  (((*rule)->_param1 == itemNum) || (((*rule)->_param1 == 0) && allowDefaults)) &&
 						(((*rule)->_param2 == closePtr->_closeUpType) || (((*rule)->_param2 == 0) && allowDefaults))) {
 					if (checkConditions((*rule)->_condition)) {
-						g_lab->doActions((*rule)->_actionList, setCloseList);
+						doActions((*rule)->_actionList, setCloseList);
 						return true;
 					}
 				}
@@ -637,20 +638,20 @@ static bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr closePtr
 /**
  * Goes through the rules if the user tries to operate an item on an object.
  */
-bool doOperateRule(Common::Point pos, int16 ItemNum, CloseDataPtr *closePtrList) {
-	g_lab->_newFileName = NOFILE;
+bool LabEngine::doOperateRule(Common::Point pos, int16 ItemNum, CloseDataPtr *closePtrList) {
+	_newFileName = NOFILE;
 	CloseDataPtr closePtr = getObject(pos, *closePtrList);
 
-	if (doOperateRuleSub(ItemNum, g_lab->_roomNum, closePtr, closePtrList, false))
+	if (doOperateRuleSub(ItemNum, _roomNum, closePtr, closePtrList, false))
 		return true;
-	else if (doOperateRuleSub(ItemNum, g_lab->_roomNum, *closePtrList, closePtrList, false))
+	else if (doOperateRuleSub(ItemNum, _roomNum, *closePtrList, closePtrList, false))
 		return true;
-	else if (doOperateRuleSub(ItemNum, g_lab->_roomNum, closePtr, closePtrList, true))
+	else if (doOperateRuleSub(ItemNum, _roomNum, closePtr, closePtrList, true))
 		return true;
-	else if (doOperateRuleSub(ItemNum, g_lab->_roomNum, *closePtrList, closePtrList, true))
+	else if (doOperateRuleSub(ItemNum, _roomNum, *closePtrList, closePtrList, true))
 		return true;
 	else {
-		g_lab->_newFileName = g_lab->_curFileName;
+		_newFileName = _curFileName;
 
 		if (doOperateRuleSub(ItemNum, 0, closePtr, closePtrList, false))
 			return true;
@@ -668,14 +669,14 @@ bool doOperateRule(Common::Point pos, int16 ItemNum, CloseDataPtr *closePtrList)
 /**
  * Goes through the rules if the user tries to go forward.
  */
-bool doGoForward(CloseDataPtr *closePtrList) {
-	RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;
+bool LabEngine::doGoForward(CloseDataPtr *closePtrList) {
+	RuleList *rules = _rooms[_roomNum]._rules;
 
 	for (RuleList::iterator ruleIter = rules->begin(); ruleIter != rules->end(); ++ruleIter) {
 		Rule *rule = *ruleIter;
-		if ((rule->_ruleType == GOFORWARD) && (rule->_param1 == (g_lab->_direction + 1))) {
+		if ((rule->_ruleType == GOFORWARD) && (rule->_param1 == (_direction + 1))) {
 			if (checkConditions(rule->_condition)) {
-				g_lab->doActions(rule->_actionList, closePtrList);
+				doActions(rule->_actionList, closePtrList);
 				return true;
 			}
 		}
@@ -687,18 +688,18 @@ bool doGoForward(CloseDataPtr *closePtrList) {
 /**
  * Goes through the rules if the user tries to turn.
  */
-bool doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList) {
+bool LabEngine::doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList) {
 	from++;
 	to++;
 
-	RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;
+	RuleList *rules = _rooms[_roomNum]._rules;
 
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 		if (((*rule)->_ruleType == TURN) ||
 			  (((*rule)->_ruleType == TURNFROMTO) &&
 			  ((*rule)->_param1 == from) && ((*rule)->_param2 == to))) {
 			if (checkConditions((*rule)->_condition)) {
-				g_lab->doActions((*rule)->_actionList, closePtrList);
+				doActions((*rule)->_actionList, closePtrList);
 				return true;
 			}
 		}
@@ -710,12 +711,12 @@ bool doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList) {
 /**
  * Goes through the rules if the user tries to go to the main view
  */
-bool doMainView(CloseDataPtr *closePtrList) {
-	RuleList *rules = g_lab->_rooms[g_lab->_roomNum]._rules;
+bool LabEngine::doMainView(CloseDataPtr *closePtrList) {
+	RuleList *rules = _rooms[_roomNum]._rules;
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 		if ((*rule)->_ruleType == GOMAINVIEW) {
 			if (checkConditions((*rule)->_condition)) {
-				g_lab->doActions((*rule)->_actionList, closePtrList);
+				doActions((*rule)->_actionList, closePtrList);
 				return true;
 			}
 		}
diff --git a/engines/lab/processroom.h b/engines/lab/processroom.h
index 20b6946..ff594da 100644
--- a/engines/lab/processroom.h
+++ b/engines/lab/processroom.h
@@ -185,17 +185,6 @@ struct MapData {
 #pragma pack(pop)
 #endif
 
-bool parse(const char *inputFile);
-ViewData *getViewData(uint16 roomNum, uint16 direction);
-uint16 processArrow(uint16 curDirection, uint16 arrow);
-void setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, bool useAbsoluteCoords = true);
-bool takeItem(uint16 x, uint16 y, CloseDataPtr *closePtrList);
-bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *closePtrList);
-bool doOperateRule(Common::Point pos, int16 itemNum, CloseDataPtr *closePtrList);
-bool doGoForward(CloseDataPtr *closePtrList);
-bool doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList);
-bool doMainView(CloseDataPtr *closePtrList);
-
 } // End of namespace Lab
 
 #endif // LAB_PROCESSROOM_H


Commit: b586f76f94a33627a2a578539001860a7ff62297
    https://github.com/scummvm/scummvm/commit/b586f76f94a33627a2a578539001860a7ff62297
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:59+01:00

Commit Message:
LAB: Review struct definitions in processroom

Changed paths:
    engines/lab/processroom.h



diff --git a/engines/lab/processroom.h b/engines/lab/processroom.h
index ff594da..97c7cdc 100644
--- a/engines/lab/processroom.h
+++ b/engines/lab/processroom.h
@@ -91,7 +91,7 @@ namespace Lab {
 #pragma pack(push, 1)
 #endif
 
-typedef struct CloseData {
+struct CloseData {
 	uint16 _x1, _y1, _x2, _y2;
 	int16 _closeUpType;          // if > 0, an object.  If < 0, an item
 	uint16 _depth;               // Level of the closeup.
@@ -99,12 +99,12 @@ typedef struct CloseData {
 	char *_message;
 	CloseData *_nextCloseUp;
 	CloseData *_subCloseUps;
-} CloseData;
+};
 
 struct ViewData {
 	int16 *_condition;
 	char *_graphicName;
-	struct ViewData *_nextCondition;
+	ViewData *_nextCondition;
 	CloseDataPtr _closeUps;
 };
 


Commit: e7a0e05301b0f08c0c3271d20fd24a2a4d0f2e71
    https://github.com/scummvm/scummvm/commit/e7a0e05301b0f08c0c3271d20fd24a2a4d0f2e71
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:33:59+01:00

Commit Message:
LAB: Merge playDiff() into readDiff()

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 5f77974..f60c1e1 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -251,9 +251,31 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 }
 
 /**
- * A separate task launched by readDiff.  Plays the DIFF.
+ * Stops an animation from running.
+ */
+void Anim::stopDiff() {
+	if (_isPlaying && _isAnim)
+		_vm->_graphics->blackScreen();
+}
+
+/**
+ * Stops an animation from running.
+ */
+void Anim::stopDiffEnd() {
+	if (_isPlaying) {
+		_stopPlayingEnd = true;
+		while (_isPlaying) {
+			_vm->_music->updateMusic();
+			diffNextFrame();
+		}
+	}
+}
+
+/**
+ * Reads in a DIFF file.
  */
-void Anim::playDiff(byte *buffer, bool onlyDiffData) {
+void Anim::readDiff(byte *buffer, bool playOnce, bool onlyDiffData) {
+	_playOnce = playOnce;
 	_waitSec = 0L;
 	_waitMicros = 0L;
 	_delayMicros = 0L;
@@ -316,9 +338,9 @@ void Anim::playDiff(byte *buffer, bool onlyDiffData) {
 		_diffHeight = _headerdata._height;
 		_vm->_utils->setBytesPerRow(_diffWidth);
 
-		_numChunks = (((int32) _diffWidth) * _diffHeight) / 0x10000;
+		_numChunks = (((int32)_diffWidth) * _diffHeight) / 0x10000;
 
-		if ((uint32)(_numChunks * 0x10000) < (uint32)(((int32) _diffWidth) * _diffHeight))
+		if ((uint32)(_numChunks * 0x10000) < (uint32)(((int32)_diffWidth) * _diffHeight))
 			_numChunks++;
 	} else {
 		return;
@@ -333,38 +355,9 @@ void Anim::playDiff(byte *buffer, bool onlyDiffData) {
 	if (_playOnce) {
 		while (_header != 65535)
 			diffNextFrame(onlyDiffData);
-	} else
-		diffNextFrame(onlyDiffData);
-}
-
-/**
- * Stops an animation from running.
- */
-void Anim::stopDiff() {
-	if (_isPlaying && _isAnim)
-		_vm->_graphics->blackScreen();
-}
-
-/**
- * Stops an animation from running.
- */
-void Anim::stopDiffEnd() {
-	if (_isPlaying) {
-		_stopPlayingEnd = true;
-		while (_isPlaying) {
-			_vm->_music->updateMusic();
-			diffNextFrame();
-		}
 	}
-}
-
-/**
- * Reads in a DIFF file.
- */
-bool Anim::readDiff(byte *buffer, bool playOnce, bool onlyDiffData) {
-	_playOnce = playOnce;
-	playDiff(buffer, onlyDiffData);
-	return true;
+	else
+		diffNextFrame(onlyDiffData);
 }
 
 } // End of namespace Lab
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 91bc0d7..207b3e3 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -84,7 +84,6 @@ private:
 	BitMap *DrawBitMap;
 
 	void readBlock(void *Buffer, uint32 Size, byte **File);
-	void playDiff(byte *buffer, bool onlyDiffData = false);
 
 public:
 	Anim(LabEngine *vm);
@@ -96,7 +95,7 @@ public:
 	bool _noPalChange;   // Don't change the palette.
 	BitMap _rawDiffBM;
 
-	bool readDiff(byte *buffer, bool playOnce, bool onlyDiffData = false);
+	void readDiff(byte *buffer, bool playOnce, bool onlyDiffData = false);
 	void diffNextFrame(bool onlyDiffData = false);
 	void stopDiff();
 	void stopDiffEnd();


Commit: f59ceebad92a3a04ad8e22535ce45eb6b0a34d31
    https://github.com/scummvm/scummvm/commit/f59ceebad92a3a04ad8e22535ce45eb6b0a34d31
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:59+01:00

Commit Message:
LAB: Move readBlock to the utility class

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h
    engines/lab/utils.cpp
    engines/lab/utils.h



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index f60c1e1..563b5fe 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -77,11 +77,6 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 		_diffPalette[i] = 0;
 }
 
-void Anim::readBlock(void *Buffer, uint32 Size, byte **File) {
-	memcpy(Buffer, *File, (size_t)Size);
-	(*File) += Size;
-}
-
 void Anim::diffNextFrame(bool onlyDiffData) {
 	if (_header == 65535)
 		// Already done.
@@ -145,59 +140,58 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 		_diffFile += 4;
 
 		switch (_header) {
-		case 8L:
-			readBlock(_diffPalette, _size, &_diffFile);
+		case 8:
+			_vm->_utils->readBlock(_diffPalette, _size, &_diffFile);
 			_isPal = true;
 			break;
 
-		case 10L:
+		case 10:
 			_rawDiffBM._planes[_curBit] = _diffFile;
 
 			if (onlyDiffData)
 				_diffFile += _size;
-			else {
-				readBlock(DrawBitMap->_planes[_curBit], _size, &_diffFile);
-			}
+			else
+				_vm->_utils->readBlock(DrawBitMap->_planes[_curBit], _size, &_diffFile);
 
 			_curBit++;
 			break;
 
-		case 11L:
+		case 11:
 			_diffFile += 4;
 			_vm->_utils->runLengthDecode(DrawBitMap->_planes[_curBit], _diffFile);
 			_curBit++;
 			_diffFile += _size - 4;
 			break;
 
-		case 12L:
+		case 12:
 			_diffFile += 4;
 			_vm->_utils->VRunLengthDecode(DrawBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow);
 			_curBit++;
 			_diffFile += _size - 4;
 			break;
 
-		case 20L:
+		case 20:
 			_vm->_utils->unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, false);
 			_curBit++;
 			_diffFile += _size;
 			break;
 
-		case 21L:
+		case 21:
 			_vm->_utils->unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, true);
 			_curBit++;
 			_diffFile += _size;
 			break;
 
-		case 25L:
+		case 25:
 			_curBit++;
 			break;
 
-		case 26L:
+		case 26:
 			_curBit++;
 			break;
 
-		case 30L:
-		case 31L:
+		case 30:
+		case 31:
 			if (_waitForEffect) {
 				while (_vm->_music->isSoundEffectActive()) {
 					_vm->_music->updateMusic();
@@ -205,8 +199,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 				}
 			}
 
-			_size -= 8L;
-
+			_size -= 8;
 
 			_diffFile += 4;
 			_sampleSpeed = READ_LE_UINT16(_diffFile);
@@ -215,7 +208,8 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 			_vm->_music->playSoundEffect(_sampleSpeed, _size, _diffFile);
 			_diffFile += _size;
 			break;
-		case 65535L:
+
+		case 65535:
 			if ((_frameNum == 1) || _playOnce || _stopPlayingEnd) {
 				bool didTOF = false;
 
@@ -262,12 +256,13 @@ void Anim::stopDiff() {
  * Stops an animation from running.
  */
 void Anim::stopDiffEnd() {
-	if (_isPlaying) {
-		_stopPlayingEnd = true;
-		while (_isPlaying) {
-			_vm->_music->updateMusic();
-			diffNextFrame();
-		}
+	if (!_isPlaying)
+		return;
+
+	_stopPlayingEnd = true;
+	while (_isPlaying) {
+		_vm->_music->updateMusic();
+		diffNextFrame();
 	}
 }
 
@@ -276,9 +271,9 @@ void Anim::stopDiffEnd() {
  */
 void Anim::readDiff(byte *buffer, bool playOnce, bool onlyDiffData) {
 	_playOnce = playOnce;
-	_waitSec = 0L;
-	_waitMicros = 0L;
-	_delayMicros = 0L;
+	_waitSec = 0;
+	_waitMicros = 0;
+	_delayMicros = 0;
 	_header = 0;
 	_curBit = 0;
 	_frameNum = 0;
@@ -342,9 +337,8 @@ void Anim::readDiff(byte *buffer, bool playOnce, bool onlyDiffData) {
 
 		if ((uint32)(_numChunks * 0x10000) < (uint32)(((int32)_diffWidth) * _diffHeight))
 			_numChunks++;
-	} else {
+	} else
 		return;
-	}
 
 	for (_header = 0; _header < 8; _header++)
 		_rawDiffBM._planes[_header] = NULL;
@@ -355,8 +349,7 @@ void Anim::readDiff(byte *buffer, bool playOnce, bool onlyDiffData) {
 	if (_playOnce) {
 		while (_header != 65535)
 			diffNextFrame(onlyDiffData);
-	}
-	else
+	} else
 		diffNextFrame(onlyDiffData);
 }
 
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 207b3e3..7669dc5 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -83,8 +83,6 @@ private:
 	uint32 _diffHeight;
 	BitMap *DrawBitMap;
 
-	void readBlock(void *Buffer, uint32 Size, byte **File);
-
 public:
 	Anim(LabEngine *vm);
 
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index a9429de..f9a6656 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -60,6 +60,21 @@ uint16 Utils::scaleY(uint16 y) {
 		return ((y * 10) / 24);
 }
 
+
+uint16 Utils::mapScaleX(uint16 x) {
+	if (_vm->_isHiRes)
+		return (x - 45);
+	else
+		return ((x - 45) >> 1);
+}
+
+uint16 Utils::mapScaleY(uint16 y) {
+	if (_vm->_isHiRes)
+		return y;
+	else
+		return ((y - 35) >> 1) - (y >> 6);
+}
+
 /**
  * Scales the VGA coords to SVGA if necessary; otherwise, returns VGA coords.
  */
@@ -422,18 +437,9 @@ uint16 Utils::getRandom(uint16 max) {
 	return ((micros + secs) % max);
 }
 
-uint16 Utils::mapScaleX(uint16 x) {
-	if (_vm->_isHiRes)
-		return (x - 45);
-	else
-		return ((x - 45) >> 1);
-}
-
-uint16 Utils::mapScaleY(uint16 y) {
-	if (_vm->_isHiRes)
-		return y;
-	else
-		return ((y - 35) >> 1) - (y >> 6);
+void Utils::readBlock(void *Buffer, uint32 Size, byte **File) {
+	memcpy(Buffer, *File, (size_t)Size);
+	(*File) += Size;
 }
 
 } // End of namespace Lab
diff --git a/engines/lab/utils.h b/engines/lab/utils.h
index ac036ad..ea6f378 100644
--- a/engines/lab/utils.h
+++ b/engines/lab/utils.h
@@ -60,6 +60,7 @@ public:
 	void VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow);
 	void setBytesPerRow(int num);
 	uint16 getRandom(uint16 max);
+	void readBlock(void *Buffer, uint32 Size, byte **File);
 };
 
 


Commit: 67b3960968b71d529236ab667bad0de5632fa5ea
    https://github.com/scummvm/scummvm/commit/67b3960968b71d529236ab667bad0de5632fa5ea
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:33:59+01:00

Commit Message:
LAB: Remove some useless use of g_lab

Changed paths:
    engines/lab/resource.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 1d9a1ae..3f615c7 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -75,7 +75,7 @@ TextFont *Resource::getFont(const char *fileName) {
 char *Resource::getText(const char *fileName) {
 	Common::File *dataFile = openDataFile(fileName);
 
-	g_lab->_music->updateMusic();
+	_vm->_music->updateMusic();
 
 	uint32 count = dataFile->size();
 	byte *buffer = new byte[count];
@@ -155,7 +155,7 @@ Common::String Resource::translateFileName(Common::String filename) {
 	Common::String fileNameStrFinal;
 
 	if (filename.hasPrefix("P:")) {
-		if (g_lab->_isHiRes)
+		if (_vm->_isHiRes)
 			fileNameStrFinal = "GAME/SPICT/";
 		else
 			fileNameStrFinal = "GAME/PICT/";
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index d015c4e..f100cba 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -93,13 +93,13 @@ static byte *loadBackPict(const char *fileName, bool tomem) {
  * Does the things to properly set up the detective notes.
  */
 void LabEngine::doNotes() {
-	TextFont *noteFont = g_lab->_resource->getFont("P:Note.fon");
-	char *ntext = g_lab->_resource->getText("Lab:Rooms/Notes");
+	TextFont *noteFont = _resource->getFont("P:Note.fon");
+	char *ntext = _resource->getText("Lab:Rooms/Notes");
 
-	g_lab->_graphics->flowText(noteFont, -2 + g_lab->_utils->svgaCord(1), 0, 0, false, false, true, true, g_lab->_utils->vgaScaleX(25) + g_lab->_utils->svgaCord(15), g_lab->_utils->vgaScaleY(50), g_lab->_utils->vgaScaleX(295) - g_lab->_utils->svgaCord(15), g_lab->_utils->vgaScaleY(148), ntext);
-	g_lab->_graphics->setPalette(g_lab->_anim->_diffPalette, 256);
+	_graphics->flowText(noteFont, -2 + _utils->svgaCord(1), 0, 0, false, false, true, true, _utils->vgaScaleX(25) + _utils->svgaCord(15), _utils->vgaScaleY(50), _utils->vgaScaleX(295) - _utils->svgaCord(15), _utils->vgaScaleY(148), ntext);
+	_graphics->setPalette(_anim->_diffPalette, 256);
 
-	g_lab->_graphics->closeFont(noteFont);
+	_graphics->closeFont(noteFont);
 	delete[] ntext;
 }
 
@@ -114,34 +114,34 @@ void LabEngine::doWestPaper() {
 	int32 FileLen, CharsPrinted;
 	uint16 y = 268;
 
-	paperFont = g_lab->_resource->getFont("P:News22.fon");
-	ntext = g_lab->_resource->getText("Lab:Rooms/Date");
-	g_lab->_graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, g_lab->_utils->vgaScaleX(57), g_lab->_utils->vgaScaleY(77) + g_lab->_utils->svgaCord(2), g_lab->_utils->vgaScaleX(262), g_lab->_utils->vgaScaleY(91), ntext);
-	g_lab->_graphics->closeFont(paperFont);
+	paperFont = _resource->getFont("P:News22.fon");
+	ntext = _resource->getText("Lab:Rooms/Date");
+	_graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(77) + _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(91), ntext);
+	_graphics->closeFont(paperFont);
 	delete[] ntext;
 
-	paperFont = g_lab->_resource->getFont("P:News32.fon");
-	ntext = g_lab->_resource->getText("Lab:Rooms/Headline");
+	paperFont = _resource->getFont("P:News32.fon");
+	ntext = _resource->getText("Lab:Rooms/Headline");
 	FileLen = strlen(ntext) - 1;
-	CharsPrinted = g_lab->_graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, g_lab->_utils->vgaScaleX(57), g_lab->_utils->vgaScaleY(86) - g_lab->_utils->svgaCord(2), g_lab->_utils->vgaScaleX(262), g_lab->_utils->vgaScaleY(118), ntext);
+	CharsPrinted = _graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(118), ntext);
 	if (CharsPrinted < FileLen) {
-		y = 130 - g_lab->_utils->svgaCord(5);
-		g_lab->_graphics->flowText(paperFont, -8 - g_lab->_utils->svgaCord(1), 0, 0, false, true, false, true, g_lab->_utils->vgaScaleX(57), g_lab->_utils->vgaScaleY(86) - g_lab->_utils->svgaCord(2), g_lab->_utils->vgaScaleX(262), g_lab->_utils->vgaScaleY(132), ntext);
+		y = 130 - _utils->svgaCord(5);
+		_graphics->flowText(paperFont, -8 - _utils->svgaCord(1), 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(132), ntext);
 	} else
-		y = 115 - g_lab->_utils->svgaCord(5);
-	g_lab->_graphics->closeFont(paperFont);
+		y = 115 - _utils->svgaCord(5);
+	_graphics->closeFont(paperFont);
 	delete[] ntext;
 
-	paperFont = g_lab->_resource->getFont("P:Note.fon");
-	ntext = g_lab->_resource->getText("Lab:Rooms/Col1");
-	CharsPrinted = g_lab->_graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 45, y, 158, 148, ntext);
+	paperFont = _resource->getFont("P:Note.fon");
+	ntext = _resource->getText("Lab:Rooms/Col1");
+	CharsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 45, y, 158, 148, ntext);
 	delete[] ntext;
-	ntext = g_lab->_resource->getText("Lab:Rooms/Col2");
-	CharsPrinted = g_lab->_graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 162, y, 275, 148, ntext);
+	ntext = _resource->getText("Lab:Rooms/Col2");
+	CharsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 162, y, 275, 148, ntext);
 	delete[] ntext;
-	g_lab->_graphics->closeFont(paperFont);
+	_graphics->closeFont(paperFont);
 
-	g_lab->_graphics->setPalette(g_lab->_anim->_diffPalette, 256);
+	_graphics->setPalette(_anim->_diffPalette, 256);
 }
 
 /**
@@ -151,15 +151,15 @@ void LabEngine::loadJournalData() {
 	char filename[20];
 	bool bridge, dirty, news, clean;
 
-	journalFont = g_lab->_resource->getFont("P:Journal.fon");
+	journalFont = _resource->getFont("P:Journal.fon");
 
-	g_lab->_music->updateMusic();
+	_music->updateMusic();
 
 	strcpy(filename, "Lab:Rooms/j0");
-	bridge = g_lab->_conditions->in(BRIDGE0) || g_lab->_conditions->in(BRIDGE1);
-	dirty  = g_lab->_conditions->in(DIRTY);
-	news   = !g_lab->_conditions->in(NONEWS);
-	clean  = !g_lab->_conditions->in(NOCLEAN);
+	bridge = _conditions->in(BRIDGE0) || _conditions->in(BRIDGE1);
+	dirty  = _conditions->in(DIRTY);
+	news   = !_conditions->in(NONEWS);
+	clean  = !_conditions->in(NOCLEAN);
 
 	if (bridge && clean && news)
 		filename[11] = '8';
@@ -180,11 +180,11 @@ void LabEngine::loadJournalData() {
 	else if (bridge)
 		filename[11] = '1';
 
-	journaltext = g_lab->_resource->getText(filename);
-	journaltexttitle = g_lab->_resource->getText("Lab:Rooms/jt");
+	journaltext = _resource->getText(filename);
+	journaltexttitle = _resource->getText("Lab:Rooms/jt");
 
-	Common::File *journalFile = g_lab->_resource->openDataFile("P:JImage");
-	Utils *utils = g_lab->_utils;
+	Common::File *journalFile = _resource->openDataFile("P:JImage");
+	Utils *utils = _utils;
 	_journalGadgetList.push_back(createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile), new Image(journalFile)));	// back
 	_journalGadgetList.push_back(createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile), new Image(journalFile)));	// foward
 	_journalGadgetList.push_back(createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2,            0, new Image(journalFile), new Image(journalFile)));	// cancel
@@ -287,14 +287,14 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 	if (needFade)
 		_graphics->fade(true, 0);
 
-	g_lab->_anim->_noPalChange = true;
+	_anim->_noPalChange = true;
 	JBackImage._imageData = _graphics->readPictToMem("P:Journal.pic", _graphics->_screenWidth, _graphics->_screenHeight);
 	GotBackImage = true;
 
 	eatMessages();
 	_event->mouseShow();
 
-	g_lab->_anim->_noPalChange = false;
+	_anim->_noPalChange = false;
 }
 
 /**
@@ -369,7 +369,7 @@ void LabEngine::doJournal() {
 	_event->mouseHide();
 
 	freeButtonList(&_journalGadgetList);
-	g_lab->_graphics->closeFont(journalFont);
+	_graphics->closeFont(journalFont);
 
 	ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
 
@@ -395,7 +395,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
 		numlines += (*text - '0');
 		text += 2;
 
-		fheight = g_lab->_graphics->textHeight(monitorFont);
+		fheight = _graphics->textHeight(monitorFont);
 		x1 = MonButton->_width + _utils->vgaScaleX(3);
 		MonGadHeight = MonButton->_height + _utils->vgaScaleY(3);
 
@@ -465,7 +465,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 				monitorPage      = 0;
 				TextFileName = Test;
 
-				ntext = g_lab->_resource->getText(TextFileName);
+				ntext = _resource->getText(TextFileName);
 				_graphics->fade(false, 0);
 				drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
 				_graphics->fade(true, 0);
@@ -491,20 +491,20 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 				return;
 
 			else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) {
-				if ((mouseY >= g_lab->_utils->vgaScaleY(171)) && (mouseY <= g_lab->_utils->vgaScaleY(200))) {
-					if ((mouseX >= g_lab->_utils->vgaScaleX(259)) && (mouseX <= g_lab->_utils->vgaScaleX(289))) {
+				if ((mouseY >= _utils->vgaScaleY(171)) && (mouseY <= _utils->vgaScaleY(200))) {
+					if ((mouseX >= _utils->vgaScaleX(259)) && (mouseX <= _utils->vgaScaleX(289))) {
 						if (!lastpage) {
 							monitorPage += 1;
 							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
 						}
-					} else if ((mouseX >= g_lab->_utils->vgaScaleX(0)) && (mouseX <= g_lab->_utils->vgaScaleX(31))) {
+					} else if ((mouseX >= _utils->vgaScaleX(0)) && (mouseX <= _utils->vgaScaleX(31))) {
 						return;
-					} else if ((mouseX >= g_lab->_utils->vgaScaleX(290)) && (mouseX <= g_lab->_utils->vgaScaleX(320))) {
+					} else if ((mouseX >= _utils->vgaScaleX(290)) && (mouseX <= _utils->vgaScaleX(320))) {
 						if (monitorPage >= 1) {
 							monitorPage -= 1;
 							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
 						}
-					} else if ((mouseX >= g_lab->_utils->vgaScaleX(31)) && (mouseX <= g_lab->_utils->vgaScaleX(59))) {
+					} else if ((mouseX >= _utils->vgaScaleX(31)) && (mouseX <= _utils->vgaScaleX(59))) {
 						if (isinteractive) {
 							monitorPage = 0;
 
@@ -558,7 +558,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 	_graphics->FadePalette = hipal;
 
 	TextFont *monitorFont = _resource->getFont("P:Map.fon");
-	Common::File *buttonFile = g_lab->_resource->openDataFile("P:MonImage");
+	Common::File *buttonFile = _resource->openDataFile("P:MonImage");
 	MonButton = new Image(buttonFile);
 	delete buttonFile;
 
@@ -571,7 +571,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 	_graphics->fade(false, 0);
 	_event->mouseHide();
 	delete[] ntext;
-	g_lab->_graphics->closeFont(monitorFont);
+	_graphics->closeFont(monitorFont);
 
 	_graphics->setAPen(0);
 	_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);


Commit: 9c94d140dbf33e0cf29bc1d3791ecdc477e091c4
    https://github.com/scummvm/scummvm/commit/9c94d140dbf33e0cf29bc1d3791ecdc477e091c4
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:00+01:00

Commit Message:
LAB: Simplify bitmap flags

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h
    engines/lab/dispman.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 563b5fe..936c492 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -61,7 +61,7 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 	_diffFile = nullptr;
 	_size = 0;
 	_rawDiffBM._bytesPerRow = 0;
-	_rawDiffBM._flags = 0;
+	_rawDiffBM._drawOnScreen = false;
 	for (int i = 0; i < 16; i++)
 		_rawDiffBM._planes[i] = nullptr;
 	_rawDiffBM._rows = 0;
@@ -82,7 +82,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 		// Already done.
 		return;
 
-	if (_vm->_graphics->_dispBitMap->_flags & BITMAPF_VIDEO) {
+	if (_vm->_graphics->_dispBitMap->_drawOnScreen) {
 		_vm->_graphics->_dispBitMap->_planes[0] = _vm->_graphics->getCurrentDrawingBuffer();
 		_vm->_graphics->_dispBitMap->_planes[1] = _vm->_graphics->_dispBitMap->_planes[0] + 0x10000;
 		_vm->_graphics->_dispBitMap->_planes[2] = _vm->_graphics->_dispBitMap->_planes[1] + 0x10000;
@@ -125,7 +125,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 			_isAnim = (_frameNum >= 3) && (!_playOnce);
 			_curBit = 0;
 
-			if (_vm->_graphics->_dispBitMap->_flags & BITMAPF_VIDEO)
+			if (_vm->_graphics->_dispBitMap->_drawOnScreen)
 				_vm->_graphics->screenUpdate();
 
 			// done with the next frame.
@@ -218,7 +218,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 						_vm->_music->updateMusic();
 						_vm->waitTOF();
 
-						if (_vm->_graphics->_dispBitMap->_flags & BITMAPF_VIDEO)
+						if (_vm->_graphics->_dispBitMap->_drawOnScreen)
 							didTOF = true;
 					}
 				}
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 7669dc5..797c553 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -50,13 +50,10 @@ struct DIFFHeader {
 struct BitMap {
 	uint16 _bytesPerRow;
 	uint16 _rows;       // unused
-	byte _flags;
+	bool _drawOnScreen;
 	byte *_planes[16];
 };
 
-#define BITMAPF_NONE  0
-#define BITMAPF_VIDEO (1<<7)
-
 class Anim {
 private:
 	LabEngine *_vm;
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 13ffd07..ba2cfc8 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -94,7 +94,7 @@ void DisplayMan::readPict(const char *filename, bool playOnce, bool onlyDiffData
 
 	_dispBitMap->_bytesPerRow = _screenWidth;
 	_dispBitMap->_rows        = _screenHeight;
-	_dispBitMap->_flags       = BITMAPF_VIDEO;
+	_dispBitMap->_drawOnScreen = true;
 
 	_vm->_anim->readDiff(_curBitmap, playOnce, onlyDiffData);
 }
@@ -102,7 +102,7 @@ void DisplayMan::readPict(const char *filename, bool playOnce, bool onlyDiffData
 /**
  * Reads in a picture into buffer memory.
  */
-byte *DisplayMan::readPictToMem(const char *filename, uint16 x, uint16 y) {
+byte *DisplayMan::readPictToMem(const char *filename, uint16 width, uint16 height) {
 	_vm->_anim->stopDiff();
 
 	loadPict(filename);
@@ -112,9 +112,9 @@ byte *DisplayMan::readPictToMem(const char *filename, uint16 x, uint16 y) {
 	if (!_vm->_music->_doNotFilestopSoundEffect)
 		_vm->_music->stopSoundEffect();
 
-	_dispBitMap->_bytesPerRow = x;
-	_dispBitMap->_rows = y;
-	_dispBitMap->_flags = BITMAPF_NONE;
+	_dispBitMap->_bytesPerRow = width;
+	_dispBitMap->_rows = height;
+	_dispBitMap->_drawOnScreen = false;
 	_dispBitMap->_planes[0] = _curBitmap;
 	_dispBitMap->_planes[1] = _dispBitMap->_planes[0] + 0x10000;
 	_dispBitMap->_planes[2] = _dispBitMap->_planes[1] + 0x10000;


Commit: 165c0b3b49dbbe5b5758b1ba34667a6f8dd44987
    https://github.com/scummvm/scummvm/commit/165c0b3b49dbbe5b5758b1ba34667a6f8dd44987
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:34:00+01:00

Commit Message:
LAB: More vars renaming

Changed paths:
    engines/lab/special.cpp



diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index f100cba..f0b8152 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -109,35 +109,35 @@ void LabEngine::doNotes() {
  * OpenHiRes already called.
  */
 void LabEngine::doWestPaper() {
-	char *ntext;
-	TextFont *paperFont;
-	int32 FileLen, CharsPrinted;
-	uint16 y = 268;
-
-	paperFont = _resource->getFont("P:News22.fon");
-	ntext = _resource->getText("Lab:Rooms/Date");
+	TextFont *paperFont = _resource->getFont("P:News22.fon");
+	char *ntext = _resource->getText("Lab:Rooms/Date");
 	_graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(77) + _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(91), ntext);
 	_graphics->closeFont(paperFont);
 	delete[] ntext;
 
 	paperFont = _resource->getFont("P:News32.fon");
 	ntext = _resource->getText("Lab:Rooms/Headline");
-	FileLen = strlen(ntext) - 1;
-	CharsPrinted = _graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(118), ntext);
-	if (CharsPrinted < FileLen) {
+
+	int fileLen = strlen(ntext) - 1;
+	int charsPrinted = _graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(118), ntext);
+
+	uint16 y;
+
+	if (charsPrinted < fileLen) {
 		y = 130 - _utils->svgaCord(5);
 		_graphics->flowText(paperFont, -8 - _utils->svgaCord(1), 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(132), ntext);
 	} else
 		y = 115 - _utils->svgaCord(5);
+
 	_graphics->closeFont(paperFont);
 	delete[] ntext;
 
 	paperFont = _resource->getFont("P:Note.fon");
 	ntext = _resource->getText("Lab:Rooms/Col1");
-	CharsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 45, y, 158, 148, ntext);
+	charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 45, y, 158, 148, ntext);
 	delete[] ntext;
 	ntext = _resource->getText("Lab:Rooms/Col2");
-	CharsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 162, y, 275, 148, ntext);
+	charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 162, y, 275, 148, ntext);
 	delete[] ntext;
 	_graphics->closeFont(paperFont);
 
@@ -148,18 +148,17 @@ void LabEngine::doWestPaper() {
  * Loads in the data for the journal.
  */
 void LabEngine::loadJournalData() {
-	char filename[20];
-	bool bridge, dirty, news, clean;
-
 	journalFont = _resource->getFont("P:Journal.fon");
 
 	_music->updateMusic();
 
+	char filename[20];
 	strcpy(filename, "Lab:Rooms/j0");
-	bridge = _conditions->in(BRIDGE0) || _conditions->in(BRIDGE1);
-	dirty  = _conditions->in(DIRTY);
-	news   = !_conditions->in(NONEWS);
-	clean  = !_conditions->in(NOCLEAN);
+
+	bool bridge = _conditions->in(BRIDGE0) || _conditions->in(BRIDGE1);
+	bool dirty  = _conditions->in(DIRTY);
+	bool news   = !_conditions->in(NONEWS);
+	bool clean  = !_conditions->in(NOCLEAN);
 
 	if (bridge && clean && news)
 		filename[11] = '8';
@@ -185,9 +184,11 @@ void LabEngine::loadJournalData() {
 
 	Common::File *journalFile = _resource->openDataFile("P:JImage");
 	Utils *utils = _utils;
+
 	_journalGadgetList.push_back(createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile), new Image(journalFile)));	// back
 	_journalGadgetList.push_back(createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile), new Image(journalFile)));	// foward
 	_journalGadgetList.push_back(createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2,            0, new Image(journalFile), new Image(journalFile)));	// cancel
+
 	delete journalFile;
 }
 
@@ -195,45 +196,45 @@ void LabEngine::loadJournalData() {
  * Draws the text to the back journal screen to the appropriate Page number
  */
 static void drawJournalText() {
-	uint16 DrawingToPage = 1;
-	int32 CharsDrawn    = 0L;
-	char *CurText = journaltext;
+	uint16 drawingToPage = 1;
+	int32 charsDrawn    = 0L;
+	char *curText = journaltext;
 
-	while (DrawingToPage < JPage) {
+	while (drawingToPage < JPage) {
 		g_lab->_music->updateMusic();
-		CurText = (char *)(journaltext + CharsDrawn);
-		CharsDrawn += g_lab->_graphics->flowTextScaled(journalFont, -2, 2, 0, false, false, false, false, 52, 32, 152, 148, CurText);
+		curText = (char *)(journaltext + charsDrawn);
+		charsDrawn += g_lab->_graphics->flowTextScaled(journalFont, -2, 2, 0, false, false, false, false, 52, 32, 152, 148, curText);
 
-		lastpage = (*CurText == 0);
+		lastpage = (*curText == 0);
 
 		if (lastpage)
-			JPage = (DrawingToPage / 2) * 2;
+			JPage = (drawingToPage / 2) * 2;
 		else
-			DrawingToPage++;
+			drawingToPage++;
 	}
 
 	if (JPage <= 1) {
-		CurText = journaltexttitle;
-		g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, true, true, true, g_lab->_utils->vgaScaleX(52), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(152), g_lab->_utils->vgaScaleY(148), CurText);
+		curText = journaltexttitle;
+		g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, true, true, true, g_lab->_utils->vgaScaleX(52), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(152), g_lab->_utils->vgaScaleY(148), curText);
 	} else {
-		CurText = (char *)(journaltext + CharsDrawn);
-		CharsDrawn += g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_utils->vgaScaleX(52), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(152), g_lab->_utils->vgaScaleY(148), CurText);
+		curText = (char *)(journaltext + charsDrawn);
+		charsDrawn += g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_utils->vgaScaleX(52), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(152), g_lab->_utils->vgaScaleY(148), curText);
 	}
 
 	g_lab->_music->updateMusic();
-	CurText = (char *)(journaltext + CharsDrawn);
-	lastpage = (*CurText == 0);
-	g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_utils->vgaScaleX(171), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(271), g_lab->_utils->vgaScaleY(148), CurText);
+	curText = (char *)(journaltext + charsDrawn);
+	lastpage = (*curText == 0);
+	g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_utils->vgaScaleX(171), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(271), g_lab->_utils->vgaScaleY(148), curText);
 
-	CurText = (char *)(journaltext + CharsDrawn);
-	lastpage = lastpage || (*CurText == 0);
+	curText = (char *)(journaltext + charsDrawn);
+	lastpage = lastpage || (*curText == 0);
 }
 
 /**
  * Does the turn page wipe.
  */
-static void turnPage(bool FromLeft) {
-	if (FromLeft) {
+static void turnPage(bool fromLeft) {
+	if (fromLeft) {
 		for (int i = 0; i < g_lab->_graphics->_screenWidth; i += 8) {
 			g_lab->_music->updateMusic();
 			g_lab->waitTOF();
@@ -301,35 +302,30 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
  * Processes user input.
  */
 void LabEngine::processJournal() {
-	IntuiMessage *Msg;
-	uint32 Class;
-	uint16 Qualifier, GadID;
-
 	while (1) {
 		// Make sure we check the music at least after every message
 		_music->updateMusic();
-		Msg = getMsg();
+		IntuiMessage *msg = getMsg();
 
-		if (Msg == NULL) {
+		if (msg == NULL) {
 			_music->updateMusic();
 		} else {
-			Class     = Msg->_msgClass;
-			Qualifier = Msg->_qualifier;
-			GadID     = Msg->_code;
+			uint32 msgClass  = msg->_msgClass;
+			uint16 qualifier = msg->_qualifier;
+			uint16 gadID     = msg->_code;
 
-			if (((Class == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & Qualifier)) ||
-				  ((Class == RAWKEY) && (GadID == 27)))
+			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & qualifier)) ||
+				  ((msgClass == RAWKEY) && (gadID == 27)))
 				return;
-
-			else if (Class == GADGETUP) {
-				if (GadID == 0) {
+			else if (msgClass == GADGETUP) {
+				if (gadID == 0) {
 					if (JPage >= 2) {
 						JPage -= 2;
 						drawJournal(1, false);
 					}
-				} else if (GadID == 1) {
+				} else if (gadID == 1) {
 					return;
-				} else if (GadID == 2) {
+				} else if (gadID == 2) {
 					if (!lastpage) {
 						JPage += 2;
 						drawJournal(2, false);
@@ -382,9 +378,9 @@ void LabEngine::doJournal() {
  * Draws the text for the monitor.
  */
 void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) {
-	uint16 DrawingToPage = 0, yspacing = 0, numlines, fheight;
-	int32 CharsDrawn    = 0L;
-	char *CurText = text;
+	uint16 drawingToPage = 0, yspacing = 0, numlines, fheight;
+	int32 charsDrawn    = 0L;
+	char *curText = text;
 
 	_event->mouseHide();
 
@@ -417,23 +413,23 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
 		_graphics->rectFill(x1, y1, x2, y2);
 	}
 
-	while (DrawingToPage < monitorPage) {
+	while (drawingToPage < monitorPage) {
 		_music->updateMusic();
-		CurText = (char *)(text + CharsDrawn);
-		CharsDrawn += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, CurText);
-		lastpage = (*CurText == 0);
+		curText = (char *)(text + charsDrawn);
+		charsDrawn += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, curText);
+		lastpage = (*curText == 0);
 
 		if (lastpage)
-			monitorPage = DrawingToPage;
+			monitorPage = drawingToPage;
 		else
-			DrawingToPage++;
+			drawingToPage++;
 	}
 
-	CurText = (char *)(text + CharsDrawn);
-	lastpage = (*CurText == 0);
-	CharsDrawn = _graphics->flowText(monitorFont, yspacing, 2, 0, false, false, false, true, x1, y1, x2, y2, CurText);
-	CurText += CharsDrawn;
-	lastpage = lastpage || (*CurText == 0);
+	curText = (char *)(text + charsDrawn);
+	lastpage = (*curText == 0);
+	charsDrawn = _graphics->flowText(monitorFont, yspacing, 2, 0, false, false, false, true, x1, y1, x2, y2, curText);
+	curText += charsDrawn;
+	lastpage = lastpage || (*curText == 0);
 
 	_event->mouseShow();
 }
@@ -442,10 +438,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
  * Processes user input.
  */
 void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	IntuiMessage *msg;
-	uint32 msgClass;
-	uint16 qualifier, code, mouseX, mouseY;
-	const char *Test = " ", *StartFileName = TextFileName;
+	const char *test = " ", *startFileName = TextFileName;
 	CloseDataPtr startClosePtr = _closeDataPtr, lastClosePtr[10];
 	uint16 depth = 0;
 
@@ -457,13 +450,13 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 				_closeDataPtr = startClosePtr;
 
 			if (_closeDataPtr == startClosePtr)
-				Test = StartFileName;
+				test = startFileName;
 			else
-				Test = _closeDataPtr->_graphicName;
+				test = _closeDataPtr->_graphicName;
 
-			if (strcmp(Test, TextFileName)) {
+			if (strcmp(test, TextFileName)) {
 				monitorPage      = 0;
-				TextFileName = Test;
+				TextFileName = test;
 
 				ntext = _resource->getText(TextFileName);
 				_graphics->fade(false, 0);
@@ -475,16 +468,16 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 
 		// Make sure we check the music at least after every message
 		_music->updateMusic();
-		msg = getMsg();
+		IntuiMessage *msg = getMsg();
 
 		if (msg == NULL) {
 			_music->updateMusic();
 		} else {
-			msgClass     = msg->_msgClass;
-			qualifier = msg->_qualifier;
-			mouseX    = msg->_mouseX;
-			mouseY    = msg->_mouseY;
-			code      = msg->_code;
+			uint32 msgClass  = msg->_msgClass;
+			uint16 qualifier = msg->_qualifier;
+			uint16 mouseX    = msg->_mouseX;
+			uint16 mouseY    = msg->_mouseY;
+			uint16 code      = msg->_code;
 
 			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & qualifier)) ||
 				  ((msgClass == RAWKEY) && (code == 27)))


Commit: 9f7ad4b5f25e3c9d6437f0ac0e5e26dba4cab330
    https://github.com/scummvm/scummvm/commit/9f7ad4b5f25e3c9d6437f0ac0e5e26dba4cab330
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:00+01:00

Commit Message:
LAB: Fix crash when closing the map

Changed paths:
    engines/lab/map.cpp



diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index c6b2277..b484a1e 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -106,7 +106,6 @@ void LabEngine::loadMapData() {
 void LabEngine::freeMapData() {
 	freeButtonList(&_mapGadgetList);
 
-	delete[] _maps;
 	delete _imgMap;
 	delete _imgRoom;
 	delete _imgUpArrowRoom;
@@ -121,8 +120,8 @@ void LabEngine::freeMapData() {
 	delete _imgMapEast;
 	delete _imgMapSouth;
 	delete _imgMapWest;
-	delete _imgXMark;
-	delete _maps;
+	// _imgXMark is a pointer to one of the four buffers above
+	delete[] _maps;
 
 	_imgMap = nullptr;
 	_imgRoom = nullptr;


Commit: aa7ec3654dfc8a01c734c41946db5d8e79f3cf9b
    https://github.com/scummvm/scummvm/commit/aa7ec3654dfc8a01c734c41946db5d8e79f3cf9b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:00+01:00

Commit Message:
LAB: Refactor readPictToMem()

This fixes crashes in the teleporter and the journal, and plugs several
memory leaks

Changed paths:
    engines/lab/anim.cpp
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/special.cpp
    engines/lab/transitions.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 936c492..20d1473 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -82,13 +82,13 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 		// Already done.
 		return;
 
-	if (_vm->_graphics->_dispBitMap->_drawOnScreen) {
-		_vm->_graphics->_dispBitMap->_planes[0] = _vm->_graphics->getCurrentDrawingBuffer();
-		_vm->_graphics->_dispBitMap->_planes[1] = _vm->_graphics->_dispBitMap->_planes[0] + 0x10000;
-		_vm->_graphics->_dispBitMap->_planes[2] = _vm->_graphics->_dispBitMap->_planes[1] + 0x10000;
-		_vm->_graphics->_dispBitMap->_planes[3] = _vm->_graphics->_dispBitMap->_planes[2] + 0x10000;
-		_vm->_graphics->_dispBitMap->_planes[4] = _vm->_graphics->_dispBitMap->_planes[3] + 0x10000;
-	}
+	if (_vm->_graphics->_dispBitMap->_drawOnScreen)
+		_vm->_graphics->_dispBitMap->_planes[0] = _vm->_graphics->getCurrentDrawingBuffer();	
+
+	_vm->_graphics->_dispBitMap->_planes[1] = _vm->_graphics->_dispBitMap->_planes[0] + 0x10000;
+	_vm->_graphics->_dispBitMap->_planes[2] = _vm->_graphics->_dispBitMap->_planes[1] + 0x10000;
+	_vm->_graphics->_dispBitMap->_planes[3] = _vm->_graphics->_dispBitMap->_planes[2] + 0x10000;
+	_vm->_graphics->_dispBitMap->_planes[4] = _vm->_graphics->_dispBitMap->_planes[3] + 0x10000;
 
 	_vm->_event->mouseHide();
 
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index ba2cfc8..df35f9f 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -80,9 +80,9 @@ void DisplayMan::loadPict(const char *filename) {
 }
 
 /**
- * Reads in a picture into the dest bitmap.
+ * Reads in a picture into the display bitmap.
  */
-void DisplayMan::readPict(const char *filename, bool playOnce, bool onlyDiffData) {
+void DisplayMan::readPict(const char *filename, bool playOnce, bool onlyDiffData, byte *memoryBuffer, uint16 maxHeight) {
 	_vm->_anim->stopDiff();
 
 	loadPict(filename);
@@ -92,40 +92,15 @@ void DisplayMan::readPict(const char *filename, bool playOnce, bool onlyDiffData
 	if (!_vm->_music->_doNotFilestopSoundEffect)
 		_vm->_music->stopSoundEffect();
 
-	_dispBitMap->_bytesPerRow = _screenWidth;
-	_dispBitMap->_rows        = _screenHeight;
-	_dispBitMap->_drawOnScreen = true;
+	_dispBitMap->_bytesPerRow  = _screenWidth;
+	_dispBitMap->_rows         = (maxHeight > 0) ? maxHeight : _screenHeight;
+	_dispBitMap->_drawOnScreen = (memoryBuffer == nullptr);
+	if (memoryBuffer)
+		_dispBitMap->_planes[0] = memoryBuffer;
 
 	_vm->_anim->readDiff(_curBitmap, playOnce, onlyDiffData);
 }
 
-/**
- * Reads in a picture into buffer memory.
- */
-byte *DisplayMan::readPictToMem(const char *filename, uint16 width, uint16 height) {
-	_vm->_anim->stopDiff();
-
-	loadPict(filename);
-
-	_vm->_music->updateMusic();
-
-	if (!_vm->_music->_doNotFilestopSoundEffect)
-		_vm->_music->stopSoundEffect();
-
-	_dispBitMap->_bytesPerRow = width;
-	_dispBitMap->_rows = height;
-	_dispBitMap->_drawOnScreen = false;
-	_dispBitMap->_planes[0] = _curBitmap;
-	_dispBitMap->_planes[1] = _dispBitMap->_planes[0] + 0x10000;
-	_dispBitMap->_planes[2] = _dispBitMap->_planes[1] + 0x10000;
-	_dispBitMap->_planes[3] = _dispBitMap->_planes[2] + 0x10000;
-	_dispBitMap->_planes[4] = _dispBitMap->_planes[3] + 0x10000;
-
-	_vm->_anim->readDiff(_curBitmap, true);
-
-	return _curBitmap;
-}
-
 void DisplayMan::freePict() {
 	delete _curBitmap;
 	_curBitmap = NULL;
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index 5938198..ad506c4 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -73,9 +73,8 @@ public:
 	virtual ~DisplayMan();
 
 	void loadPict(const char *filename);
-	void readPict(const char *filename, bool playOnce, bool onlyDiffData = false);
+	void readPict(const char *filename, bool playOnce, bool onlyDiffData = false, byte *memoryBuffer = nullptr, uint16 maxHeight = 0);
 	void freePict();
-	byte *readPictToMem(const char *filename, uint16 x, uint16 y);
 	void doScrollBlack();
 	void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem);
 	void doScrollWipe(char *filename);
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index f0b8152..6289cf2 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -51,7 +51,7 @@ static char *journaltext, *journaltexttitle;
 static uint16 JPage = 0;
 static bool lastpage = false;
 static Image JBackImage, ScreenImage;
-static bool GotBackImage = false;
+static byte *_blankJournal;
 static uint16 monitorPage;
 static const char *TextFileName;
 
@@ -67,16 +67,11 @@ Image *MonButton;
 #define NOCLEAN     152
 
 
-static byte *loadBackPict(const char *fileName, bool tomem) {
-	byte *res = nullptr;
-
+static void loadBackPict(const char *fileName) {
 	g_lab->_graphics->FadePalette = hipal;
-	g_lab->_anim->_noPalChange = true;
 
-	if (tomem)
-		res = g_lab->_graphics->readPictToMem(fileName, g_lab->_graphics->_screenWidth, g_lab->_graphics->_screenHeight);
-	else
-		g_lab->_graphics->readPict(fileName, true);
+	g_lab->_anim->_noPalChange = true;
+	g_lab->_graphics->readPict(fileName, true);
 
 	for (uint16 i = 0; i < 16; i++) {
 		hipal[i] = ((g_lab->_anim->_diffPalette[i * 3] >> 2) << 8) +
@@ -85,8 +80,6 @@ static byte *loadBackPict(const char *fileName, bool tomem) {
 	}
 
 	g_lab->_anim->_noPalChange = false;
-
-	return res;
 }
 
 /**
@@ -184,12 +177,21 @@ void LabEngine::loadJournalData() {
 
 	Common::File *journalFile = _resource->openDataFile("P:JImage");
 	Utils *utils = _utils;
-
 	_journalGadgetList.push_back(createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile), new Image(journalFile)));	// back
-	_journalGadgetList.push_back(createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile), new Image(journalFile)));	// foward
 	_journalGadgetList.push_back(createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2,            0, new Image(journalFile), new Image(journalFile)));	// cancel
-
+	_journalGadgetList.push_back(createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile), new Image(journalFile)));	// forward
 	delete journalFile;
+
+	_anim->_noPalChange = true;
+	JBackImage._imageData = new byte[_graphics->_screenWidth * _graphics->_screenHeight];
+	_graphics->readPict("P:Journal.pic", true, false, JBackImage._imageData);
+	_anim->_noPalChange = false;
+
+	// Keep a copy of the blank journal
+	_blankJournal = new byte[_graphics->_screenWidth * _graphics->_screenHeight];
+	memcpy(_blankJournal, JBackImage._imageData, _graphics->_screenWidth * _graphics->_screenHeight);
+
+	ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
 }
 
 /**
@@ -256,15 +258,11 @@ static void turnPage(bool fromLeft) {
  */
 void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 	_event->mouseHide();
-
 	_music->updateMusic();
-
-	if (!GotBackImage)
-		JBackImage._imageData = loadBackPict("P:Journal.pic", true);
-
 	drawJournalText();
 
-	ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
+	// TODO: This is only called to set the palette correctly. Refactor, if possible
+	loadBackPict("P:Journal.pic");
 
 	if (wipenum == 0)
 		JBackImage.blitBitmap(0, 0, &ScreenImage, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false);
@@ -272,7 +270,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 		turnPage((bool)(wipenum == 1));
 
 	Gadget *backGadget = _event->getGadget(0);
-	Gadget *forwardGadget = _event->getGadget(1);
+	Gadget *forwardGadget = _event->getGadget(2);
 
 	if (JPage == 0)
 		disableGadget(backGadget, 15);
@@ -284,18 +282,14 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 	else
 		enableGadget(forwardGadget);
 
-
 	if (needFade)
 		_graphics->fade(true, 0);
 
-	_anim->_noPalChange = true;
-	JBackImage._imageData = _graphics->readPictToMem("P:Journal.pic", _graphics->_screenWidth, _graphics->_screenHeight);
-	GotBackImage = true;
+	// Reset the journal background, so that all the text that has been blitted on it is erased
+	memcpy(JBackImage._imageData, _blankJournal, _graphics->_screenWidth * _graphics->_screenHeight);
 
 	eatMessages();
 	_event->mouseShow();
-
-	_anim->_noPalChange = false;
 }
 
 /**
@@ -343,7 +337,6 @@ void LabEngine::doJournal() {
 	_graphics->blackAllScreen();
 
 	lastpage    = false;
-	GotBackImage = false;
 
 	JBackImage._width = _graphics->_screenWidth;
 	JBackImage._height = _graphics->_screenHeight;
@@ -355,15 +348,16 @@ void LabEngine::doJournal() {
 	_music->updateMusic();
 	loadJournalData();
 
-	drawJournal(0, true);
-
 	_event->attachGadgetList(&_journalGadgetList);
+	drawJournal(0, true);
 	_event->mouseShow();
 	processJournal();
 	_event->attachGadgetList(NULL);
 	_graphics->fade(false, 0);
 	_event->mouseHide();
 
+	delete[] _blankJournal;
+	delete[] JBackImage._imageData;
 	freeButtonList(&_journalGadgetList);
 	_graphics->closeFont(journalFont);
 
@@ -556,7 +550,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 	delete buttonFile;
 
 	ntext = _resource->getText(textfile);
-	loadBackPict(background, false);
+	loadBackPict(background);
 	drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
 	_event->mouseShow();
 	_graphics->fade(true, 0);
diff --git a/engines/lab/transitions.cpp b/engines/lab/transitions.cpp
index d70da5c..5f0f419 100644
--- a/engines/lab/transitions.cpp
+++ b/engines/lab/transitions.cpp
@@ -283,12 +283,14 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, char *filename) {
 	else
 		_vm->_curFileName = _vm->getPictName(closePtrList);
 
-	byte *BitMapMem = readPictToMem(_vm->_curFileName, _screenWidth, lastY + 5);
+	byte *bitMapBuffer = new byte[_screenWidth * (lastY + 5)];
+	readPict(_vm->_curFileName, true, false, bitMapBuffer, lastY + 5);
+
 	setPalette(_vm->_anim->_diffPalette, 256);
 
 	imSource._width = _screenWidth;
 	imSource._height = lastY;
-	imSource._imageData = BitMapMem;
+	imSource._imageData = bitMapBuffer;
 
 	imDest._width = _screenWidth;
 	imDest._height = _screenHeight;
@@ -319,6 +321,8 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, char *filename) {
 			}	// while
 		}	// for i
 	}	// for j
+
+	delete[] bitMapBuffer;
 }
 
 /**


Commit: e0d546a4eb704bc2cc1f2d130c28bc73e7767408
    https://github.com/scummvm/scummvm/commit/e0d546a4eb704bc2cc1f2d130c28bc73e7767408
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:00+01:00

Commit Message:
LAB: Remove extra whitespace

Changed paths:
    engines/lab/anim.cpp
    engines/lab/utils.h



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 20d1473..a461996 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -83,7 +83,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 		return;
 
 	if (_vm->_graphics->_dispBitMap->_drawOnScreen)
-		_vm->_graphics->_dispBitMap->_planes[0] = _vm->_graphics->getCurrentDrawingBuffer();	
+		_vm->_graphics->_dispBitMap->_planes[0] = _vm->_graphics->getCurrentDrawingBuffer();
 
 	_vm->_graphics->_dispBitMap->_planes[1] = _vm->_graphics->_dispBitMap->_planes[0] + 0x10000;
 	_vm->_graphics->_dispBitMap->_planes[2] = _vm->_graphics->_dispBitMap->_planes[1] + 0x10000;
diff --git a/engines/lab/utils.h b/engines/lab/utils.h
index ea6f378..da1f89a 100644
--- a/engines/lab/utils.h
+++ b/engines/lab/utils.h
@@ -46,7 +46,7 @@ private:
 
 public:
 	Utils(LabEngine *vm);
-	
+
 	uint16 scaleX(uint16 x);
 	uint16 scaleY(uint16 y);
 	int16 vgaScaleX(int16 x);


Commit: b77f726469fd6ff3ccad633b75fe432392c3201d
    https://github.com/scummvm/scummvm/commit/b77f726469fd6ff3ccad633b75fe432392c3201d
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:00+01:00

Commit Message:
LAB: Reduce some variable scopes, some renaming

Changed paths:
    engines/lab/transitions.cpp



diff --git a/engines/lab/transitions.cpp b/engines/lab/transitions.cpp
index 5f0f419..d7adff3 100644
--- a/engines/lab/transitions.cpp
+++ b/engines/lab/transitions.cpp
@@ -43,25 +43,21 @@ namespace Lab {
  * Scrolls the display to black.
  */
 void DisplayMan::doScrollBlack() {
-	byte *tempmem;
-	Image im;
-	uint32 size, copysize;
-	byte *baseAddr;
 	uint16 width = _vm->_utils->vgaScaleX(320);
 	uint16 height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
 	byte *mem = new byte[width * height];
 
 	_vm->_event->mouseHide();
 
-	im._width = width;
-	im._height = height;
-	im._imageData = mem;
+	Image img;
+	img._width = width;
+	img._height = height;
+	img._imageData = mem;
 	_vm->_music->updateMusic();
-	im.readScreenImage(0, 0);
+	img.readScreenImage(0, 0);
 	_vm->_music->updateMusic();
 
-	baseAddr = getCurrentDrawingBuffer();
-
+	byte *baseAddr = getCurrentDrawingBuffer();
 	uint16 by = _vm->_utils->vgaScaleX(4);
 	uint16 nheight = height;
 
@@ -78,8 +74,9 @@ void DisplayMan::doScrollBlack() {
 
 		mem += by * width;
 		nheight -= by;
-		size = (int32)nheight * (int32)width;
-		tempmem = mem;
+		uint32 copysize;
+		uint32 size = (int32)nheight * (int32)width;
+		byte *tempmem = mem;
 
 		while (size) {
 			if (size > _screenBytesPerPage)
@@ -113,25 +110,25 @@ void DisplayMan::doScrollBlack() {
 	_vm->_event->mouseShow();
 }
 
-void DisplayMan::copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem) {
+void DisplayMan::copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startLine, byte *mem) {
 	byte *baseAddr = getCurrentDrawingBuffer();
 
 	uint32 size = (int32)(height - nheight) * (int32)width;
-	mem += startline * width;
+	mem += startLine * width;
 	uint16 curPage = ((int32)nheight * (int32)width) / _screenBytesPerPage;
 	uint32 offSet = ((int32)nheight * (int32)width) - (curPage * _screenBytesPerPage);
 
 	while (size) {
-		uint32 copysize;
+		uint32 copySize;
 		if (size > (_screenBytesPerPage - offSet))
-			copysize = _screenBytesPerPage - offSet;
+			copySize = _screenBytesPerPage - offSet;
 		else
-			copysize = size;
+			copySize = size;
 
-		size -= copysize;
+		size -= copySize;
 
-		memcpy(baseAddr + (offSet >> 2), mem, copysize);
-		mem += copysize;
+		memcpy(baseAddr + (offSet >> 2), mem, copySize);
+		mem += copySize;
 		curPage++;
 		offSet = 0;
 	}
@@ -141,7 +138,7 @@ void DisplayMan::copyPage(uint16 width, uint16 height, uint16 nheight, uint16 st
  * Scrolls the display to a new picture from a black screen.
  */
 void DisplayMan::doScrollWipe(char *filename) {
-	uint16 startline = 0, onrow = 0;
+	uint16 startLine = 0, onRow = 0;
 
 	_vm->_event->mouseHide();
 	uint16 width = _vm->_utils->vgaScaleX(320);
@@ -160,26 +157,26 @@ void DisplayMan::doScrollWipe(char *filename) {
 	uint16 by = _vm->_utils->vgaScaleX(3);
 	uint16 nheight = height;
 
-	while (onrow < _vm->_anim->_headerdata._height) {
+	while (onRow < _vm->_anim->_headerdata._height) {
 		_vm->_music->updateMusic();
 
 		if ((by > nheight) && nheight)
 			by = nheight;
 
-		if ((startline + by) > (_vm->_anim->_headerdata._height - height - 1))
+		if ((startLine + by) > (_vm->_anim->_headerdata._height - height - 1))
 			break;
 
 		if (nheight)
 			nheight -= by;
 
-		copyPage(width, height, nheight, startline, mem);
+		copyPage(width, height, nheight, startLine, mem);
 
 		screenUpdate();
 
 		if (!nheight)
-			startline += by;
+			startLine += by;
 
-		onrow += by;
+		onRow += by;
 
 		if (nheight <= (height / 4))
 			by = _vm->_utils->vgaScaleX(5);
@@ -215,12 +212,12 @@ void DisplayMan::doScrollBounce() {
 	byte *mem = _vm->_anim->_rawDiffBM._planes[0];
 
 	_vm->_music->updateMusic();
-	int startline = _vm->_anim->_headerdata._height - height - 1;
+	int startLine = _vm->_anim->_headerdata._height - height - 1;
 
 	for (int i = 0; i < 5; i++) {
 		_vm->_music->updateMusic();
-		startline -= newby[i];
-		copyPage(width, height, 0, startline, mem);
+		startLine -= newby[i];
+		copyPage(width, height, 0, startLine, mem);
 
 		screenUpdate();
 		_vm->waitTOF();
@@ -228,8 +225,8 @@ void DisplayMan::doScrollBounce() {
 
 	for (int i = 8; i > 0; i--) {
 		_vm->_music->updateMusic();
-		startline += newby1[i - 1];
-		copyPage(width, height, 0, startline, mem);
+		startLine += newby1[i - 1];
+		copyPage(width, height, 0, startLine, mem);
 
 		screenUpdate();
 		_vm->waitTOF();
@@ -242,14 +239,13 @@ void DisplayMan::doScrollBounce() {
  * Does the transporter wipe.
  */
 void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, char *filename) {
-	uint16 lastY, curY, linesdone = 0, lineslast;
-	Image imSource, imDest;
+	uint16 lastY, curY, linesDone = 0, linesLast;
 
 	if (_vm->_isHiRes) {
-		lineslast = 3;
+		linesLast = 3;
 		lastY = 358;
 	} else {
-		lineslast = 1;
+		linesLast = 1;
 		lastY = 148;
 	}
 
@@ -258,10 +254,10 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, char *filename) {
 			curY = i * 2;
 
 			while (curY < lastY) {
-				if (linesdone >= lineslast) {
+				if (linesDone >= linesLast) {
 					_vm->_music->updateMusic();
 					_vm->waitTOF();
-					linesdone = 0;
+					linesDone = 0;
 				}
 
 				if (j == 9)
@@ -269,7 +265,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, char *filename) {
 				else
 					rectFill(0, curY, _screenWidth - 1, curY + 1);
 				curY += 4;
-				linesdone++;
+				linesDone++;
 			}	// while
 		}	// for i
 
@@ -288,10 +284,12 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, char *filename) {
 
 	setPalette(_vm->_anim->_diffPalette, 256);
 
+	Image imSource;
 	imSource._width = _screenWidth;
 	imSource._height = lastY;
 	imSource._imageData = bitMapBuffer;
 
+	Image imDest;
 	imDest._width = _screenWidth;
 	imDest._height = _screenHeight;
 	imDest._imageData = getCurrentDrawingBuffer();
@@ -301,10 +299,10 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, char *filename) {
 			curY = i * 2;
 
 			while (curY < lastY) {
-				if (linesdone >= lineslast) {
+				if (linesDone >= linesLast) {
 					_vm->_music->updateMusic();
 					_vm->waitTOF();
-					linesdone = 0;
+					linesDone = 0;
 				}
 
 				imDest._imageData = getCurrentDrawingBuffer();
@@ -317,7 +315,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, char *filename) {
 					imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, bitmapHeight, false);
 				}
 				curY += 4;
-				linesdone++;
+				linesDone++;
 			}	// while
 		}	// for i
 	}	// for j
@@ -393,7 +391,6 @@ void DisplayMan::blackAllScreen() {
  */
 void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer) {
 	Image im;
-
 	im._imageData = buffer;
 
 	if (x1 > x2)
@@ -428,7 +425,6 @@ void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint1
  */
 void DisplayMan::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer) {
 	Image im;
-
 	im._imageData = buffer;
 
 	if (x1 > x2)
@@ -465,27 +461,26 @@ uint16 DisplayMan::fadeNumIn(uint16 num, uint16 res, uint16 counter) {
 	return (num - ((((int32)(15 - counter)) * ((int32)(num - res))) / 15));
 }
 
-
 uint16 DisplayMan::fadeNumOut(uint16 num, uint16 res, uint16 counter) {
 	return (num - ((((int32) counter) * ((int32)(num - res))) / 15));
 }
 
-void DisplayMan::fade(bool fadein, uint16 res) {
-	uint16 newpal[16];
+void DisplayMan::fade(bool fadeIn, uint16 res) {
+	uint16 newPal[16];
 
 	for (uint16 i = 0; i < 16; i++) {
 		for (uint16 palIdx = 0; palIdx < 16; palIdx++) {
-			if (fadein)
-				newpal[palIdx] = (0x00F & fadeNumIn(0x00F & FadePalette[palIdx], 0x00F & res, i)) +
+			if (fadeIn)
+				newPal[palIdx] = (0x00F & fadeNumIn(0x00F & FadePalette[palIdx], 0x00F & res, i)) +
 				(0x0F0 & fadeNumIn(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) +
 				(0xF00 & fadeNumIn(0xF00 & FadePalette[palIdx], 0xF00 & res, i));
 			else
-				newpal[palIdx] = (0x00F & fadeNumOut(0x00F & FadePalette[palIdx], 0x00F & res, i)) +
+				newPal[palIdx] = (0x00F & fadeNumOut(0x00F & FadePalette[palIdx], 0x00F & res, i)) +
 				(0x0F0 & fadeNumOut(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) +
 				(0xF00 & fadeNumOut(0xF00 & FadePalette[palIdx], 0xF00 & res, i));
 		}
 
-		setAmigaPal(newpal, 16);
+		setAmigaPal(newPal, 16);
 		_vm->waitTOF();
 		_vm->_music->updateMusic();
 	}


Commit: 8f5c91ee07b65f977ec556e22a5ddf8a916f776d
    https://github.com/scummvm/scummvm/commit/8f5c91ee07b65f977ec556e22a5ddf8a916f776d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:00+01:00

Commit Message:
LAB: Move all the tile puzzle related functionality into its own class

Changed paths:
  A engines/lab/tilepuzzle.h
    engines/lab/engine.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/savegame.cpp
    engines/lab/tilepuzzle.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 4cfdd45..b80910e 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -40,6 +40,7 @@
 #include "lab/music.h"
 #include "lab/processroom.h"
 #include "lab/resource.h"
+#include "lab/tilepuzzle.h"
 #include "lab/utils.h"
 
 namespace Lab {
@@ -122,8 +123,7 @@ void LabEngine::freeScreens() {
 
 	for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++) {
 		delete _invImages[imgIdx];
-		delete _numberImages[imgIdx];
-		_invImages[imgIdx] = _numberImages[imgIdx] = nullptr;
+		_invImages[imgIdx] = nullptr;
 	}
 }
 
@@ -459,13 +459,11 @@ void LabEngine::mainGameLoop() {
 
 				if (_closeDataPtr) {
 					if ((_closeDataPtr->_closeUpType == SPECIALLOCK) && _mainDisplay)
-						// LAB: Labyrinth specific code
-						showCombination(_curFileName);
+						_tilePuzzle->showCombination(_curFileName);
 					else if (((_closeDataPtr->_closeUpType == SPECIALBRICK)  ||
 								  (_closeDataPtr->_closeUpType == SPECIALBRICKNOMOUSE)) &&
 								  _mainDisplay)
-						// LAB: Labyrinth specific code
-						showTile(_curFileName, (bool)(_closeDataPtr->_closeUpType == SPECIALBRICKNOMOUSE));
+						_tilePuzzle->showTile(_curFileName, (bool)(_closeDataPtr->_closeUpType == SPECIALBRICKNOMOUSE));
 					else
 						_graphics->readPict(_curFileName, false);
 				} else
@@ -943,10 +941,9 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 
 		if (_closeDataPtr) {
 			if ((_closeDataPtr->_closeUpType == SPECIALLOCK) && _mainDisplay)
-				// LAB: Labyrinth specific code
-				mouseCombination(curPos);
+				_tilePuzzle->mouseCombination(curPos);
 			else if ((_closeDataPtr->_closeUpType == SPECIALBRICK) && _mainDisplay)
-				mouseTile(curPos);
+				_tilePuzzle->mouseTile(curPos);
 			else
 				doit = true;
 		} else
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 7a80f64..be5b955 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -43,6 +43,7 @@
 #include "lab/music.h"
 #include "lab/processroom.h"
 #include "lab/resource.h"
+#include "lab/tilepuzzle.h"
 #include "lab/utils.h"
 
 namespace Lab {
@@ -86,6 +87,7 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_anim = nullptr;
 	_graphics = nullptr;
 	_rooms = nullptr;
+	_tilePuzzle = nullptr;
 	_utils = nullptr;
 
 	_lastTooLong = false;
@@ -97,12 +99,8 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 
 	for (int i = 0; i < 10; i++) {
 		_invImages[i] = nullptr;
-		_numberImages[i] = nullptr;
 	}
 
-	for (int i = 0; i < 16; i++)
-		_tiles[i] = nullptr;
-
 	_curFileName = nullptr;
 	_nextFileName = nullptr;
 	_newFileName = nullptr;
@@ -128,8 +126,6 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_imgXMark = nullptr;
 	_maps = nullptr;
 
-	initTilePuzzle();
-
 	//const Common::FSNode gameDataDir(ConfMan.get("path"));
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game/pict");
@@ -147,6 +143,7 @@ LabEngine::~LabEngine() {
 	delete _anim;
 	delete _graphics;
 	delete[] _rooms;
+	delete _tilePuzzle;
 	delete _utils;
 	delete _imgMap;
 	delete _imgRoom;
@@ -164,9 +161,6 @@ LabEngine::~LabEngine() {
 	delete _imgMapWest;
 	delete _imgXMark;
 	delete _maps;
-
-	for (int i = 0; i < 16; i++)
-		delete _tiles[i];
 }
 
 Common::Error LabEngine::run() {
@@ -180,6 +174,7 @@ Common::Error LabEngine::run() {
 	_music = new Music(this);
 	_graphics = new DisplayMan(this);
 	_anim = new Anim(this);
+	_tilePuzzle = new TilePuzzle(this);
 	_utils = new Utils(this);
 
 	if (getPlatform() == Common::kPlatformWindows) {
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index b407f31..7160df5 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -58,6 +58,7 @@ class Image;
 class LargeSet;
 class Music;
 class Resource;
+class TilePuzzle;
 class Utils;
 
 enum GameFeatures {
@@ -133,6 +134,7 @@ public:
 	Anim *_anim;
 	DisplayMan *_graphics;
 	RoomData *_rooms;
+	TilePuzzle *_tilePuzzle;
 	Utils *_utils;
 
 	int _roomNum;
@@ -160,16 +162,12 @@ public:
 	GadgetList _invGadgetList;
 	Image *_moveImages[20];
 	Image *_invImages[10];
-	Image *_numberImages[10];
-	uint16 _curTile[4][4];
-	byte _combination[6];
 
 private:
 	int _lastWaitTOFTicks;
 	bool _lastTooLong;
 	CloseDataPtr _closeDataPtr;
 	InventoryData *_inventory;
-	Image *_tiles[16];
 	GadgetList _journalGadgetList;
 	GadgetList _mapGadgetList;
 	Image *_imgMap, *_imgRoom, *_imgUpArrowRoom, *_imgDownArrowRoom, *_imgBridge;
@@ -213,7 +211,6 @@ public:
 	char *getPictName(CloseDataPtr *closePtrList);
 
 private:
-	// engine.cpp
 	void freeScreens();
 	void perFlipGadget(uint16 gadID);
 	bool doCloseUp(CloseDataPtr closePtr);
@@ -222,17 +219,6 @@ private:
 	void mayShowCrumbIndicator();
 	void mayShowCrumbIndicatorOff();
 	const char *getInvName(uint16 curInv);
-	void mouseTile(Common::Point pos);
-	void changeTile(uint16 col, uint16 row);
-	void mouseCombination(Common::Point pos);
-	void doTile(bool showsolution);
-	void showTile(const char *filename, bool showsolution);
-	void doTileScroll(uint16 col, uint16 row, uint16 scrolltype);
-	void changeCombination(uint16 number);
-	void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer);
-	void doCombination();
-	void showCombination(const char *filename);
-	void initTilePuzzle();
 	bool saveRestoreGame();
 	Common::Rect roomCoords(uint16 curRoom);
 	void drawRoomMap(uint16 curRoom, bool drawMarkFl);
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 686b537..622c1a5 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -28,6 +28,7 @@
  *
  */
 
+#include "common/savefile.h"
 #include "common/translation.h"
 
 #include "gui/message.h"
@@ -43,6 +44,7 @@
 #include "lab/music.h"
 #include "lab/processroom.h"
 #include "lab/savegame.h"
+#include "lab/tilepuzzle.h"
 
 namespace Lab {
 
@@ -122,7 +124,7 @@ bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
  * Writes the game out to disk.
  */
 bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc) {
-	uint16 i, j;
+	uint16 i;
 	Common::String fileName = g_lab->generateSaveFileName(slot);
 	Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
 	Common::OutSaveFile *file = saveFileManager->openForSaving(fileName);
@@ -147,14 +149,7 @@ bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc)
 	for (i = 0; i < g_lab->_roomsFound->_lastElement / (8 * 2); i++)
 		file->writeUint16LE(g_lab->_roomsFound->_array[i]);
 
-	// Combination lock and tile stuff
-	for (i = 0; i < 6; i++)
-		file->writeByte(g_lab->_combination[i]);
-
-	// Tiles
-	for (i = 0; i < 4; i++)
-		for (j = 0; j < 4; j++)
-			file->writeUint16LE(g_lab->_curTile[i][j]);
+	g_lab->_tilePuzzle->save(file);
 
 	// Breadcrumbs
 	for (i = 0; i < sizeof(g_lab->_breadCrumbs); i++) {
@@ -173,7 +168,7 @@ bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc)
  * Reads the game from disk.
  */
 bool loadGame(uint16 *Direction, uint16 *Quarters, int slot) {
-	uint16 i, j;
+	uint16 i;
 	Common::String fileName = g_lab->generateSaveFileName(slot);
 	Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
 	Common::InSaveFile *file = saveFileManager->openForLoading(fileName);
@@ -195,14 +190,7 @@ bool loadGame(uint16 *Direction, uint16 *Quarters, int slot) {
 	for (i = 0; i < g_lab->_roomsFound->_lastElement / (8 * 2); i++)
 		g_lab->_roomsFound->_array[i] = file->readUint16LE();
 
-	// Combination lock and tile stuff
-	for (i = 0; i < 6; i++)
-		g_lab->_combination[i] = file->readByte();
-
-	// Tiles
-	for (i = 0; i < 4; i++)
-		for (j = 0; j < 4; j++)
-			g_lab->_curTile[i][j] = file->readUint16LE();
+	g_lab->_tilePuzzle->load(file);
 
 	// Breadcrumbs
 	for (i = 0; i < 128; i++) {
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index 652c633..782bcda 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -33,12 +33,12 @@
 #include "gui/message.h"
 
 #include "lab/lab.h"
-
 #include "lab/anim.h"
 #include "lab/dispman.h"
 #include "lab/image.h"
 #include "lab/labsets.h"
 #include "lab/resource.h"
+#include "lab/tilepuzzle.h"
 #include "lab/utils.h"
 
 namespace Lab {
@@ -59,7 +59,7 @@ const uint16 SOLUTION[4][4] = {
 
 const int COMBINATION_X[6] = { 45, 83, 129, 166, 211, 248 };
 
-void LabEngine::initTilePuzzle() {
+TilePuzzle::TilePuzzle(LabEngine *vm) : _vm(vm) {
 	for (int i = 0; i < 16; i++)
 		_tiles[i] = nullptr;
 
@@ -70,13 +70,26 @@ void LabEngine::initTilePuzzle() {
 
 	for (int i = 0; i < 6; i++)
 		_combination[i] = 0;
+
+	for (int i = 0; i < 10; i++)
+		_numberImages[i] = nullptr;
+}
+
+TilePuzzle::~TilePuzzle() {
+	for (int i = 0; i < 16; i++)
+		delete _tiles[i];
+
+	for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++) {
+		delete _numberImages[imgIdx];
+		_numberImages[imgIdx] = nullptr;
+	}
 }
 
 /**
  * Processes mouse clicks and changes the combination.
  */
-void LabEngine::mouseTile(Common::Point pos) {
-	Common::Point realPos = _utils->vgaUnscale(pos);
+void TilePuzzle::mouseTile(Common::Point pos) {
+	Common::Point realPos = _vm->_utils->vgaUnscale(pos);
 
 	if ((realPos.x < 101) || (realPos.y < 26))
 		return;
@@ -91,7 +104,7 @@ void LabEngine::mouseTile(Common::Point pos) {
 /**
  * Changes the combination number of one of the slots
  */
-void LabEngine::changeTile(uint16 col, uint16 row) {
+void TilePuzzle::changeTile(uint16 col, uint16 row) {
 	int16 scrolltype = -1;
 
 	if (row > 0) {
@@ -129,7 +142,7 @@ void LabEngine::changeTile(uint16 col, uint16 row) {
 	if (scrolltype != -1) {
 		doTileScroll(col, row, scrolltype);
 
-		if (getFeatures() & GF_WINDOWS_TRIAL) {
+		if (_vm->getFeatures() & GF_WINDOWS_TRIAL) {
 			GUI::MessageDialog trialMessage("This puzzle is not available in the trial version of the game");
 			trialMessage.runModal();
 			return;
@@ -151,9 +164,9 @@ void LabEngine::changeTile(uint16 col, uint16 row) {
 
 		if (check) {
 			// unlocked combination
-			_conditions->inclElement(BRICKOPEN);
-			_anim->_doBlack = true;
-			_graphics->readPict("p:Up/BDOpen", true);
+			_vm->_conditions->inclElement(BRICKOPEN);
+			_vm->_anim->_doBlack = true;
+			_vm->_graphics->readPict("p:Up/BDOpen", true);
 		}
 	}
 }
@@ -161,8 +174,8 @@ void LabEngine::changeTile(uint16 col, uint16 row) {
 /**
  * Processes mouse clicks and changes the combination.
  */
-void LabEngine::mouseCombination(Common::Point pos) {
-	Common::Point realPos = _utils->vgaUnscale(pos);
+void TilePuzzle::mouseCombination(Common::Point pos) {
+	Common::Point realPos = _vm->_utils->vgaUnscale(pos);
 
 	if (!Common::Rect(44, 63, 285, 99).contains(realPos))
 		return;
@@ -187,25 +200,25 @@ void LabEngine::mouseCombination(Common::Point pos) {
 /**
  * Draws the images of the combination lock to the display bitmap.
  */
-void LabEngine::doTile(bool showsolution) {
+void TilePuzzle::doTile(bool showsolution) {
 	uint16 row = 0, col = 0, rowm, colm, num;
 	int16 rows, cols;
 
 	if (showsolution) {
-		rowm = _utils->vgaScaleY(23);
-		colm = _utils->vgaScaleX(27);
+		rowm = _vm->_utils->vgaScaleY(23);
+		colm = _vm->_utils->vgaScaleX(27);
 
-		rows = _utils->vgaScaleY(31);
-		cols = _utils->vgaScaleX(105);
+		rows = _vm->_utils->vgaScaleY(31);
+		cols = _vm->_utils->vgaScaleX(105);
 	} else {
-		_graphics->setAPen(0);
-		_graphics->rectFillScaled(97, 22, 220, 126);
+		_vm->_graphics->setAPen(0);
+		_vm->_graphics->rectFillScaled(97, 22, 220, 126);
 
-		rowm = _utils->vgaScaleY(25);
-		colm = _utils->vgaScaleX(30);
+		rowm = _vm->_utils->vgaScaleY(25);
+		colm = _vm->_utils->vgaScaleX(30);
 
-		rows = _utils->vgaScaleY(25);
-		cols = _utils->vgaScaleX(100);
+		rows = _vm->_utils->vgaScaleY(25);
+		cols = _vm->_utils->vgaScaleX(100);
 	}
 
 	while (row < 4) {
@@ -229,63 +242,63 @@ void LabEngine::doTile(bool showsolution) {
 /**
  * Reads in a backdrop picture.
  */
-void LabEngine::showTile(const char *filename, bool showsolution) {
-	uint16 start = showsolution ? 0 : 1;
+void TilePuzzle::showTile(const char *filename, bool showSolution) {
+	uint16 start = showSolution ? 0 : 1;
 
-	_anim->_doBlack = true;
-	_anim->_noPalChange = true;
-	_graphics->readPict(filename, true);
-	_anim->_noPalChange = false;
-	_graphics->blackScreen();
+	_vm->_anim->_doBlack = true;
+	_vm->_anim->_noPalChange = true;
+	_vm->_graphics->readPict(filename, true);
+	_vm->_anim->_noPalChange = false;
+	_vm->_graphics->blackScreen();
 
-	Common::File *tileFile = tileFile = _resource->openDataFile(showsolution ? "P:TileSolution" : "P:Tile");
+	Common::File *tileFile = _vm->_resource->openDataFile(showSolution ? "P:TileSolution" : "P:Tile");
 
 	for (uint16 curBit = start; curBit < 16; curBit++)
 		_tiles[curBit] = new Image(tileFile);
 
 	delete tileFile;
 
-	doTile(showsolution);
-	_graphics->setPalette(_anim->_diffPalette, 256);
+	doTile(showSolution);
+	_vm->_graphics->setPalette(_vm->_anim->_diffPalette, 256);
 }
 
 /**
  * Does the scrolling for the tiles on the tile puzzle.
  */
-void LabEngine::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
+void TilePuzzle::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 	int16 dX = 0, dY = 0, dx = 0, dy = 0, sx = 0, sy = 0;
 	uint16 last = 0;
 
 	if (scrolltype == LEFTSCROLL) {
-		dX = _utils->vgaScaleX(5);
-		sx = _utils->vgaScaleX(5);
+		dX = _vm->_utils->vgaScaleX(5);
+		sx = _vm->_utils->vgaScaleX(5);
 		last = 6;
 	} else if (scrolltype == RIGHTSCROLL) {
-		dX = _utils->vgaScaleX(-5);
-		dx = _utils->vgaScaleX(-5);
-		sx = _utils->vgaScaleX(5);
+		dX = _vm->_utils->vgaScaleX(-5);
+		dx = _vm->_utils->vgaScaleX(-5);
+		sx = _vm->_utils->vgaScaleX(5);
 		last = 6;
 	} else if (scrolltype == UPSCROLL) {
-		dY = _utils->vgaScaleY(5);
-		sy = _utils->vgaScaleY(5);
+		dY = _vm->_utils->vgaScaleY(5);
+		sy = _vm->_utils->vgaScaleY(5);
 		last = 5;
 	} else if (scrolltype == DOWNSCROLL) {
-		dY = _utils->vgaScaleY(-5);
-		dy = _utils->vgaScaleY(-5);
-		sy = _utils->vgaScaleY(5);
+		dY = _vm->_utils->vgaScaleY(-5);
+		dy = _vm->_utils->vgaScaleY(-5);
+		sy = _vm->_utils->vgaScaleY(5);
 		last = 5;
 	}
 
-	sx += _utils->svgaCord(2);
+	sx += _vm->_utils->svgaCord(2);
 
-	uint16 x1 = _utils->vgaScaleX(100) + (col * _utils->vgaScaleX(30)) + dx;
-	uint16 y1 = _utils->vgaScaleY(25) + (row * _utils->vgaScaleY(25)) + dy;
+	uint16 x1 = _vm->_utils->vgaScaleX(100) + (col * _vm->_utils->vgaScaleX(30)) + dx;
+	uint16 y1 = _vm->_utils->vgaScaleY(25) + (row * _vm->_utils->vgaScaleY(25)) + dy;
 
 	byte *buffer = new byte[_tiles[1]->_width * _tiles[1]->_height * 2L];
 
 	for (uint16 i = 0; i < last; i++) {
-		waitTOF();
-		scrollRaster(dX, dY, x1, y1, x1 + _utils->vgaScaleX(28) + sx, y1 + _utils->vgaScaleY(23) + sy, buffer);
+		_vm->waitTOF();
+		scrollRaster(dX, dY, x1, y1, x1 + _vm->_utils->vgaScaleX(28) + sx, y1 + _vm->_utils->vgaScaleY(23) + sy, buffer);
 		x1 += dX;
 		y1 += dY;
 	}
@@ -296,7 +309,7 @@ void LabEngine::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 /**
  * Changes the combination number of one of the slots
  */
-void LabEngine::changeCombination(uint16 number) {
+void TilePuzzle::changeCombination(uint16 number) {
 	const int solution[6] = { 0, 4, 0, 8, 7, 2 };
 
 	Image display;
@@ -310,22 +323,22 @@ void LabEngine::changeCombination(uint16 number) {
 
 	combnum = _combination[number];
 
-	display._imageData = _graphics->getCurrentDrawingBuffer();
-	display._width     = _graphics->_screenWidth;
-	display._height    = _graphics->_screenHeight;
+	display._imageData = _vm->_graphics->getCurrentDrawingBuffer();
+	display._width     = _vm->_graphics->_screenWidth;
+	display._height    = _vm->_graphics->_screenHeight;
 
 	byte *buffer = new byte[_tiles[1]->_width * _tiles[1]->_height * 2L];
 
 	for (uint16 i = 1; i <= (_numberImages[combnum]->_height / 2); i++) {
-		if (_isHiRes) {
+		if (_vm->_isHiRes) {
 			if (i & 1)
-				waitTOF();
+				_vm->waitTOF();
 		} else
-			waitTOF();
+			_vm->waitTOF();
 
-		display._imageData = _graphics->getCurrentDrawingBuffer();
-		_graphics->scrollDisplayY(2, _utils->vgaScaleX(COMBINATION_X[number]), _utils->vgaScaleY(65), _utils->vgaScaleX(COMBINATION_X[number]) + (_numberImages[combnum])->_width - 1, _utils->vgaScaleY(65) + (_numberImages[combnum])->_height, buffer);
-		_numberImages[combnum]->blitBitmap(0, (_numberImages[combnum])->_height - (2 * i), &(display), _utils->vgaScaleX(COMBINATION_X[number]), _utils->vgaScaleY(65), (_numberImages[combnum])->_width, 2, false);
+		display._imageData = _vm->_graphics->getCurrentDrawingBuffer();
+		_vm->_graphics->scrollDisplayY(2, _vm->_utils->vgaScaleX(COMBINATION_X[number]), _vm->_utils->vgaScaleY(65), _vm->_utils->vgaScaleX(COMBINATION_X[number]) + (_numberImages[combnum])->_width - 1, _vm->_utils->vgaScaleY(65) + (_numberImages[combnum])->_height, buffer);
+		_numberImages[combnum]->blitBitmap(0, (_numberImages[combnum])->_height - (2 * i), &(display), _vm->_utils->vgaScaleX(COMBINATION_X[number]), _vm->_utils->vgaScaleY(65), (_numberImages[combnum])->_width, 2, false);
 	}
 
 	delete[] buffer;
@@ -334,39 +347,39 @@ void LabEngine::changeCombination(uint16 number) {
 		unlocked &= (_combination[i] == solution[i]);
 
 	if (unlocked)
-		_conditions->inclElement(COMBINATIONUNLOCKED);
+		_vm->_conditions->inclElement(COMBINATIONUNLOCKED);
 	else
-		_conditions->exclElement(COMBINATIONUNLOCKED);
+		_vm->_conditions->exclElement(COMBINATIONUNLOCKED);
 }
 
-void LabEngine::scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer) {
+void TilePuzzle::scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer) {
 	if (dx)
-		_graphics->scrollDisplayX(dx, x1, y1, x2, y2, buffer);
+		_vm->_graphics->scrollDisplayX(dx, x1, y1, x2, y2, buffer);
 
 	if (dy)
-		_graphics->scrollDisplayY(dy, x1, y1, x2, y2, buffer);
+		_vm->_graphics->scrollDisplayY(dy, x1, y1, x2, y2, buffer);
 }
 
 /**
  * Draws the images of the combination lock to the display bitmap.
  */
-void LabEngine::doCombination() {
+void TilePuzzle::doCombination() {
 	for (uint16 i = 0; i <= 5; i++)
-		_numberImages[_combination[i]]->drawImage(_utils->vgaScaleX(COMBINATION_X[i]), _utils->vgaScaleY(65));
+		_numberImages[_combination[i]]->drawImage(_vm->_utils->vgaScaleX(COMBINATION_X[i]), _vm->_utils->vgaScaleY(65));
 }
 
 /**
  * Reads in a backdrop picture.
  */
-void LabEngine::showCombination(const char *filename) {
-	_anim->_doBlack = true;
-	_anim->_noPalChange = true;
-	_graphics->readPict(filename, true);
-	_anim->_noPalChange = false;
+void TilePuzzle::showCombination(const char *filename) {
+	_vm->_anim->_doBlack = true;
+	_vm->_anim->_noPalChange = true;
+	_vm->_graphics->readPict(filename, true);
+	_vm->_anim->_noPalChange = false;
 
-	_graphics->blackScreen();
+	_vm->_graphics->blackScreen();
 
-	Common::File *numFile = _resource->openDataFile("P:Numbers");
+	Common::File *numFile = _vm->_resource->openDataFile("P:Numbers");
 
 	for (uint16 CurBit = 0; CurBit < 10; CurBit++)
 		_numberImages[CurBit] = new Image(numFile);
@@ -375,7 +388,33 @@ void LabEngine::showCombination(const char *filename) {
 
 	doCombination();
 
-	_graphics->setPalette(_anim->_diffPalette, 256);
+	_vm->_graphics->setPalette(_vm->_anim->_diffPalette, 256);
+}
+
+void TilePuzzle::save(Common::OutSaveFile *file) {
+	uint16 i, j;
+
+	// Combination lock and tile stuff
+	for (i = 0; i < 6; i++)
+		file->writeByte(_combination[i]);
+
+	// Tiles
+	for (i = 0; i < 4; i++)
+		for (j = 0; j < 4; j++)
+			file->writeUint16LE(_curTile[i][j]);
+}
+
+void TilePuzzle::load(Common::InSaveFile *file) {
+	uint16 i, j;
+
+	// Combination lock and tile stuff
+	for (i = 0; i < 6; i++)
+		_combination[i] = file->readByte();
+
+	// Tiles
+	for (i = 0; i < 4; i++)
+		for (j = 0; j < 4; j++)
+			_curTile[i][j] = file->readUint16LE();
 }
 
 } // End of namespace Lab
diff --git a/engines/lab/tilepuzzle.h b/engines/lab/tilepuzzle.h
new file mode 100644
index 0000000..a20f4ce
--- /dev/null
+++ b/engines/lab/tilepuzzle.h
@@ -0,0 +1,70 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+/*
+ * This code is based on Labyrinth of Time code with assistance of
+ *
+ * Copyright (c) 1993 Terra Nova Development
+ * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
+ *
+ */
+
+#ifndef LAB_TILEPUZZLE_H
+#define LAB_TILEPUZZLE_H
+
+#include "common/savefile.h"
+
+namespace Lab {
+
+class LabEngine;
+
+class TilePuzzle {
+private:
+	LabEngine *_vm;
+	Image *_tiles[16];
+	Image *_numberImages[10];
+	uint16 _curTile[4][4];
+	byte _combination[6];
+
+public:
+	TilePuzzle(LabEngine *vm);
+	virtual ~TilePuzzle();
+
+	void mouseTile(Common::Point pos);
+	void showTile(const char *filename, bool showSolution);
+	void mouseCombination(Common::Point pos);
+	void showCombination(const char *filename);
+	void save(Common::OutSaveFile *file);
+	void load(Common::InSaveFile *file);
+
+private:
+	void doTile(bool showsolution);
+	void doTileScroll(uint16 col, uint16 row, uint16 scrolltype);
+	void changeCombination(uint16 number);
+	void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer);
+	void doCombination();
+	void changeTile(uint16 col, uint16 row);
+};
+
+} // End of namespace Lab
+
+#endif // LAB_TILEPUZZLE_H


Commit: 46a25b93abc8b44cc2c1e44f7ba73f86de64399b
    https://github.com/scummvm/scummvm/commit/46a25b93abc8b44cc2c1e44f7ba73f86de64399b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:00+01:00

Commit Message:
LAB: Rewrite some code using switch statements

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index b80910e..c9e1348 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -280,8 +280,8 @@ void LabEngine::interfaceOn() {
  * If the user hits the "Use" gadget; things that can get used on themselves.
  */
 bool LabEngine::doUse(uint16 curInv) {
-	if (curInv == MAPNUM) {
-		// LAB: Labyrinth specific
+	switch (curInv) {
+	case MAPNUM:
 		drawStaticMessage(kTextUseMap);
 		interfaceOff();
 		_anim->stopDiff();
@@ -291,8 +291,8 @@ bool LabEngine::doUse(uint16 curInv) {
 		_graphics->setPalette(initcolors, 8);
 		_graphics->drawMessage(nullptr);
 		_graphics->drawPanel();
-	} else if (curInv == JOURNALNUM) {
-		// LAB: Labyrinth specific
+		return true;
+	case JOURNALNUM:
 		drawStaticMessage(kTextUseJournal);
 		interfaceOff();
 		_anim->stopDiff();
@@ -301,14 +301,15 @@ bool LabEngine::doUse(uint16 curInv) {
 		doJournal();
 		_graphics->drawPanel();
 		_graphics->drawMessage(nullptr);
-	} else if (curInv == LAMPNUM) {
-		// LAB: Labyrinth specific
+		return true;
+	case LAMPNUM:
 		interfaceOff();
 
 		if (_conditions->in(LAMPON)) {
 			drawStaticMessage(kTextTurnLampOff);
 			_conditions->exclElement(LAMPON);
-		} else {
+		}
+		else {
 			drawStaticMessage(kTextTurnLampOn);
 			_conditions->inclElement(LAMPON);
 		}
@@ -320,29 +321,29 @@ bool LabEngine::doUse(uint16 curInv) {
 
 		_anim->_doBlack = false;
 		_nextFileName = getInvName(curInv);
-	} else if (curInv == BELTNUM) {
-		// LAB: Labyrinth specific
+		return true;
+	case BELTNUM:
 		if (!_conditions->in(BELTGLOW))
 			_conditions->inclElement(BELTGLOW);
 
 		_anim->_doBlack = false;
 		_nextFileName = getInvName(curInv);
-	} else if (curInv == WHISKEYNUM) {
-		// LAB: Labyrinth specific
+		return true;
+	case WHISKEYNUM:
 		_conditions->inclElement(USEDHELMET);
 		drawStaticMessage(kTextUseWhiskey);
-	} else if (curInv == PITHHELMETNUM) {
-		// LAB: Labyrinth specific
+		return true;
+	case PITHHELMETNUM:
 		_conditions->inclElement(USEDHELMET);
 		drawStaticMessage(kTextUsePith);
-	} else if (curInv == HELMETNUM) {
-		// LAB: Labyrinth specific
+		return true;
+	case HELMETNUM:
 		_conditions->inclElement(USEDHELMET);
 		drawStaticMessage(kTextUseHelmet);
-	} else
+		return true;
+	default:
 		return false;
-
-	return true;
+	}
 }
 
 /**
@@ -458,14 +459,20 @@ void LabEngine::mainGameLoop() {
 				_curFileName = _nextFileName;
 
 				if (_closeDataPtr) {
-					if ((_closeDataPtr->_closeUpType == SPECIALLOCK) && _mainDisplay)
-						_tilePuzzle->showCombination(_curFileName);
-					else if (((_closeDataPtr->_closeUpType == SPECIALBRICK)  ||
-								  (_closeDataPtr->_closeUpType == SPECIALBRICKNOMOUSE)) &&
-								  _mainDisplay)
-						_tilePuzzle->showTile(_curFileName, (bool)(_closeDataPtr->_closeUpType == SPECIALBRICKNOMOUSE));
-					else
+					switch (_closeDataPtr->_closeUpType) {
+					case SPECIALLOCK:
+						if (_mainDisplay)
+							_tilePuzzle->showCombination(_curFileName);
+						break;
+					case SPECIALBRICK:
+					case SPECIALBRICKNOMOUSE:
+						if (_mainDisplay)
+							_tilePuzzle->showTile(_curFileName, (_closeDataPtr->_closeUpType == SPECIALBRICKNOMOUSE));
+						break;
+					default:
 						_graphics->readPict(_curFileName, false);
+						break;
+					}
 				} else
 					_graphics->readPict(_curFileName, false);
 
@@ -503,12 +510,19 @@ void LabEngine::mainGameLoop() {
 
 				if (result != 0) {
 					uint16 code = 0;
-					if (result == VKEY_UPARROW)
+					switch (result) {
+					case VKEY_UPARROW:
 						code = 7;
-					else if (result == VKEY_LTARROW)
+						break;
+					case VKEY_LTARROW:
 						code = 6;
-					else if (result == VKEY_RTARROW)
+						break;
+					case VKEY_RTARROW:
 						code = 8;
+						break;
+					default:
+						break;
+					}
 
 					gotMessage = true;
 					mayShowCrumbIndicator();
@@ -776,8 +790,6 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 					}
 				} else if (_droppingCrumbs && oldRoomNum != _roomNum) {
 					// If in surreal maze, turn off DroppingCrumbs.
-					// Note: These numbers were generated by parsing the
-					// "Maps" file, which is why they are hard-coded. Bleh!
 					if (_roomNum >= 245 && _roomNum <= 280) {
 						_followingCrumbs = false;
 						_droppingCrumbs = false;
@@ -940,12 +952,19 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 		doit = false;
 
 		if (_closeDataPtr) {
-			if ((_closeDataPtr->_closeUpType == SPECIALLOCK) && _mainDisplay)
-				_tilePuzzle->mouseCombination(curPos);
-			else if ((_closeDataPtr->_closeUpType == SPECIALBRICK) && _mainDisplay)
-				_tilePuzzle->mouseTile(curPos);
-			else
+			switch (_closeDataPtr->_closeUpType) {
+			case SPECIALLOCK:
+				if (_mainDisplay)
+					_tilePuzzle->mouseCombination(curPos);
+				break;
+			case SPECIALBRICK:
+				if (_mainDisplay)
+					_tilePuzzle->mouseTile(curPos);
+				break;
+			default:
 				doit = true;
+				break;
+			}
 		} else
 			doit = true;
 


Commit: 7d4e71d29e9b97f3991b3264c509369ec8a91122
    https://github.com/scummvm/scummvm/commit/7d4e71d29e9b97f3991b3264c509369ec8a91122
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:00+01:00

Commit Message:
LAB: Change the map floor showing code, when changing floors

This greatly simplifies the code that shows a floor when an arrow is
pressed. Also, it changes the behavior of the arrows to show all of
the visited floors, instead of a specific subset. I believe that this
makes the map better, more usable and less confusing than the original

Changed paths:
    engines/lab/lab.h
    engines/lab/map.cpp



diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 7160df5..b7491ac 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -222,9 +222,9 @@ private:
 	bool saveRestoreGame();
 	Common::Rect roomCoords(uint16 curRoom);
 	void drawRoomMap(uint16 curRoom, bool drawMarkFl);
-	bool onFloor(uint16 floorNum);
-	bool getUpFloor(uint16 *floorNum);
-	bool getDownFloor(uint16 *floorNum);
+	bool floorVisited(uint16 floorNum);
+	uint16 getUpperFloor(uint16 floorNum);
+	uint16 getLowerFloor(uint16 floorNum);
 	bool checkConditions(int16 *condition);
 	ViewData *getViewData(uint16 roomNum, uint16 direction);
 	CloseData *getObject(Common::Point pos, CloseDataPtr closePtr);
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index b484a1e..db99550 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -317,7 +317,7 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) {
 /**
  * Checks if a floor has been visited.
  */
-bool LabEngine::onFloor(uint16 floorNum) {
+bool LabEngine::floorVisited(uint16 floorNum) {
 	for (uint16 i = 1; i <= _maxRooms; i++) {
 		if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x)
 			return true;
@@ -327,48 +327,33 @@ bool LabEngine::onFloor(uint16 floorNum) {
 }
 
 /**
- * Figures out which floor, if any, should be gone to if the up arrow is hit
+ * Returns the floor to show when the up arrow is pressed
+ * Note: The original did not show all the visited floors, but we do
  */
-bool LabEngine::getUpFloor(uint16 *floorNum) {
-	do {
-		if (*floorNum < kFloorUpper)
-			(*floorNum)++;
-		else {
-			*floorNum   = kFloorCarnival + 1;
-			return false;
-		}
-	} while ((!onFloor(*floorNum)) && (*floorNum <= kFloorCarnival));
+uint16 LabEngine::getUpperFloor(uint16 floorNum) {
+	if (floorNum == kFloorCarnival || floorNum == kFloorNone)
+		return kFloorNone;
+
+	for (uint16 i = floorNum; i < kFloorCarnival; i++)
+		if (floorVisited(i + 1))
+			return i + 1;
 
-	return true;
+	return kFloorNone;
 }
 
 /**
- * Figures out which floor, if any, should be gone to if the down arrow is
- * hit.
+ * Returns the floor to show when the down arrow is pressed
+ * Note: The original did not show all the visited floors, but we do
  */
-bool LabEngine::getDownFloor(uint16 *floorNum) {
-	do {
-		if ((*floorNum == kFloorLower) || (*floorNum == kFloorNone)) {
-			*floorNum = kFloorNone;
-			return false;
-		} else if (*floorNum > kFloorUpper) {
-			// Labyrinth specific code
-			if (*floorNum == kFloorHedgeMaze)
-				*floorNum = kFloorUpper;
-			else if ((*floorNum == kFloorCarnival) || (*floorNum == kFloorMedMaze))
-				*floorNum = kFloorMiddle;
-			else if (*floorNum == kFloorSurMaze)
-				*floorNum = kFloorLower;
-			else {
-				*floorNum = kFloorNone;
-				return false;
-			}
-		} else
-			(*floorNum)--;
+uint16 LabEngine::getLowerFloor(uint16 floorNum) {
+	if (floorNum == kFloorLower || floorNum == kFloorNone)
+		return kFloorNone;
 
-	} while ((!onFloor(*floorNum)) && (*floorNum != kFloorNone));
+	for (uint16 i = floorNum; i > kFloorLower; i--)
+		if (floorVisited(i - 1))
+			return i - 1;
 
-	return true;
+	return kFloorNone;
 }
 
 /**
@@ -399,37 +384,31 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad
 	if ((_maps[curRoom]._pageNumber == floorNum) && _roomsFound->in(curRoom) && _maps[curRoom]._x)
 		drawRoomMap(curRoom, true);
 
-	uint16 tempfloor = floorNum;
-	bool noOverlay = getUpFloor(&tempfloor);
-
 	Gadget *upGadget = _event->getGadget(1);
 	Gadget *downGadget = _event->getGadget(2);
 
-	if (noOverlay)
+	if (getUpperFloor(floorNum) != kFloorNone)
 		enableGadget(upGadget);
 	else
 		disableGadget(upGadget, 12);
 
-	tempfloor = floorNum;
-	noOverlay = getDownFloor(&tempfloor);
-
-	if (noOverlay)
+	if (getLowerFloor(floorNum) != kFloorNone)
 		enableGadget(downGadget);
 	else
 		disableGadget(downGadget, 12);
 
 	// Labyrinth specific code
 	if (floorNum == kFloorLower) {
-		if (onFloor(kFloorSurMaze))
+		if (floorVisited(kFloorSurMaze))
 			_imgMaze->drawImage(_utils->mapScaleX(538), _utils->mapScaleY(277));
 	} else if (floorNum == kFloorMiddle) {
-		if (onFloor(kFloorCarnival))
+		if (floorVisited(kFloorCarnival))
 			_imgMaze->drawImage(_utils->mapScaleX(358), _utils->mapScaleY(72));
 
-		if (onFloor(kFloorMedMaze))
+		if (floorVisited(kFloorMedMaze))
 			_imgMaze->drawImage(_utils->mapScaleX(557), _utils->mapScaleY(325));
 	} else if (floorNum == kFloorUpper) {
-		if (onFloor(kFloorHedgeMaze))
+		if (floorVisited(kFloorHedgeMaze))
 			_imgHugeMaze->drawImage(_utils->mapScaleX(524), _utils->mapScaleY(97));
 	} else if (floorNum == kFloorSurMaze) {
 		char *sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str();
@@ -510,31 +489,27 @@ void LabEngine::processMap(uint16 curRoom) {
 					return;
 				} else if (gadgetID == 1) {
 					// Up arrow
-					uint16 oldFloor = curFloor;
-					bool drawmap = getUpFloor(&curFloor);
-
-					if (drawmap) {
+					uint16 upperFloor = getUpperFloor(curFloor);
+					if (upperFloor != kFloorNone) {
+						curFloor = upperFloor;
 						_graphics->fade(false, 0);
 						drawMap(curRoom, curMsg, curFloor, false, false);
 						_graphics->fade(true, 0);
-					} else
-						curFloor = oldFloor;
+					}
 				} else if (gadgetID == 2) {
 					// Down arrow
-					uint16 oldFloor = curFloor;
-					bool drawmap = getDownFloor(&curFloor);
-
-					if (drawmap) {
+					uint16 lowerFloor = getLowerFloor(curFloor);
+					if (lowerFloor != kFloorNone) {
+						curFloor = lowerFloor;
 						_graphics->fade(false, 0);
 						drawMap(curRoom, curMsg, curFloor, false, false);
 						_graphics->fade(true, 0);
-					} else
-						curFloor = oldFloor;
+					}
 				}
 			} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) {
 				if ((curFloor == kFloorLower) && (mouseX >= _utils->mapScaleX(538)) && (mouseY >= _utils->mapScaleY(277))
 					  && (mouseX <= _utils->mapScaleX(633)) && (mouseY <= _utils->mapScaleY(352))
-					  && onFloor(kFloorSurMaze)) {
+					  && floorVisited(kFloorSurMaze)) {
 					curFloor = kFloorSurMaze;
 
 					_graphics->fade(false, 0);
@@ -542,7 +517,7 @@ void LabEngine::processMap(uint16 curRoom) {
 					_graphics->fade(true, 0);
 				} else if ((curFloor == kFloorMiddle) && (mouseX >= _utils->mapScaleX(358)) && (mouseY >= _utils->mapScaleY(71))
 							  && (mouseX <= _utils->mapScaleX(452)) && (mouseY <= _utils->mapScaleY(147))
-							  && onFloor(kFloorCarnival)) {
+							  && floorVisited(kFloorCarnival)) {
 					curFloor = kFloorCarnival;
 
 					_graphics->fade(false, 0);
@@ -550,7 +525,7 @@ void LabEngine::processMap(uint16 curRoom) {
 					_graphics->fade(true, 0);
 				} else if ((curFloor == kFloorMiddle) && (mouseX >= _utils->mapScaleX(557)) && (mouseY >= _utils->mapScaleY(325))
 						  && (mouseX <= _utils->mapScaleX(653)) && (mouseY <= _utils->mapScaleY(401))
-						  && onFloor(kFloorMedMaze)) {
+						  && floorVisited(kFloorMedMaze)) {
 					curFloor = kFloorMedMaze;
 
 					_graphics->fade(false, 0);
@@ -558,7 +533,7 @@ void LabEngine::processMap(uint16 curRoom) {
 					_graphics->fade(true, 0);
 				} else if ((curFloor == kFloorUpper) && (mouseX >= _utils->mapScaleX(524)) && (mouseY >=  _utils->mapScaleY(97))
 						  && (mouseX <= _utils->mapScaleX(645)) && (mouseY <= _utils->mapScaleY(207))
-						  && onFloor(kFloorHedgeMaze)) {
+						  && floorVisited(kFloorHedgeMaze)) {
 					curFloor = kFloorHedgeMaze;
 
 					_graphics->fade(false, 0);


Commit: 4fb53ad170f483bbce2e27643cd3ee1fa604cebd
    https://github.com/scummvm/scummvm/commit/4fb53ad170f483bbce2e27643cd3ee1fa604cebd
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:00+01:00

Commit Message:
LAB: Some renames, simplified saveGame() and loadGame()

Changed paths:
    engines/lab/engine.cpp
    engines/lab/lab.h
    engines/lab/resource.h
    engines/lab/savegame.cpp
    engines/lab/savegame.h



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index c9e1348..17518fb 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -50,37 +50,37 @@ namespace Lab {
 #define SPECIALBRICK        101
 #define SPECIALBRICKNOMOUSE 102
 
-#define MAPNUM               28
-#define JOURNALNUM            9
-#define WESTPAPERNUM         18
-#define NOTESNUM             12
-#define WHISKEYNUM           25
-#define PITHHELMETNUM         7
-#define HELMETNUM             1
-
-#define LAMPNUM              27
-#define LAMPON              151
-
-#define BELTNUM               3
-#define BELTGLOW             70
-
-#define USEDHELMET          184
-
-#define QUARTERNUM           30
-
-
-#define MUSEUMMONITOR        71
-#define GRAMAPHONEMONITOR    72
-#define UNICYCLEMONITOR      73
-#define STATUEMONITOR        74
-#define TALISMANMONITOR      75
-#define LUTEMONITOR          76
-#define CLOCKMONITOR         77
-#define WINDOWMONITOR        78
-#define BELTMONITOR          79
-#define LIBRARYMONITOR       80
-#define TERMINALMONITOR      81
-#define LEVERSMONITOR        82
+enum Items {
+	kItemHelmet = 1,
+	kItemBelt = 3,
+	kItemPithHelmet = 7,
+	kItemJournal = 9,
+	kItemNotes = 12,
+	kItemWestPaper = 18,
+	kItemWhiskey = 25,
+	kItemLamp = 27,
+	kItemMap = 28,
+	kItemQuarter = 30
+};
+
+#define kCondLampOn         151
+#define kCondBeltGlowing     70
+#define kCondUsedHelmet     184
+
+enum Monitors {
+	kMonitorMuseum = 71,
+	kMonitorGramophone = 72,
+	kMonitorUnicycle = 73,
+	kMonitorStatue = 74,
+	kMonitorTalisman = 75,
+	kMonitorLute = 76,
+	kMonitorClock = 77,
+	kMonitorWindow = 78,
+	//kMonitorBelt = 79,
+	kMonitorLibrary = 80,
+	kMonitorTerminal = 81
+	//kMonitorLevers = 82
+};
 
 static char initcolors[] = { '\x00', '\x00', '\x00', '\x30',
 							 '\x30', '\x30', '\x10', '\x10',
@@ -89,6 +89,14 @@ static char initcolors[] = { '\x00', '\x00', '\x00', '\x30',
 							 '\x24', '\x24', '\x2c', '\x2c',
 							 '\x2c', '\x08', '\x08', '\x08' };
 
+uint16 LabEngine::getQuarters() {
+	return _inventory[kItemQuarter]._many;
+}
+
+void LabEngine::setQuarters(uint16 quarters) {
+	_inventory[kItemQuarter]._many = quarters;
+}
+
 /**
  * Draws the message for the room.
  */
@@ -100,9 +108,9 @@ void LabEngine::drawRoomMessage(uint16 curInv, CloseDataPtr closePtr) {
 
 	if (_alternate) {
 		if ((curInv <= _numInv) && _conditions->in(curInv) && _inventory[curInv]._bitmapName) {
-			if ((curInv == LAMPNUM) && _conditions->in(LAMPON))
+			if ((curInv == kItemLamp) && _conditions->in(kCondLampOn))
 				// LAB: Labyrinth specific
-				drawStaticMessage(kTextLampOn);
+				drawStaticMessage(kTextkLampOn);
 			else if (_inventory[curInv]._many > 1) {
 				Common::String roomMessage = Common::String(_inventory[curInv]._name) + "  (" + Common::String::format("%d", _inventory[curInv]._many) + ")";
 				_graphics->drawMessage(roomMessage.c_str());
@@ -182,30 +190,30 @@ bool LabEngine::doCloseUp(CloseDataPtr closePtr) {
 	}
 
 	switch (closePtr->_closeUpType) {
-	case MUSEUMMONITOR:
-	case LIBRARYMONITOR:
-	case WINDOWMONITOR:
+	case kMonitorMuseum:
+	case kMonitorLibrary:
+	case kMonitorWindow:
 		doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, monrtmargin, 165);
 		break;
-	case GRAMAPHONEMONITOR:
+	case kMonitorGramophone:
 		doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, 171, 165);
 		break;
-	case UNICYCLEMONITOR:
+	case kMonitorUnicycle:
 		doMonitor(closePtr->_graphicName, closePtr->_message, false, 100, montopmargin, monrtmargin, 165);
 		break;
-	case STATUEMONITOR:
+	case kMonitorStatue:
 		doMonitor(closePtr->_graphicName, closePtr->_message, false, 117, montopmargin, monrtmargin, 165);
 		break;
-	case TALISMANMONITOR:
+	case kMonitorTalisman:
 		doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, 184, 165);
 		break;
-	case LUTEMONITOR:
+	case kMonitorLute:
 		doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, lutertmargin, 165);
 		break;
-	case CLOCKMONITOR:
+	case kMonitorClock:
 		doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, 206, 165);
 		break;
-	case TERMINALMONITOR:
+	case kMonitorTerminal:
 		doMonitor(closePtr->_graphicName, closePtr->_message, true, monltmargin, montopmargin, monrtmargin, 165);
 		break;
 	default:
@@ -225,19 +233,19 @@ const char *LabEngine::getInvName(uint16 curInv) {
 	if (_mainDisplay)
 		return _inventory[curInv]._bitmapName;
 
-	if ((curInv == LAMPNUM) && _conditions->in(LAMPON))
+	if ((curInv == kItemLamp) && _conditions->in(kCondLampOn))
 		return "P:Mines/120";
 
-	if ((curInv == BELTNUM) && _conditions->in(BELTGLOW))
-		return "P:Future/BeltGlow";
+	if ((curInv == kItemBelt) && _conditions->in(kCondBeltGlowing))
+		return "P:Future/kCondBeltGlowing";
 
-	if (curInv == WESTPAPERNUM) {
+	if (curInv == kItemWestPaper) {
 		_curFileName = _inventory[curInv]._bitmapName;
 		_anim->_noPalChange = true;
 		_graphics->readPict(_curFileName, false);
 		_anim->_noPalChange = false;
 		doWestPaper();
-	} else if (curInv == NOTESNUM) {
+	} else if (curInv == kItemNotes) {
 		_curFileName = _inventory[curInv]._bitmapName;
 		_anim->_noPalChange = true;
 		_graphics->readPict(_curFileName, false);
@@ -281,7 +289,7 @@ void LabEngine::interfaceOn() {
  */
 bool LabEngine::doUse(uint16 curInv) {
 	switch (curInv) {
-	case MAPNUM:
+	case kItemMap:
 		drawStaticMessage(kTextUseMap);
 		interfaceOff();
 		_anim->stopDiff();
@@ -292,7 +300,7 @@ bool LabEngine::doUse(uint16 curInv) {
 		_graphics->drawMessage(nullptr);
 		_graphics->drawPanel();
 		return true;
-	case JOURNALNUM:
+	case kItemJournal:
 		drawStaticMessage(kTextUseJournal);
 		interfaceOff();
 		_anim->stopDiff();
@@ -302,16 +310,16 @@ bool LabEngine::doUse(uint16 curInv) {
 		_graphics->drawPanel();
 		_graphics->drawMessage(nullptr);
 		return true;
-	case LAMPNUM:
+	case kItemLamp:
 		interfaceOff();
 
-		if (_conditions->in(LAMPON)) {
+		if (_conditions->in(kCondLampOn)) {
 			drawStaticMessage(kTextTurnLampOff);
-			_conditions->exclElement(LAMPON);
+			_conditions->exclElement(kCondLampOn);
 		}
 		else {
-			drawStaticMessage(kTextTurnLampOn);
-			_conditions->inclElement(LAMPON);
+			drawStaticMessage(kTextTurnkLampOn);
+			_conditions->inclElement(kCondLampOn);
 		}
 
 		_anim->_doBlack = false;
@@ -322,23 +330,23 @@ bool LabEngine::doUse(uint16 curInv) {
 		_anim->_doBlack = false;
 		_nextFileName = getInvName(curInv);
 		return true;
-	case BELTNUM:
-		if (!_conditions->in(BELTGLOW))
-			_conditions->inclElement(BELTGLOW);
+	case kItemBelt:
+		if (!_conditions->in(kCondBeltGlowing))
+			_conditions->inclElement(kCondBeltGlowing);
 
 		_anim->_doBlack = false;
 		_nextFileName = getInvName(curInv);
 		return true;
-	case WHISKEYNUM:
-		_conditions->inclElement(USEDHELMET);
+	case kItemWhiskey:
+		_conditions->inclElement(kCondUsedHelmet);
 		drawStaticMessage(kTextUseWhiskey);
 		return true;
-	case PITHHELMETNUM:
-		_conditions->inclElement(USEDHELMET);
+	case kItemPithHelmet:
+		_conditions->inclElement(kCondUsedHelmet);
 		drawStaticMessage(kTextUsePith);
 		return true;
-	case HELMETNUM:
-		_conditions->inclElement(USEDHELMET);
+	case kItemHelmet:
+		_conditions->inclElement(kCondUsedHelmet);
 		drawStaticMessage(kTextUseHelmet);
 		return true;
 	default:
@@ -394,7 +402,7 @@ void LabEngine::decIncInv(uint16 *curInv, bool decreaseFl) {
  */
 void LabEngine::mainGameLoop() {
 	uint16 actionMode = 4;
-	uint16 curInv = MAPNUM;
+	uint16 curInv = kItemMap;
 
 	bool forceDraw = false;
 	bool gotMessage = true;
@@ -574,7 +582,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 	Common::Point curPos = tmpPos;
 
 	uint16 oldDirection = 0;
-	uint16 lastInv = MAPNUM;
+	uint16 lastInv = kItemMap;
 	CloseDataPtr wrkClosePtr = nullptr;
 	bool doit;
 
@@ -729,7 +737,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 				_graphics->screenUpdate();
 			}
 		} else if (gadgetId == 9) {
-			doUse(MAPNUM);
+			doUse(kItemMap);
 
 			mayShowCrumbIndicator();
 			_graphics->screenUpdate();
@@ -850,8 +858,8 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 			_closeDataPtr = nullptr;
 			_mainDisplay = true;
 
-			curInv = MAPNUM;
-			lastInv = MAPNUM;
+			curInv = kItemMap;
+			lastInv = kItemMap;
 
 			_nextFileName = getInvName(curInv);
 
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index b7491ac..9581925 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -74,8 +74,6 @@ enum GameFeatures {
 #define UPSCROLL       3
 #define DOWNSCROLL     4
 
-#define QUARTERNUM  30
-
 typedef Common::List<Gadget *> GadgetList;
 
 struct CrumbData {
@@ -210,6 +208,11 @@ public:
 	void changeVolume(int delta);
 	char *getPictName(CloseDataPtr *closePtrList);
 
+	uint16 getQuarters();
+	void setQuarters(uint16 quarters);
+	uint16 getDirection() { return _direction; }
+	void setDirection(uint16 direction) { _direction = direction; };
+
 private:
 	void freeScreens();
 	void perFlipGadget(uint16 gadID);
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index 2273d79..4826558 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -51,7 +51,7 @@ enum StaticText {
 	kTextFacingSouth,
 	kTextFacingWest,
 
-	kTextLampOn,
+	kTextkLampOn,
 
 	kTextTurnLeft,
 	kTextTurnRight,
@@ -85,7 +85,7 @@ enum StaticText {
 
 	kTextUseMap,
 	kTextUseJournal,
-	kTextTurnLampOn,
+	kTextTurnkLampOn,
 	kTextTurnLampOff,
 	kTextUseWhiskey,
 	kTextUsePith,
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 622c1a5..9ead742 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -123,7 +123,7 @@ bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
 /**
  * Writes the game out to disk.
  */
-bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc) {
+bool saveGame(int slot, Common::String desc) {
 	uint16 i;
 	Common::String fileName = g_lab->generateSaveFileName(slot);
 	Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
@@ -138,8 +138,8 @@ bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc)
 
 	writeSaveGameHeader(file, desc);
 	file->writeUint16LE(g_lab->_roomNum);
-	file->writeUint16LE(Direction);
-	file->writeUint16LE(Quarters);
+	file->writeUint16LE(g_lab->getDirection());
+	file->writeUint16LE(g_lab->getQuarters());
 
 	// Conditions
 	for (i = 0; i < g_lab->_conditions->_lastElement / (8 * 2); i++)
@@ -167,7 +167,7 @@ bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc)
 /**
  * Reads the game from disk.
  */
-bool loadGame(uint16 *Direction, uint16 *Quarters, int slot) {
+bool loadGame(int slot) {
 	uint16 i;
 	Common::String fileName = g_lab->generateSaveFileName(slot);
 	Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
@@ -179,8 +179,8 @@ bool loadGame(uint16 *Direction, uint16 *Quarters, int slot) {
 	SaveGameHeader header;
 	readSaveGameHeader(file, header);
 	g_lab->_roomNum = file->readUint16LE();
-	*Direction = file->readUint16LE();
-	*Quarters = file->readUint16LE();
+	g_lab->setDirection(file->readUint16LE());
+	g_lab->setQuarters(file->readUint16LE());
 
 	// Conditions
 	for (i = 0; i < g_lab->_conditions->_lastElement / (8 * 2); i++)
@@ -234,14 +234,14 @@ bool LabEngine::saveRestoreGame() {
 				desc = dialog->createDefaultSaveDescription(slot);
 			}
 
-			isOK = saveGame(_direction, _inventory[QUARTERNUM]._many, slot, desc);
+			isOK = saveGame(slot, desc);
 		}
 	} else {
 		// Restore
 		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
 		int slot = dialog->runModalWithCurrentTarget();
 		if (slot >= 0) {
-			isOK = loadGame(&_direction, &(_inventory[QUARTERNUM]._many), slot);
+			isOK = loadGame(slot);
 			if (isOK)
 				_music->resetMusic();
 		}
diff --git a/engines/lab/savegame.h b/engines/lab/savegame.h
index 608da99..f4f08b6 100644
--- a/engines/lab/savegame.h
+++ b/engines/lab/savegame.h
@@ -44,8 +44,8 @@ struct SaveGameHeader {
 	uint16 _direction;
 };
 
-bool saveGame(uint16 Direction, uint16 Quarters, int slot, Common::String desc);
-bool loadGame(uint16 *Direction, uint16 *Quarters, int slot);
+bool saveGame(int slot, Common::String desc);
+bool loadGame(int slot);
 bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header);
 
 } // End of namespace Lab


Commit: 0c0b2da235bfbbc3a11ef9677137d5a77f5b35a2
    https://github.com/scummvm/scummvm/commit/0c0b2da235bfbbc3a11ef9677137d5a77f5b35a2
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:00+01:00

Commit Message:
LAB: Move some defines which are only used in the tile puzzle

Changed paths:
    engines/lab/lab.h
    engines/lab/tilepuzzle.cpp



diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 9581925..639983b 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -67,12 +67,6 @@ enum GameFeatures {
 };
 
 #define ONESECOND      1000
-#define BRICKOPEN      115
-#define COMBINATIONUNLOCKED  130
-#define LEFTSCROLL     1
-#define RIGHTSCROLL    2
-#define UPSCROLL       3
-#define DOWNSCROLL     4
 
 typedef Common::List<Gadget *> GadgetList;
 
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index 782bcda..4d461a8 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -43,6 +43,16 @@
 
 namespace Lab {
 
+#define BRICKOPEN      115
+#define COMBINATIONUNLOCKED  130
+
+enum TileScroll {
+	kScrollLeft = 1,
+	kScrollRight = 2,
+	kScrollUp = 3,
+	kScrollDown = 4
+};
+
 const uint16 INIT_TILE[4][4] = {
 	{ 1, 5, 9, 13 },
 	{ 2, 6, 10, 14 },
@@ -111,7 +121,7 @@ void TilePuzzle::changeTile(uint16 col, uint16 row) {
 		if (_curTile[col][row - 1] == 0) {
 			_curTile[col][row - 1] = _curTile[col][row];
 			_curTile[col][row] = 0;
-			scrolltype = DOWNSCROLL;
+			scrolltype = kScrollDown;
 		}
 	}
 
@@ -119,7 +129,7 @@ void TilePuzzle::changeTile(uint16 col, uint16 row) {
 		if (_curTile[col - 1][row] == 0) {
 			_curTile[col - 1][row] = _curTile[col][row];
 			_curTile[col][row] = 0;
-			scrolltype = RIGHTSCROLL;
+			scrolltype = kScrollRight;
 		}
 	}
 
@@ -127,7 +137,7 @@ void TilePuzzle::changeTile(uint16 col, uint16 row) {
 		if (_curTile[col][row + 1] == 0) {
 			_curTile[col][row + 1] = _curTile[col][row];
 			_curTile[col][row] = 0;
-			scrolltype = UPSCROLL;
+			scrolltype = kScrollUp;
 		}
 	}
 
@@ -135,7 +145,7 @@ void TilePuzzle::changeTile(uint16 col, uint16 row) {
 		if (_curTile[col + 1][row] == 0) {
 			_curTile[col + 1][row] = _curTile[col][row];
 			_curTile[col][row] = 0;
-			scrolltype = LEFTSCROLL;
+			scrolltype = kScrollLeft;
 		}
 	}
 
@@ -269,20 +279,20 @@ void TilePuzzle::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 	int16 dX = 0, dY = 0, dx = 0, dy = 0, sx = 0, sy = 0;
 	uint16 last = 0;
 
-	if (scrolltype == LEFTSCROLL) {
+	if (scrolltype == kScrollLeft) {
 		dX = _vm->_utils->vgaScaleX(5);
 		sx = _vm->_utils->vgaScaleX(5);
 		last = 6;
-	} else if (scrolltype == RIGHTSCROLL) {
+	} else if (scrolltype == kScrollRight) {
 		dX = _vm->_utils->vgaScaleX(-5);
 		dx = _vm->_utils->vgaScaleX(-5);
 		sx = _vm->_utils->vgaScaleX(5);
 		last = 6;
-	} else if (scrolltype == UPSCROLL) {
+	} else if (scrolltype == kScrollUp) {
 		dY = _vm->_utils->vgaScaleY(5);
 		sy = _vm->_utils->vgaScaleY(5);
 		last = 5;
-	} else if (scrolltype == DOWNSCROLL) {
+	} else if (scrolltype == kScrollDown) {
 		dY = _vm->_utils->vgaScaleY(-5);
 		dy = _vm->_utils->vgaScaleY(-5);
 		sy = _vm->_utils->vgaScaleY(5);


Commit: 7bb45a8eaaf663cca9d0765d84b38967c3cc3275
    https://github.com/scummvm/scummvm/commit/7bb45a8eaaf663cca9d0765d84b38967c3cc3275
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:01+01:00

Commit Message:
LAB: Move timing functions to the utility class

Changed paths:
  R engines/lab/timing.cpp
    engines/lab/anim.cpp
    engines/lab/engine.cpp
    engines/lab/intro.cpp
    engines/lab/lab.h
    engines/lab/module.mk
    engines/lab/processroom.cpp
    engines/lab/utils.cpp
    engines/lab/utils.h



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index a461996..3bed365 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -98,8 +98,8 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 
 			if (!onlyDiffData) {
 				if (_headerdata._fps) {
-					_vm->waitForTime(_waitSec, _waitMicros);
-					_vm->addCurTime(0L, _delayMicros, &_waitSec, &_waitMicros);
+					_vm->_utils->waitForTime(_waitSec, _waitMicros);
+					_vm->_utils->addCurTime(0L, _delayMicros, &_waitSec, &_waitMicros);
 				}
 
 				if (_isPal && !_noPalChange) {
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 17518fb..f0d3ab7 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -609,7 +609,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 					_followCrumbsFast = (code == 'r' || code == 'R');
 					_isCrumbTurning = false;
 					_isCrumbWaiting = false;
-					getTime(&_crumbSecs, &_crumbMicros);
+					_utils->getTime(&_crumbSecs, &_crumbMicros);
 
 					if (_alternate) {
 						eatMessages();
@@ -930,7 +930,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 					_followCrumbsFast = false;
 					_isCrumbTurning = false;
 					_isCrumbWaiting = false;
-					getTime(&_crumbSecs, &_crumbMicros);
+					_utils->getTime(&_crumbSecs, &_crumbMicros);
 
 					eatMessages();
 					_alternate = false;
@@ -1144,7 +1144,7 @@ int LabEngine::followCrumbs() {
 		uint32 Secs;
 		uint32 Micros;
 
-		timeDiff(_crumbSecs, _crumbMicros, &Secs, &Micros);
+		_utils->timeDiff(_crumbSecs, _crumbMicros, &Secs, &Micros);
 
 		if (Secs != 0 || Micros != 0)
 			return 0;
@@ -1189,7 +1189,7 @@ int LabEngine::followCrumbs() {
 		_isCrumbTurning = (moveDir != VKEY_UPARROW);
 		_isCrumbWaiting = true;
 
-		addCurTime(theDelay / ONESECOND, theDelay % ONESECOND, &_crumbSecs, &_crumbMicros);
+		_utils->addCurTime(theDelay / ONESECOND, theDelay % ONESECOND, &_crumbSecs, &_crumbMicros);
 	}
 
 	return moveDir;
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index d0406bc..633691c 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -36,6 +36,7 @@
 #include "lab/intro.h"
 #include "lab/music.h"
 #include "lab/resource.h"
+#include "lab/utils.h"
 
 namespace Lab {
 
@@ -131,7 +132,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 				return;
 			}
 
-			_vm->getTime(&lastSecs, &lastMicros);
+			_vm->_utils->getTime(&lastSecs, &lastMicros);
 		}
 
 		msg = _vm->getMsg();
@@ -139,8 +140,8 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 		if (msg == NULL) {
 			_vm->_music->updateMusic();
 			_vm->_anim->diffNextFrame();
-			_vm->getTime(&secs, &micros);
-			_vm->anyTimeDiff(lastSecs, lastMicros, secs, micros, &secs, &micros);
+			_vm->_utils->getTime(&secs, &micros);
+			_vm->_utils->anyTimeDiff(lastSecs, lastMicros, secs, micros, &secs, &micros);
 
 			if (secs > timeDelay) {
 				if (end) {
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 639983b..d9f59f0 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -103,13 +103,6 @@ public:
 
 	LargeSet *_conditions, *_roomsFound;
 
-	// timing.cpp
-	void getTime(uint32 *secs, uint32 *micros);
-	void addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *timeMicros);
-	void anyTimeDiff(uint32 sec1, uint32 micros1, uint32 sec2, uint32 micros2, uint32 *diffSecs, uint32 *diffMicros);
-	void timeDiff(uint32 sec, uint32 micros, uint32 *diffSec, uint32 *diffMicros);
-	void waitForTime(uint32 sec, uint32 micros);
-
 private:
 	uint32 _extraGameFeatures;
 	bool _interfaceOff;
@@ -117,7 +110,6 @@ private:
 	bool _quitLab;
 	bool _mainDisplay;
 	// timing.cpp
-	void microDelay(uint32 secs, uint32 micros);
 
 public:
 	EventManager *_event;
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index 0d05de2..a0dcfde 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -18,7 +18,6 @@ MODULE_OBJS := \
 	savegame.o \
 	special.o \
 	tilepuzzle.o \
-	timing.o \
 	transitions.o \
 	utils.o
 
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 49287ae..b997942 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -425,14 +425,14 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 
 		case WAITSECS: {
 				uint32 startSecs, startMicros, curSecs, curMicros;
-				addCurTime(actionList->_param1, 0, &startSecs, &startMicros);
+				_utils->addCurTime(actionList->_param1, 0, &startSecs, &startMicros);
 
 				_graphics->screenUpdate();
 
 				while (1) {
 					_music->updateMusic();
 					_anim->diffNextFrame();
-					getTime(&curSecs, &curMicros);
+					_utils->getTime(&curSecs, &curMicros);
 
 					if ((curSecs > startSecs) || ((curSecs == startSecs) && (curMicros >= startMicros)))
 						break;
diff --git a/engines/lab/timing.cpp b/engines/lab/timing.cpp
deleted file mode 100644
index 1cbe6d3..0000000
--- a/engines/lab/timing.cpp
+++ /dev/null
@@ -1,127 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "lab/lab.h"
-
-namespace Lab {
-
-/**
- * Waits for for Secs seconds and Micros microseconds to pass.
- */
-void LabEngine::microDelay(uint32 secs, uint32 micros) {
-	uint32 waitSecs, waitMicros;
-	addCurTime(secs, micros, &waitSecs, &waitMicros);
-
-	while (1) {
-		getTime(&secs, &micros);
-
-		if ((secs > waitSecs) || ((secs == waitSecs) && (micros >= waitMicros)))
-			return;
-
-		g_system->delayMillis(10);
-	}
-}
-
-/**
- * Gets the current system time.
- */
-void LabEngine::getTime(uint32 *secs, uint32 *micros) {
-	uint32 t = g_system->getMillis();
-
-	*secs = t / 1000;
-	*micros = t % 1000;
-}
-
-/**
- * Adds seconds and microseconds to current time to get a new time.
- */
-void LabEngine::addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *timeMicros) {
-	getTime(timeSec, timeMicros);
-
-	(*timeSec) += sec;
-	(*timeMicros) += micros;
-
-	if (*timeMicros >= ONESECOND) {
-		(*timeSec)++;
-		(*timeMicros) -= ONESECOND;
-	}
-}
-
-/**
- * Finds the difference between time1 and time2.  If time1 is later than
- * time2, returns 0.
- */
-void LabEngine::anyTimeDiff(uint32 sec1, uint32 micros1, uint32 sec2, uint32 micros2, uint32 *diffSecs, uint32 *diffMicros) {
-	*diffSecs = 0;
-	*diffMicros = 0;
-
-	if (sec1 > sec2)
-		return;
-	else if ((sec1 == sec2) && (micros1 >= micros2))
-		return;
-
-	if (micros1 > micros2) {
-		*diffSecs = sec2 - sec1 - 1;
-		*diffMicros = (ONESECOND - micros1) + micros2;
-	} else {
-		*diffSecs = sec2 - sec1;
-		*diffMicros = micros2 - micros1;
-	}
-}
-
-/**
- * Finds the difference between the current time, and a future time. Returns
- * 0 if the future time is actually before the current time.
- */
-void LabEngine::timeDiff(uint32 sec, uint32 micros, uint32 *diffSec, uint32 *diffMicros) {
-	uint32 curSec, curMicros;
-	getTime(&curSec, &curMicros);
-	anyTimeDiff(curSec, curMicros, sec, micros, diffSec, diffMicros);
-}
-
-/**
- * Waits for a specified time to occur.
- */
-void LabEngine::waitForTime(uint32 sec, uint32 micros) {
-	uint32 curSec, curMicros;
-	getTime(&curSec, &curMicros);
-
-	if (curSec > sec)
-		return;
-	else if ((curSec == sec) && (curMicros >= micros))
-		return;
-
-	if (curMicros > micros)
-		microDelay(sec - curSec - 1, (ONESECOND - curMicros) + micros - 1);
-	else
-		microDelay(sec - curSec, micros - curMicros - 1);
-}
-
-} // End of namespace Lab
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index f9a6656..1ac0837 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -433,7 +433,7 @@ void Utils::setBytesPerRow(int num) {
 uint16 Utils::getRandom(uint16 max) {
 	uint32 secs, micros;
 
-	_vm->getTime(&secs, &micros);
+	getTime(&secs, &micros);
 	return ((micros + secs) % max);
 }
 
@@ -442,4 +442,95 @@ void Utils::readBlock(void *Buffer, uint32 Size, byte **File) {
 	(*File) += Size;
 }
 
+/**
+ * Waits for for Secs seconds and Micros microseconds to pass.
+ */
+void Utils::microDelay(uint32 secs, uint32 micros) {
+	uint32 waitSecs, waitMicros;
+	addCurTime(secs, micros, &waitSecs, &waitMicros);
+
+	while (1) {
+		getTime(&secs, &micros);
+
+		if ((secs > waitSecs) || ((secs == waitSecs) && (micros >= waitMicros)))
+			return;
+
+		g_system->delayMillis(10);
+	}
+}
+
+/**
+ * Gets the current system time.
+ */
+void Utils::getTime(uint32 *secs, uint32 *micros) {
+	uint32 t = g_system->getMillis();
+
+	*secs = t / 1000;
+	*micros = t % 1000;
+}
+
+/**
+ * Adds seconds and microseconds to current time to get a new time.
+ */
+void Utils::addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *timeMicros) {
+	getTime(timeSec, timeMicros);
+
+	(*timeSec) += sec;
+	(*timeMicros) += micros;
+
+	if (*timeMicros >= ONESECOND) {
+		(*timeSec)++;
+		(*timeMicros) -= ONESECOND;
+	}
+}
+
+/**
+ * Finds the difference between time1 and time2.  If time1 is later than
+ * time2, returns 0.
+ */
+void Utils::anyTimeDiff(uint32 sec1, uint32 micros1, uint32 sec2, uint32 micros2, uint32 *diffSecs, uint32 *diffMicros) {
+	*diffSecs = 0;
+	*diffMicros = 0;
+
+	if (sec1 > sec2)
+		return;
+	else if ((sec1 == sec2) && (micros1 >= micros2))
+		return;
+
+	if (micros1 > micros2) {
+		*diffSecs = sec2 - sec1 - 1;
+		*diffMicros = (ONESECOND - micros1) + micros2;
+	} else {
+		*diffSecs = sec2 - sec1;
+		*diffMicros = micros2 - micros1;
+	}
+}
+
+/**
+ * Finds the difference between the current time, and a future time. Returns
+ * 0 if the future time is actually before the current time.
+ */
+void Utils::timeDiff(uint32 sec, uint32 micros, uint32 *diffSec, uint32 *diffMicros) {
+	uint32 curSec, curMicros;
+	getTime(&curSec, &curMicros);
+	anyTimeDiff(curSec, curMicros, sec, micros, diffSec, diffMicros);
+}
+
+/**
+ * Waits for a specified time to occur.
+ */
+void Utils::waitForTime(uint32 sec, uint32 micros) {
+	uint32 curSec, curMicros;
+	getTime(&curSec, &curMicros);
+
+	if (curSec > sec)
+		return;
+	else if ((curSec == sec) && (curMicros >= micros))
+		return;
+
+	if (curMicros > micros)
+		microDelay(sec - curSec - 1, (ONESECOND - curMicros) + micros - 1);
+	else
+		microDelay(sec - curSec, micros - curMicros - 1);
+}
 } // End of namespace Lab
diff --git a/engines/lab/utils.h b/engines/lab/utils.h
index da1f89a..9d6e187 100644
--- a/engines/lab/utils.h
+++ b/engines/lab/utils.h
@@ -43,6 +43,7 @@ private:
 	void VUnDiffByteByte(byte *Dest, byte *diff, uint16 bytesperrow);
 	void VUnDiffByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow);
 	void VUnDiffByteLong(uint32 *Dest, uint32 *diff, uint16 bytesperrow);
+	void microDelay(uint32 secs, uint32 micros);
 
 public:
 	Utils(LabEngine *vm);
@@ -61,6 +62,11 @@ public:
 	void setBytesPerRow(int num);
 	uint16 getRandom(uint16 max);
 	void readBlock(void *Buffer, uint32 Size, byte **File);
+	void addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *timeMicros);
+	void getTime(uint32 *secs, uint32 *micros);
+	void waitForTime(uint32 sec, uint32 micros);
+	void anyTimeDiff(uint32 sec1, uint32 micros1, uint32 sec2, uint32 micros2, uint32 *diffSecs, uint32 *diffMicros);
+	void timeDiff(uint32 sec, uint32 micros, uint32 *diffSec, uint32 *diffMicros);
 };
 
 


Commit: f47d41930f84d61b5cb2de4685d798e3b8aaca6b
    https://github.com/scummvm/scummvm/commit/f47d41930f84d61b5cb2de4685d798e3b8aaca6b
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:01+01:00

Commit Message:
LAB: Review LabEngine definition, make private a lot of members

Changed paths:
    engines/lab/lab.h



diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index d9f59f0..970ca35 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -87,151 +87,148 @@ typedef Common::List<Rule *> RuleList;
 #define WEST    3
 
 class LabEngine : public Engine {
-public:
-	LabEngine(OSystem *syst, const ADGameDescription *gameDesc);
-	~LabEngine();
-
-	virtual Common::Error run();
-	void go();
-
-	const ADGameDescription *_gameDescription;
-	Common::Platform getPlatform() const;
-	uint32 getFeatures() const;
-
-	bool hasFeature(EngineFeature f) const;
-	Common::String generateSaveFileName(uint slot);
-
-	LargeSet *_conditions, *_roomsFound;
-
 private:
-	uint32 _extraGameFeatures;
 	bool _interfaceOff;
+	bool _isCrumbWaiting;
+	bool _mainDisplay;
 	bool _noUpdateDiff;
 	bool _quitLab;
-	bool _mainDisplay;
-	// timing.cpp
+	bool _lastTooLong;
 
-public:
-	EventManager *_event;
-	Resource *_resource;
-	Music *_music;
-	Anim *_anim;
-	DisplayMan *_graphics;
-	RoomData *_rooms;
-	TilePuzzle *_tilePuzzle;
-	Utils *_utils;
+	int _lastWaitTOFTicks;
 
-	int _roomNum;
-	CrumbData _breadCrumbs[MAX_CRUMBS];
-	uint16 _numCrumbs;
-	bool _droppingCrumbs;
-	bool _followingCrumbs;
-	bool _followCrumbsFast;
-	bool _isCrumbTurning;
-	uint32 _crumbSecs, _crumbMicros;
-	bool _isCrumbWaiting;
-	bool _alternate;
-	bool _isHiRes;
-	uint16 _numInv;
-	uint16 _manyRooms;
 	uint16 _direction;
-	uint16 _highestCondition;
+	uint16 _maxRooms;
+
+	uint32 _extraGameFeatures;
 
-	const char *_curFileName;
 	const char *_nextFileName;
-	// When ProcessRoom.c decides to change the filename of the current picture.
 	const char *_newFileName;
-	TextFont *_msgFont;
-	GadgetList _moveGadgetList;
-	GadgetList _invGadgetList;
-	Image *_moveImages[20];
-	Image *_invImages[10];
 
-private:
-	int _lastWaitTOFTicks;
-	bool _lastTooLong;
 	CloseDataPtr _closeDataPtr;
-	InventoryData *_inventory;
 	GadgetList _journalGadgetList;
 	GadgetList _mapGadgetList;
 	Image *_imgMap, *_imgRoom, *_imgUpArrowRoom, *_imgDownArrowRoom, *_imgBridge;
 	Image *_imgHRoom, *_imgVRoom, *_imgMaze, *_imgHugeMaze, *_imgPath, *_imgMapNorth;
 	Image *_imgMapEast, *_imgMapSouth, *_imgMapWest, *_imgXMark;
-	uint16 _maxRooms;
+	InventoryData *_inventory;
 	MapData *_maps;
 
-private:
-	bool fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Common::Point tmpPos,
-			uint16 &curInv, IntuiMessage *curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode);
+public:
+	bool _alternate;
+	bool _droppingCrumbs;
+	bool _followingCrumbs;
+	bool _followCrumbsFast;
+	bool _isCrumbTurning;
+	bool _isHiRes;
+
+	int _roomNum;
+
+	uint16 _highestCondition;
+	uint16 _manyRooms;
+	uint16 _numCrumbs;
+	uint16 _numInv;
+
+	uint32 _crumbSecs, _crumbMicros;
+
+	const char *_curFileName;
+
+	Anim *_anim;
+	CrumbData _breadCrumbs[MAX_CRUMBS];
+	DisplayMan *_graphics;
+	EventManager *_event;
+	GadgetList _invGadgetList;
+	GadgetList _moveGadgetList;
+	Image *_invImages[10];
+	Image *_moveImages[20];
+	LargeSet *_conditions, *_roomsFound;
+	Music *_music;
+	Resource *_resource;
+	RoomData *_rooms;
+	TextFont *_msgFont;
+	TilePuzzle *_tilePuzzle;
+	Utils *_utils;
 
 public:
+	LabEngine(OSystem *syst, const ADGameDescription *gameDesc);
+	~LabEngine();
+
+	virtual Common::Error run();
+	void go();
+
+	const ADGameDescription *_gameDescription;
+	Common::Platform getPlatform() const;
+	uint32 getFeatures() const;
+
+	bool hasFeature(EngineFeature f) const;
+	Common::String generateSaveFileName(uint slot);
+
+	void changeVolume(int delta);
+	uint16 getDirection() { return _direction; }
+	IntuiMessage *getMsg();
+	char *getPictName(CloseDataPtr *closePtrList);
+	uint16 getQuarters();
+	void setDirection(uint16 direction) { _direction = direction; };
+	void setQuarters(uint16 quarters);
 	void waitTOF();
-	void drawRoomMessage(uint16 curInv, CloseDataPtr closePtr);
-	void interfaceOff();
-	void interfaceOn();
-	void decIncInv(uint16 *CurInv, bool dec);
+
+private:
 	Gadget *checkNumGadgetHit(GadgetList *gadgetList, uint16 key);
-	IntuiMessage *getMsg();
-	void loadMapData();
-	void drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fadeOut, bool fadeIn);
-	void processMap(uint16 curRoom);
-	void doMap(uint16 curRoom);
-	void freeMapData();
-	void loadJournalData();
-	void drawJournal(uint16 wipenum, bool needFade);
-	void processJournal();
+	void decIncInv(uint16 *CurInv, bool dec);
 	void doJournal();
-	void drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive);
-	void processMonitor(char *ntext, TextFont *monitorFont, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void doMap(uint16 curRoom);
 	void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void doNotes();
 	void doWestPaper();
-	void eatMessages();
-	void drawStaticMessage(byte index);
 	void drawDirection(CloseDataPtr closePtr);
+	void drawJournal(uint16 wipenum, bool needFade);
+	void drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fadeOut, bool fadeIn);
+	void drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive);
+	void drawRoomMessage(uint16 curInv, CloseDataPtr closePtr);
+	void drawStaticMessage(byte index);
+	void eatMessages();
 	int followCrumbs();
-
-	void changeVolume(int delta);
-	char *getPictName(CloseDataPtr *closePtrList);
-
-	uint16 getQuarters();
-	void setQuarters(uint16 quarters);
-	uint16 getDirection() { return _direction; }
-	void setDirection(uint16 direction) { _direction = direction; };
+	void freeMapData();
+	bool fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Common::Point tmpPos,
+		uint16 &curInv, IntuiMessage *curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode);
+	void interfaceOff();
+	void interfaceOn();
+	void loadJournalData();
+	void loadMapData();
+	void processJournal();
+	void processMap(uint16 curRoom);
+	void processMonitor(char *ntext, TextFont *monitorFont, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 
 private:
-	void freeScreens();
-	void perFlipGadget(uint16 gadID);
+	bool checkConditions(int16 *condition);
+	void doActions(Action *actionList, CloseDataPtr *closePtrList);
+	bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *closePtrList);
+	bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults);
 	bool doCloseUp(CloseDataPtr closePtr);
-	void mainGameLoop();
+	bool doGoForward(CloseDataPtr *closePtrList);
+	bool doMainView(CloseDataPtr *closePtrList);
+	bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults);
+	bool doOperateRule(Common::Point pos, int16 ItemNum, CloseDataPtr *closePtrList);
+	bool doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList);
 	bool doUse(uint16 curInv);
-	void mayShowCrumbIndicator();
-	void mayShowCrumbIndicatorOff();
-	const char *getInvName(uint16 curInv);
-	bool saveRestoreGame();
-	Common::Rect roomCoords(uint16 curRoom);
 	void drawRoomMap(uint16 curRoom, bool drawMarkFl);
+	CloseDataPtr findClosePtrMatch(CloseDataPtr closePtr, CloseDataPtr closePtrList);
 	bool floorVisited(uint16 floorNum);
-	uint16 getUpperFloor(uint16 floorNum);
+	void freeScreens();
+	const char *getInvName(uint16 curInv);
 	uint16 getLowerFloor(uint16 floorNum);
-	bool checkConditions(int16 *condition);
-	ViewData *getViewData(uint16 roomNum, uint16 direction);
 	CloseData *getObject(Common::Point pos, CloseDataPtr closePtr);
-	CloseDataPtr findClosePtrMatch(CloseDataPtr closePtr, CloseDataPtr closePtrList);
+	uint16 getUpperFloor(uint16 floorNum);
+	ViewData *getViewData(uint16 roomNum, uint16 direction);
+	void mainGameLoop();
+	void mayShowCrumbIndicator();
+	void mayShowCrumbIndicatorOff();
+	void perFlipGadget(uint16 gadID);
 	uint16 processArrow(uint16 curDirection, uint16 arrow);
+	Common::Rect roomCoords(uint16 curRoom);
+	bool saveRestoreGame();
 	void setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, bool useAbsoluteCoords);
 	bool takeItem(uint16 x, uint16 y, CloseDataPtr *closePtrList);
-	bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults);
-	bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *closePtrList);
-	bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults);
-	bool doOperateRule(Common::Point pos, int16 ItemNum, CloseDataPtr *closePtrList);
-	bool doGoForward(CloseDataPtr *closePtrList);
-	bool doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList);
-	bool doMainView(CloseDataPtr *closePtrList);
-
-public:
-	void doActions(Action *actionList, CloseDataPtr *closePtrList);
-
 };
 
 extern LabEngine *g_lab;


Commit: a01f0689693363bf7a46ef36c9e3885670fb657b
    https://github.com/scummvm/scummvm/commit/a01f0689693363bf7a46ef36c9e3885670fb657b
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:01+01:00

Commit Message:
LAB: Merge transitions in dispman

Changed paths:
  R engines/lab/transitions.cpp
    engines/lab/dispman.cpp
    engines/lab/module.mk



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index df35f9f..d2f5f8d 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -748,4 +748,452 @@ void DisplayMan::text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char
 		text++;
 	}
 }
+
+/**
+ * Scrolls the display to black.
+ */
+void DisplayMan::doScrollBlack() {
+	uint16 width = _vm->_utils->vgaScaleX(320);
+	uint16 height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
+	byte *mem = new byte[width * height];
+
+	_vm->_event->mouseHide();
+
+	Image img;
+	img._width = width;
+	img._height = height;
+	img._imageData = mem;
+	_vm->_music->updateMusic();
+	img.readScreenImage(0, 0);
+	_vm->_music->updateMusic();
+
+	byte *baseAddr = getCurrentDrawingBuffer();
+	uint16 by = _vm->_utils->vgaScaleX(4);
+	uint16 nheight = height;
+
+	while (nheight) {
+		_vm->_music->updateMusic();
+
+		if (!_vm->_isHiRes)
+			_vm->waitTOF();
+
+		baseAddr = getCurrentDrawingBuffer();
+
+		if (by > nheight)
+			by = nheight;
+
+		mem += by * width;
+		nheight -= by;
+		uint32 copysize;
+		uint32 size = (int32)nheight * (int32)width;
+		byte *tempmem = mem;
+
+		while (size) {
+			if (size > _screenBytesPerPage)
+				copysize = _screenBytesPerPage;
+			else
+				copysize = size;
+
+			size -= copysize;
+
+			memcpy(baseAddr, tempmem, copysize);
+			tempmem += copysize;
+		}
+
+		setAPen(0);
+		rectFill(0, nheight, width - 1, nheight + by - 1);
+
+		screenUpdate();
+
+		if (!_vm->_isHiRes) {
+			if (nheight <= (height / 8))
+				by = 1;
+			else if (nheight <= (height / 4))
+				by = 2;
+			else if (nheight <= (height / 2))
+				by = 3;
+		}
+	}
+
+	delete[] mem;
+	freePict();
+	_vm->_event->mouseShow();
+}
+
+void DisplayMan::copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startLine, byte *mem) {
+	byte *baseAddr = getCurrentDrawingBuffer();
+
+	uint32 size = (int32)(height - nheight) * (int32)width;
+	mem += startLine * width;
+	uint16 curPage = ((int32)nheight * (int32)width) / _screenBytesPerPage;
+	uint32 offSet = ((int32)nheight * (int32)width) - (curPage * _screenBytesPerPage);
+
+	while (size) {
+		uint32 copySize;
+		if (size > (_screenBytesPerPage - offSet))
+			copySize = _screenBytesPerPage - offSet;
+		else
+			copySize = size;
+
+		size -= copySize;
+
+		memcpy(baseAddr + (offSet >> 2), mem, copySize);
+		mem += copySize;
+		curPage++;
+		offSet = 0;
+	}
+}
+
+/**
+ * Scrolls the display to a new picture from a black screen.
+ */
+void DisplayMan::doScrollWipe(char *filename) {
+	uint16 startLine = 0, onRow = 0;
+
+	_vm->_event->mouseHide();
+	uint16 width = _vm->_utils->vgaScaleX(320);
+	uint16 height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
+
+	while (_vm->_music->isSoundEffectActive()) {
+		_vm->_music->updateMusic();
+		_vm->waitTOF();
+	}
+
+	readPict(filename, true, true);
+	setPalette(_vm->_anim->_diffPalette, 256);
+	byte *mem = _vm->_anim->_rawDiffBM._planes[0];
+
+	_vm->_music->updateMusic();
+	uint16 by = _vm->_utils->vgaScaleX(3);
+	uint16 nheight = height;
+
+	while (onRow < _vm->_anim->_headerdata._height) {
+		_vm->_music->updateMusic();
+
+		if ((by > nheight) && nheight)
+			by = nheight;
+
+		if ((startLine + by) > (_vm->_anim->_headerdata._height - height - 1))
+			break;
+
+		if (nheight)
+			nheight -= by;
+
+		copyPage(width, height, nheight, startLine, mem);
+
+		screenUpdate();
+
+		if (!nheight)
+			startLine += by;
+
+		onRow += by;
+
+		if (nheight <= (height / 4))
+			by = _vm->_utils->vgaScaleX(5);
+		else if (nheight <= (height / 3))
+			by = _vm->_utils->vgaScaleX(4);
+		else if (nheight <= (height / 2))
+			by = _vm->_utils->vgaScaleX(3);
+	}
+
+	_vm->_event->mouseShow();
+}
+
+/**
+ * Does the scroll bounce.  Assumes bitmap already in memory.
+ */
+void DisplayMan::doScrollBounce() {
+	const uint16 *newby, *newby1;
+
+	const uint16 newbyd[5] = {5, 4, 3, 2, 1}, newby1d[8] = {3, 3, 2, 2, 2, 1, 1, 1};
+	const uint16 newbyw[5] = {10, 8, 6, 4, 2}, newby1w[8] = {6, 6, 4, 4, 4, 2, 2, 2};
+
+	if (_vm->getPlatform() != Common::kPlatformWindows) {
+		newby = newbyd;
+		newby1 = newby1d;
+	} else {
+		newby = newbyw;
+		newby1 = newby1w;
+	}
+
+	_vm->_event->mouseHide();
+	int width = _vm->_utils->vgaScaleX(320);
+	int height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
+	byte *mem = _vm->_anim->_rawDiffBM._planes[0];
+
+	_vm->_music->updateMusic();
+	int startLine = _vm->_anim->_headerdata._height - height - 1;
+
+	for (int i = 0; i < 5; i++) {
+		_vm->_music->updateMusic();
+		startLine -= newby[i];
+		copyPage(width, height, 0, startLine, mem);
+
+		screenUpdate();
+		_vm->waitTOF();
+	}
+
+	for (int i = 8; i > 0; i--) {
+		_vm->_music->updateMusic();
+		startLine += newby1[i - 1];
+		copyPage(width, height, 0, startLine, mem);
+
+		screenUpdate();
+		_vm->waitTOF();
+	}
+
+	_vm->_event->mouseShow();
+}
+
+/**
+ * Does the transporter wipe.
+ */
+void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, char *filename) {
+	uint16 lastY, curY, linesDone = 0, linesLast;
+
+	if (_vm->_isHiRes) {
+		linesLast = 3;
+		lastY = 358;
+	} else {
+		linesLast = 1;
+		lastY = 148;
+	}
+
+	for (uint16 j = 0; j < 2; j++) {
+		for (uint16 i = 0; i < 2; i++) {
+			curY = i * 2;
+
+			while (curY < lastY) {
+				if (linesDone >= linesLast) {
+					_vm->_music->updateMusic();
+					_vm->waitTOF();
+					linesDone = 0;
+				}
+
+				if (j == 9)
+					overlayRect(0, 0, curY, _screenWidth - 1, curY + 1);
+				else
+					rectFill(0, curY, _screenWidth - 1, curY + 1);
+				curY += 4;
+				linesDone++;
+			}	// while
+		}	// for i
+
+		setAPen(0);
+	}	// for j
+
+	if (filename == NULL)
+		_vm->_curFileName = _vm->getPictName(closePtrList);
+	else if (filename[0] > ' ')
+		_vm->_curFileName = filename;
+	else
+		_vm->_curFileName = _vm->getPictName(closePtrList);
+
+	byte *bitMapBuffer = new byte[_screenWidth * (lastY + 5)];
+	readPict(_vm->_curFileName, true, false, bitMapBuffer, lastY + 5);
+
+	setPalette(_vm->_anim->_diffPalette, 256);
+
+	Image imSource;
+	imSource._width = _screenWidth;
+	imSource._height = lastY;
+	imSource._imageData = bitMapBuffer;
+
+	Image imDest;
+	imDest._width = _screenWidth;
+	imDest._height = _screenHeight;
+	imDest._imageData = getCurrentDrawingBuffer();
+
+	for (uint16 j = 0; j < 2; j++) {
+		for (uint16 i = 0; i < 2; i++) {
+			curY = i * 2;
+
+			while (curY < lastY) {
+				if (linesDone >= linesLast) {
+					_vm->_music->updateMusic();
+					_vm->waitTOF();
+					linesDone = 0;
+				}
+
+				imDest._imageData = getCurrentDrawingBuffer();
+
+				if (j == 0) {
+					imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, 2, false);
+					overlayRect(0, 0, curY, _screenWidth - 1, curY + 1);
+				} else {
+					uint16 bitmapHeight = (curY == lastY) ? 1 : 2;
+					imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, bitmapHeight, false);
+				}
+				curY += 4;
+				linesDone++;
+			}	// while
+		}	// for i
+	}	// for j
+
+	delete[] bitMapBuffer;
+}
+
+/**
+ * Does a certain number of pre-programmed wipes.
+ */
+void DisplayMan::doTransition(TransitionType transitionType, CloseDataPtr *closePtrList, char *filename) {
+	switch (transitionType) {
+	case kTransitionWipe:
+	case kTransitionTransporter:
+		doTransWipe(closePtrList, filename);
+		break;
+	case kTransitionScrollWipe:
+		doScrollWipe(filename);
+		break;
+	case kTransitionScrollBlack:
+		doScrollBlack();
+		break;
+	case kTransitionScrollBounce:
+		doScrollBounce();
+		break;
+	case kTransitionReadFirstFrame:
+		readPict(filename, false);
+		break;
+	case kTransitionReadNextFrame:
+		_vm->_anim->diffNextFrame();
+		break;
+	case kTransitionNone:
+	default:
+		break;
+	}
+}
+
+/**
+ * Changes the front screen to black.
+ */
+void DisplayMan::blackScreen() {
+	byte pal[256 * 3];
+	memset(pal, 0, 248 * 3);
+	writeColorRegs(pal, 8, 248);
+
+	g_system->delayMillis(32);
+}
+
+/**
+ * Changes the front screen to white.
+ */
+void DisplayMan::whiteScreen() {
+	byte pal[256 * 3];
+	memset(pal, 255, 248 * 3);
+	writeColorRegs(pal, 8, 248);
+}
+
+/**
+ * Changes the entire screen to black.
+*/
+void DisplayMan::blackAllScreen() {
+	byte pal[256 * 3];
+	memset(pal, 0, 256 * 3);
+	writeColorRegs(pal, 0, 256);
+
+	g_system->delayMillis(32);
+}
+
+/**
+ * Scrolls the display in the x direction by blitting.
+ * The _tempScrollData variable must be initialized to some memory, or this
+ * function will fail.
+ */
+void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer) {
+	Image im;
+	im._imageData = buffer;
+
+	if (x1 > x2)
+		SWAP<uint16>(x1, x2);
+
+	if (y1 > y2)
+		SWAP<uint16>(y1, y2);
+
+	if (dx > 0) {
+		im._width = x2 - x1 + 1 - dx;
+		im._height = y2 - y1 + 1;
+
+		im.readScreenImage(x1, y1);
+		im.drawImage(x1 + dx, y1);
+
+		setAPen(0);
+		rectFill(x1, y1, x1 + dx - 1, y2);
+	} else if (dx < 0) {
+		im._width = x2 - x1 + 1 + dx;
+		im._height = y2 - y1 + 1;
+
+		im.readScreenImage(x1 - dx, y1);
+		im.drawImage(x1, y1);
+
+		setAPen(0);
+		rectFill(x2 + dx + 1, y1, x2, y2);
+	}
+}
+
+/**
+ * Scrolls the display in the y direction by blitting.
+ */
+void DisplayMan::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer) {
+	Image im;
+	im._imageData = buffer;
+
+	if (x1 > x2)
+		SWAP<uint16>(x1, x2);
+
+	if (y1 > y2)
+		SWAP<uint16>(y1, y2);
+
+	if (dy > 0) {
+		im._width = x2 - x1 + 1;
+		im._height = y2 - y1 + 1 - dy;
+
+		im.readScreenImage(x1, y1);
+		im.drawImage(x1, y1 + dy);
+
+		setAPen(0);
+		rectFill(x1, y1, x2, y1 + dy - 1);
+	} else if (dy < 0) {
+		im._width = x2 - x1 + 1;
+		im._height = y2 - y1 + 1 + dy;
+
+		im.readScreenImage(x1, y1 - dy);
+		im.drawImage(x1, y1);
+
+		setAPen(0);
+		rectFill(x1, y2 + dy + 1, x2, y2);
+	}
+}
+
+/**
+ * Does the fading of the Palette on the screen.
+ */
+uint16 DisplayMan::fadeNumIn(uint16 num, uint16 res, uint16 counter) {
+	return (num - ((((int32)(15 - counter)) * ((int32)(num - res))) / 15));
+}
+
+uint16 DisplayMan::fadeNumOut(uint16 num, uint16 res, uint16 counter) {
+	return (num - ((((int32) counter) * ((int32)(num - res))) / 15));
+}
+
+void DisplayMan::fade(bool fadeIn, uint16 res) {
+	uint16 newPal[16];
+
+	for (uint16 i = 0; i < 16; i++) {
+		for (uint16 palIdx = 0; palIdx < 16; palIdx++) {
+			if (fadeIn)
+				newPal[palIdx] = (0x00F & fadeNumIn(0x00F & FadePalette[palIdx], 0x00F & res, i)) +
+				(0x0F0 & fadeNumIn(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) +
+				(0xF00 & fadeNumIn(0xF00 & FadePalette[palIdx], 0xF00 & res, i));
+			else
+				newPal[palIdx] = (0x00F & fadeNumOut(0x00F & FadePalette[palIdx], 0x00F & res, i)) +
+				(0x0F0 & fadeNumOut(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) +
+				(0xF00 & fadeNumOut(0xF00 & FadePalette[palIdx], 0xF00 & res, i));
+		}
+
+		setAmigaPal(newPal, 16);
+		_vm->waitTOF();
+		_vm->_music->updateMusic();
+	}
+}
+
 } // End of namespace Lab
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index a0dcfde..6b7932a 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -18,7 +18,6 @@ MODULE_OBJS := \
 	savegame.o \
 	special.o \
 	tilepuzzle.o \
-	transitions.o \
 	utils.o
 
 # This module can be built as a plugin
diff --git a/engines/lab/transitions.cpp b/engines/lab/transitions.cpp
deleted file mode 100644
index d7adff3..0000000
--- a/engines/lab/transitions.cpp
+++ /dev/null
@@ -1,489 +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.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#include "lab/lab.h"
-
-#include "lab/anim.h"
-#include "lab/dispman.h"
-#include "lab/eventman.h"
-#include "lab/image.h"
-#include "lab/music.h"
-#include "lab/utils.h"
-
-namespace Lab {
-
-/**
- * Scrolls the display to black.
- */
-void DisplayMan::doScrollBlack() {
-	uint16 width = _vm->_utils->vgaScaleX(320);
-	uint16 height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
-	byte *mem = new byte[width * height];
-
-	_vm->_event->mouseHide();
-
-	Image img;
-	img._width = width;
-	img._height = height;
-	img._imageData = mem;
-	_vm->_music->updateMusic();
-	img.readScreenImage(0, 0);
-	_vm->_music->updateMusic();
-
-	byte *baseAddr = getCurrentDrawingBuffer();
-	uint16 by = _vm->_utils->vgaScaleX(4);
-	uint16 nheight = height;
-
-	while (nheight) {
-		_vm->_music->updateMusic();
-
-		if (!_vm->_isHiRes)
-			_vm->waitTOF();
-
-		baseAddr = getCurrentDrawingBuffer();
-
-		if (by > nheight)
-			by = nheight;
-
-		mem += by * width;
-		nheight -= by;
-		uint32 copysize;
-		uint32 size = (int32)nheight * (int32)width;
-		byte *tempmem = mem;
-
-		while (size) {
-			if (size > _screenBytesPerPage)
-				copysize = _screenBytesPerPage;
-			else
-				copysize = size;
-
-			size -= copysize;
-
-			memcpy(baseAddr, tempmem, copysize);
-			tempmem += copysize;
-		}
-
-		setAPen(0);
-		rectFill(0, nheight, width - 1, nheight + by - 1);
-
-		screenUpdate();
-
-		if (!_vm->_isHiRes) {
-			if (nheight <= (height / 8))
-				by = 1;
-			else if (nheight <= (height / 4))
-				by = 2;
-			else if (nheight <= (height / 2))
-				by = 3;
-		}
-	}
-
-	delete[] mem;
-	freePict();
-	_vm->_event->mouseShow();
-}
-
-void DisplayMan::copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startLine, byte *mem) {
-	byte *baseAddr = getCurrentDrawingBuffer();
-
-	uint32 size = (int32)(height - nheight) * (int32)width;
-	mem += startLine * width;
-	uint16 curPage = ((int32)nheight * (int32)width) / _screenBytesPerPage;
-	uint32 offSet = ((int32)nheight * (int32)width) - (curPage * _screenBytesPerPage);
-
-	while (size) {
-		uint32 copySize;
-		if (size > (_screenBytesPerPage - offSet))
-			copySize = _screenBytesPerPage - offSet;
-		else
-			copySize = size;
-
-		size -= copySize;
-
-		memcpy(baseAddr + (offSet >> 2), mem, copySize);
-		mem += copySize;
-		curPage++;
-		offSet = 0;
-	}
-}
-
-/**
- * Scrolls the display to a new picture from a black screen.
- */
-void DisplayMan::doScrollWipe(char *filename) {
-	uint16 startLine = 0, onRow = 0;
-
-	_vm->_event->mouseHide();
-	uint16 width = _vm->_utils->vgaScaleX(320);
-	uint16 height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
-
-	while (_vm->_music->isSoundEffectActive()) {
-		_vm->_music->updateMusic();
-		_vm->waitTOF();
-	}
-
-	readPict(filename, true, true);
-	setPalette(_vm->_anim->_diffPalette, 256);
-	byte *mem = _vm->_anim->_rawDiffBM._planes[0];
-
-	_vm->_music->updateMusic();
-	uint16 by = _vm->_utils->vgaScaleX(3);
-	uint16 nheight = height;
-
-	while (onRow < _vm->_anim->_headerdata._height) {
-		_vm->_music->updateMusic();
-
-		if ((by > nheight) && nheight)
-			by = nheight;
-
-		if ((startLine + by) > (_vm->_anim->_headerdata._height - height - 1))
-			break;
-
-		if (nheight)
-			nheight -= by;
-
-		copyPage(width, height, nheight, startLine, mem);
-
-		screenUpdate();
-
-		if (!nheight)
-			startLine += by;
-
-		onRow += by;
-
-		if (nheight <= (height / 4))
-			by = _vm->_utils->vgaScaleX(5);
-		else if (nheight <= (height / 3))
-			by = _vm->_utils->vgaScaleX(4);
-		else if (nheight <= (height / 2))
-			by = _vm->_utils->vgaScaleX(3);
-	}
-
-	_vm->_event->mouseShow();
-}
-
-/**
- * Does the scroll bounce.  Assumes bitmap already in memory.
- */
-void DisplayMan::doScrollBounce() {
-	const uint16 *newby, *newby1;
-
-	const uint16 newbyd[5] = {5, 4, 3, 2, 1}, newby1d[8] = {3, 3, 2, 2, 2, 1, 1, 1};
-	const uint16 newbyw[5] = {10, 8, 6, 4, 2}, newby1w[8] = {6, 6, 4, 4, 4, 2, 2, 2};
-
-	if (_vm->getPlatform() != Common::kPlatformWindows) {
-		newby = newbyd;
-		newby1 = newby1d;
-	} else {
-		newby = newbyw;
-		newby1 = newby1w;
-	}
-
-	_vm->_event->mouseHide();
-	int width = _vm->_utils->vgaScaleX(320);
-	int height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
-	byte *mem = _vm->_anim->_rawDiffBM._planes[0];
-
-	_vm->_music->updateMusic();
-	int startLine = _vm->_anim->_headerdata._height - height - 1;
-
-	for (int i = 0; i < 5; i++) {
-		_vm->_music->updateMusic();
-		startLine -= newby[i];
-		copyPage(width, height, 0, startLine, mem);
-
-		screenUpdate();
-		_vm->waitTOF();
-	}
-
-	for (int i = 8; i > 0; i--) {
-		_vm->_music->updateMusic();
-		startLine += newby1[i - 1];
-		copyPage(width, height, 0, startLine, mem);
-
-		screenUpdate();
-		_vm->waitTOF();
-	}
-
-	_vm->_event->mouseShow();
-}
-
-/**
- * Does the transporter wipe.
- */
-void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, char *filename) {
-	uint16 lastY, curY, linesDone = 0, linesLast;
-
-	if (_vm->_isHiRes) {
-		linesLast = 3;
-		lastY = 358;
-	} else {
-		linesLast = 1;
-		lastY = 148;
-	}
-
-	for (uint16 j = 0; j < 2; j++) {
-		for (uint16 i = 0; i < 2; i++) {
-			curY = i * 2;
-
-			while (curY < lastY) {
-				if (linesDone >= linesLast) {
-					_vm->_music->updateMusic();
-					_vm->waitTOF();
-					linesDone = 0;
-				}
-
-				if (j == 9)
-					overlayRect(0, 0, curY, _screenWidth - 1, curY + 1);
-				else
-					rectFill(0, curY, _screenWidth - 1, curY + 1);
-				curY += 4;
-				linesDone++;
-			}	// while
-		}	// for i
-
-		setAPen(0);
-	}	// for j
-
-	if (filename == NULL)
-		_vm->_curFileName = _vm->getPictName(closePtrList);
-	else if (filename[0] > ' ')
-		_vm->_curFileName = filename;
-	else
-		_vm->_curFileName = _vm->getPictName(closePtrList);
-
-	byte *bitMapBuffer = new byte[_screenWidth * (lastY + 5)];
-	readPict(_vm->_curFileName, true, false, bitMapBuffer, lastY + 5);
-
-	setPalette(_vm->_anim->_diffPalette, 256);
-
-	Image imSource;
-	imSource._width = _screenWidth;
-	imSource._height = lastY;
-	imSource._imageData = bitMapBuffer;
-
-	Image imDest;
-	imDest._width = _screenWidth;
-	imDest._height = _screenHeight;
-	imDest._imageData = getCurrentDrawingBuffer();
-
-	for (uint16 j = 0; j < 2; j++) {
-		for (uint16 i = 0; i < 2; i++) {
-			curY = i * 2;
-
-			while (curY < lastY) {
-				if (linesDone >= linesLast) {
-					_vm->_music->updateMusic();
-					_vm->waitTOF();
-					linesDone = 0;
-				}
-
-				imDest._imageData = getCurrentDrawingBuffer();
-
-				if (j == 0) {
-					imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, 2, false);
-					overlayRect(0, 0, curY, _screenWidth - 1, curY + 1);
-				} else {
-					uint16 bitmapHeight = (curY == lastY) ? 1 : 2;
-					imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, bitmapHeight, false);
-				}
-				curY += 4;
-				linesDone++;
-			}	// while
-		}	// for i
-	}	// for j
-
-	delete[] bitMapBuffer;
-}
-
-/**
- * Does a certain number of pre-programmed wipes.
- */
-void DisplayMan::doTransition(TransitionType transitionType, CloseDataPtr *closePtrList, char *filename) {
-	switch (transitionType) {
-	case kTransitionWipe:
-	case kTransitionTransporter:
-		doTransWipe(closePtrList, filename);
-		break;
-	case kTransitionScrollWipe:
-		doScrollWipe(filename);
-		break;
-	case kTransitionScrollBlack:
-		doScrollBlack();
-		break;
-	case kTransitionScrollBounce:
-		doScrollBounce();
-		break;
-	case kTransitionReadFirstFrame:
-		readPict(filename, false);
-		break;
-	case kTransitionReadNextFrame:
-		_vm->_anim->diffNextFrame();
-		break;
-	case kTransitionNone:
-	default:
-		break;
-	}
-}
-
-/**
- * Changes the front screen to black.
- */
-void DisplayMan::blackScreen() {
-	byte pal[256 * 3];
-	memset(pal, 0, 248 * 3);
-	writeColorRegs(pal, 8, 248);
-
-	g_system->delayMillis(32);
-}
-
-/**
- * Changes the front screen to white.
- */
-void DisplayMan::whiteScreen() {
-	byte pal[256 * 3];
-	memset(pal, 255, 248 * 3);
-	writeColorRegs(pal, 8, 248);
-}
-
-/**
- * Changes the entire screen to black.
-*/
-void DisplayMan::blackAllScreen() {
-	byte pal[256 * 3];
-	memset(pal, 0, 256 * 3);
-	writeColorRegs(pal, 0, 256);
-
-	g_system->delayMillis(32);
-}
-
-/**
- * Scrolls the display in the x direction by blitting.
- * The _tempScrollData variable must be initialized to some memory, or this
- * function will fail.
- */
-void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer) {
-	Image im;
-	im._imageData = buffer;
-
-	if (x1 > x2)
-		SWAP<uint16>(x1, x2);
-
-	if (y1 > y2)
-		SWAP<uint16>(y1, y2);
-
-	if (dx > 0) {
-		im._width = x2 - x1 + 1 - dx;
-		im._height = y2 - y1 + 1;
-
-		im.readScreenImage(x1, y1);
-		im.drawImage(x1 + dx, y1);
-
-		setAPen(0);
-		rectFill(x1, y1, x1 + dx - 1, y2);
-	} else if (dx < 0) {
-		im._width = x2 - x1 + 1 + dx;
-		im._height = y2 - y1 + 1;
-
-		im.readScreenImage(x1 - dx, y1);
-		im.drawImage(x1, y1);
-
-		setAPen(0);
-		rectFill(x2 + dx + 1, y1, x2, y2);
-	}
-}
-
-/**
- * Scrolls the display in the y direction by blitting.
- */
-void DisplayMan::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer) {
-	Image im;
-	im._imageData = buffer;
-
-	if (x1 > x2)
-		SWAP<uint16>(x1, x2);
-
-	if (y1 > y2)
-		SWAP<uint16>(y1, y2);
-
-	if (dy > 0) {
-		im._width = x2 - x1 + 1;
-		im._height = y2 - y1 + 1 - dy;
-
-		im.readScreenImage(x1, y1);
-		im.drawImage(x1, y1 + dy);
-
-		setAPen(0);
-		rectFill(x1, y1, x2, y1 + dy - 1);
-	} else if (dy < 0) {
-		im._width = x2 - x1 + 1;
-		im._height = y2 - y1 + 1 + dy;
-
-		im.readScreenImage(x1, y1 - dy);
-		im.drawImage(x1, y1);
-
-		setAPen(0);
-		rectFill(x1, y2 + dy + 1, x2, y2);
-	}
-}
-
-/**
- * Does the fading of the Palette on the screen.
- */
-uint16 DisplayMan::fadeNumIn(uint16 num, uint16 res, uint16 counter) {
-	return (num - ((((int32)(15 - counter)) * ((int32)(num - res))) / 15));
-}
-
-uint16 DisplayMan::fadeNumOut(uint16 num, uint16 res, uint16 counter) {
-	return (num - ((((int32) counter) * ((int32)(num - res))) / 15));
-}
-
-void DisplayMan::fade(bool fadeIn, uint16 res) {
-	uint16 newPal[16];
-
-	for (uint16 i = 0; i < 16; i++) {
-		for (uint16 palIdx = 0; palIdx < 16; palIdx++) {
-			if (fadeIn)
-				newPal[palIdx] = (0x00F & fadeNumIn(0x00F & FadePalette[palIdx], 0x00F & res, i)) +
-				(0x0F0 & fadeNumIn(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) +
-				(0xF00 & fadeNumIn(0xF00 & FadePalette[palIdx], 0xF00 & res, i));
-			else
-				newPal[palIdx] = (0x00F & fadeNumOut(0x00F & FadePalette[palIdx], 0x00F & res, i)) +
-				(0x0F0 & fadeNumOut(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) +
-				(0xF00 & fadeNumOut(0xF00 & FadePalette[palIdx], 0xF00 & res, i));
-		}
-
-		setAmigaPal(newPal, 16);
-		_vm->waitTOF();
-		_vm->_music->updateMusic();
-	}
-}
-
-} // End of namespace Lab


Commit: 1b0a7db0b604b5dddaa0e01cbafe2f3fdc760ce9
    https://github.com/scummvm/scummvm/commit/1b0a7db0b604b5dddaa0e01cbafe2f3fdc760ce9
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:01+01:00

Commit Message:
LAB: Get rid of getTime(), readBlock() and getRandom()

Also, simplify some time-related functions

Changed paths:
    engines/lab/anim.cpp
    engines/lab/engine.cpp
    engines/lab/intro.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/processroom.cpp
    engines/lab/utils.cpp
    engines/lab/utils.h



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 3bed365..ac51860 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -141,18 +141,20 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 
 		switch (_header) {
 		case 8:
-			_vm->_utils->readBlock(_diffPalette, _size, &_diffFile);
+			memcpy(_diffPalette, _diffFile, _size);
+			_diffFile += _size;
 			_isPal = true;
 			break;
 
 		case 10:
 			_rawDiffBM._planes[_curBit] = _diffFile;
 
-			if (onlyDiffData)
+			if (onlyDiffData) {
 				_diffFile += _size;
-			else
-				_vm->_utils->readBlock(DrawBitMap->_planes[_curBit], _size, &_diffFile);
-
+			} else {
+				memcpy(DrawBitMap->_planes[_curBit], _diffFile, _size);
+				_diffFile += _size;
+			}
 			_curBit++;
 			break;
 
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index f0d3ab7..1b77d04 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -609,7 +609,9 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 					_followCrumbsFast = (code == 'r' || code == 'R');
 					_isCrumbTurning = false;
 					_isCrumbWaiting = false;
-					_utils->getTime(&_crumbSecs, &_crumbMicros);
+					uint32 t = g_system->getMillis();
+					_crumbSecs = t / 1000;
+					_crumbMicros = t % 1000;
 
 					if (_alternate) {
 						eatMessages();
@@ -930,7 +932,9 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 					_followCrumbsFast = false;
 					_isCrumbTurning = false;
 					_isCrumbWaiting = false;
-					_utils->getTime(&_crumbSecs, &_crumbMicros);
+					uint32 t = g_system->getMillis();
+					_crumbSecs = t / 1000;
+					_crumbMicros = t % 1000;
 
 					eatMessages();
 					_alternate = false;
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 633691c..0165116 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -132,7 +132,9 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 				return;
 			}
 
-			_vm->_utils->getTime(&lastSecs, &lastMicros);
+			uint32 t = g_system->getMillis();
+			lastSecs = t / 1000;
+			lastMicros = t % 1000;
 		}
 
 		msg = _vm->getMsg();
@@ -140,7 +142,10 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 		if (msg == NULL) {
 			_vm->_music->updateMusic();
 			_vm->_anim->diffNextFrame();
-			_vm->_utils->getTime(&secs, &micros);
+
+			uint32 t = g_system->getMillis();
+			secs = t / 1000;
+			micros = t % 1000;
 			_vm->_utils->anyTimeDiff(lastSecs, lastMicros, secs, micros, &secs, &micros);
 
 			if (secs > timeDelay) {
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index be5b955..e33c443 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -51,7 +51,7 @@ namespace Lab {
 LabEngine *g_lab;
 
 LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
- : Engine(syst), _gameDescription(gameDesc), _extraGameFeatures(0) {
+ : Engine(syst), _gameDescription(gameDesc), _extraGameFeatures(0), _rnd("lab") {
 	g_lab = this;
 
 	_lastWaitTOFTicks = 0;
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 970ca35..b03b4b3 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -32,6 +32,7 @@
 #define LAB_H
 
 #include "common/system.h"
+#include "common/random.h"
 #include "common/rect.h"
 
 #include "engines/engine.h"
@@ -114,6 +115,8 @@ private:
 	InventoryData *_inventory;
 	MapData *_maps;
 
+	Common::RandomSource _rnd;
+
 public:
 	bool _alternate;
 	bool _droppingCrumbs;
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index b997942..bd9d02e 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -370,7 +370,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 		case SHOWMESSAGES: {
 				char **str = (char **)actionList->_data;
 				_graphics->_doNotDrawMessage = false;
-				_graphics->drawMessage(str[_utils->getRandom(actionList->_param1)]);
+				_graphics->drawMessage(str[_rnd.getRandomNumber(actionList->_param1)]);
 				_graphics->_doNotDrawMessage = true;
 			}
 			break;
@@ -424,18 +424,13 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			break;
 
 		case WAITSECS: {
-				uint32 startSecs, startMicros, curSecs, curMicros;
-				_utils->addCurTime(actionList->_param1, 0, &startSecs, &startMicros);
+				uint32 targetMillis = g_system->getMillis() + actionList->_param1 * 1000;
 
 				_graphics->screenUpdate();
 
-				while (1) {
+				while (g_system->getMillis() < targetMillis) {
 					_music->updateMusic();
 					_anim->diffNextFrame();
-					_utils->getTime(&curSecs, &curMicros);
-
-					if ((curSecs > startSecs) || ((curSecs == startSecs) && (curMicros >= startMicros)))
-						break;
 				}
 			}
 			break;
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index 1ac0837..3adcc95 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -428,55 +428,12 @@ void Utils::setBytesPerRow(int num) {
 }
 
 /**
- * Generates a random number.
- */
-uint16 Utils::getRandom(uint16 max) {
-	uint32 secs, micros;
-
-	getTime(&secs, &micros);
-	return ((micros + secs) % max);
-}
-
-void Utils::readBlock(void *Buffer, uint32 Size, byte **File) {
-	memcpy(Buffer, *File, (size_t)Size);
-	(*File) += Size;
-}
-
-/**
- * Waits for for Secs seconds and Micros microseconds to pass.
- */
-void Utils::microDelay(uint32 secs, uint32 micros) {
-	uint32 waitSecs, waitMicros;
-	addCurTime(secs, micros, &waitSecs, &waitMicros);
-
-	while (1) {
-		getTime(&secs, &micros);
-
-		if ((secs > waitSecs) || ((secs == waitSecs) && (micros >= waitMicros)))
-			return;
-
-		g_system->delayMillis(10);
-	}
-}
-
-/**
- * Gets the current system time.
- */
-void Utils::getTime(uint32 *secs, uint32 *micros) {
-	uint32 t = g_system->getMillis();
-
-	*secs = t / 1000;
-	*micros = t % 1000;
-}
-
-/**
  * Adds seconds and microseconds to current time to get a new time.
  */
 void Utils::addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *timeMicros) {
-	getTime(timeSec, timeMicros);
-
-	(*timeSec) += sec;
-	(*timeMicros) += micros;
+	uint32 t = g_system->getMillis();
+	*timeSec = (t / 1000) + sec;
+	*timeMicros = (t % 1000) + micros;
 
 	if (*timeMicros >= ONESECOND) {
 		(*timeSec)++;
@@ -511,21 +468,32 @@ void Utils::anyTimeDiff(uint32 sec1, uint32 micros1, uint32 sec2, uint32 micros2
  * 0 if the future time is actually before the current time.
  */
 void Utils::timeDiff(uint32 sec, uint32 micros, uint32 *diffSec, uint32 *diffMicros) {
-	uint32 curSec, curMicros;
-	getTime(&curSec, &curMicros);
+	uint32 t = g_system->getMillis();
+	uint32 curSec = t / 1000;
+	uint32 curMicros = t % 1000;
+
 	anyTimeDiff(curSec, curMicros, sec, micros, diffSec, diffMicros);
 }
 
 /**
+* Waits for Secs seconds and Micros microseconds to pass.
+*/
+void Utils::microDelay(uint32 secs, uint32 micros) {
+	uint32 targetMillis = g_system->getMillis() + secs * 1000 + micros;
+	while (g_system->getMillis() < targetMillis)
+		g_system->delayMillis(10);
+}
+
+/**
  * Waits for a specified time to occur.
  */
 void Utils::waitForTime(uint32 sec, uint32 micros) {
-	uint32 curSec, curMicros;
-	getTime(&curSec, &curMicros);
+	uint32 targetMillis = sec * 1000 + micros;
+	uint32 t = g_system->getMillis();
+	uint32 curSec = t / 1000;
+	uint32 curMicros = t % 1000;
 
-	if (curSec > sec)
-		return;
-	else if ((curSec == sec) && (curMicros >= micros))
+	if (t >= targetMillis)
 		return;
 
 	if (curMicros > micros)
diff --git a/engines/lab/utils.h b/engines/lab/utils.h
index 9d6e187..65c00a3 100644
--- a/engines/lab/utils.h
+++ b/engines/lab/utils.h
@@ -60,10 +60,7 @@ public:
 	void runLengthDecode(byte *dest, byte *source);
 	void VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow);
 	void setBytesPerRow(int num);
-	uint16 getRandom(uint16 max);
-	void readBlock(void *Buffer, uint32 Size, byte **File);
 	void addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *timeMicros);
-	void getTime(uint32 *secs, uint32 *micros);
 	void waitForTime(uint32 sec, uint32 micros);
 	void anyTimeDiff(uint32 sec1, uint32 micros1, uint32 sec2, uint32 micros2, uint32 *diffSecs, uint32 *diffMicros);
 	void timeDiff(uint32 sec, uint32 micros, uint32 *diffSec, uint32 *diffMicros);


Commit: 452c20ab8abd8f01050e37f355fa2efeb6ef3743
    https://github.com/scummvm/scummvm/commit/452c20ab8abd8f01050e37f355fa2efeb6ef3743
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:01+01:00

Commit Message:
LAB: Get rid of the rest of the custom time delay functions

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h
    engines/lab/engine.cpp
    engines/lab/intro.cpp
    engines/lab/utils.cpp
    engines/lab/utils.h



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index ac51860..347841d 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -46,8 +46,6 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 	_headerdata._height = 0;
 	_headerdata._fps = 0;
 	_headerdata._flags = 0;
-	_waitSec = 0;
-	_waitMicros = 0;
 	_delayMicros = 0;
 	_continuous = false;
 	_isPlaying = false;
@@ -98,8 +96,9 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 
 			if (!onlyDiffData) {
 				if (_headerdata._fps) {
-					_vm->_utils->waitForTime(_waitSec, _waitMicros);
-					_vm->_utils->addCurTime(0L, _delayMicros, &_waitSec, &_waitMicros);
+					uint32 targetMillis = g_system->getMillis() + _delayMicros;
+					while (g_system->getMillis() < targetMillis)
+						g_system->delayMillis(10);
 				}
 
 				if (_isPal && !_noPalChange) {
@@ -273,8 +272,6 @@ void Anim::stopDiffEnd() {
  */
 void Anim::readDiff(byte *buffer, bool playOnce, bool onlyDiffData) {
 	_playOnce = playOnce;
-	_waitSec = 0;
-	_waitMicros = 0;
 	_delayMicros = 0;
 	_header = 0;
 	_curBit = 0;
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 797c553..6c18224 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -61,8 +61,6 @@ private:
 	uint32 _header;
 	uint16 _curBit;
 	uint16 _numChunks;
-	uint32 _waitSec;
-	uint32 _waitMicros;
 	uint32 _delayMicros;
 	bool _continuous;
 	bool _isPlaying;
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 1b77d04..a22409e 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -1145,12 +1145,7 @@ int LabEngine::followCrumbs() {
 	};
 
 	if (_isCrumbWaiting) {
-		uint32 Secs;
-		uint32 Micros;
-
-		_utils->timeDiff(_crumbSecs, _crumbMicros, &Secs, &Micros);
-
-		if (Secs != 0 || Micros != 0)
+		if (g_system->getMillis() <= _crumbSecs * 1000 + _crumbMicros)
 			return 0;
 
 		_isCrumbWaiting = false;
@@ -1193,7 +1188,8 @@ int LabEngine::followCrumbs() {
 		_isCrumbTurning = (moveDir != VKEY_UPARROW);
 		_isCrumbWaiting = true;
 
-		_utils->addCurTime(theDelay / ONESECOND, theDelay % ONESECOND, &_crumbSecs, &_crumbMicros);
+		_crumbSecs   = (theDelay + g_system->getMillis()) / 1000;
+		_crumbMicros = (theDelay + g_system->getMillis()) % 1000;
 	}
 
 	return moveDir;
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 0165116..b6fbf04 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -75,19 +75,13 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 	char path[50] = "Lab:rooms/Intro/";
 	strcat(path, filename);
 
-	uint timeDelay;
-	if (isScreen) {
-		_vm->_music->updateMusic();
-		timeDelay = 35;
-	} else {
-		_vm->_music->updateMusic();
-		timeDelay = 7;
-	}
+	uint timeDelay = (isScreen) ? 35 : 7;
+	_vm->_music->updateMusic();
 
 	if (_quitIntro)
 		return;
 
-	uint32 lastSecs = 0L, lastMicros = 0L, secs = 0L, micros = 0L;
+	uint32 lastMillis = 0;
 	IntuiMessage *msg;
 	bool drawNextText = true, end = false, begin = true;
 
@@ -132,9 +126,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 				return;
 			}
 
-			uint32 t = g_system->getMillis();
-			lastSecs = t / 1000;
-			lastMicros = t % 1000;
+			lastMillis = g_system->getMillis();
 		}
 
 		msg = _vm->getMsg();
@@ -143,12 +135,9 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 			_vm->_music->updateMusic();
 			_vm->_anim->diffNextFrame();
 
-			uint32 t = g_system->getMillis();
-			secs = t / 1000;
-			micros = t % 1000;
-			_vm->_utils->anyTimeDiff(lastSecs, lastMicros, secs, micros, &secs, &micros);
+			uint32 elapsedSeconds = (g_system->getMillis() - lastMillis) / 1000;
 
-			if (secs > timeDelay) {
+			if (elapsedSeconds > timeDelay) {
 				if (end) {
 					if (isScreen)
 						_vm->_graphics->fade(false, 0);
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index 3adcc95..ec69d81 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -427,78 +427,4 @@ void Utils::setBytesPerRow(int num) {
 	_dataBytesPerRow = num;
 }
 
-/**
- * Adds seconds and microseconds to current time to get a new time.
- */
-void Utils::addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *timeMicros) {
-	uint32 t = g_system->getMillis();
-	*timeSec = (t / 1000) + sec;
-	*timeMicros = (t % 1000) + micros;
-
-	if (*timeMicros >= ONESECOND) {
-		(*timeSec)++;
-		(*timeMicros) -= ONESECOND;
-	}
-}
-
-/**
- * Finds the difference between time1 and time2.  If time1 is later than
- * time2, returns 0.
- */
-void Utils::anyTimeDiff(uint32 sec1, uint32 micros1, uint32 sec2, uint32 micros2, uint32 *diffSecs, uint32 *diffMicros) {
-	*diffSecs = 0;
-	*diffMicros = 0;
-
-	if (sec1 > sec2)
-		return;
-	else if ((sec1 == sec2) && (micros1 >= micros2))
-		return;
-
-	if (micros1 > micros2) {
-		*diffSecs = sec2 - sec1 - 1;
-		*diffMicros = (ONESECOND - micros1) + micros2;
-	} else {
-		*diffSecs = sec2 - sec1;
-		*diffMicros = micros2 - micros1;
-	}
-}
-
-/**
- * Finds the difference between the current time, and a future time. Returns
- * 0 if the future time is actually before the current time.
- */
-void Utils::timeDiff(uint32 sec, uint32 micros, uint32 *diffSec, uint32 *diffMicros) {
-	uint32 t = g_system->getMillis();
-	uint32 curSec = t / 1000;
-	uint32 curMicros = t % 1000;
-
-	anyTimeDiff(curSec, curMicros, sec, micros, diffSec, diffMicros);
-}
-
-/**
-* Waits for Secs seconds and Micros microseconds to pass.
-*/
-void Utils::microDelay(uint32 secs, uint32 micros) {
-	uint32 targetMillis = g_system->getMillis() + secs * 1000 + micros;
-	while (g_system->getMillis() < targetMillis)
-		g_system->delayMillis(10);
-}
-
-/**
- * Waits for a specified time to occur.
- */
-void Utils::waitForTime(uint32 sec, uint32 micros) {
-	uint32 targetMillis = sec * 1000 + micros;
-	uint32 t = g_system->getMillis();
-	uint32 curSec = t / 1000;
-	uint32 curMicros = t % 1000;
-
-	if (t >= targetMillis)
-		return;
-
-	if (curMicros > micros)
-		microDelay(sec - curSec - 1, (ONESECOND - curMicros) + micros - 1);
-	else
-		microDelay(sec - curSec, micros - curMicros - 1);
-}
 } // End of namespace Lab
diff --git a/engines/lab/utils.h b/engines/lab/utils.h
index 65c00a3..b0aa58f 100644
--- a/engines/lab/utils.h
+++ b/engines/lab/utils.h
@@ -43,7 +43,6 @@ private:
 	void VUnDiffByteByte(byte *Dest, byte *diff, uint16 bytesperrow);
 	void VUnDiffByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow);
 	void VUnDiffByteLong(uint32 *Dest, uint32 *diff, uint16 bytesperrow);
-	void microDelay(uint32 secs, uint32 micros);
 
 public:
 	Utils(LabEngine *vm);
@@ -60,10 +59,6 @@ public:
 	void runLengthDecode(byte *dest, byte *source);
 	void VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow);
 	void setBytesPerRow(int num);
-	void addCurTime(uint32 sec, uint32 micros, uint32 *timeSec, uint32 *timeMicros);
-	void waitForTime(uint32 sec, uint32 micros);
-	void anyTimeDiff(uint32 sec1, uint32 micros1, uint32 sec2, uint32 micros2, uint32 *diffSecs, uint32 *diffMicros);
-	void timeDiff(uint32 sec, uint32 micros, uint32 *diffSec, uint32 *diffMicros);
 };
 
 


Commit: cd85e5dd34dbf2431778d32be228bde327ddeda1
    https://github.com/scummvm/scummvm/commit/cd85e5dd34dbf2431778d32be228bde327ddeda1
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:01+01:00

Commit Message:
LAB: Remove unneeded static

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index a22409e..367f541 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -1137,7 +1137,7 @@ void LabEngine::go() {
  */
 int LabEngine::followCrumbs() {
 	// NORTH, SOUTH, EAST, WEST
-	static int movement[4][4] = {
+	int movement[4][4] = {
 		{ VKEY_UPARROW, VKEY_RTARROW, VKEY_RTARROW, VKEY_LTARROW },
 		{ VKEY_RTARROW, VKEY_UPARROW, VKEY_LTARROW, VKEY_RTARROW },
 		{ VKEY_LTARROW, VKEY_RTARROW, VKEY_UPARROW, VKEY_RTARROW },


Commit: aad3b063b388e3d8cf4b4cc88bfc1d311d800c1b
    https://github.com/scummvm/scummvm/commit/aad3b063b388e3d8cf4b4cc88bfc1d311d800c1b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:01+01:00

Commit Message:
LAB: The mouse cursor data is constant

Changed paths:
    engines/lab/eventman.cpp



diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 2b39397..e447719 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -39,7 +39,7 @@
 
 namespace Lab {
 
-static byte mouseData[] = {
+static const byte mouseData[] = {
 	1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
 	1, 7, 1, 0, 0, 0, 0, 0, 0, 0,
 	1, 7, 7, 1, 0, 0, 0, 0, 0, 0,


Commit: aef304a83b15f5e829341f53b7af02099b2b32d3
    https://github.com/scummvm/scummvm/commit/aef304a83b15f5e829341f53b7af02099b2b32d3
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:01+01:00

Commit Message:
LAB: Some renaming and refactoring in special.cpp

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/special.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index d2f5f8d..83022ba 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -79,6 +79,20 @@ void DisplayMan::loadPict(const char *filename) {
 	delete bitmapFile;
 }
 
+void DisplayMan::loadBackPict(const char *fileName, uint16 *highPal) {
+	FadePalette = highPal;
+	_vm->_anim->_noPalChange = true;
+	readPict(fileName, true);
+
+	for (uint16 i = 0; i < 16; i++) {
+		highPal[i] = ((_vm->_anim->_diffPalette[i * 3] >> 2) << 8) +
+			((_vm->_anim->_diffPalette[i * 3 + 1] >> 2) << 4) +
+			((_vm->_anim->_diffPalette[i * 3 + 2] >> 2));
+	}
+
+	_vm->_anim->_noPalChange = false;
+}
+
 /**
  * Reads in a picture into the display bitmap.
  */
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index ad506c4..58a517e 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -73,6 +73,7 @@ public:
 	virtual ~DisplayMan();
 
 	void loadPict(const char *filename);
+	void loadBackPict(const char *fileName, uint16 *highPal);
 	void readPict(const char *filename, bool playOnce, bool onlyDiffData = false, byte *memoryBuffer = nullptr, uint16 maxHeight = 0);
 	void freePict();
 	void doScrollBlack();
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index e33c443..e7df814 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -126,6 +126,19 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_imgXMark = nullptr;
 	_maps = nullptr;
 
+	_blankJournal = nullptr;
+	_journalFont = nullptr;
+	_journalText = nullptr;
+	_journalTextTitle = nullptr;
+	_journalPage = 0;
+	_lastPage = false;
+	_monitorPage = 0;
+	_monitorTextFilename = "";
+	_monitorButton = nullptr;
+	_monitorGadgetHeight = 1;
+	for (int i = 0; i < 20; i++)
+		_highPalette[i] = 0;
+
 	//const Common::FSNode gameDataDir(ConfMan.get("path"));
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game");
 	//SearchMan.addSubDirectoryMatching(gameDataDir, "game/pict");
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index b03b4b3..08f7fc6 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -37,6 +37,8 @@
 
 #include "engines/engine.h"
 
+#include "lab/image.h"
+
 struct ADGameDescription;
 
 namespace Lab {
@@ -91,20 +93,28 @@ class LabEngine : public Engine {
 private:
 	bool _interfaceOff;
 	bool _isCrumbWaiting;
+	bool _lastTooLong;
+	bool _lastPage;
 	bool _mainDisplay;
 	bool _noUpdateDiff;
 	bool _quitLab;
-	bool _lastTooLong;
 
 	int _lastWaitTOFTicks;
 
 	uint16 _direction;
+	uint16 _highPalette[20];
+	uint16 _journalPage;
 	uint16 _maxRooms;
+	uint16 _monitorPage;
+	uint16 _monitorGadgetHeight;
 
 	uint32 _extraGameFeatures;
 
+	char *_journalText;
+	char *_journalTextTitle;
 	const char *_nextFileName;
 	const char *_newFileName;
+	const char *_monitorTextFilename;
 
 	CloseDataPtr _closeDataPtr;
 	GadgetList _journalGadgetList;
@@ -114,9 +124,15 @@ private:
 	Image *_imgMapEast, *_imgMapSouth, *_imgMapWest, *_imgXMark;
 	InventoryData *_inventory;
 	MapData *_maps;
+	byte *_blankJournal;
+	Image *_monitorButton;
+	TextFont *_journalFont;
 
 	Common::RandomSource _rnd;
 
+	Image journalBackImage;
+	Image ScreenImage;
+
 public:
 	bool _alternate;
 	bool _droppingCrumbs;
@@ -176,62 +192,62 @@ public:
 	void waitTOF();
 
 private:
+	bool checkConditions(int16 *condition);
 	Gadget *checkNumGadgetHit(GadgetList *gadgetList, uint16 key);
 	void decIncInv(uint16 *CurInv, bool dec);
+	void doActions(Action *actionList, CloseDataPtr *closePtrList);
+	bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *closePtrList);
+	bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults);
+	bool doCloseUp(CloseDataPtr closePtr);
+	bool doGoForward(CloseDataPtr *closePtrList);
 	void doJournal();
+	bool doMainView(CloseDataPtr *closePtrList);
 	void doMap(uint16 curRoom);
 	void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void doNotes();
+	bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults);
+	bool doOperateRule(Common::Point pos, int16 ItemNum, CloseDataPtr *closePtrList);
+	bool doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList);
+	bool doUse(uint16 curInv);
 	void doWestPaper();
 	void drawDirection(CloseDataPtr closePtr);
 	void drawJournal(uint16 wipenum, bool needFade);
+	void drawJournalText();
 	void drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fadeOut, bool fadeIn);
 	void drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive);
+	void drawRoomMap(uint16 curRoom, bool drawMarkFl);
 	void drawRoomMessage(uint16 curInv, CloseDataPtr closePtr);
 	void drawStaticMessage(byte index);
 	void eatMessages();
+	CloseDataPtr findClosePtrMatch(CloseDataPtr closePtr, CloseDataPtr closePtrList);
+	bool floorVisited(uint16 floorNum);
 	int followCrumbs();
 	void freeMapData();
+	void freeScreens();
 	bool fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Common::Point tmpPos,
 		uint16 &curInv, IntuiMessage *curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode);
-	void interfaceOff();
-	void interfaceOn();
-	void loadJournalData();
-	void loadMapData();
-	void processJournal();
-	void processMap(uint16 curRoom);
-	void processMonitor(char *ntext, TextFont *monitorFont, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-
-private:
-	bool checkConditions(int16 *condition);
-	void doActions(Action *actionList, CloseDataPtr *closePtrList);
-	bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *closePtrList);
-	bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults);
-	bool doCloseUp(CloseDataPtr closePtr);
-	bool doGoForward(CloseDataPtr *closePtrList);
-	bool doMainView(CloseDataPtr *closePtrList);
-	bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults);
-	bool doOperateRule(Common::Point pos, int16 ItemNum, CloseDataPtr *closePtrList);
-	bool doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList);
-	bool doUse(uint16 curInv);
-	void drawRoomMap(uint16 curRoom, bool drawMarkFl);
-	CloseDataPtr findClosePtrMatch(CloseDataPtr closePtr, CloseDataPtr closePtrList);
-	bool floorVisited(uint16 floorNum);
-	void freeScreens();
 	const char *getInvName(uint16 curInv);
 	uint16 getLowerFloor(uint16 floorNum);
 	CloseData *getObject(Common::Point pos, CloseDataPtr closePtr);
 	uint16 getUpperFloor(uint16 floorNum);
 	ViewData *getViewData(uint16 roomNum, uint16 direction);
+	void interfaceOff();
+	void interfaceOn();
+	void loadJournalData();
+	void loadMapData();
 	void mainGameLoop();
 	void mayShowCrumbIndicator();
 	void mayShowCrumbIndicatorOff();
 	void perFlipGadget(uint16 gadID);
 	uint16 processArrow(uint16 curDirection, uint16 arrow);
+	void processJournal();
+	void processMap(uint16 curRoom);
+	void processMonitor(char *ntext, TextFont *monitorFont, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	Common::Rect roomCoords(uint16 curRoom);
 	bool saveRestoreGame();
 	void setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, bool useAbsoluteCoords);
 	bool takeItem(uint16 x, uint16 y, CloseDataPtr *closePtrList);
+	void turnPage(bool fromLeft);
 };
 
 extern LabEngine *g_lab;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 6289cf2..90f20b7 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -42,46 +42,12 @@
 #include "lab/utils.h"
 
 namespace Lab {
-
-static uint16 MonGadHeight = 1;
-static uint16 hipal[20];
-
-static TextFont *journalFont;
-static char *journaltext, *journaltexttitle;
-static uint16 JPage = 0;
-static bool lastpage = false;
-static Image JBackImage, ScreenImage;
-static byte *_blankJournal;
-static uint16 monitorPage;
-static const char *TextFileName;
-
-Image *MonButton;
-
-#define INCL(BITSET,BIT) ((BITSET) |= (BIT))
-#define SETBIT(BITSET,BITNUM)   INCL(BITSET, (1 << (BITNUM)))
-#define INBIT(BITSET,BITNUM)    ( ((1 << (BITNUM)) & (BITSET)) > 0 )
 #define BRIDGE0     148
 #define BRIDGE1     104
 #define DIRTY       175
 #define NONEWS      135
 #define NOCLEAN     152
 
-
-static void loadBackPict(const char *fileName) {
-	g_lab->_graphics->FadePalette = hipal;
-
-	g_lab->_anim->_noPalChange = true;
-	g_lab->_graphics->readPict(fileName, true);
-
-	for (uint16 i = 0; i < 16; i++) {
-		hipal[i] = ((g_lab->_anim->_diffPalette[i * 3] >> 2) << 8) +
-				((g_lab->_anim->_diffPalette[i * 3 + 1] >> 2) << 4) +
-				((g_lab->_anim->_diffPalette[i * 3 + 2] >> 2));
-	}
-
-	g_lab->_anim->_noPalChange = false;
-}
-
 /**
  * Does the things to properly set up the detective notes.
  */
@@ -96,7 +62,6 @@ void LabEngine::doNotes() {
 	delete[] ntext;
 }
 
-
 /**
  * Does the things to properly set up the old west newspaper.  Assumes that
  * OpenHiRes already called.
@@ -141,7 +106,7 @@ void LabEngine::doWestPaper() {
  * Loads in the data for the journal.
  */
 void LabEngine::loadJournalData() {
-	journalFont = _resource->getFont("P:Journal.fon");
+	_journalFont = _resource->getFont("P:Journal.fon");
 
 	_music->updateMusic();
 
@@ -172,8 +137,8 @@ void LabEngine::loadJournalData() {
 	else if (bridge)
 		filename[11] = '1';
 
-	journaltext = _resource->getText(filename);
-	journaltexttitle = _resource->getText("Lab:Rooms/jt");
+	_journalText = _resource->getText(filename);
+	_journalTextTitle = _resource->getText("Lab:Rooms/jt");
 
 	Common::File *journalFile = _resource->openDataFile("P:JImage");
 	Utils *utils = _utils;
@@ -183,13 +148,13 @@ void LabEngine::loadJournalData() {
 	delete journalFile;
 
 	_anim->_noPalChange = true;
-	JBackImage._imageData = new byte[_graphics->_screenWidth * _graphics->_screenHeight];
-	_graphics->readPict("P:Journal.pic", true, false, JBackImage._imageData);
+	journalBackImage._imageData = new byte[_graphics->_screenWidth * _graphics->_screenHeight];
+	_graphics->readPict("P:Journal.pic", true, false, journalBackImage._imageData);
 	_anim->_noPalChange = false;
 
 	// Keep a copy of the blank journal
 	_blankJournal = new byte[_graphics->_screenWidth * _graphics->_screenHeight];
-	memcpy(_blankJournal, JBackImage._imageData, _graphics->_screenWidth * _graphics->_screenHeight);
+	memcpy(_blankJournal, journalBackImage._imageData, _graphics->_screenWidth * _graphics->_screenHeight);
 
 	ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
 }
@@ -197,58 +162,58 @@ void LabEngine::loadJournalData() {
 /**
  * Draws the text to the back journal screen to the appropriate Page number
  */
-static void drawJournalText() {
+void LabEngine::drawJournalText() {
 	uint16 drawingToPage = 1;
-	int32 charsDrawn    = 0L;
-	char *curText = journaltext;
+	int32 charsDrawn = 0;
+	char *curText = _journalText;
 
-	while (drawingToPage < JPage) {
-		g_lab->_music->updateMusic();
-		curText = (char *)(journaltext + charsDrawn);
-		charsDrawn += g_lab->_graphics->flowTextScaled(journalFont, -2, 2, 0, false, false, false, false, 52, 32, 152, 148, curText);
+	while (drawingToPage < _journalPage) {
+		_music->updateMusic();
+		curText = (char *)(_journalText + charsDrawn);
+		charsDrawn += _graphics->flowTextScaled(_journalFont, -2, 2, 0, false, false, false, false, 52, 32, 152, 148, curText);
 
-		lastpage = (*curText == 0);
+		_lastPage = (*curText == 0);
 
-		if (lastpage)
-			JPage = (drawingToPage / 2) * 2;
+		if (_lastPage)
+			_journalPage = (drawingToPage / 2) * 2;
 		else
 			drawingToPage++;
 	}
 
-	if (JPage <= 1) {
-		curText = journaltexttitle;
-		g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, true, true, true, g_lab->_utils->vgaScaleX(52), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(152), g_lab->_utils->vgaScaleY(148), curText);
+	if (_journalPage <= 1) {
+		curText = _journalTextTitle;
+		_graphics->flowTextToMem(&journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText);
 	} else {
-		curText = (char *)(journaltext + charsDrawn);
-		charsDrawn += g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_utils->vgaScaleX(52), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(152), g_lab->_utils->vgaScaleY(148), curText);
+		curText = (char *)(_journalText + charsDrawn);
+		charsDrawn += g_lab->_graphics->flowTextToMem(&journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText);
 	}
 
-	g_lab->_music->updateMusic();
-	curText = (char *)(journaltext + charsDrawn);
-	lastpage = (*curText == 0);
-	g_lab->_graphics->flowTextToMem(&JBackImage, journalFont, -2, 2, 0, false, false, false, true, g_lab->_utils->vgaScaleX(171), g_lab->_utils->vgaScaleY(32), g_lab->_utils->vgaScaleX(271), g_lab->_utils->vgaScaleY(148), curText);
+	_music->updateMusic();
+	curText = (char *)(_journalText + charsDrawn);
+	_lastPage = (*curText == 0);
+	_graphics->flowTextToMem(&journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(171), _utils->vgaScaleY(32), _utils->vgaScaleX(271), _utils->vgaScaleY(148), curText);
 
-	curText = (char *)(journaltext + charsDrawn);
-	lastpage = lastpage || (*curText == 0);
+	curText = (char *)(_journalText + charsDrawn);
+	_lastPage = _lastPage || (*curText == 0);
 }
 
 /**
  * Does the turn page wipe.
  */
-static void turnPage(bool fromLeft) {
+void LabEngine::turnPage(bool fromLeft) {
 	if (fromLeft) {
-		for (int i = 0; i < g_lab->_graphics->_screenWidth; i += 8) {
-			g_lab->_music->updateMusic();
-			g_lab->waitTOF();
-			ScreenImage._imageData = g_lab->_graphics->getCurrentDrawingBuffer();
-			JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_graphics->_screenHeight, false);
+		for (int i = 0; i < _graphics->_screenWidth; i += 8) {
+			_music->updateMusic();
+			waitTOF();
+			ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
+			journalBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, _graphics->_screenHeight, false);
 		}
 	} else {
-		for (int i = (g_lab->_graphics->_screenWidth - 8); i > 0; i -= 8) {
-			g_lab->_music->updateMusic();
-			g_lab->waitTOF();
-			ScreenImage._imageData = g_lab->_graphics->getCurrentDrawingBuffer();
-			JBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, g_lab->_graphics->_screenHeight, false);
+		for (int i = (_graphics->_screenWidth - 8); i > 0; i -= 8) {
+			_music->updateMusic();
+			waitTOF();
+			ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
+			journalBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, _graphics->_screenHeight, false);
 		}
 	}
 }
@@ -260,24 +225,22 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 	_event->mouseHide();
 	_music->updateMusic();
 	drawJournalText();
-
-	// TODO: This is only called to set the palette correctly. Refactor, if possible
-	loadBackPict("P:Journal.pic");
+	_graphics->loadBackPict("P:Journal.pic", _highPalette);
 
 	if (wipenum == 0)
-		JBackImage.blitBitmap(0, 0, &ScreenImage, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false);
+		journalBackImage.blitBitmap(0, 0, &ScreenImage, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false);
 	else
 		turnPage((bool)(wipenum == 1));
 
 	Gadget *backGadget = _event->getGadget(0);
 	Gadget *forwardGadget = _event->getGadget(2);
 
-	if (JPage == 0)
+	if (_journalPage == 0)
 		disableGadget(backGadget, 15);
 	else
 		enableGadget(backGadget);
 
-	if (lastpage)
+	if (_lastPage)
 		disableGadget(forwardGadget, 15);
 	else
 		enableGadget(forwardGadget);
@@ -286,7 +249,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 		_graphics->fade(true, 0);
 
 	// Reset the journal background, so that all the text that has been blitted on it is erased
-	memcpy(JBackImage._imageData, _blankJournal, _graphics->_screenWidth * _graphics->_screenHeight);
+	memcpy(journalBackImage._imageData, _blankJournal, _graphics->_screenWidth * _graphics->_screenHeight);
 
 	eatMessages();
 	_event->mouseShow();
@@ -313,15 +276,15 @@ void LabEngine::processJournal() {
 				return;
 			else if (msgClass == GADGETUP) {
 				if (gadID == 0) {
-					if (JPage >= 2) {
-						JPage -= 2;
+					if (_journalPage >= 2) {
+						_journalPage -= 2;
 						drawJournal(1, false);
 					}
 				} else if (gadID == 1) {
 					return;
 				} else if (gadID == 2) {
-					if (!lastpage) {
-						JPage += 2;
+					if (!_lastPage) {
+						_journalPage += 2;
 						drawJournal(2, false);
 					}
 				}
@@ -336,13 +299,13 @@ void LabEngine::processJournal() {
 void LabEngine::doJournal() {
 	_graphics->blackAllScreen();
 
-	lastpage    = false;
+	_lastPage    = false;
 
-	JBackImage._width = _graphics->_screenWidth;
-	JBackImage._height = _graphics->_screenHeight;
-	JBackImage._imageData = NULL;
+	journalBackImage._width = _graphics->_screenWidth;
+	journalBackImage._height = _graphics->_screenHeight;
+	journalBackImage._imageData = NULL;
 
-	ScreenImage = JBackImage;
+	ScreenImage = journalBackImage;
 	ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
 
 	_music->updateMusic();
@@ -357,9 +320,9 @@ void LabEngine::doJournal() {
 	_event->mouseHide();
 
 	delete[] _blankJournal;
-	delete[] JBackImage._imageData;
+	delete[] journalBackImage._imageData;
 	freeButtonList(&_journalGadgetList);
-	_graphics->closeFont(journalFont);
+	_graphics->closeFont(_journalFont);
 
 	ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
 
@@ -386,19 +349,19 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
 		text += 2;
 
 		fheight = _graphics->textHeight(monitorFont);
-		x1 = MonButton->_width + _utils->vgaScaleX(3);
-		MonGadHeight = MonButton->_height + _utils->vgaScaleY(3);
+		x1 = _monitorButton->_width + _utils->vgaScaleX(3);
+		_monitorGadgetHeight = _monitorButton->_height + _utils->vgaScaleY(3);
 
-		if (MonGadHeight > fheight)
-			yspacing = MonGadHeight - fheight;
+		if (_monitorGadgetHeight > fheight)
+			yspacing = _monitorGadgetHeight - fheight;
 		else
-			MonGadHeight = fheight;
+			_monitorGadgetHeight = fheight;
 
 		_graphics->setAPen(0);
 		_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2);
 
 		for (uint16 i = 0; i < numlines; i++)
-			MonButton->drawImage(0, i * MonGadHeight);
+			_monitorButton->drawImage(0, i * _monitorGadgetHeight);
 	} else if (isinteractive) {
 		_graphics->setAPen(0);
 		_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2);
@@ -407,23 +370,23 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
 		_graphics->rectFill(x1, y1, x2, y2);
 	}
 
-	while (drawingToPage < monitorPage) {
+	while (drawingToPage < _monitorPage) {
 		_music->updateMusic();
 		curText = (char *)(text + charsDrawn);
 		charsDrawn += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, curText);
-		lastpage = (*curText == 0);
+		_lastPage = (*curText == 0);
 
-		if (lastpage)
-			monitorPage = drawingToPage;
+		if (_lastPage)
+			_monitorPage = drawingToPage;
 		else
 			drawingToPage++;
 	}
 
 	curText = (char *)(text + charsDrawn);
-	lastpage = (*curText == 0);
+	_lastPage = (*curText == 0);
 	charsDrawn = _graphics->flowText(monitorFont, yspacing, 2, 0, false, false, false, true, x1, y1, x2, y2, curText);
 	curText += charsDrawn;
-	lastpage = lastpage || (*curText == 0);
+	_lastPage = _lastPage || (*curText == 0);
 
 	_event->mouseShow();
 }
@@ -432,7 +395,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
  * Processes user input.
  */
 void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	const char *test = " ", *startFileName = TextFileName;
+	const char *test = " ", *startFileName = _monitorTextFilename;
 	CloseDataPtr startClosePtr = _closeDataPtr, lastClosePtr[10];
 	uint16 depth = 0;
 
@@ -448,11 +411,11 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 			else
 				test = _closeDataPtr->_graphicName;
 
-			if (strcmp(test, TextFileName)) {
-				monitorPage      = 0;
-				TextFileName = test;
+			if (strcmp(test, _monitorTextFilename)) {
+				_monitorPage      = 0;
+				_monitorTextFilename = test;
 
-				ntext = _resource->getText(TextFileName);
+				ntext = _resource->getText(_monitorTextFilename);
 				_graphics->fade(false, 0);
 				drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
 				_graphics->fade(true, 0);
@@ -480,33 +443,33 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 			else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) {
 				if ((mouseY >= _utils->vgaScaleY(171)) && (mouseY <= _utils->vgaScaleY(200))) {
 					if ((mouseX >= _utils->vgaScaleX(259)) && (mouseX <= _utils->vgaScaleX(289))) {
-						if (!lastpage) {
-							monitorPage += 1;
+						if (!_lastPage) {
+							_monitorPage += 1;
 							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
 						}
 					} else if ((mouseX >= _utils->vgaScaleX(0)) && (mouseX <= _utils->vgaScaleX(31))) {
 						return;
 					} else if ((mouseX >= _utils->vgaScaleX(290)) && (mouseX <= _utils->vgaScaleX(320))) {
-						if (monitorPage >= 1) {
-							monitorPage -= 1;
+						if (_monitorPage >= 1) {
+							_monitorPage -= 1;
 							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
 						}
 					} else if ((mouseX >= _utils->vgaScaleX(31)) && (mouseX <= _utils->vgaScaleX(59))) {
 						if (isinteractive) {
-							monitorPage = 0;
+							_monitorPage = 0;
 
 							if (depth) {
 								depth--;
 								_closeDataPtr = lastClosePtr[depth];
 							}
-						} else if (monitorPage > 0) {
-							monitorPage = 0;
+						} else if (_monitorPage > 0) {
+							_monitorPage = 0;
 							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
 						}
 					}
 				} else if (isinteractive) {
 					CloseDataPtr tmpClosePtr = _closeDataPtr;
-					mouseY = 64 + (mouseY / MonGadHeight) * 42;
+					mouseY = 64 + (mouseY / _monitorGadgetHeight) * 42;
 					mouseX = 101;
 					setCurrentClose(Common::Point(mouseX, mouseY), &_closeDataPtr, false);
 
@@ -531,7 +494,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 	y1 = _utils->vgaScaleY(y1);
 	y2 = _utils->vgaScaleY(y2);
 
-	TextFileName = textfile;
+	_monitorTextFilename = textfile;
 
 	_graphics->blackAllScreen();
 	_graphics->readPict("P:Mon/Monitor.1", true);
@@ -540,17 +503,17 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 	_graphics->readPict("P:Mon/NWD3", true);
 	_graphics->blackAllScreen();
 
-	monitorPage = 0;
-	lastpage = false;
-	_graphics->FadePalette = hipal;
+	_monitorPage = 0;
+	_lastPage = false;
+	_graphics->FadePalette = _highPalette;
 
 	TextFont *monitorFont = _resource->getFont("P:Map.fon");
 	Common::File *buttonFile = _resource->openDataFile("P:MonImage");
-	MonButton = new Image(buttonFile);
+	_monitorButton = new Image(buttonFile);
 	delete buttonFile;
 
 	ntext = _resource->getText(textfile);
-	loadBackPict(background);
+	_graphics->loadBackPict(background, _highPalette);
 	drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
 	_event->mouseShow();
 	_graphics->fade(true, 0);


Commit: ac346869f759475ad00751159a6bad5064f235a2
    https://github.com/scummvm/scummvm/commit/ac346869f759475ad00751159a6bad5064f235a2
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:01+01:00

Commit Message:
LAB: Remove a useless use of g_lab

Changed paths:
    engines/lab/special.cpp



diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 90f20b7..f043d0a 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -185,7 +185,7 @@ void LabEngine::drawJournalText() {
 		_graphics->flowTextToMem(&journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText);
 	} else {
 		curText = (char *)(_journalText + charsDrawn);
-		charsDrawn += g_lab->_graphics->flowTextToMem(&journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText);
+		charsDrawn += _graphics->flowTextToMem(&journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText);
 	}
 
 	_music->updateMusic();


Commit: 6668b76edcb0d0be70314f417c13f535756b0d2c
    https://github.com/scummvm/scummvm/commit/6668b76edcb0d0be70314f417c13f535756b0d2c
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:02+01:00

Commit Message:
LAB: Remove some more useless g_lab

Changed paths:
    engines/lab/intro.cpp
    engines/lab/music.cpp



diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index b6fbf04..fbe1fac 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -88,7 +88,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 	int32 cls, code, Drawn;
 	int16 qualifier;
 
-	Common::File *textFile = g_lab->_resource->openDataFile(path);
+	Common::File *textFile = _vm->_resource->openDataFile(path);
 	byte *textBuffer = new byte[textFile->size()];
 	textFile->read(textBuffer, textFile->size());
 	delete textFile;
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index feddea5..a996f31 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -178,7 +178,7 @@ bool Music::initMusic() {
 	else
 		filename = "Music:BackGrou";
 
-	_file = g_lab->_resource->openDataFile(filename);
+	_file = _vm->_resource->openDataFile(filename);
 	startMusic(true);
 	return true;
 }
@@ -274,7 +274,7 @@ void Music::changeMusic(const char *newmusic) {
 			_tLeftInFile = _leftinfile;
 	}
 
-	_file = g_lab->_resource->openDataFile(newmusic);
+	_file = _vm->_resource->openDataFile(newmusic);
 	// turn music off
 	_musicOn = true;
 	setMusic(false);


Commit: 47368c157ebf870248a61de4b81e181fa7713671
    https://github.com/scummvm/scummvm/commit/47368c157ebf870248a61de4b81e181fa7713671
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:02+01:00

Commit Message:
LAB: Review Music declaration, some refactoring and renaming

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/map.cpp
    engines/lab/music.cpp
    engines/lab/music.h
    engines/lab/processroom.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 83022ba..4cc3c24 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -103,7 +103,7 @@ void DisplayMan::readPict(const char *filename, bool playOnce, bool onlyDiffData
 
 	_vm->_music->updateMusic();
 
-	if (!_vm->_music->_doNotFilestopSoundEffect)
+	if (!_vm->_music->_unstoppableSoundEffect)
 		_vm->_music->stopSoundEffect();
 
 	_dispBitMap->_bytesPerRow  = _screenWidth;
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index db99550..5d978b7 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -87,7 +87,7 @@ void LabEngine::loadMapData() {
 
 	Common::File *mapFile = _resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0'));
 	_music->updateMusic();
-	if (!_music->_doNotFilestopSoundEffect)
+	if (!_music->_unstoppableSoundEffect)
 		_music->stopSoundEffect();
 
 	_maxRooms = mapFile->readUint16LE();
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index a996f31..cca7633 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -50,16 +50,16 @@ Music::Music(LabEngine *vm) : _vm(vm) {
 	_tFile = 0;
 	_musicPaused = false;
 
-	_tMusicOn = false;
+	_oldMusicOn = false;
 	_tLeftInFile = 0;
 
-	_leftinfile = 0;
+	_leftInFile = 0;
 
 	_musicOn = false;
-	_winmusic = false;
+	_winMusic = false;
 	_loopSoundEffect = false;
 	_queuingAudioStream = NULL;
-	_doNotFilestopSoundEffect = false;
+	_unstoppableSoundEffect = false;
 	_lastMusicRoom = 1;
 	_doReset = true;
 	_waitTillFinished = false;
@@ -104,12 +104,12 @@ uint16 Music::getPlayingBufferCount() {
 	return (_queuingAudioStream) ? _queuingAudioStream->numQueuedStreams() : 0;
 }
 
-void Music::playSoundEffect(uint16 SampleSpeed, uint32 Length, void *Data) {
+void Music::playSoundEffect(uint16 sampleSpeed, uint32 length, void *data) {
 	pauseBackMusic();
 	stopSoundEffect();
 
-	if (SampleSpeed < 4000)
-		SampleSpeed = 4000;
+	if (sampleSpeed < 4000)
+		sampleSpeed = 4000;
 
 	byte soundFlags = Audio::FLAG_LITTLE_ENDIAN;
 	if (_vm->getPlatform() == Common::kPlatformWindows)
@@ -117,7 +117,7 @@ void Music::playSoundEffect(uint16 SampleSpeed, uint32 Length, void *Data) {
 	else
 		soundFlags |= Audio::FLAG_UNSIGNED;
 
-	Audio::SeekableAudioStream *audioStream = Audio::makeRawStream((const byte *)Data, Length, SampleSpeed, soundFlags, DisposeAfterUse::NO);
+	Audio::SeekableAudioStream *audioStream = Audio::makeRawStream((const byte *)data, length, sampleSpeed, soundFlags, DisposeAfterUse::NO);
 	uint loops = (_loopSoundEffect) ? 0 : 1;
 	Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, loops);
 	_vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, loopingAudioStream);
@@ -133,16 +133,16 @@ bool Music::isSoundEffectActive() const {
 }
 
 void Music::fillbuffer(byte *musicBuffer) {
-	if (MUSICBUFSIZE < _leftinfile) {
+	if (MUSICBUFSIZE < _leftInFile) {
 		_file->read(musicBuffer, MUSICBUFSIZE);
-		_leftinfile -= MUSICBUFSIZE;
+		_leftInFile -= MUSICBUFSIZE;
 	} else {
-		_file->read(musicBuffer, _leftinfile);
+		_file->read(musicBuffer, _leftInFile);
 
-		memset((char *)musicBuffer + _leftinfile, 0, MUSICBUFSIZE - _leftinfile);
+		memset((char *)musicBuffer + _leftInFile, 0, MUSICBUFSIZE - _leftInFile);
 
 		_file->seek(0);
-		_leftinfile = _file->size();
+		_leftInFile = _file->size();
 	}
 }
 
@@ -157,7 +157,7 @@ void Music::startMusic(bool restartFl) {
 
 	if (restartFl) {
 		_file->seek(0);
-		_leftinfile  = _file->size();
+		_leftInFile  = _file->size();
 	}
 
 	_musicOn = true;
@@ -173,7 +173,7 @@ bool Music::initMusic() {
 
 	const char *filename;
 
-	if (_winmusic)
+	if (_winMusic)
 		filename = "Music:WinGame";
 	else
 		filename = "Music:BackGrou";
@@ -267,11 +267,11 @@ void Music::checkRoomMusic() {
 void Music::changeMusic(const char *newmusic) {
 	if (!_tFile) {
 		_tFile = _file;
-		_tMusicOn = _musicOn;
-		_tLeftInFile = _leftinfile + 65536L;
+		_oldMusicOn = _musicOn;
+		_tLeftInFile = _leftInFile + 65536L;
 
 		if (_tLeftInFile > (uint32)_tFile->size())
-			_tLeftInFile = _leftinfile;
+			_tLeftInFile = _leftInFile;
 	}
 
 	_file = _vm->_resource->openDataFile(newmusic);
@@ -295,20 +295,20 @@ void Music::resetMusic() {
 		_file->close();
 
 	_file      = _tFile;
-	_leftinfile = _tLeftInFile;
+	_leftInFile = _tLeftInFile;
 
-	_file->seek(_file->size() - _leftinfile);
+	_file->seek(_file->size() - _leftInFile);
 
 	_musicOn = true;
 	setMusic(false);
 	updateMusic();
 
-	if (!_tMusicOn) {
+	if (!_oldMusicOn) {
 		_tFile = 0;
 		return;
 	}
 
-	_musicOn = _tMusicOn;
+	_musicOn = _oldMusicOn;
 	startMusic(false);
 
 	_tFile = 0;
@@ -320,7 +320,7 @@ void Music::resetMusic() {
 bool Music::readMusic(const char *filename, bool waitTillFinished) {
 	Common::File *file = _vm->_resource->openDataFile(filename, MKTAG('D', 'I', 'F', 'F'));
 	updateMusic();
-	if (!_doNotFilestopSoundEffect)
+	if (!_unstoppableSoundEffect)
 		stopSoundEffect();
 
 	if (!file)
@@ -334,9 +334,10 @@ bool Music::readMusic(const char *filename, bool waitTillFinished) {
 
 void Music::readSound(bool waitTillFinished, Common::File *file) {
 	uint32 magicBytes = file->readUint32LE();
-	if (magicBytes != 1219009121L)
+	if (magicBytes != 1219009121L) {
+		warning("readSound: Bad signature, skipping");
 		return;
-
+	}
 	uint32 soundTag = file->readUint32LE();
 	uint32 soundSize = file->readUint32LE();
 
@@ -367,16 +368,14 @@ void Music::readSound(bool waitTillFinished, Common::File *file) {
 			byte *soundData = (byte *)malloc(soundSize);
 			file->read(soundData, soundSize);
 			playSoundEffect(sampleRate, soundSize, soundData);
-		}
-		else if (soundTag == 65535L) {
+		} else if (soundTag == 65535L) {
 			if (waitTillFinished) {
 				while (isSoundEffectActive()) {
 					updateMusic();
 					_vm->waitTOF();
 				}
 			}
-		}
-		else
+		} else
 			file->skip(soundSize);
 	}
 }
diff --git a/engines/lab/music.h b/engines/lab/music.h
index 5efd2e3..57524ba 100644
--- a/engines/lab/music.h
+++ b/engines/lab/music.h
@@ -46,52 +46,56 @@ class LabEngine;
 #define MAXBUFFERS         5L
 
 class Music {
-public:
-	Music(LabEngine *vm);
-
-	bool initMusic();
-	void freeMusic();
-	void updateMusic();
-	uint16 getPlayingBufferCount();
-	void closeMusic();
-	void setMusic(bool on);
-	void resumeBackMusic();
-	void pauseBackMusic();
-	void changeMusic(const char *newmusic);
-	void checkRoomMusic();
-	void resetMusic();
-	void setMusicReset(bool reset) { _doReset = reset; }
-	void playSoundEffect(uint16 SampleSpeed, uint32 Length, void *Data);
-	void stopSoundEffect();
-	bool isSoundEffectActive() const;
-	bool readMusic(const char *filename, bool waitTillFinished);
-
-	bool _winmusic, _doNotFilestopSoundEffect;
-	bool _musicOn;
-	bool _loopSoundEffect;
-	bool _waitTillFinished;
-	uint16 _lastMusicRoom ;
-	bool _doReset;
-
 private:
-	void fillbuffer(byte *musicBuffer);
-	void startMusic(bool restartFl);
-	void readSound(bool waitTillFinished, Common::File *file);
-
 	LabEngine *_vm;
 
 	Common::File *_file;
 	Common::File *_tFile;
+
+	bool _doReset;
+	bool _musicOn;
 	bool _musicPaused;
+	bool _oldMusicOn;
+	bool _winMusic;
+
+	uint16 _lastMusicRoom ;
 
-	bool _tMusicOn;
 	uint32 _tLeftInFile;
-	uint32 _leftinfile;
+	uint32 _leftInFile;
 
 	Audio::SoundHandle _musicHandle;
 	Audio::SoundHandle _sfxHandle;
-
 	Audio::QueuingAudioStream *_queuingAudioStream;
+
+private:
+	void fillbuffer(byte *musicBuffer);
+	uint16 getPlayingBufferCount();
+	void pauseBackMusic();
+	void readSound(bool waitTillFinished, Common::File *file);
+	void startMusic(bool restartFl);
+
+public:
+	bool _unstoppableSoundEffect;
+	bool _loopSoundEffect;
+	bool _waitTillFinished;
+
+public:
+	Music(LabEngine *vm);
+
+	void changeMusic(const char *newmusic);
+	void checkRoomMusic();
+	void freeMusic();
+	bool initMusic();
+	bool isSoundEffectActive() const;
+	void playSoundEffect(uint16 sampleSpeed, uint32 length, void *data);
+	bool readMusic(const char *filename, bool waitTillFinished);
+	void resetMusic();
+	void resumeBackMusic();
+	void setMusic(bool on);
+	void setMusicReset(bool reset) { _doReset = reset; }
+	void setWinMusic() { _winMusic = true; }
+	void stopSoundEffect();
+	void updateMusic();
 };
 
 } // End of namespace Lab
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index bd9d02e..c09d918 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -296,7 +296,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			break;
 
 		case PLAYSOUNDCONT:
-			_music->_doNotFilestopSoundEffect = true;
+			_music->_unstoppableSoundEffect = true;
 			_music->_loopSoundEffect = true;
 			_music->readMusic((char *)actionList->_data, _music->_waitTillFinished);
 			break;
@@ -476,7 +476,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			break;
 
 		case WINMUSIC:
-			_music->_winmusic = true;
+			_music->setWinMusic();
 			_music->freeMusic();
 			_music->initMusic();
 			break;
@@ -544,7 +544,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 		}
 	}
 
-	_music->_doNotFilestopSoundEffect = false;
+	_music->_unstoppableSoundEffect = false;
 }
 
 /**


Commit: 7efd471a92ca6a8d9f7e2c9acdd17be847b7ef73
    https://github.com/scummvm/scummvm/commit/7efd471a92ca6a8d9f7e2c9acdd17be847b7ef73
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:02+01:00

Commit Message:
LAB: check header define names, rename a parameter of processMonitor()

Changed paths:
    engines/lab/image.h
    engines/lab/interface.h
    engines/lab/lab.h
    engines/lab/music.h
    engines/lab/special.cpp



diff --git a/engines/lab/image.h b/engines/lab/image.h
index 0e2f831..34e3d36 100644
--- a/engines/lab/image.h
+++ b/engines/lab/image.h
@@ -55,4 +55,4 @@ public:
 
 } // End of namespace Lab
 
-#endif // LAB_H
+#endif // LAB_IMAGE_H
diff --git a/engines/lab/interface.h b/engines/lab/interface.h
index c4b2341..10e0815 100644
--- a/engines/lab/interface.h
+++ b/engines/lab/interface.h
@@ -28,8 +28,8 @@
  *
  */
 
-#ifndef LAB_INTEFACE_H
-#define LAB_INTEFACE_H
+#ifndef LAB_INTEFARCE_H
+#define LAB_INTEFARCE_H
 
 namespace Lab {
 
@@ -112,4 +112,4 @@ IntuiMessage *getMsg();
 
 } // End of namespace Lab
 
-#endif // LAB_INTEFACE_H
+#endif // LAB_INTEFARCE_H
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 08f7fc6..92ffa26 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -28,8 +28,8 @@
  *
  */
 
-#ifndef LAB_H
-#define LAB_H
+#ifndef LAB_LAB_H
+#define LAB_LAB_H
 
 #include "common/system.h"
 #include "common/random.h"
@@ -242,7 +242,7 @@ private:
 	uint16 processArrow(uint16 curDirection, uint16 arrow);
 	void processJournal();
 	void processMap(uint16 curRoom);
-	void processMonitor(char *ntext, TextFont *monitorFont, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void processMonitor(char *ntext, TextFont *monitorFont, bool isInteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	Common::Rect roomCoords(uint16 curRoom);
 	bool saveRestoreGame();
 	void setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, bool useAbsoluteCoords);
@@ -254,4 +254,4 @@ extern LabEngine *g_lab;
 
 } // End of namespace Lab
 
-#endif // LAB_H
+#endif // LAB_LAB_H
diff --git a/engines/lab/music.h b/engines/lab/music.h
index 57524ba..02c6820 100644
--- a/engines/lab/music.h
+++ b/engines/lab/music.h
@@ -43,7 +43,7 @@ class LabEngine;
 //----- From LabMusic.c -----
 //---------------------------
 
-#define MAXBUFFERS         5L
+#define MAXBUFFERS 5
 
 class Music {
 private:
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index f043d0a..5b2da2a 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -394,7 +394,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
 /**
  * Processes user input.
  */
-void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isInteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	const char *test = " ", *startFileName = _monitorTextFilename;
 	CloseDataPtr startClosePtr = _closeDataPtr, lastClosePtr[10];
 	uint16 depth = 0;
@@ -402,7 +402,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 	lastClosePtr[0] = _closeDataPtr;
 
 	while (1) {
-		if (isinteractive) {
+		if (isInteractive) {
 			if (_closeDataPtr == NULL)
 				_closeDataPtr = startClosePtr;
 
@@ -417,7 +417,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 
 				ntext = _resource->getText(_monitorTextFilename);
 				_graphics->fade(false, 0);
-				drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
+				drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive);
 				_graphics->fade(true, 0);
 				delete[] ntext;
 			}
@@ -445,17 +445,17 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 					if ((mouseX >= _utils->vgaScaleX(259)) && (mouseX <= _utils->vgaScaleX(289))) {
 						if (!_lastPage) {
 							_monitorPage += 1;
-							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
+							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive);
 						}
 					} else if ((mouseX >= _utils->vgaScaleX(0)) && (mouseX <= _utils->vgaScaleX(31))) {
 						return;
 					} else if ((mouseX >= _utils->vgaScaleX(290)) && (mouseX <= _utils->vgaScaleX(320))) {
 						if (_monitorPage >= 1) {
 							_monitorPage -= 1;
-							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
+							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive);
 						}
 					} else if ((mouseX >= _utils->vgaScaleX(31)) && (mouseX <= _utils->vgaScaleX(59))) {
-						if (isinteractive) {
+						if (isInteractive) {
 							_monitorPage = 0;
 
 							if (depth) {
@@ -464,10 +464,10 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isintera
 							}
 						} else if (_monitorPage > 0) {
 							_monitorPage = 0;
-							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
+							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive);
 						}
 					}
-				} else if (isinteractive) {
+				} else if (isInteractive) {
 					CloseDataPtr tmpClosePtr = _closeDataPtr;
 					mouseY = 64 + (mouseY / _monitorGadgetHeight) * 42;
 					mouseX = 101;


Commit: c837e67070913166177a19b2d0d6d925d4569c83
    https://github.com/scummvm/scummvm/commit/c837e67070913166177a19b2d0d6d925d4569c83
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:02+01:00

Commit Message:
LAB: Move interface functions to EventMan

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/eventman.h
    engines/lab/interface.cpp
    engines/lab/interface.h
    engines/lab/intro.cpp
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 4cc3c24..0aa49f9 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -383,7 +383,7 @@ void DisplayMan::drawPanel() {
 		setAPen(4);
 		// The horizontal lines under the black one
 		drawHLine(0, _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(319));
-		drawGadgetList(&_vm->_moveGadgetList);
+		_vm->_event->drawGadgetList(&_vm->_moveGadgetList);
 	} else {
 		if (_vm->getPlatform() != Common::kPlatformWindows) {
 			// Vertical Black lines
@@ -413,7 +413,7 @@ void DisplayMan::drawPanel() {
 			drawVLine(_vm->_utils->vgaScaleX(232), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
 		}
 
-		drawGadgetList(&_vm->_invGadgetList);
+		_vm->_event->drawGadgetList(&_vm->_invGadgetList);
 	}
 
 	_vm->_event->mouseShow();
@@ -436,16 +436,16 @@ void DisplayMan::setUpScreens() {
 	// The key mapping was only set for the Windows version.
 	// It's very convenient to have those shortcut, so I added them
 	// for all versions. (Strangerke)
-	_vm->_moveGadgetList.push_back(createButton(  1, y, 0,          't', _vm->_moveImages[0],  _vm->_moveImages[1]));
-	_vm->_moveGadgetList.push_back(createButton( 33, y, 1,          'm', _vm->_moveImages[2],  _vm->_moveImages[3]));
-	_vm->_moveGadgetList.push_back(createButton( 65, y, 2,          'o', _vm->_moveImages[4],  _vm->_moveImages[5]));
-	_vm->_moveGadgetList.push_back(createButton( 97, y, 3,          'c', _vm->_moveImages[6],  _vm->_moveImages[7]));
-	_vm->_moveGadgetList.push_back(createButton(129, y, 4,          'l', _vm->_moveImages[8],  _vm->_moveImages[9]));
-	_vm->_moveGadgetList.push_back(createButton(161, y, 5,          'i', _vm->_moveImages[12], _vm->_moveImages[13]));
-	_vm->_moveGadgetList.push_back(createButton(193, y, 6, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]));
-	_vm->_moveGadgetList.push_back(createButton(225, y, 7, VKEY_UPARROW, _vm->_moveImages[16], _vm->_moveImages[17]));
-	_vm->_moveGadgetList.push_back(createButton(257, y, 8, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]));
-	_vm->_moveGadgetList.push_back(createButton(289, y, 9,          'p', _vm->_moveImages[10], _vm->_moveImages[11]));
+	_vm->_moveGadgetList.push_back(_vm->_event->createButton(  1, y, 0,          't', _vm->_moveImages[0],  _vm->_moveImages[1]));
+	_vm->_moveGadgetList.push_back(_vm->_event->createButton( 33, y, 1,          'm', _vm->_moveImages[2],  _vm->_moveImages[3]));
+	_vm->_moveGadgetList.push_back(_vm->_event->createButton( 65, y, 2,          'o', _vm->_moveImages[4],  _vm->_moveImages[5]));
+	_vm->_moveGadgetList.push_back(_vm->_event->createButton( 97, y, 3,          'c', _vm->_moveImages[6],  _vm->_moveImages[7]));
+	_vm->_moveGadgetList.push_back(_vm->_event->createButton(129, y, 4,          'l', _vm->_moveImages[8],  _vm->_moveImages[9]));
+	_vm->_moveGadgetList.push_back(_vm->_event->createButton(161, y, 5,          'i', _vm->_moveImages[12], _vm->_moveImages[13]));
+	_vm->_moveGadgetList.push_back(_vm->_event->createButton(193, y, 6, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]));
+	_vm->_moveGadgetList.push_back(_vm->_event->createButton(225, y, 7, VKEY_UPARROW, _vm->_moveImages[16], _vm->_moveImages[17]));
+	_vm->_moveGadgetList.push_back(_vm->_event->createButton(257, y, 8, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]));
+	_vm->_moveGadgetList.push_back(_vm->_event->createButton(289, y, 9,          'p', _vm->_moveImages[10], _vm->_moveImages[11]));
 
 	Common::File *invFile = _vm->_resource->openDataFile("P:Inv");
 	if (_vm->getPlatform() == Common::kPlatformWindows) {
@@ -455,18 +455,18 @@ void DisplayMan::setUpScreens() {
 		for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++)
 			_vm->_invImages[imgIdx] = new Image(invFile);
 	}
-	_vm->_invGadgetList.push_back(createButton( 24, y, 0,          'm', _vm->_invImages[0],   _vm->_invImages[1]));
-	_vm->_invGadgetList.push_back(createButton( 56, y, 1,          'g', _vm->_invImages[2],   _vm->_invImages[3]));
-	_vm->_invGadgetList.push_back(createButton( 94, y, 2,          'u', _vm->_invImages[4],   _vm->_invImages[5]));
-	_vm->_invGadgetList.push_back(createButton(126, y, 3,          'l', _vm->_moveImages[8],  _vm->_moveImages[9]));
-	_vm->_invGadgetList.push_back(createButton(164, y, 4, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]));
-	_vm->_invGadgetList.push_back(createButton(196, y, 5, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]));
+	_vm->_invGadgetList.push_back(_vm->_event->createButton( 24, y, 0,          'm', _vm->_invImages[0],   _vm->_invImages[1]));
+	_vm->_invGadgetList.push_back(_vm->_event->createButton( 56, y, 1,          'g', _vm->_invImages[2],   _vm->_invImages[3]));
+	_vm->_invGadgetList.push_back(_vm->_event->createButton( 94, y, 2,          'u', _vm->_invImages[4],   _vm->_invImages[5]));
+	_vm->_invGadgetList.push_back(_vm->_event->createButton(126, y, 3,          'l', _vm->_moveImages[8],  _vm->_moveImages[9]));
+	_vm->_invGadgetList.push_back(_vm->_event->createButton(164, y, 4, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]));
+	_vm->_invGadgetList.push_back(_vm->_event->createButton(196, y, 5, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]));
 
 	// The windows version has 2 extra gadgets for breadcrumb trail
 	// TODO: the game is really hard to play without those, maybe we could add something to enable that.
 	if (_vm->getPlatform() == Common::kPlatformWindows) {
-		_vm->_invGadgetList.push_back(createButton(234, y, 6, 'b', _vm->_invImages[6], _vm->_invImages[7]));
-		_vm->_invGadgetList.push_back(createButton(266, y, 7, 'f', _vm->_invImages[8], _vm->_invImages[9]));
+		_vm->_invGadgetList.push_back(_vm->_event->createButton(234, y, 6, 'b', _vm->_invImages[6], _vm->_invImages[7]));
+		_vm->_invGadgetList.push_back(_vm->_event->createButton(266, y, 7, 'f', _vm->_invImages[8], _vm->_invImages[9]));
 	}
 
 	delete invFile;
diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h
index 420c7d0..f9facd8 100644
--- a/engines/lab/eventman.h
+++ b/engines/lab/eventman.h
@@ -31,11 +31,28 @@
 #ifndef LAB_EVENTMAN_H
 #define LAB_EVENTMAN_H
 
-namespace Lab {
+#include "common/events.h"
 
-struct Gadget;
+namespace Lab {
 
 class LabEngine;
+class Image;
+
+struct IntuiMessage {
+	uint32 _msgClass;
+	uint16 _code, _qualifier, _mouseX, _mouseY, _gadgetID;
+	uint32 _seconds, _micros;
+};
+
+
+struct Gadget {
+	uint16 x, y, _gadgetID;
+	uint16 _keyEquiv; // if not zero, a key that activates gadget
+	bool isEnabled;
+	Image *_image, *_altImage;
+};
+
+typedef Common::List<Gadget *> GadgetList;
 
 class EventManager {
 private:
@@ -56,6 +73,7 @@ public:
 
 	GadgetList *_screenGadgetList;
 	Gadget *_hitGadget;
+	Common::KeyState _keyPressed;
 
 	Gadget *checkGadgetHit(GadgetList *gadgetList, Common::Point pos);
 	void initMouse();
@@ -74,6 +92,15 @@ public:
 	void processInput(bool can_delay = false);
 	uint16 getNextChar();
 	Common::Point updateAndGetMousePos();
+
+	Gadget *checkNumGadgetHit(GadgetList *gadgetList, uint16 key);
+	Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt);
+	void freeButtonList(GadgetList *gadgetList);
+	void drawGadgetList(GadgetList *gadgetList);
+	void disableGadget(Gadget *curgad, uint16 pencolor);
+	void enableGadget(Gadget *curgad);
+	IntuiMessage *getMsg();
+	uint16 makeGadgetKeyEquiv(uint16 key);
 };
 
 } // End of namespace Lab
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 0ccbd48..b540a31 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -40,26 +40,24 @@
 
 namespace Lab {
 
-Common::KeyState _keyPressed;
-
-Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt) {
-	Gadget *gptr = new Gadget();
-
-	if (gptr) {
-		gptr->x = g_lab->_utils->vgaScaleX(x);
-		gptr->y = y;
-		gptr->_gadgetID = id;
-		gptr->_keyEquiv = key;
-		gptr->_image = im;
-		gptr->_altImage = imalt;
-		gptr->isEnabled = true;
-
-		return gptr;
+Gadget *EventManager::createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *image, Image *altImage) {
+	Gadget *gadget = new Gadget();
+
+	if (gadget) {
+		gadget->x = _vm->_utils->vgaScaleX(x);
+		gadget->y = y;
+		gadget->_gadgetID = id;
+		gadget->_keyEquiv = key;
+		gadget->_image = image;
+		gadget->_altImage = altImage;
+		gadget->isEnabled = true;
+
+		return gadget;
 	} else
 		return nullptr;
 }
 
-void freeButtonList(GadgetList *gadgetList) {
+void EventManager::freeButtonList(GadgetList *gadgetList) {
 	for (GadgetList::iterator gadgetIter = gadgetList->begin(); gadgetIter != gadgetList->end(); ++gadgetIter) {
 		Gadget *gadget = *gadgetIter;
 		delete gadget->_image;
@@ -73,7 +71,7 @@ void freeButtonList(GadgetList *gadgetList) {
 /**
  * Draws a gadget list to the screen.
  */
-void drawGadgetList(GadgetList *gadgetList) {
+void EventManager::drawGadgetList(GadgetList *gadgetList) {
 	for (GadgetList::iterator gadget = gadgetList->begin(); gadget != gadgetList->end(); ++gadget) {
 		(*gadget)->_image->drawImage((*gadget)->x, (*gadget)->y);
 
@@ -85,23 +83,23 @@ void drawGadgetList(GadgetList *gadgetList) {
 /**
  * Dims a gadget, and makes it unavailable for using.
  */
-void disableGadget(Gadget *curgad, uint16 pencolor) {
-	g_lab->_graphics->overlayRect(pencolor, curgad->x, curgad->y, curgad->x + curgad->_image->_width - 1, curgad->y + curgad->_image->_height - 1);
-	curgad->isEnabled = false;
+void EventManager::disableGadget(Gadget *gadget, uint16 penColor) {
+	_vm->_graphics->overlayRect(penColor, gadget->x, gadget->y, gadget->x + gadget->_image->_width - 1, gadget->y + gadget->_image->_height - 1);
+	gadget->isEnabled = false;
 }
 
 /**
  * Undims a gadget, and makes it available again.
  */
-void enableGadget(Gadget *curgad) {
-	curgad->_image->drawImage(curgad->x, curgad->y);
-	curgad->isEnabled = true;
+void EventManager::enableGadget(Gadget *gadget) {
+	gadget->_image->drawImage(gadget->x, gadget->y);
+	gadget->isEnabled = true;
 }
 
 /**
  * Make a key press have the right case for a gadget KeyEquiv value.
  */
-uint16 makeGadgetKeyEquiv(uint16 key) {
+uint16 EventManager::makeGadgetKeyEquiv(uint16 key) {
 	if (Common::isAlnum(key))
 		key = tolower(key);
 
@@ -112,7 +110,7 @@ uint16 makeGadgetKeyEquiv(uint16 key) {
  * Checks whether or not the coords fall within one of the gadgets in a list
  * of gadgets.
  */
-Gadget *LabEngine::checkNumGadgetHit(GadgetList *gadgetList, uint16 key) {
+Gadget *EventManager::checkNumGadgetHit(GadgetList *gadgetList, uint16 key) {
 	uint16 gkey = key - '0';
 
 	if (!gadgetList)
@@ -123,59 +121,59 @@ Gadget *LabEngine::checkNumGadgetHit(GadgetList *gadgetList, uint16 key) {
 		if ((gkey - 1 == gadget->_gadgetID || (gkey == 0 && gadget->_gadgetID == 9) ||
 			  (gadget->_keyEquiv != 0 && makeGadgetKeyEquiv(key) == gadget->_keyEquiv))
 			  && gadget->isEnabled) {
-			_event->mouseHide();
+			mouseHide();
 			gadget->_altImage->drawImage(gadget->x, gadget->y);
-			_event->mouseShow();
+			mouseShow();
 			g_system->delayMillis(80);
-			_event->mouseHide();
+			mouseHide();
 			gadget->_image->drawImage(gadget->x, gadget->y);
-			_event->mouseShow();
+			mouseShow();
 
 			return gadget;
 		}
 	}
 
-	return NULL;
+	return nullptr;
 }
 
-IntuiMessage IMessage;
-
 IntuiMessage *LabEngine::getMsg() {
+	static IntuiMessage message;
+
 	_event->updateMouse();
 
-	int qualifiers = _keyPressed.flags;
+	int qualifiers = _event->_keyPressed.flags;
 	Gadget *curgad  = _event->mouseGadget();
 
 	if (curgad) {
 		_event->updateMouse();
-		IMessage._msgClass = GADGETUP;
-		IMessage._code  = curgad->_gadgetID;
-		IMessage._gadgetID = curgad->_gadgetID;
-		IMessage._qualifier = qualifiers;
-		return &IMessage;
-	} else if (_event->mouseButton(&IMessage._mouseX, &IMessage._mouseY, true)) {
+		message._msgClass = GADGETUP;
+		message._code  = curgad->_gadgetID;
+		message._gadgetID = curgad->_gadgetID;
+		message._qualifier = qualifiers;
+		return &message;
+	} else if (_event->mouseButton(&message._mouseX, &message._mouseY, true)) {
 		// Left Button
-		IMessage._qualifier = IEQUALIFIER_LEFTBUTTON | qualifiers;
-		IMessage._msgClass = MOUSEBUTTONS;
-		return &IMessage;
-	} else if (_event->mouseButton(&IMessage._mouseX, &IMessage._mouseY, false)) {
+		message._qualifier = IEQUALIFIER_LEFTBUTTON | qualifiers;
+		message._msgClass = MOUSEBUTTONS;
+		return &message;
+	} else if (_event->mouseButton(&message._mouseX, &message._mouseY, false)) {
 		// Right Button
-		IMessage._qualifier = IEQUALIFIER_RBUTTON | qualifiers;
-		IMessage._msgClass = MOUSEBUTTONS;
-		return &IMessage;
-	} else if (_event->keyPress(&IMessage._code)) {
+		message._qualifier = IEQUALIFIER_RBUTTON | qualifiers;
+		message._msgClass = MOUSEBUTTONS;
+		return &message;
+	} else if (_event->keyPress(&message._code)) {
 		// Keyboard key
-		curgad = checkNumGadgetHit(_event->_screenGadgetList, IMessage._code);
+		curgad = _event->checkNumGadgetHit(_event->_screenGadgetList, message._code);
 
 		if (curgad) {
-			IMessage._msgClass = GADGETUP;
-			IMessage._code  = curgad->_gadgetID;
-			IMessage._gadgetID = curgad->_gadgetID;
+			message._msgClass = GADGETUP;
+			message._code  = curgad->_gadgetID;
+			message._gadgetID = curgad->_gadgetID;
 		} else
-			IMessage._msgClass = RAWKEY;
+			message._msgClass = RAWKEY;
 
-		IMessage._qualifier = qualifiers;
-		return &IMessage;
+		message._qualifier = qualifiers;
+		return &message;
 	} else
 		return nullptr;
 }
diff --git a/engines/lab/interface.h b/engines/lab/interface.h
index 10e0815..c8ac171 100644
--- a/engines/lab/interface.h
+++ b/engines/lab/interface.h
@@ -28,28 +28,11 @@
  *
  */
 
-#ifndef LAB_INTEFARCE_H
-#define LAB_INTEFARCE_H
+#ifndef LAB_INTERFARCE_H
+#define LAB_INTERFARCE_H
 
 namespace Lab {
 
-class Image;
-
-struct IntuiMessage {
-	uint32 _msgClass;
-	uint16 _code, _qualifier, _mouseX, _mouseY, _gadgetID;
-	uint32 _seconds, _micros;
-};
-
-
-struct Gadget {
-	uint16 x, y, _gadgetID;
-	uint16 _keyEquiv; // if not zero, a key that activates gadget
-	bool isEnabled;
-	Image *_image, *_altImage;
-};
-
-typedef Common::List<Gadget *> GadgetList;
 
 // Defines for the Class variable in IntuiMessage
 #define SIZEVERIFY  0x00000001
@@ -103,13 +86,7 @@ typedef Common::List<Gadget *> GadgetList;
 //--------------------------- Function Prototypes ---------------------------
 //---------------------------------------------------------------------------
 
-Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt);
-void freeButtonList(GadgetList *gadgetList);
-void drawGadgetList(GadgetList *gadgetList);
-void disableGadget(Gadget *curgad, uint16 pencolor);
-void enableGadget(Gadget *curgad);
-IntuiMessage *getMsg();
 
 } // End of namespace Lab
 
-#endif // LAB_INTEFARCE_H
+#endif // LAB_INTERFARCE_H
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index fbe1fac..d918cb9 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -32,6 +32,7 @@
 
 #include "lab/anim.h"
 #include "lab/dispman.h"
+#include "lab/eventman.h"
 #include "lab/interface.h"
 #include "lab/intro.h"
 #include "lab/music.h"
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 92ffa26..1b98c11 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -193,7 +193,6 @@ public:
 
 private:
 	bool checkConditions(int16 *condition);
-	Gadget *checkNumGadgetHit(GadgetList *gadgetList, uint16 key);
 	void decIncInv(uint16 *CurInv, bool dec);
 	void doActions(Action *actionList, CloseDataPtr *closePtrList);
 	bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *closePtrList);
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 5d978b7..c76f3cb 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -79,9 +79,9 @@ void LabEngine::loadMapData() {
 	_imgPath = new Image(mapImages);
 	_imgBridge = new Image(mapImages);
 
-	_mapGadgetList.push_back(createButton( 8,  _utils->vgaScaleY(105), 0, VKEY_LTARROW, new Image(mapImages), new Image(mapImages)));	// back
-	_mapGadgetList.push_back(createButton( 55, _utils->vgaScaleY(105), 1, VKEY_UPARROW, new Image(mapImages), new Image(mapImages)));	// up
-	_mapGadgetList.push_back(createButton(101, _utils->vgaScaleY(105), 2, VKEY_DNARROW, new Image(mapImages), new Image(mapImages)));	// down
+	_mapGadgetList.push_back(_event->createButton( 8,  _utils->vgaScaleY(105), 0, VKEY_LTARROW, new Image(mapImages), new Image(mapImages)));	// back
+	_mapGadgetList.push_back(_event->createButton( 55, _utils->vgaScaleY(105), 1, VKEY_UPARROW, new Image(mapImages), new Image(mapImages)));	// up
+	_mapGadgetList.push_back(_event->createButton(101, _utils->vgaScaleY(105), 2, VKEY_DNARROW, new Image(mapImages), new Image(mapImages)));	// down
 
 	delete mapImages;
 
@@ -104,7 +104,7 @@ void LabEngine::loadMapData() {
 }
 
 void LabEngine::freeMapData() {
-	freeButtonList(&_mapGadgetList);
+	_event->freeButtonList(&_mapGadgetList);
 
 	delete _imgMap;
 	delete _imgRoom;
@@ -369,7 +369,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad
 	_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);
 
 	_imgMap->drawImage(0, 0);
-	drawGadgetList(&_mapGadgetList);
+	_event->drawGadgetList(&_mapGadgetList);
 
 	for (uint16 i = 1; i <= _maxRooms; i++) {
 		if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x) {
@@ -388,14 +388,14 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad
 	Gadget *downGadget = _event->getGadget(2);
 
 	if (getUpperFloor(floorNum) != kFloorNone)
-		enableGadget(upGadget);
+		_event->enableGadget(upGadget);
 	else
-		disableGadget(upGadget, 12);
+		_event->disableGadget(upGadget, 12);
 
 	if (getLowerFloor(floorNum) != kFloorNone)
-		enableGadget(downGadget);
+		_event->enableGadget(downGadget);
 	else
-		disableGadget(downGadget, 12);
+		_event->disableGadget(downGadget, 12);
 
 	// Labyrinth specific code
 	if (floorNum == kFloorLower) {
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 5b2da2a..0024adb 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -142,9 +142,9 @@ void LabEngine::loadJournalData() {
 
 	Common::File *journalFile = _resource->openDataFile("P:JImage");
 	Utils *utils = _utils;
-	_journalGadgetList.push_back(createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile), new Image(journalFile)));	// back
-	_journalGadgetList.push_back(createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2,            0, new Image(journalFile), new Image(journalFile)));	// cancel
-	_journalGadgetList.push_back(createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile), new Image(journalFile)));	// forward
+	_journalGadgetList.push_back(_event->createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile), new Image(journalFile)));	// back
+	_journalGadgetList.push_back(_event->createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2,            0, new Image(journalFile), new Image(journalFile)));	// cancel
+	_journalGadgetList.push_back(_event->createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile), new Image(journalFile)));	// forward
 	delete journalFile;
 
 	_anim->_noPalChange = true;
@@ -236,14 +236,14 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 	Gadget *forwardGadget = _event->getGadget(2);
 
 	if (_journalPage == 0)
-		disableGadget(backGadget, 15);
+		_event->disableGadget(backGadget, 15);
 	else
-		enableGadget(backGadget);
+		_event->enableGadget(backGadget);
 
 	if (_lastPage)
-		disableGadget(forwardGadget, 15);
+		_event->disableGadget(forwardGadget, 15);
 	else
-		enableGadget(forwardGadget);
+		_event->enableGadget(forwardGadget);
 
 	if (needFade)
 		_graphics->fade(true, 0);
@@ -321,7 +321,7 @@ void LabEngine::doJournal() {
 
 	delete[] _blankJournal;
 	delete[] journalBackImage._imageData;
-	freeButtonList(&_journalGadgetList);
+	_event->freeButtonList(&_journalGadgetList);
 	_graphics->closeFont(_journalFont);
 
 	ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();


Commit: 7c1401264ca0da173dfe4de09ca4884d63feeb55
    https://github.com/scummvm/scummvm/commit/7c1401264ca0da173dfe4de09ca4884d63feeb55
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:02+01:00

Commit Message:
LAB: Remove interface.h, get rid of a lot of useless defines

Changed paths:
  R engines/lab/interface.h
    engines/lab/dispman.cpp
    engines/lab/engine.cpp
    engines/lab/eventman.cpp
    engines/lab/eventman.h
    engines/lab/interface.cpp
    engines/lab/intro.cpp
    engines/lab/map.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 0aa49f9..0c2f562 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -35,7 +35,6 @@
 #include "lab/anim.h"
 #include "lab/dispman.h"
 #include "lab/eventman.h"
-#include "lab/interface.h"
 #include "lab/music.h"
 #include "lab/image.h"
 #include "lab/resource.h"
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 367f541..47d631c9 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -34,7 +34,6 @@
 #include "lab/dispman.h"
 #include "lab/eventman.h"
 #include "lab/image.h"
-#include "lab/interface.h"
 #include "lab/intro.h"
 #include "lab/labsets.h"
 #include "lab/music.h"
@@ -687,7 +686,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 	if (_graphics->_longWinInFront) {
 		if ((msgClass == RAWKEY) || ((msgClass == MOUSEBUTTONS) &&
 			  ((IEQUALIFIER_LEFTBUTTON & qualifier) ||
-				(IEQUALIFIER_RBUTTON & qualifier)))) {
+				(IEQUALIFIER_RIGHTBUTTON & qualifier)))) {
 			_graphics->_longWinInFront = false;
 			_graphics->_doNotDrawMessage = false;
 			_graphics->drawPanel();
@@ -1063,7 +1062,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 
 		if (wrkClosePtr)
 			_event->setMousePos(Common::Point(_utils->scaleX((wrkClosePtr->_x1 + wrkClosePtr->_x2) / 2), _utils->scaleY((wrkClosePtr->_y1 + wrkClosePtr->_y2) / 2)));
-	} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & qualifier)) {
+	} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) {
 		eatMessages();
 		_alternate = !_alternate;
 		_anim->_doBlack = true;
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index e447719..7b5d184 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -35,7 +35,6 @@
 #include "lab/dispman.h"
 #include "lab/eventman.h"
 #include "lab/image.h"
-#include "lab/interface.h"
 
 namespace Lab {
 
diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h
index f9facd8..3becfeb 100644
--- a/engines/lab/eventman.h
+++ b/engines/lab/eventman.h
@@ -38,6 +38,21 @@ namespace Lab {
 class LabEngine;
 class Image;
 
+// Defines for the Class variable in IntuiMessage
+#define MOUSEBUTTONS    0x00000008
+#define GADGETUP		0x00000040
+#define RAWKEY			0x00000400
+#define DELTAMOVE		0x00100000
+
+// Defines for the Qualifier variable in IntuiMessage
+#define IEQUALIFIER_RIGHTBUTTON     0x2000
+#define IEQUALIFIER_LEFTBUTTON      0x4000
+
+#define VKEY_UPARROW    273
+#define VKEY_DNARROW    274
+#define VKEY_RTARROW    275
+#define VKEY_LTARROW    276
+
 struct IntuiMessage {
 	uint32 _msgClass;
 	uint16 _code, _qualifier, _mouseX, _mouseY, _gadgetID;
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index b540a31..08a53e2 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -35,7 +35,6 @@
 #include "lab/dispman.h"
 #include "lab/eventman.h"
 #include "lab/image.h"
-#include "lab/interface.h"
 #include "lab/utils.h"
 
 namespace Lab {
@@ -158,7 +157,7 @@ IntuiMessage *LabEngine::getMsg() {
 		return &message;
 	} else if (_event->mouseButton(&message._mouseX, &message._mouseY, false)) {
 		// Right Button
-		message._qualifier = IEQUALIFIER_RBUTTON | qualifiers;
+		message._qualifier = IEQUALIFIER_RIGHTBUTTON | qualifiers;
 		message._msgClass = MOUSEBUTTONS;
 		return &message;
 	} else if (_event->keyPress(&message._code)) {
diff --git a/engines/lab/interface.h b/engines/lab/interface.h
deleted file mode 100644
index c8ac171..0000000
--- a/engines/lab/interface.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#ifndef LAB_INTERFARCE_H
-#define LAB_INTERFARCE_H
-
-namespace Lab {
-
-
-// Defines for the Class variable in IntuiMessage
-#define SIZEVERIFY  0x00000001
-#define NEWSIZE     0x00000002
-#define REFRESHWINDOW   0x00000004
-#define MOUSEBUTTONS    0x00000008
-#define MOUSEMOVE   0x00000010
-#define GADGETDOWN  0x00000020
-#define GADGETUP    0x00000040
-#define REQSET      0x00000080
-#define MENUPICK    0x00000100
-#define CLOSEWINDOW 0x00000200
-#define RAWKEY      0x00000400
-#define REQVERIFY   0x00000800
-#define REQCLEAR    0x00001000
-#define MENUVERIFY  0x00002000
-#define NEWPREFS    0x00004000
-#define DISKINSERTED    0x00008000
-#define DISKREMOVED 0x00010000
-#define WBENCHMESSAGE   0x00020000  // System use only
-#define ACTIVEWINDOW    0x00040000
-#define INACTIVEWINDOW  0x00080000
-#define DELTAMOVE   0x00100000
-#define VANULLLAKEY  0x00200000
-
-
-// Defines for the Qualifier variable in IntuiMessage
-#define IEQUALIFIER_LSHIFT      0x0001
-#define IEQUALIFIER_RSHIFT      0x0002
-#define IEQUALIFIER_CAPSLOCK        0x0004
-#define IEQUALIFIER_CONTROL     0x0008
-#define IEQUALIFIER_LALT        0x0010
-#define IEQUALIFIER_RALT        0x0020
-#define IEQUALIFIER_LCOMMAND        0x0040
-#define IEQUALIFIER_RCOMMAND        0x0080
-#define IEQUALIFIER_NUMERICPAD      0x0100
-#define IEQUALIFIER_REPEAT      0x0200
-#define IEQUALIFIER_INTERRUPT       0x0400
-#define IEQUALIFIER_MULTIBROADCAST  0x0800
-#define IEQUALIFIER_MIDBUTTON       0x1000
-#define IEQUALIFIER_RBUTTON     0x2000
-#define IEQUALIFIER_LEFTBUTTON      0x4000
-
-#define VKEY_UPARROW    273
-#define VKEY_DNARROW    274
-#define VKEY_RTARROW    275
-#define VKEY_LTARROW    276
-
-
-//---------------------------------------------------------------------------
-//--------------------------- Function Prototypes ---------------------------
-//---------------------------------------------------------------------------
-
-
-} // End of namespace Lab
-
-#endif // LAB_INTERFARCE_H
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index d918cb9..5b170f5 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -33,7 +33,6 @@
 #include "lab/anim.h"
 #include "lab/dispman.h"
 #include "lab/eventman.h"
-#include "lab/interface.h"
 #include "lab/intro.h"
 #include "lab/music.h"
 #include "lab/resource.h"
@@ -61,7 +60,7 @@ void Intro::introEatMessages() {
 		if (msg == NULL)
 			return;
 		else {
-			if (((msg->_msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & msg->_qualifier)) ||
+			if (((msg->_msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & msg->_qualifier)) ||
 				  ((msg->_msgClass == RAWKEY) && (msg->_code == 27))
 				)
 				_quitIntro = true;
@@ -156,7 +155,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 			qualifier = msg->_qualifier;
 			code      = msg->_code;
 
-			if (((cls == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & qualifier)) ||
+			if (((cls == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) ||
 				  ((cls == RAWKEY) && (code == 27))) {
 				_quitIntro = true;
 
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index c76f3cb..d0dce93 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -33,7 +33,6 @@
 #include "lab/dispman.h"
 #include "lab/eventman.h"
 #include "lab/image.h"
-#include "lab/interface.h"
 #include "lab/labsets.h"
 #include "lab/music.h"
 #include "lab/processroom.h"
@@ -480,7 +479,7 @@ void LabEngine::processMap(uint16 curRoom) {
 			uint16 mouseX    = msg->_mouseX;
 			uint16 mouseY    = msg->_mouseY;
 
-			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & qualifier)) || ((msgClass == RAWKEY) && (msgCode == 27)))
+			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || ((msgClass == RAWKEY) && (msgCode == 27)))
 				return;
 
 			if (msgClass == GADGETUP) {
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 0024adb..b689637 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -34,7 +34,6 @@
 #include "lab/dispman.h"
 #include "lab/eventman.h"
 #include "lab/image.h"
-#include "lab/interface.h"
 #include "lab/labsets.h"
 #include "lab/music.h"
 #include "lab/processroom.h"
@@ -271,7 +270,7 @@ void LabEngine::processJournal() {
 			uint16 qualifier = msg->_qualifier;
 			uint16 gadID     = msg->_code;
 
-			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & qualifier)) ||
+			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) ||
 				  ((msgClass == RAWKEY) && (gadID == 27)))
 				return;
 			else if (msgClass == GADGETUP) {
@@ -436,7 +435,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 			uint16 mouseY    = msg->_mouseY;
 			uint16 code      = msg->_code;
 
-			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RBUTTON & qualifier)) ||
+			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) ||
 				  ((msgClass == RAWKEY) && (code == 27)))
 				return;
 


Commit: 577b60d7853156851894430ad8032ed14b353e33
    https://github.com/scummvm/scummvm/commit/577b60d7853156851894430ad8032ed14b353e33
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:02+01:00

Commit Message:
LAB: Move getMsg to the event manager

Changed paths:
    engines/lab/engine.cpp
    engines/lab/interface.cpp
    engines/lab/intro.cpp
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 47d631c9..bd625be 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -163,7 +163,7 @@ void LabEngine::eatMessages() {
 	IntuiMessage *msg;
 
 	do {
-		msg = getMsg();
+		msg = _event->getMsg();
 	} while (msg);
 }
 
@@ -503,7 +503,7 @@ void LabEngine::mainGameLoop() {
 		// Make sure we check the music at least after every message
 		_music->updateMusic();
 		interfaceOn();
-		IntuiMessage *curMsg = getMsg();
+		IntuiMessage *curMsg = _event->getMsg();
 
 		if (!curMsg) {
 			// Does music load and next animation frame when you've run out of messages
@@ -645,7 +645,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 			while (1) {
 				// Make sure we check the music at least after every message
 				_music->updateMusic();
-				curMsg = getMsg();
+				curMsg = _event->getMsg();
 
 				if (!curMsg) {
 					// Does music load and next animation frame when you've run out of messages
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 08a53e2..cd062a8 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -135,34 +135,34 @@ Gadget *EventManager::checkNumGadgetHit(GadgetList *gadgetList, uint16 key) {
 	return nullptr;
 }
 
-IntuiMessage *LabEngine::getMsg() {
+IntuiMessage *EventManager::getMsg() {
 	static IntuiMessage message;
 
-	_event->updateMouse();
+	updateMouse();
 
-	int qualifiers = _event->_keyPressed.flags;
-	Gadget *curgad  = _event->mouseGadget();
+	int qualifiers = _keyPressed.flags;
+	Gadget *curgad  = mouseGadget();
 
 	if (curgad) {
-		_event->updateMouse();
+		updateMouse();
 		message._msgClass = GADGETUP;
 		message._code  = curgad->_gadgetID;
 		message._gadgetID = curgad->_gadgetID;
 		message._qualifier = qualifiers;
 		return &message;
-	} else if (_event->mouseButton(&message._mouseX, &message._mouseY, true)) {
+	} else if (mouseButton(&message._mouseX, &message._mouseY, true)) {
 		// Left Button
 		message._qualifier = IEQUALIFIER_LEFTBUTTON | qualifiers;
 		message._msgClass = MOUSEBUTTONS;
 		return &message;
-	} else if (_event->mouseButton(&message._mouseX, &message._mouseY, false)) {
+	} else if (mouseButton(&message._mouseX, &message._mouseY, false)) {
 		// Right Button
 		message._qualifier = IEQUALIFIER_RIGHTBUTTON | qualifiers;
 		message._msgClass = MOUSEBUTTONS;
 		return &message;
-	} else if (_event->keyPress(&message._code)) {
+	} else if (keyPress(&message._code)) {
 		// Keyboard key
-		curgad = _event->checkNumGadgetHit(_event->_screenGadgetList, message._code);
+		curgad = checkNumGadgetHit(_screenGadgetList, message._code);
 
 		if (curgad) {
 			message._msgClass = GADGETUP;
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 5b170f5..2e88132 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -50,7 +50,7 @@ Intro::Intro(LabEngine *vm) : _vm(vm) {
  */
 void Intro::introEatMessages() {
 	while (1) {
-		IntuiMessage *msg = _vm->getMsg();
+		IntuiMessage *msg = _vm->_event->getMsg();
 
 		if (g_engine->shouldQuit()) {
 			_quitIntro = true;
@@ -129,7 +129,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 			lastMillis = g_system->getMillis();
 		}
 
-		msg = _vm->getMsg();
+		msg = _vm->_event->getMsg();
 
 		if (msg == NULL) {
 			_vm->_music->updateMusic();
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 1b98c11..eb8db5c 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -184,7 +184,6 @@ public:
 
 	void changeVolume(int delta);
 	uint16 getDirection() { return _direction; }
-	IntuiMessage *getMsg();
 	char *getPictName(CloseDataPtr *closePtrList);
 	uint16 getQuarters();
 	void setDirection(uint16 direction) { _direction = direction; };
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index d0dce93..316334f 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -439,7 +439,7 @@ void LabEngine::processMap(uint16 curRoom) {
 	while (1) {
 		// Make sure we check the music at least after every message
 		_music->updateMusic();
-		IntuiMessage *msg = getMsg();
+		IntuiMessage *msg = _event->getMsg();
 
 		if (!msg) {
 			_music->updateMusic();
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index b689637..1fc5c67 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -261,7 +261,7 @@ void LabEngine::processJournal() {
 	while (1) {
 		// Make sure we check the music at least after every message
 		_music->updateMusic();
-		IntuiMessage *msg = getMsg();
+		IntuiMessage *msg = _event->getMsg();
 
 		if (msg == NULL) {
 			_music->updateMusic();
@@ -424,7 +424,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 
 		// Make sure we check the music at least after every message
 		_music->updateMusic();
-		IntuiMessage *msg = getMsg();
+		IntuiMessage *msg = _event->getMsg();
 
 		if (msg == NULL) {
 			_music->updateMusic();


Commit: 0dcfd74b840c6bdeb3b5dbd431a1354d9c1f47ce
    https://github.com/scummvm/scummvm/commit/0dcfd74b840c6bdeb3b5dbd431a1354d9c1f47ce
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:02+01:00

Commit Message:
LAB: Simplify fromCrumbs()

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index bd625be..748b0ef 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -588,24 +588,26 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 	_anim->_doBlack = false;
 
 	if ((msgClass == RAWKEY) && (!_graphics->_longWinInFront)) {
+		byte codeLower = tolower(code);
+
 		if (code == 13) {
 			// The return key
 			msgClass = MOUSEBUTTONS;
 			qualifier = IEQUALIFIER_LEFTBUTTON;
 			curPos = _event->getMousePos();
-		} else if (getPlatform() == Common::kPlatformWindows && (code == 'b' || code == 'B')) {
+		} else if (getPlatform() == Common::kPlatformWindows && codeLower == 'b') {
 			// Start bread crumbs
 			_breadCrumbs[0]._roomNum = 0;
 			_numCrumbs = 0;
 			_droppingCrumbs = true;
 			mayShowCrumbIndicator();
 			_graphics->screenUpdate();
-		} else if (code == 'f' || code == 'F' || code == 'r' || code == 'R') {
+		} else if (codeLower == 'f' || codeLower == 'r') {
 			// Follow bread crumbs
 			if (_droppingCrumbs) {
 				if (_numCrumbs > 0) {
 					_followingCrumbs = true;
-					_followCrumbsFast = (code == 'r' || code == 'R');
+					_followCrumbsFast = (codeLower == 'r');
 					_isCrumbTurning = false;
 					_isCrumbWaiting = false;
 					uint32 t = g_system->getMillis();
@@ -634,11 +636,10 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 					_graphics->screenUpdate();
 				}
 			}
-		} else if ((code == 315) || (code == 'x') || (code == 'X') || (code == 'q') || (code == 'Q')) {
+		} else if (code == 315 || codeLower == 'x' || codeLower == 'q') {
 			// Quit?
 			_graphics->_doNotDrawMessage = false;
 			_graphics->drawMessage("Do you want to quit? (Y/N)");
-			doit = false;
 			eatMessages();
 			interfaceOff();
 
@@ -653,9 +654,10 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 					_anim->diffNextFrame();
 				} else {
 					if (curMsg->_msgClass == RAWKEY) {
-						if ((curMsg->_code == 'Y') || (curMsg->_code == 'y') || (curMsg->_code == 'Q') || (curMsg->_code == 'q')) {
-							doit = true;
-							break;
+						codeLower = tolower(curMsg->_code);
+						if (codeLower == 'y' || codeLower == 'q') {
+							_anim->stopDiff();
+							return false;
 						} else if (curMsg->_code < 128) {
 							break;
 						}
@@ -665,13 +667,8 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 				}
 			}
 
-			if (doit) {
-				_anim->stopDiff();
-				return false;
-			} else {
-				forceDraw = true;
-				interfaceOn();
-			}
+			forceDraw = true;
+			interfaceOn();
 		} else if (code == 9) {
 			// TAB key
 			msgClass = DELTAMOVE;


Commit: ff43ec7e868b0b707ee5584bc004c593c3bd70ef
    https://github.com/scummvm/scummvm/commit/ff43ec7e868b0b707ee5584bc004c593c3bd70ef
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:02+01:00

Commit Message:
LAB: Now that timing works correctly, disable some annoying delays

Changed paths:
    engines/lab/anim.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 347841d..ae4fb80 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -314,9 +314,14 @@ void Anim::readDiff(byte *buffer, bool playOnce, bool onlyDiffData) {
 		_diffFile += 2;
 		_headerdata._height = READ_LE_UINT16(_diffFile);
 		_diffFile += 2;
-		_headerdata._depth = _diffFile[0];
+		_headerdata._depth = *_diffFile;
 		_diffFile++;
-		_headerdata._fps = _diffFile[0];
+		_headerdata._fps = *_diffFile;
+		// HACK: The original game defines a 1 second delay when changing screens, which is
+		// very annoying. In this case, we just set it to no delay, to make the game a bit
+		// less frustrating
+		if (_headerdata._fps == 1)
+			_headerdata._fps = 0;
 		_diffFile++;
 		_headerdata._bufferSize = READ_LE_UINT32(_diffFile);
 		_diffFile += 4;


Commit: ceb5ef18e5490d07c40adb5797f026de05036387
    https://github.com/scummvm/scummvm/commit/ceb5ef18e5490d07c40adb5797f026de05036387
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:02+01:00

Commit Message:
LAB: Get rid of a superfluous global variable

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index ae4fb80..6762a42 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -55,7 +55,6 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 	_donePal = false;
 	_frameNum = 0;
 	_playOnce = false;
-	_buffer = nullptr;
 	_diffFile = nullptr;
 	_size = 0;
 	_rawDiffBM._bytesPerRow = 0;
@@ -76,6 +75,8 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 }
 
 void Anim::diffNextFrame(bool onlyDiffData) {
+	byte *buffer = _diffFile;
+
 	if (_header == 65535)
 		// Already done.
 		return;
@@ -119,7 +120,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 			_frameNum++;
 
 			if ((_frameNum == 1) && (_continuous || (!_playOnce)))
-				_buffer = _diffFile;
+				buffer = _diffFile;
 
 			_isAnim = (_frameNum >= 3) && (!_playOnce);
 			_curBit = 0;
@@ -235,7 +236,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 
 			// Random frame number so it never gets back to 2
 			_frameNum = 4;
-			_diffFile = _buffer;
+			_diffFile = buffer;
 			break;
 
 		default:
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 6c18224..e2d79fa 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -69,7 +69,6 @@ private:
 	bool _donePal;
 	uint16 _frameNum;
 	bool _playOnce;
-	byte *_buffer;
 	byte *_diffFile;
 	uint32 _size;
 	bool _stopPlayingEnd;


Commit: 40b16afcab183189c32ee697e6e027e734d72542
    https://github.com/scummvm/scummvm/commit/40b16afcab183189c32ee697e6e027e734d72542
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:02+01:00

Commit Message:
LAB: Get rid of _unstoppableSoundEffect

_loopSoundEffect is used for the exact same purpose

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/map.cpp
    engines/lab/music.cpp
    engines/lab/music.h
    engines/lab/processroom.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 0c2f562..d5ae0f4 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -102,7 +102,7 @@ void DisplayMan::readPict(const char *filename, bool playOnce, bool onlyDiffData
 
 	_vm->_music->updateMusic();
 
-	if (!_vm->_music->_unstoppableSoundEffect)
+	if (!_vm->_music->_loopSoundEffect)
 		_vm->_music->stopSoundEffect();
 
 	_dispBitMap->_bytesPerRow  = _screenWidth;
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 316334f..179bba5 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -86,7 +86,7 @@ void LabEngine::loadMapData() {
 
 	Common::File *mapFile = _resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0'));
 	_music->updateMusic();
-	if (!_music->_unstoppableSoundEffect)
+	if (!_music->_loopSoundEffect)
 		_music->stopSoundEffect();
 
 	_maxRooms = mapFile->readUint16LE();
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index cca7633..1d2527b 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -59,7 +59,6 @@ Music::Music(LabEngine *vm) : _vm(vm) {
 	_winMusic = false;
 	_loopSoundEffect = false;
 	_queuingAudioStream = NULL;
-	_unstoppableSoundEffect = false;
 	_lastMusicRoom = 1;
 	_doReset = true;
 	_waitTillFinished = false;
@@ -320,7 +319,7 @@ void Music::resetMusic() {
 bool Music::readMusic(const char *filename, bool waitTillFinished) {
 	Common::File *file = _vm->_resource->openDataFile(filename, MKTAG('D', 'I', 'F', 'F'));
 	updateMusic();
-	if (!_unstoppableSoundEffect)
+	if (!_loopSoundEffect)
 		stopSoundEffect();
 
 	if (!file)
diff --git a/engines/lab/music.h b/engines/lab/music.h
index 02c6820..35fd583 100644
--- a/engines/lab/music.h
+++ b/engines/lab/music.h
@@ -75,7 +75,6 @@ private:
 	void startMusic(bool restartFl);
 
 public:
-	bool _unstoppableSoundEffect;
 	bool _loopSoundEffect;
 	bool _waitTillFinished;
 
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index c09d918..6000f4a 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -296,7 +296,6 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			break;
 
 		case PLAYSOUNDCONT:
-			_music->_unstoppableSoundEffect = true;
 			_music->_loopSoundEffect = true;
 			_music->readMusic((char *)actionList->_data, _music->_waitTillFinished);
 			break;
@@ -543,8 +542,6 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			waitTOF();
 		}
 	}
-
-	_music->_unstoppableSoundEffect = false;
 }
 
 /**


Commit: dffaffdd096d9ee7457a8b3b8f1db78af1b0cff5
    https://github.com/scummvm/scummvm/commit/dffaffdd096d9ee7457a8b3b8f1db78af1b0cff5
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:02+01:00

Commit Message:
LAB: Simplify calls to initMusic()

Changed paths:
    engines/lab/intro.cpp
    engines/lab/music.cpp
    engines/lab/music.h
    engines/lab/processroom.cpp



diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 2e88132..7c77e8a 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -262,7 +262,7 @@ void Intro::introSequence() {
 	}
 
 	_vm->_graphics->blackAllScreen();
-	_vm->_music->initMusic();
+	_vm->_music->initMusic("Music:BackGrou");
 
 	_vm->_anim->_noPalChange = true;
 	if (_vm->getPlatform() != Common::kPlatformWindows)
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 1d2527b..b9a3f10 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -56,7 +56,6 @@ Music::Music(LabEngine *vm) : _vm(vm) {
 	_leftInFile = 0;
 
 	_musicOn = false;
-	_winMusic = false;
 	_loopSoundEffect = false;
 	_queuingAudioStream = NULL;
 	_lastMusicRoom = 1;
@@ -166,17 +165,9 @@ void Music::startMusic(bool restartFl) {
 /**
  * Initializes the music buffers.
  */
-bool Music::initMusic() {
+bool Music::initMusic(const char *filename) {
 	_musicOn = true;
 	_musicPaused = false;
-
-	const char *filename;
-
-	if (_winMusic)
-		filename = "Music:WinGame";
-	else
-		filename = "Music:BackGrou";
-
 	_file = _vm->_resource->openDataFile(filename);
 	startMusic(true);
 	return true;
diff --git a/engines/lab/music.h b/engines/lab/music.h
index 35fd583..d5dd241 100644
--- a/engines/lab/music.h
+++ b/engines/lab/music.h
@@ -56,7 +56,6 @@ private:
 	bool _musicOn;
 	bool _musicPaused;
 	bool _oldMusicOn;
-	bool _winMusic;
 
 	uint16 _lastMusicRoom ;
 
@@ -84,7 +83,7 @@ public:
 	void changeMusic(const char *newmusic);
 	void checkRoomMusic();
 	void freeMusic();
-	bool initMusic();
+	bool initMusic(const char *filename);
 	bool isSoundEffectActive() const;
 	void playSoundEffect(uint16 sampleSpeed, uint32 length, void *data);
 	bool readMusic(const char *filename, bool waitTillFinished);
@@ -92,7 +91,6 @@ public:
 	void resumeBackMusic();
 	void setMusic(bool on);
 	void setMusicReset(bool reset) { _doReset = reset; }
-	void setWinMusic() { _winMusic = true; }
 	void stopSoundEffect();
 	void updateMusic();
 };
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 6000f4a..bdf1d96 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -475,9 +475,8 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			break;
 
 		case WINMUSIC:
-			_music->setWinMusic();
 			_music->freeMusic();
-			_music->initMusic();
+			_music->initMusic("Music:WinGame");
 			break;
 
 		case WINGAME:


Commit: 231dda2ba989fb2993d3c82f1dd79be34bba436f
    https://github.com/scummvm/scummvm/commit/231dda2ba989fb2993d3c82f1dd79be34bba436f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:02+01:00

Commit Message:
LAB: Fix regression in animation code in looping animations

This fixes Daedalus' flight animation in the ending cutscene

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 6762a42..842d3d6 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -56,6 +56,7 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 	_frameNum = 0;
 	_playOnce = false;
 	_diffFile = nullptr;
+	_diffFileStart = nullptr;
 	_size = 0;
 	_rawDiffBM._bytesPerRow = 0;
 	_rawDiffBM._drawOnScreen = false;
@@ -75,8 +76,6 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 }
 
 void Anim::diffNextFrame(bool onlyDiffData) {
-	byte *buffer = _diffFile;
-
 	if (_header == 65535)
 		// Already done.
 		return;
@@ -120,7 +119,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 			_frameNum++;
 
 			if ((_frameNum == 1) && (_continuous || (!_playOnce)))
-				buffer = _diffFile;
+				_diffFileStart = _diffFile;
 
 			_isAnim = (_frameNum >= 3) && (!_playOnce);
 			_curBit = 0;
@@ -236,7 +235,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 
 			// Random frame number so it never gets back to 2
 			_frameNum = 4;
-			_diffFile = buffer;
+			_diffFile = _diffFileStart;
 			break;
 
 		default:
@@ -287,7 +286,7 @@ void Anim::readDiff(byte *buffer, bool playOnce, bool onlyDiffData) {
 		_vm->_graphics->blackScreen();
 	}
 
-	_diffFile = buffer;
+	_diffFile = _diffFileStart = buffer;
 
 	_continuous = false;
 	uint32 signature = READ_BE_UINT32(_diffFile);
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index e2d79fa..6e568a4 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -70,6 +70,7 @@ private:
 	uint16 _frameNum;
 	bool _playOnce;
 	byte *_diffFile;
+	byte *_diffFileStart;
 	uint32 _size;
 	bool _stopPlayingEnd;
 	uint16 _sampleSpeed;


Commit: c883769adc7ca1dcf5c2157a6ea09238ead59a56
    https://github.com/scummvm/scummvm/commit/c883769adc7ca1dcf5c2157a6ea09238ead59a56
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:03+01:00

Commit Message:
LAB: Move the LAB2 teaser screen in a separate function

Changed paths:
    engines/lab/engine.cpp
    engines/lab/lab.h
    engines/lab/processroom.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 748b0ef..9ae7beb 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -575,6 +575,26 @@ void LabEngine::mainGameLoop() {
 	}
 }
 
+void LabEngine::showLab2Teaser() {
+	_graphics->blackAllScreen();
+	_graphics->readPict("P:End/L2In.1", true);
+
+	for (uint16 i = 0; i < 120; i++) {
+		_music->updateMusic();
+		waitTOF();
+	}
+
+	_graphics->readPict("P:End/L2In.9", true);
+	_graphics->readPict("P:End/Lost", true);
+
+	warning("STUB: waitForPress");
+	while (!1) { // 1 means ignore SDL_ProcessInput calls
+		_music->updateMusic();
+		_anim->diffNextFrame();
+		waitTOF();
+	}
+}
+
 bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Common::Point tmpPos,
 			uint16 &curInv, IntuiMessage *curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode) {
 	uint32 msgClass = tmpClass;
@@ -1099,27 +1119,6 @@ void LabEngine::go() {
 	_event->mouseShow();
 	mainGameLoop();
 
-	if (_quitLab) {
-		// Won the game
-		_graphics->blackAllScreen();
-		_graphics->readPict("P:End/L2In.1", true);
-
-		for (uint16 i = 0; i < 120; i++) {
-			_music->updateMusic();
-			waitTOF();
-		}
-
-		_graphics->readPict("P:End/L2In.9", true);
-		_graphics->readPict("P:End/Lost", true);
-
-		warning("STUB: waitForPress");
-		while (!1) { // 1 means ignore SDL_ProcessInput calls
-			_music->updateMusic();
-			_anim->diffNextFrame();
-			waitTOF();
-		}
-	}
-
 	_graphics->closeFont(_msgFont);
 	_graphics->freePict();
 
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index eb8db5c..7c438c4 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -234,6 +234,7 @@ private:
 	void loadJournalData();
 	void loadMapData();
 	void mainGameLoop();
+	void showLab2Teaser();
 	void mayShowCrumbIndicator();
 	void mayShowCrumbIndicatorOff();
 	void perFlipGadget(uint16 gadID);
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index bdf1d96..7b9e413 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -481,10 +481,12 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 
 		case WINGAME:
 			_quitLab = true;
+			showLab2Teaser();
 			break;
 
 		case LOSTGAME:
-			_quitLab = true;
+			// This seems to be unused?
+			error("Unused opcode LOSTGAME has been called");
 			break;
 
 		case RESETBUFFER:


Commit: 1524e20ef1f55d4af9ded4e599d3dda26f93e0b7
    https://github.com/scummvm/scummvm/commit/1524e20ef1f55d4af9ded4e599d3dda26f93e0b7
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:03+01:00

Commit Message:
LAB: Simplify the room doors array

Changed paths:
    engines/lab/processroom.cpp
    engines/lab/processroom.h
    engines/lab/resource.cpp



diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 7b9e413..c754d28 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -180,17 +180,7 @@ void LabEngine::drawDirection(CloseDataPtr closePtr) {
  */
 uint16 LabEngine::processArrow(uint16 curDirection, uint16 arrow) {
 	if (arrow == 1) { // Forward
-		uint16 room = 1;
-
-		if (curDirection == NORTH)
-			room = _rooms[_roomNum]._northDoor;
-		else if (curDirection == SOUTH)
-			room = _rooms[_roomNum]._southDoor;
-		else if (curDirection == EAST)
-			room = _rooms[_roomNum]._eastDoor;
-		else if (curDirection == WEST)
-			room = _rooms[_roomNum]._westDoor;
-
+		uint16 room = _rooms[_roomNum]._doors[curDirection];
 		if (room != 0)
 			_roomNum = room;
 
diff --git a/engines/lab/processroom.h b/engines/lab/processroom.h
index 97c7cdc..1d3316e 100644
--- a/engines/lab/processroom.h
+++ b/engines/lab/processroom.h
@@ -127,10 +127,7 @@ struct Rule {
 };
 
 struct RoomData {
-	uint16 _northDoor;
-	uint16 _southDoor;
-	uint16 _eastDoor;
-	uint16 _westDoor;
+	uint16 _doors[4];
 	byte _transitionType;
 	ViewData *_view[4];
 	RuleList *_rules;
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 3f615c7..cb29bc6 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -98,10 +98,10 @@ bool Resource::readRoomData(const char *fileName) {
 	memset(_vm->_rooms, 0, (_vm->_manyRooms + 1) * sizeof(RoomData));
 
 	for (uint16 i = 1; i <= _vm->_manyRooms; i++) {
-		_vm->_rooms[i]._northDoor = dataFile->readUint16LE();
-		_vm->_rooms[i]._southDoor = dataFile->readUint16LE();
-		_vm->_rooms[i]._eastDoor = dataFile->readUint16LE();
-		_vm->_rooms[i]._westDoor = dataFile->readUint16LE();
+		_vm->_rooms[i]._doors[NORTH] = dataFile->readUint16LE();
+		_vm->_rooms[i]._doors[SOUTH] = dataFile->readUint16LE();
+		_vm->_rooms[i]._doors[EAST] = dataFile->readUint16LE();
+		_vm->_rooms[i]._doors[WEST] = dataFile->readUint16LE();
 		_vm->_rooms[i]._transitionType = dataFile->readByte();
 
 		_vm->_rooms[i]._view[NORTH] = nullptr;


Commit: 2332fb617c0c26da563cb60625b24d824ad4630b
    https://github.com/scummvm/scummvm/commit/2332fb617c0c26da563cb60625b24d824ad4630b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:03+01:00

Commit Message:
LAB: Rename gadget to button

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/engine.cpp
    engines/lab/eventman.cpp
    engines/lab/eventman.h
    engines/lab/interface.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/processroom.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index d5ae0f4..736b7ea 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -312,7 +312,7 @@ int32 DisplayMan::longDrawMessage(const char *str) {
 	if (str == NULL)
 		return 0;
 
-	_vm->_event->attachGadgetList(NULL);
+	_vm->_event->attachButtonList(NULL);
 	_vm->_event->mouseHide();
 	strcpy(newText, str);
 
@@ -373,7 +373,7 @@ void DisplayMan::drawPanel() {
 	// Second Line
 	setAPen(5);
 	drawHLine(0, _vm->_utils->vgaScaleY(149) + 1 + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319));
-	// Gadget Separators
+	// Button Separators
 	setAPen(0);
 	// First black line to separate buttons
 	drawHLine(0, _vm->_utils->vgaScaleY(170), _vm->_utils->vgaScaleX(319));
@@ -382,7 +382,7 @@ void DisplayMan::drawPanel() {
 		setAPen(4);
 		// The horizontal lines under the black one
 		drawHLine(0, _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(319));
-		_vm->_event->drawGadgetList(&_vm->_moveGadgetList);
+		_vm->_event->drawButtonList(&_vm->_moveButtonList);
 	} else {
 		if (_vm->getPlatform() != Common::kPlatformWindows) {
 			// Vertical Black lines
@@ -412,7 +412,7 @@ void DisplayMan::drawPanel() {
 			drawVLine(_vm->_utils->vgaScaleX(232), _vm->_utils->vgaScaleY(170) + 2, _vm->_utils->vgaScaleY(198));
 		}
 
-		_vm->_event->drawGadgetList(&_vm->_invGadgetList);
+		_vm->_event->drawButtonList(&_vm->_invButtonList);
 	}
 
 	_vm->_event->mouseShow();
@@ -429,22 +429,22 @@ void DisplayMan::setUpScreens() {
 		_vm->_moveImages[i] = new Image(controlFile);
 	delete controlFile;
 
-	// Creates the gadgets for the movement control panel
+	// Creates the buttons for the movement control panel
 	uint16 y = _vm->_utils->vgaScaleY(173) - _vm->_utils->svgaCord(2);
 
 	// The key mapping was only set for the Windows version.
 	// It's very convenient to have those shortcut, so I added them
 	// for all versions. (Strangerke)
-	_vm->_moveGadgetList.push_back(_vm->_event->createButton(  1, y, 0,          't', _vm->_moveImages[0],  _vm->_moveImages[1]));
-	_vm->_moveGadgetList.push_back(_vm->_event->createButton( 33, y, 1,          'm', _vm->_moveImages[2],  _vm->_moveImages[3]));
-	_vm->_moveGadgetList.push_back(_vm->_event->createButton( 65, y, 2,          'o', _vm->_moveImages[4],  _vm->_moveImages[5]));
-	_vm->_moveGadgetList.push_back(_vm->_event->createButton( 97, y, 3,          'c', _vm->_moveImages[6],  _vm->_moveImages[7]));
-	_vm->_moveGadgetList.push_back(_vm->_event->createButton(129, y, 4,          'l', _vm->_moveImages[8],  _vm->_moveImages[9]));
-	_vm->_moveGadgetList.push_back(_vm->_event->createButton(161, y, 5,          'i', _vm->_moveImages[12], _vm->_moveImages[13]));
-	_vm->_moveGadgetList.push_back(_vm->_event->createButton(193, y, 6, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]));
-	_vm->_moveGadgetList.push_back(_vm->_event->createButton(225, y, 7, VKEY_UPARROW, _vm->_moveImages[16], _vm->_moveImages[17]));
-	_vm->_moveGadgetList.push_back(_vm->_event->createButton(257, y, 8, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]));
-	_vm->_moveGadgetList.push_back(_vm->_event->createButton(289, y, 9,          'p', _vm->_moveImages[10], _vm->_moveImages[11]));
+	_vm->_moveButtonList.push_back(_vm->_event->createButton(  1, y, 0,          't', _vm->_moveImages[0],  _vm->_moveImages[1]));
+	_vm->_moveButtonList.push_back(_vm->_event->createButton( 33, y, 1,          'm', _vm->_moveImages[2],  _vm->_moveImages[3]));
+	_vm->_moveButtonList.push_back(_vm->_event->createButton( 65, y, 2,          'o', _vm->_moveImages[4],  _vm->_moveImages[5]));
+	_vm->_moveButtonList.push_back(_vm->_event->createButton( 97, y, 3,          'c', _vm->_moveImages[6],  _vm->_moveImages[7]));
+	_vm->_moveButtonList.push_back(_vm->_event->createButton(129, y, 4,          'l', _vm->_moveImages[8],  _vm->_moveImages[9]));
+	_vm->_moveButtonList.push_back(_vm->_event->createButton(161, y, 5,          'i', _vm->_moveImages[12], _vm->_moveImages[13]));
+	_vm->_moveButtonList.push_back(_vm->_event->createButton(193, y, 6, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]));
+	_vm->_moveButtonList.push_back(_vm->_event->createButton(225, y, 7, VKEY_UPARROW, _vm->_moveImages[16], _vm->_moveImages[17]));
+	_vm->_moveButtonList.push_back(_vm->_event->createButton(257, y, 8, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]));
+	_vm->_moveButtonList.push_back(_vm->_event->createButton(289, y, 9,          'p', _vm->_moveImages[10], _vm->_moveImages[11]));
 
 	Common::File *invFile = _vm->_resource->openDataFile("P:Inv");
 	if (_vm->getPlatform() == Common::kPlatformWindows) {
@@ -454,18 +454,18 @@ void DisplayMan::setUpScreens() {
 		for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++)
 			_vm->_invImages[imgIdx] = new Image(invFile);
 	}
-	_vm->_invGadgetList.push_back(_vm->_event->createButton( 24, y, 0,          'm', _vm->_invImages[0],   _vm->_invImages[1]));
-	_vm->_invGadgetList.push_back(_vm->_event->createButton( 56, y, 1,          'g', _vm->_invImages[2],   _vm->_invImages[3]));
-	_vm->_invGadgetList.push_back(_vm->_event->createButton( 94, y, 2,          'u', _vm->_invImages[4],   _vm->_invImages[5]));
-	_vm->_invGadgetList.push_back(_vm->_event->createButton(126, y, 3,          'l', _vm->_moveImages[8],  _vm->_moveImages[9]));
-	_vm->_invGadgetList.push_back(_vm->_event->createButton(164, y, 4, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]));
-	_vm->_invGadgetList.push_back(_vm->_event->createButton(196, y, 5, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]));
-
-	// The windows version has 2 extra gadgets for breadcrumb trail
+	_vm->_invButtonList.push_back(_vm->_event->createButton( 24, y, 0,          'm', _vm->_invImages[0],   _vm->_invImages[1]));
+	_vm->_invButtonList.push_back(_vm->_event->createButton( 56, y, 1,          'g', _vm->_invImages[2],   _vm->_invImages[3]));
+	_vm->_invButtonList.push_back(_vm->_event->createButton( 94, y, 2,          'u', _vm->_invImages[4],   _vm->_invImages[5]));
+	_vm->_invButtonList.push_back(_vm->_event->createButton(126, y, 3,          'l', _vm->_moveImages[8],  _vm->_moveImages[9]));
+	_vm->_invButtonList.push_back(_vm->_event->createButton(164, y, 4, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]));
+	_vm->_invButtonList.push_back(_vm->_event->createButton(196, y, 5, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]));
+
+	// The windows version has 2 extra buttons for breadcrumb trail
 	// TODO: the game is really hard to play without those, maybe we could add something to enable that.
 	if (_vm->getPlatform() == Common::kPlatformWindows) {
-		_vm->_invGadgetList.push_back(_vm->_event->createButton(234, y, 6, 'b', _vm->_invImages[6], _vm->_invImages[7]));
-		_vm->_invGadgetList.push_back(_vm->_event->createButton(266, y, 7, 'f', _vm->_invImages[8], _vm->_invImages[9]));
+		_vm->_invButtonList.push_back(_vm->_event->createButton(234, y, 6, 'b', _vm->_invImages[6], _vm->_invImages[7]));
+		_vm->_invButtonList.push_back(_vm->_event->createButton(266, y, 7, 'f', _vm->_invImages[8], _vm->_invImages[9]));
 	}
 
 	delete invFile;
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 9ae7beb..ed08d85 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -135,19 +135,19 @@ void LabEngine::freeScreens() {
 }
 
 /**
- * Permanently flips the imagery of a gadget.
+ * Permanently flips the imagery of a button.
  */
-void LabEngine::perFlipGadget(uint16 gadgetId) {
-	for (GadgetList::iterator gadget = _moveGadgetList.begin(); gadget != _moveGadgetList.end(); ++gadget) {
-		Gadget *topGadget = *gadget;
-		if (topGadget->_gadgetID == gadgetId) {
-			Image *tmpImage = topGadget->_image;
-			topGadget->_image = topGadget->_altImage;
-			topGadget->_altImage = tmpImage;
+void LabEngine::perFlipButton(uint16 buttonId) {
+	for (ButtonList::iterator button = _moveButtonList.begin(); button != _moveButtonList.end(); ++button) {
+		Button *topButton = *button;
+		if (topButton->_buttonID == buttonId) {
+			Image *tmpImage = topButton->_image;
+			topButton->_image = topButton->_altImage;
+			topButton->_altImage = tmpImage;
 
 			if (!_alternate) {
 				_event->mouseHide();
-				topGadget->_image->drawImage(topGadget->x, topGadget->y);
+				topButton->_image->drawImage(topButton->x, topButton->y);
 				_event->mouseShow();
 			}
 
@@ -260,7 +260,7 @@ const char *LabEngine::getInvName(uint16 curInv) {
  */
 void LabEngine::interfaceOff() {
 	if (!_interfaceOff) {
-		_event->attachGadgetList(nullptr);
+		_event->attachButtonList(nullptr);
 		_event->mouseHide();
 		_interfaceOff = true;
 	}
@@ -276,15 +276,15 @@ void LabEngine::interfaceOn() {
 	}
 
 	if (_graphics->_longWinInFront)
-		_event->attachGadgetList(nullptr);
+		_event->attachButtonList(nullptr);
 	else if (_alternate)
-		_event->attachGadgetList(&_invGadgetList);
+		_event->attachButtonList(&_invButtonList);
 	else
-		_event->attachGadgetList(&_moveGadgetList);
+		_event->attachButtonList(&_moveButtonList);
 }
 
 /**
- * If the user hits the "Use" gadget; things that can get used on themselves.
+ * If the user hits the "Use" button; things that can get used on themselves.
  */
 bool LabEngine::doUse(uint16 curInv) {
 	switch (curInv) {
@@ -427,7 +427,7 @@ void LabEngine::mainGameLoop() {
 	_graphics->_longWinInFront = false;
 	_graphics->drawPanel();
 
-	perFlipGadget(actionMode);
+	perFlipButton(actionMode);
 
 	// Set up initial picture.
 	while (1) {
@@ -534,7 +534,7 @@ void LabEngine::mainGameLoop() {
 					gotMessage = true;
 					mayShowCrumbIndicator();
 					_graphics->screenUpdate();
-					if (!fromCrumbs(GADGETUP, code, 0, _event->updateAndGetMousePos(), curInv, curMsg, forceDraw, code, actionMode))
+					if (!fromCrumbs(BUTTONUP, code, 0, _event->updateAndGetMousePos(), curInv, curMsg, forceDraw, code, actionMode))
 						break;
 				}
 			}
@@ -549,7 +549,7 @@ void LabEngine::mainGameLoop() {
 			curPos.y  = curMsg->_mouseY;
 
 			_followingCrumbs = false;
-			if (!fromCrumbs(curMsg->_msgClass, curMsg->_code, curMsg->_qualifier, curPos, curInv, curMsg, forceDraw, curMsg->_gadgetID, actionMode))
+			if (!fromCrumbs(curMsg->_msgClass, curMsg->_code, curMsg->_qualifier, curPos, curInv, curMsg, forceDraw, curMsg->_buttonID, actionMode))
 				break;
 		}
 	}
@@ -596,7 +596,7 @@ void LabEngine::showLab2Teaser() {
 }
 
 bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Common::Point tmpPos,
-			uint16 &curInv, IntuiMessage *curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode) {
+			uint16 &curInv, IntuiMessage *curMsg, bool &forceDraw, uint16 buttonId, uint16 &actionMode) {
 	uint32 msgClass = tmpClass;
 	Common::Point curPos = tmpPos;
 
@@ -641,7 +641,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 						_graphics->_doNotDrawMessage = false;
 
 						_mainDisplay = true;
-						// Sets the correct gadget list
+						// Sets the correct button list
 						interfaceOn();
 						_graphics->drawPanel();
 						drawRoomMessage(curInv, _closeDataPtr);
@@ -710,9 +710,9 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 			drawRoomMessage(curInv, _closeDataPtr);
 			_graphics->screenUpdate();
 		}
-	} else if ((msgClass == GADGETUP) && !_alternate) {
-		if (gadgetId <= 5) {
-			if ((actionMode == 4) && (gadgetId == 4) && _closeDataPtr) {
+	} else if ((msgClass == BUTTONUP) && !_alternate) {
+		if (buttonId <= 5) {
+			if ((actionMode == 4) && (buttonId == 4) && _closeDataPtr) {
 				doMainView(&_closeDataPtr);
 
 				_anim->_doBlack = true;
@@ -720,13 +720,13 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 				_closeDataPtr = nullptr;
 				mayShowCrumbIndicator();
 				_graphics->screenUpdate();
-			} else if (gadgetId == 5) {
+			} else if (buttonId == 5) {
 				eatMessages();
 
 				_alternate = true;
 				_anim->_doBlack = true;
 				_graphics->_doNotDrawMessage = false;
-				// Sets the correct gadget list
+				// Sets the correct button list
 				interfaceOn();
 				_mainDisplay = false;
 
@@ -743,29 +743,29 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 				_graphics->screenUpdate();
 			} else {
 				uint16 oldActionMode = actionMode;
-				actionMode = gadgetId;
+				actionMode = buttonId;
 
 				if (oldActionMode < 5)
-					perFlipGadget(oldActionMode);
+					perFlipButton(oldActionMode);
 
-				perFlipGadget(actionMode);
+				perFlipButton(actionMode);
 
-				if (gadgetId <= 4)
-					drawStaticMessage(kTextTakeWhat + gadgetId);
+				if (buttonId <= 4)
+					drawStaticMessage(kTextTakeWhat + buttonId);
 				_graphics->screenUpdate();
 			}
-		} else if (gadgetId == 9) {
+		} else if (buttonId == 9) {
 			doUse(kItemMap);
 
 			mayShowCrumbIndicator();
 			_graphics->screenUpdate();
-		} else if (gadgetId >= 6) {
-			// Arrow Gadgets
+		} else if (buttonId >= 6) {
+			// Arrow Buttons
 			_closeDataPtr = nullptr;
 			wrkClosePtr = nullptr;
 
-			if ((gadgetId == 6) || (gadgetId == 8)) {
-				if (gadgetId == 6)
+			if ((buttonId == 6) || (buttonId == 8)) {
+				if (buttonId == 6)
 					drawStaticMessage(kTextTurnLeft);
 				else
 					drawStaticMessage(kTextTurnRight);
@@ -774,7 +774,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 
 				oldDirection = _direction;
 
-				uint16 newDir = processArrow(_direction, gadgetId - 6);
+				uint16 newDir = processArrow(_direction, buttonId - 6);
 				doTurn(_direction, newDir, &_closeDataPtr);
 				_anim->_doBlack = true;
 				_direction = newDir;
@@ -782,7 +782,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 
 				mayShowCrumbIndicator();
 				_graphics->screenUpdate();
-			} else if (gadgetId == 7) {
+			} else if (buttonId == 7) {
 				uint16 oldRoomNum = _roomNum;
 
 				if (doGoForward(&_closeDataPtr)) {
@@ -790,7 +790,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 						_anim->_doBlack = true;
 				} else {
 					_anim->_doBlack = true;
-					_direction = processArrow(_direction, gadgetId - 6);
+					_direction = processArrow(_direction, buttonId - 6);
 
 					if (oldRoomNum != _roomNum) {
 						drawStaticMessage(kTextGoForward);
@@ -847,17 +847,17 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 				_graphics->screenUpdate();
 			}
 		}
-	} else if ((msgClass == GADGETUP) && _alternate) {
+	} else if ((msgClass == BUTTONUP) && _alternate) {
 		_anim->_doBlack = true;
 
-		if (gadgetId == 0) {
+		if (buttonId == 0) {
 			eatMessages();
 			_alternate = false;
 			_anim->_doBlack = true;
 			_graphics->_doNotDrawMessage = false;
 
 			_mainDisplay = true;
-			// Sets the correct gadget list
+			// Sets the correct button list
 			interfaceOn();
 			_graphics->drawPanel();
 			drawRoomMessage(curInv, _closeDataPtr);
@@ -865,9 +865,9 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 			_graphics->screenUpdate();
 		}
 
-		gadgetId--;
+		buttonId--;
 
-		if (gadgetId == 0) {
+		if (buttonId == 0) {
 			interfaceOff();
 			_anim->stopDiff();
 			_curFileName = " ";
@@ -889,21 +889,21 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 				g_system->delayMillis(1000);
 			}
 			_graphics->screenUpdate();
-		} else if (gadgetId == 1) {
+		} else if (buttonId == 1) {
 			if (!doUse(curInv)) {
 				uint16 oldActionMode = actionMode;
 				// Use button
 				actionMode = 5;
 
 				if (oldActionMode < 5)
-					perFlipGadget(oldActionMode);
+					perFlipButton(oldActionMode);
 
 				drawStaticMessage(kTextUseOnWhat);
 				_mainDisplay = true;
 
 				_graphics->screenUpdate();
 			}
-		} else if (gadgetId == 2) {
+		} else if (buttonId == 2) {
 			_mainDisplay = !_mainDisplay;
 
 			if ((curInv == 0) || (curInv > _numInv)) {
@@ -917,30 +917,30 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 				_nextFileName = getInvName(curInv);
 
 			_graphics->screenUpdate();
-		} else if (gadgetId == 3) {
-			// Left gadget
+		} else if (buttonId == 3) {
+			// Left button
 			decIncInv(&curInv, true);
 			lastInv = curInv;
 			_graphics->_doNotDrawMessage = false;
 			drawRoomMessage(curInv, _closeDataPtr);
 
 			_graphics->screenUpdate();
-		} else if (gadgetId == 4) {
-			// Right gadget
+		} else if (buttonId == 4) {
+			// Right button
 			decIncInv(&curInv, false);
 			lastInv = curInv;
 			_graphics->_doNotDrawMessage = false;
 			drawRoomMessage(curInv, _closeDataPtr);
 
 			_graphics->screenUpdate();
-		} else if (gadgetId == 5) {
+		} else if (buttonId == 5) {
 			// bread crumbs
 			_breadCrumbs[0]._roomNum = 0;
 			_numCrumbs = 0;
 			_droppingCrumbs = true;
 			mayShowCrumbIndicator();
 			_graphics->screenUpdate();
-		} else if (gadgetId == 6) {
+		} else if (buttonId == 6) {
 			// follow crumbs
 			if (_droppingCrumbs) {
 				if (_numCrumbs > 0) {
@@ -958,7 +958,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 					_graphics->_doNotDrawMessage = false;
 
 					_mainDisplay = true;
-					// Sets the correct gadget list
+					// Sets the correct button list
 					interfaceOn();
 					_graphics->drawPanel();
 					drawRoomMessage(curInv, _closeDataPtr);
@@ -1085,7 +1085,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 		_anim->_doBlack = true;
 		_graphics->_doNotDrawMessage = false;
 		_mainDisplay = true;
-		// Sets the correct gadget list
+		// Sets the correct button list
 		interfaceOn();
 
 		if (_alternate) {
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 7b5d184..63ca63a 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -60,49 +60,49 @@ static const byte mouseData[] = {
 #define MOUSE_HEIGHT 15
 
 /**
- * Checks whether or not the cords fall within one of the gadgets in a list
- * of gadgets.
+ * Checks whether or not the cords fall within one of the buttons in a list
+ * of buttons.
  */
-Gadget *EventManager::checkGadgetHit(GadgetList *gadgetList, Common::Point pos) {
-	for (GadgetList::iterator gadgetItr = gadgetList->begin(); gadgetItr != gadgetList->end(); ++gadgetItr) {
-		Gadget *gadget = *gadgetItr;
-		Common::Rect gadgetRect(gadget->x, gadget->y, gadget->x + gadget->_image->_width - 1, gadget->y + gadget->_image->_height - 1);
+Button *EventManager::checkButtonHit(ButtonList *buttonList, Common::Point pos) {
+	for (ButtonList::iterator buttonItr = buttonList->begin(); buttonItr != buttonList->end(); ++buttonItr) {
+		Button *button = *buttonItr;
+		Common::Rect buttonRect(button->x, button->y, button->x + button->_image->_width - 1, button->y + button->_image->_height - 1);
 
-		if (gadgetRect.contains(pos) && gadget->isEnabled) {
+		if (buttonRect.contains(pos) && button->isEnabled) {
 			if (_vm->_isHiRes) {
-				_hitGadget = gadget;
+				_hitButton = button;
 			} else {
 				mouseHide();
-				gadget->_altImage->drawImage(gadget->x, gadget->y);
+				button->_altImage->drawImage(button->x, button->y);
 				mouseShow();
 
 				for (uint16 i = 0; i < 3; i++)
 					_vm->waitTOF();
 
 				mouseHide();
-				gadget->_image->drawImage(gadget->x, gadget->y);
+				button->_image->drawImage(button->x, button->y);
 				mouseShow();
 			}
 
-			return gadget;
+			return button;
 		}
 	}
 
 	return NULL;
 }
 
-void EventManager::attachGadgetList(GadgetList *gadgetList) {
-	if (_screenGadgetList != gadgetList)
-		_lastGadgetHit = nullptr;
+void EventManager::attachButtonList(ButtonList *buttonList) {
+	if (_screenButtonList != buttonList)
+		_lastButtonHit = nullptr;
 
-	_screenGadgetList = gadgetList;
+	_screenButtonList = buttonList;
 }
 
-Gadget *EventManager::getGadget(uint16 id) {
-	for (GadgetList::iterator gadgetItr = _screenGadgetList->begin(); gadgetItr != _screenGadgetList->end(); ++gadgetItr) {
-		Gadget *gadget = *gadgetItr;
-		if (gadget->_gadgetID == id)
-			return gadget;
+Button *EventManager::getButton(uint16 id) {
+	for (ButtonList::iterator buttonItr = _screenButtonList->begin(); buttonItr != _screenButtonList->end(); ++buttonItr) {
+		Button *button = *buttonItr;
+		if (button->_buttonID == id)
+			return button;
 	}
 
 	return nullptr;
@@ -113,9 +113,9 @@ EventManager::EventManager(LabEngine *vm) : _vm(vm) {
 	_rightClick = false;
 
 	_mouseHidden = true;
-	_lastGadgetHit = nullptr;
-	_screenGadgetList = nullptr;
-	_hitGadget = nullptr;
+	_lastButtonHit = nullptr;
+	_screenButtonList = nullptr;
+	_hitButton = nullptr;
 	_nextKeyIn = 0;
 	_nextKeyOut = 0;
 	_mousePos = Common::Point(0, 0);
@@ -129,12 +129,12 @@ EventManager::EventManager(LabEngine *vm) : _vm(vm) {
 void EventManager::mouseHandler(int flag, Common::Point pos) {
 	if (flag & 0x02) {
 		// Left mouse button click
-		Gadget *tmp = NULL;
-		if (_screenGadgetList)
-			tmp = checkGadgetHit(_screenGadgetList, _vm->_isHiRes ? pos : Common::Point(pos.x / 2, pos.y));
+		Button *tmp = NULL;
+		if (_screenButtonList)
+			tmp = checkButtonHit(_screenButtonList, _vm->_isHiRes ? pos : Common::Point(pos.x / 2, pos.y));
 
 		if (tmp)
-			_lastGadgetHit = tmp;
+			_lastButtonHit = tmp;
 		else
 			_leftClick = true;
 	}
@@ -150,19 +150,19 @@ void EventManager::updateMouse() {
 	if (!_mouseHidden)
 		doUpdateDisplay = true;
 
-	if (_hitGadget) {
+	if (_hitButton) {
 		mouseHide();
-		_hitGadget->_altImage->drawImage(_hitGadget->x, _hitGadget->y);
+		_hitButton->_altImage->drawImage(_hitButton->x, _hitButton->y);
 		mouseShow();
 
 		for (uint16 i = 0; i < 3; i++)
 			_vm->waitTOF();
 
 		mouseHide();
-		_hitGadget->_image->drawImage(_hitGadget->x, _hitGadget->y);
+		_hitButton->_image->drawImage(_hitButton->x, _hitButton->y);
 		mouseShow();
 		doUpdateDisplay = true;
-		_hitGadget = nullptr;
+		_hitButton = nullptr;
 	}
 
 	if (doUpdateDisplay)
@@ -251,10 +251,10 @@ bool EventManager::mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
 	return false;
 }
 
-Gadget *EventManager::mouseGadget() {
-	Gadget *temp = _lastGadgetHit;
+Button *EventManager::mouseButton() {
+	Button *temp = _lastButtonHit;
 
-	_lastGadgetHit = nullptr;
+	_lastButtonHit = nullptr;
 	return temp;
 }
 
diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h
index 3becfeb..cf61c40 100644
--- a/engines/lab/eventman.h
+++ b/engines/lab/eventman.h
@@ -40,7 +40,7 @@ class Image;
 
 // Defines for the Class variable in IntuiMessage
 #define MOUSEBUTTONS    0x00000008
-#define GADGETUP		0x00000040
+#define BUTTONUP		0x00000040
 #define RAWKEY			0x00000400
 #define DELTAMOVE		0x00100000
 
@@ -55,19 +55,19 @@ class Image;
 
 struct IntuiMessage {
 	uint32 _msgClass;
-	uint16 _code, _qualifier, _mouseX, _mouseY, _gadgetID;
+	uint16 _code, _qualifier, _mouseX, _mouseY, _buttonID;
 	uint32 _seconds, _micros;
 };
 
 
-struct Gadget {
-	uint16 x, y, _gadgetID;
-	uint16 _keyEquiv; // if not zero, a key that activates gadget
+struct Button {
+	uint16 x, y, _buttonID;
+	uint16 _keyEquiv; // if not zero, a key that activates button
 	bool isEnabled;
 	Image *_image, *_altImage;
 };
 
-typedef Common::List<Gadget *> GadgetList;
+typedef Common::List<Button *> ButtonList;
 
 class EventManager {
 private:
@@ -76,7 +76,7 @@ private:
 	bool _rightClick;
 
 	bool _mouseHidden;
-	Gadget *_lastGadgetHit;
+	Button *_lastButtonHit;
 	uint16 _nextKeyIn;
 	uint16 _nextKeyOut;
 	Common::Point _mousePos;
@@ -86,11 +86,11 @@ private:
 public:
 	EventManager (LabEngine *vm);
 
-	GadgetList *_screenGadgetList;
-	Gadget *_hitGadget;
+	ButtonList *_screenButtonList;
+	Button *_hitButton;
 	Common::KeyState _keyPressed;
 
-	Gadget *checkGadgetHit(GadgetList *gadgetList, Common::Point pos);
+	Button *checkButtonHit(ButtonList *buttonList, Common::Point pos);
 	void initMouse();
 	void updateMouse();
 	void mouseShow();
@@ -98,9 +98,9 @@ public:
 	Common::Point getMousePos();
 	void setMousePos(Common::Point pos);
 	bool mouseButton(uint16 *x, uint16 *y, bool leftButton);
-	Gadget *mouseGadget();
-	void attachGadgetList(GadgetList *gadgetList);
-	Gadget *getGadget(uint16 id);
+	Button *mouseButton();
+	void attachButtonList(ButtonList *buttonList);
+	Button *getButton(uint16 id);
 	void mouseHandler(int flag, Common::Point pos);
 	bool keyPress(uint16 *keyCode);
 	bool haveNextChar();
@@ -108,14 +108,14 @@ public:
 	uint16 getNextChar();
 	Common::Point updateAndGetMousePos();
 
-	Gadget *checkNumGadgetHit(GadgetList *gadgetList, uint16 key);
-	Gadget *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt);
-	void freeButtonList(GadgetList *gadgetList);
-	void drawGadgetList(GadgetList *gadgetList);
-	void disableGadget(Gadget *curgad, uint16 pencolor);
-	void enableGadget(Gadget *curgad);
+	Button *checkNumButtonHit(ButtonList *buttonList, uint16 key);
+	Button *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt);
+	void freeButtonList(ButtonList *buttonList);
+	void drawButtonList(ButtonList *buttonList);
+	void disableButton(Button *curgad, uint16 pencolor);
+	void enableButton(Button *curgad);
 	IntuiMessage *getMsg();
-	uint16 makeGadgetKeyEquiv(uint16 key);
+	uint16 makeButtonKeyEquiv(uint16 key);
 };
 
 } // End of namespace Lab
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index cd062a8..acc5a8a 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -39,66 +39,66 @@
 
 namespace Lab {
 
-Gadget *EventManager::createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *image, Image *altImage) {
-	Gadget *gadget = new Gadget();
-
-	if (gadget) {
-		gadget->x = _vm->_utils->vgaScaleX(x);
-		gadget->y = y;
-		gadget->_gadgetID = id;
-		gadget->_keyEquiv = key;
-		gadget->_image = image;
-		gadget->_altImage = altImage;
-		gadget->isEnabled = true;
-
-		return gadget;
+Button *EventManager::createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *image, Image *altImage) {
+	Button *button = new Button();
+
+	if (button) {
+		button->x = _vm->_utils->vgaScaleX(x);
+		button->y = y;
+		button->_buttonID = id;
+		button->_keyEquiv = key;
+		button->_image = image;
+		button->_altImage = altImage;
+		button->isEnabled = true;
+
+		return button;
 	} else
 		return nullptr;
 }
 
-void EventManager::freeButtonList(GadgetList *gadgetList) {
-	for (GadgetList::iterator gadgetIter = gadgetList->begin(); gadgetIter != gadgetList->end(); ++gadgetIter) {
-		Gadget *gadget = *gadgetIter;
-		delete gadget->_image;
-		delete gadget->_altImage;
-		delete gadget;
+void EventManager::freeButtonList(ButtonList *buttonList) {
+	for (ButtonList::iterator buttonIter = buttonList->begin(); buttonIter != buttonList->end(); ++buttonIter) {
+		Button *button = *buttonIter;
+		delete button->_image;
+		delete button->_altImage;
+		delete button;
 	}
 
-	gadgetList->clear();
+	buttonList->clear();
 }
 
 /**
- * Draws a gadget list to the screen.
+ * Draws a button list to the screen.
  */
-void EventManager::drawGadgetList(GadgetList *gadgetList) {
-	for (GadgetList::iterator gadget = gadgetList->begin(); gadget != gadgetList->end(); ++gadget) {
-		(*gadget)->_image->drawImage((*gadget)->x, (*gadget)->y);
+void EventManager::drawButtonList(ButtonList *buttonList) {
+	for (ButtonList::iterator button = buttonList->begin(); button != buttonList->end(); ++button) {
+		(*button)->_image->drawImage((*button)->x, (*button)->y);
 
-		if (!(*gadget)->isEnabled)
-			disableGadget((*gadget), 1);
+		if (!(*button)->isEnabled)
+			disableButton((*button), 1);
 	}
 }
 
 /**
- * Dims a gadget, and makes it unavailable for using.
+ * Dims a button, and makes it unavailable for using.
  */
-void EventManager::disableGadget(Gadget *gadget, uint16 penColor) {
-	_vm->_graphics->overlayRect(penColor, gadget->x, gadget->y, gadget->x + gadget->_image->_width - 1, gadget->y + gadget->_image->_height - 1);
-	gadget->isEnabled = false;
+void EventManager::disableButton(Button *button, uint16 penColor) {
+	_vm->_graphics->overlayRect(penColor, button->x, button->y, button->x + button->_image->_width - 1, button->y + button->_image->_height - 1);
+	button->isEnabled = false;
 }
 
 /**
- * Undims a gadget, and makes it available again.
+ * Undims a button, and makes it available again.
  */
-void EventManager::enableGadget(Gadget *gadget) {
-	gadget->_image->drawImage(gadget->x, gadget->y);
-	gadget->isEnabled = true;
+void EventManager::enableButton(Button *button) {
+	button->_image->drawImage(button->x, button->y);
+	button->isEnabled = true;
 }
 
 /**
- * Make a key press have the right case for a gadget KeyEquiv value.
+ * Make a key press have the right case for a button KeyEquiv value.
  */
-uint16 EventManager::makeGadgetKeyEquiv(uint16 key) {
+uint16 EventManager::makeButtonKeyEquiv(uint16 key) {
 	if (Common::isAlnum(key))
 		key = tolower(key);
 
@@ -106,29 +106,29 @@ uint16 EventManager::makeGadgetKeyEquiv(uint16 key) {
 }
 
 /**
- * Checks whether or not the coords fall within one of the gadgets in a list
- * of gadgets.
+ * Checks whether or not the coords fall within one of the buttons in a list
+ * of buttons.
  */
-Gadget *EventManager::checkNumGadgetHit(GadgetList *gadgetList, uint16 key) {
+Button *EventManager::checkNumButtonHit(ButtonList *buttonList, uint16 key) {
 	uint16 gkey = key - '0';
 
-	if (!gadgetList)
+	if (!buttonList)
 		return nullptr;
 
-	for (GadgetList::iterator gadgetItr = gadgetList->begin(); gadgetItr != gadgetList->end(); ++gadgetItr) {
-		Gadget *gadget = *gadgetItr;
-		if ((gkey - 1 == gadget->_gadgetID || (gkey == 0 && gadget->_gadgetID == 9) ||
-			  (gadget->_keyEquiv != 0 && makeGadgetKeyEquiv(key) == gadget->_keyEquiv))
-			  && gadget->isEnabled) {
+	for (ButtonList::iterator buttonItr = buttonList->begin(); buttonItr != buttonList->end(); ++buttonItr) {
+		Button *button = *buttonItr;
+		if ((gkey - 1 == button->_buttonID || (gkey == 0 && button->_buttonID == 9) ||
+			  (button->_keyEquiv != 0 && makeButtonKeyEquiv(key) == button->_keyEquiv))
+			  && button->isEnabled) {
 			mouseHide();
-			gadget->_altImage->drawImage(gadget->x, gadget->y);
+			button->_altImage->drawImage(button->x, button->y);
 			mouseShow();
 			g_system->delayMillis(80);
 			mouseHide();
-			gadget->_image->drawImage(gadget->x, gadget->y);
+			button->_image->drawImage(button->x, button->y);
 			mouseShow();
 
-			return gadget;
+			return button;
 		}
 	}
 
@@ -141,13 +141,13 @@ IntuiMessage *EventManager::getMsg() {
 	updateMouse();
 
 	int qualifiers = _keyPressed.flags;
-	Gadget *curgad  = mouseGadget();
+	Button *curgad  = mouseButton();
 
 	if (curgad) {
 		updateMouse();
-		message._msgClass = GADGETUP;
-		message._code  = curgad->_gadgetID;
-		message._gadgetID = curgad->_gadgetID;
+		message._msgClass = BUTTONUP;
+		message._code  = curgad->_buttonID;
+		message._buttonID = curgad->_buttonID;
 		message._qualifier = qualifiers;
 		return &message;
 	} else if (mouseButton(&message._mouseX, &message._mouseY, true)) {
@@ -162,12 +162,12 @@ IntuiMessage *EventManager::getMsg() {
 		return &message;
 	} else if (keyPress(&message._code)) {
 		// Keyboard key
-		curgad = checkNumGadgetHit(_screenGadgetList, message._code);
+		curgad = checkNumButtonHit(_screenButtonList, message._code);
 
 		if (curgad) {
-			message._msgClass = GADGETUP;
-			message._code  = curgad->_gadgetID;
-			message._gadgetID = curgad->_gadgetID;
+			message._msgClass = BUTTONUP;
+			message._code  = curgad->_buttonID;
+			message._buttonID = curgad->_buttonID;
 		} else
 			message._msgClass = RAWKEY;
 
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index e7df814..06ab61d 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -135,7 +135,7 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_monitorPage = 0;
 	_monitorTextFilename = "";
 	_monitorButton = nullptr;
-	_monitorGadgetHeight = 1;
+	_monitorButtonHeight = 1;
 	for (int i = 0; i < 20; i++)
 		_highPalette[i] = 0;
 
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 7c438c4..770e1ea 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -46,7 +46,7 @@ namespace Lab {
 struct MapData;
 struct Action;
 struct CloseData;
-struct Gadget;
+struct Button;
 struct IntuiMessage;
 struct InventoryData;
 struct RoomData;
@@ -71,7 +71,7 @@ enum GameFeatures {
 
 #define ONESECOND      1000
 
-typedef Common::List<Gadget *> GadgetList;
+typedef Common::List<Button *> ButtonList;
 
 struct CrumbData {
 	uint16 _roomNum;
@@ -106,7 +106,7 @@ private:
 	uint16 _journalPage;
 	uint16 _maxRooms;
 	uint16 _monitorPage;
-	uint16 _monitorGadgetHeight;
+	uint16 _monitorButtonHeight;
 
 	uint32 _extraGameFeatures;
 
@@ -117,8 +117,8 @@ private:
 	const char *_monitorTextFilename;
 
 	CloseDataPtr _closeDataPtr;
-	GadgetList _journalGadgetList;
-	GadgetList _mapGadgetList;
+	ButtonList _journalButtonList;
+	ButtonList _mapButtonList;
 	Image *_imgMap, *_imgRoom, *_imgUpArrowRoom, *_imgDownArrowRoom, *_imgBridge;
 	Image *_imgHRoom, *_imgVRoom, *_imgMaze, *_imgHugeMaze, *_imgPath, *_imgMapNorth;
 	Image *_imgMapEast, *_imgMapSouth, *_imgMapWest, *_imgXMark;
@@ -156,8 +156,8 @@ public:
 	CrumbData _breadCrumbs[MAX_CRUMBS];
 	DisplayMan *_graphics;
 	EventManager *_event;
-	GadgetList _invGadgetList;
-	GadgetList _moveGadgetList;
+	ButtonList _invButtonList;
+	ButtonList _moveButtonList;
 	Image *_invImages[10];
 	Image *_moveImages[20];
 	LargeSet *_conditions, *_roomsFound;
@@ -223,7 +223,7 @@ private:
 	void freeMapData();
 	void freeScreens();
 	bool fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Common::Point tmpPos,
-		uint16 &curInv, IntuiMessage *curMsg, bool &forceDraw, uint16 gadgetId, uint16 &actionMode);
+		uint16 &curInv, IntuiMessage *curMsg, bool &forceDraw, uint16 buttonId, uint16 &actionMode);
 	const char *getInvName(uint16 curInv);
 	uint16 getLowerFloor(uint16 floorNum);
 	CloseData *getObject(Common::Point pos, CloseDataPtr closePtr);
@@ -237,7 +237,7 @@ private:
 	void showLab2Teaser();
 	void mayShowCrumbIndicator();
 	void mayShowCrumbIndicatorOff();
-	void perFlipGadget(uint16 gadID);
+	void perFlipButton(uint16 gadID);
 	uint16 processArrow(uint16 curDirection, uint16 arrow);
 	void processJournal();
 	void processMap(uint16 curRoom);
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 179bba5..2258775 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -78,9 +78,9 @@ void LabEngine::loadMapData() {
 	_imgPath = new Image(mapImages);
 	_imgBridge = new Image(mapImages);
 
-	_mapGadgetList.push_back(_event->createButton( 8,  _utils->vgaScaleY(105), 0, VKEY_LTARROW, new Image(mapImages), new Image(mapImages)));	// back
-	_mapGadgetList.push_back(_event->createButton( 55, _utils->vgaScaleY(105), 1, VKEY_UPARROW, new Image(mapImages), new Image(mapImages)));	// up
-	_mapGadgetList.push_back(_event->createButton(101, _utils->vgaScaleY(105), 2, VKEY_DNARROW, new Image(mapImages), new Image(mapImages)));	// down
+	_mapButtonList.push_back(_event->createButton( 8,  _utils->vgaScaleY(105), 0, VKEY_LTARROW, new Image(mapImages), new Image(mapImages)));	// back
+	_mapButtonList.push_back(_event->createButton( 55, _utils->vgaScaleY(105), 1, VKEY_UPARROW, new Image(mapImages), new Image(mapImages)));	// up
+	_mapButtonList.push_back(_event->createButton(101, _utils->vgaScaleY(105), 2, VKEY_DNARROW, new Image(mapImages), new Image(mapImages)));	// down
 
 	delete mapImages;
 
@@ -103,7 +103,7 @@ void LabEngine::loadMapData() {
 }
 
 void LabEngine::freeMapData() {
-	_event->freeButtonList(&_mapGadgetList);
+	_event->freeButtonList(&_mapButtonList);
 
 	delete _imgMap;
 	delete _imgRoom;
@@ -368,7 +368,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad
 	_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);
 
 	_imgMap->drawImage(0, 0);
-	_event->drawGadgetList(&_mapGadgetList);
+	_event->drawButtonList(&_mapButtonList);
 
 	for (uint16 i = 1; i <= _maxRooms; i++) {
 		if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x) {
@@ -383,18 +383,18 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad
 	if ((_maps[curRoom]._pageNumber == floorNum) && _roomsFound->in(curRoom) && _maps[curRoom]._x)
 		drawRoomMap(curRoom, true);
 
-	Gadget *upGadget = _event->getGadget(1);
-	Gadget *downGadget = _event->getGadget(2);
+	Button *upButton = _event->getButton(1);
+	Button *downButton = _event->getButton(2);
 
 	if (getUpperFloor(floorNum) != kFloorNone)
-		_event->enableGadget(upGadget);
+		_event->enableButton(upButton);
 	else
-		_event->disableGadget(upGadget, 12);
+		_event->disableButton(upButton, 12);
 
 	if (getLowerFloor(floorNum) != kFloorNone)
-		_event->enableGadget(downGadget);
+		_event->enableButton(downButton);
 	else
-		_event->disableGadget(downGadget, 12);
+		_event->disableButton(downButton, 12);
 
 	// Labyrinth specific code
 	if (floorNum == kFloorLower) {
@@ -474,7 +474,7 @@ void LabEngine::processMap(uint16 curRoom) {
 		} else {
 			uint32 msgClass  = msg->_msgClass;
 			uint16 msgCode   = msg->_code;
-			uint16 gadgetID  = msg->_gadgetID;
+			uint16 buttonID  = msg->_buttonID;
 			uint16 qualifier = msg->_qualifier;
 			uint16 mouseX    = msg->_mouseX;
 			uint16 mouseY    = msg->_mouseY;
@@ -482,11 +482,11 @@ void LabEngine::processMap(uint16 curRoom) {
 			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || ((msgClass == RAWKEY) && (msgCode == 27)))
 				return;
 
-			if (msgClass == GADGETUP) {
-				if (gadgetID == 0) {
+			if (msgClass == BUTTONUP) {
+				if (buttonID == 0) {
 					// Quit menu button
 					return;
-				} else if (gadgetID == 1) {
+				} else if (buttonID == 1) {
 					// Up arrow
 					uint16 upperFloor = getUpperFloor(curFloor);
 					if (upperFloor != kFloorNone) {
@@ -495,7 +495,7 @@ void LabEngine::processMap(uint16 curRoom) {
 						drawMap(curRoom, curMsg, curFloor, false, false);
 						_graphics->fade(true, 0);
 					}
-				} else if (gadgetID == 2) {
+				} else if (buttonID == 2) {
 					// Down arrow
 					uint16 lowerFloor = getLowerFloor(curFloor);
 					if (lowerFloor != kFloorNone) {
@@ -613,12 +613,12 @@ void LabEngine::doMap(uint16 curRoom) {
 	else if (_direction == WEST)
 		_imgXMark = _imgMapWest;
 
-	_event->attachGadgetList(&_mapGadgetList);
+	_event->attachButtonList(&_mapButtonList);
 	drawMap(curRoom, curRoom, _maps[curRoom]._pageNumber, false, true);
 	_event->mouseShow();
 	_graphics->screenUpdate();
 	processMap(curRoom);
-	_event->attachGadgetList(nullptr);
+	_event->attachButtonList(nullptr);
 	_graphics->fade(false, 0);
 	_graphics->blackAllScreen();
 	_event->mouseHide();
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index c754d28..e95b676 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -176,7 +176,7 @@ void LabEngine::drawDirection(CloseDataPtr closePtr) {
 }
 
 /**
- * process a arrow gadget movement.
+ * process a arrow button movement.
  */
 uint16 LabEngine::processArrow(uint16 curDirection, uint16 arrow) {
 	if (arrow == 1) { // Forward
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 1fc5c67..0f5e00b 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -141,9 +141,9 @@ void LabEngine::loadJournalData() {
 
 	Common::File *journalFile = _resource->openDataFile("P:JImage");
 	Utils *utils = _utils;
-	_journalGadgetList.push_back(_event->createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile), new Image(journalFile)));	// back
-	_journalGadgetList.push_back(_event->createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2,            0, new Image(journalFile), new Image(journalFile)));	// cancel
-	_journalGadgetList.push_back(_event->createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile), new Image(journalFile)));	// forward
+	_journalButtonList.push_back(_event->createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile), new Image(journalFile)));	// back
+	_journalButtonList.push_back(_event->createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2,            0, new Image(journalFile), new Image(journalFile)));	// cancel
+	_journalButtonList.push_back(_event->createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile), new Image(journalFile)));	// forward
 	delete journalFile;
 
 	_anim->_noPalChange = true;
@@ -231,18 +231,18 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 	else
 		turnPage((bool)(wipenum == 1));
 
-	Gadget *backGadget = _event->getGadget(0);
-	Gadget *forwardGadget = _event->getGadget(2);
+	Button *backButton = _event->getButton(0);
+	Button *forwardButton = _event->getButton(2);
 
 	if (_journalPage == 0)
-		_event->disableGadget(backGadget, 15);
+		_event->disableButton(backButton, 15);
 	else
-		_event->enableGadget(backGadget);
+		_event->enableButton(backButton);
 
 	if (_lastPage)
-		_event->disableGadget(forwardGadget, 15);
+		_event->disableButton(forwardButton, 15);
 	else
-		_event->enableGadget(forwardGadget);
+		_event->enableButton(forwardButton);
 
 	if (needFade)
 		_graphics->fade(true, 0);
@@ -273,7 +273,7 @@ void LabEngine::processJournal() {
 			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) ||
 				  ((msgClass == RAWKEY) && (gadID == 27)))
 				return;
-			else if (msgClass == GADGETUP) {
+			else if (msgClass == BUTTONUP) {
 				if (gadID == 0) {
 					if (_journalPage >= 2) {
 						_journalPage -= 2;
@@ -310,17 +310,17 @@ void LabEngine::doJournal() {
 	_music->updateMusic();
 	loadJournalData();
 
-	_event->attachGadgetList(&_journalGadgetList);
+	_event->attachButtonList(&_journalButtonList);
 	drawJournal(0, true);
 	_event->mouseShow();
 	processJournal();
-	_event->attachGadgetList(NULL);
+	_event->attachButtonList(NULL);
 	_graphics->fade(false, 0);
 	_event->mouseHide();
 
 	delete[] _blankJournal;
 	delete[] journalBackImage._imageData;
-	_event->freeButtonList(&_journalGadgetList);
+	_event->freeButtonList(&_journalButtonList);
 	_graphics->closeFont(_journalFont);
 
 	ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
@@ -349,18 +349,18 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
 
 		fheight = _graphics->textHeight(monitorFont);
 		x1 = _monitorButton->_width + _utils->vgaScaleX(3);
-		_monitorGadgetHeight = _monitorButton->_height + _utils->vgaScaleY(3);
+		_monitorButtonHeight = _monitorButton->_height + _utils->vgaScaleY(3);
 
-		if (_monitorGadgetHeight > fheight)
-			yspacing = _monitorGadgetHeight - fheight;
+		if (_monitorButtonHeight > fheight)
+			yspacing = _monitorButtonHeight - fheight;
 		else
-			_monitorGadgetHeight = fheight;
+			_monitorButtonHeight = fheight;
 
 		_graphics->setAPen(0);
 		_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2);
 
 		for (uint16 i = 0; i < numlines; i++)
-			_monitorButton->drawImage(0, i * _monitorGadgetHeight);
+			_monitorButton->drawImage(0, i * _monitorButtonHeight);
 	} else if (isinteractive) {
 		_graphics->setAPen(0);
 		_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2);
@@ -468,7 +468,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 					}
 				} else if (isInteractive) {
 					CloseDataPtr tmpClosePtr = _closeDataPtr;
-					mouseY = 64 + (mouseY / _monitorGadgetHeight) * 42;
+					mouseY = 64 + (mouseY / _monitorButtonHeight) * 42;
 					mouseX = 101;
 					setCurrentClose(Common::Point(mouseX, mouseY), &_closeDataPtr, false);
 


Commit: f0e345a1a2d3963974888007d1b86221ba2ee64d
    https://github.com/scummvm/scummvm/commit/f0e345a1a2d3963974888007d1b86221ba2ee64d
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:03+01:00

Commit Message:
LAB: Make some functions and variables private in eventMan

Changed paths:
    engines/lab/eventman.h



diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h
index cf61c40..669866d 100644
--- a/engines/lab/eventman.h
+++ b/engines/lab/eventman.h
@@ -72,50 +72,52 @@ typedef Common::List<Button *> ButtonList;
 class EventManager {
 private:
 	LabEngine *_vm;
+
 	bool _leftClick;
 	bool _rightClick;
-
 	bool _mouseHidden;
-	Button *_lastButtonHit;
+	bool _mouseAtEdge;
+
 	uint16 _nextKeyIn;
 	uint16 _nextKeyOut;
-	Common::Point _mousePos;
-	bool _mouseAtEdge;
 	uint16 _keyBuf[64];
 
-public:
-	EventManager (LabEngine *vm);
-
-	ButtonList *_screenButtonList;
 	Button *_hitButton;
+	Button *_lastButtonHit;
+	ButtonList *_screenButtonList;
+	Common::Point _mousePos;
 	Common::KeyState _keyPressed;
 
+private:
 	Button *checkButtonHit(ButtonList *buttonList, Common::Point pos);
-	void initMouse();
-	void updateMouse();
-	void mouseShow();
-	void mouseHide();
-	Common::Point getMousePos();
-	void setMousePos(Common::Point pos);
 	bool mouseButton(uint16 *x, uint16 *y, bool leftButton);
 	Button *mouseButton();
-	void attachButtonList(ButtonList *buttonList);
-	Button *getButton(uint16 id);
 	void mouseHandler(int flag, Common::Point pos);
 	bool keyPress(uint16 *keyCode);
 	bool haveNextChar();
-	void processInput(bool can_delay = false);
 	uint16 getNextChar();
-	Common::Point updateAndGetMousePos();
-
 	Button *checkNumButtonHit(ButtonList *buttonList, uint16 key);
+	uint16 makeButtonKeyEquiv(uint16 key);
+
+public:
+	EventManager (LabEngine *vm);
+
+	void attachButtonList(ButtonList *buttonList);
 	Button *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt);
-	void freeButtonList(ButtonList *buttonList);
-	void drawButtonList(ButtonList *buttonList);
 	void disableButton(Button *curgad, uint16 pencolor);
+	void drawButtonList(ButtonList *buttonList);
 	void enableButton(Button *curgad);
+	void freeButtonList(ButtonList *buttonList);
+	Button *getButton(uint16 id);
+	Common::Point getMousePos();
 	IntuiMessage *getMsg();
-	uint16 makeButtonKeyEquiv(uint16 key);
+	void initMouse();
+	void mouseShow();
+	void mouseHide();
+	void processInput(bool can_delay = false);
+	void setMousePos(Common::Point pos);
+	void updateMouse();
+	Common::Point updateAndGetMousePos();
 };
 
 } // End of namespace Lab


Commit: e994c90d9bb68f8be6de5238f1e8192b4d5424f6
    https://github.com/scummvm/scummvm/commit/e994c90d9bb68f8be6de5238f1e8192b4d5424f6
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:03+01:00

Commit Message:
LAB: Simplify the crumb wait time code

Changed paths:
    engines/lab/anim.cpp
    engines/lab/engine.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 842d3d6..04da59e 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -348,7 +348,7 @@ void Anim::readDiff(byte *buffer, bool playOnce, bool onlyDiffData) {
 		_rawDiffBM._planes[_header] = NULL;
 
 	if (_headerdata._fps)
-		_delayMicros = ONESECOND / _headerdata._fps;
+		_delayMicros = 1000 / _headerdata._fps;
 
 	if (_playOnce) {
 		while (_header != 65535)
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index ed08d85..3d71d94 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -630,9 +630,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 					_followCrumbsFast = (codeLower == 'r');
 					_isCrumbTurning = false;
 					_isCrumbWaiting = false;
-					uint32 t = g_system->getMillis();
-					_crumbSecs = t / 1000;
-					_crumbMicros = t % 1000;
+					_crumbTimestamp = g_system->getMillis();
 
 					if (_alternate) {
 						eatMessages();
@@ -948,9 +946,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 					_followCrumbsFast = false;
 					_isCrumbTurning = false;
 					_isCrumbWaiting = false;
-					uint32 t = g_system->getMillis();
-					_crumbSecs = t / 1000;
-					_crumbMicros = t % 1000;
+					_crumbTimestamp = g_system->getMillis();
 
 					eatMessages();
 					_alternate = false;
@@ -1140,7 +1136,7 @@ int LabEngine::followCrumbs() {
 	};
 
 	if (_isCrumbWaiting) {
-		if (g_system->getMillis() <= _crumbSecs * 1000 + _crumbMicros)
+		if (g_system->getMillis() <= _crumbTimestamp)
 			return 0;
 
 		_isCrumbWaiting = false;
@@ -1178,13 +1174,11 @@ int LabEngine::followCrumbs() {
 		_droppingCrumbs = false;
 		_followingCrumbs = false;
 	} else {
-		int theDelay = (_followCrumbsFast ? ONESECOND / 4 : ONESECOND);
-
 		_isCrumbTurning = (moveDir != VKEY_UPARROW);
 		_isCrumbWaiting = true;
 
-		_crumbSecs   = (theDelay + g_system->getMillis()) / 1000;
-		_crumbMicros = (theDelay + g_system->getMillis()) % 1000;
+		int theDelay = (_followCrumbsFast ? 1000 / 4 : 1000);
+		_crumbTimestamp = theDelay + g_system->getMillis();
 	}
 
 	return moveDir;
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 06ab61d..1b62147 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -77,8 +77,7 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_manyRooms = 0;
 	_direction = 0;
 	_highestCondition = 0;
-	_crumbSecs = 0;
-	_crumbMicros = 0;
+	_crumbTimestamp = 0;
 	_maxRooms = 0;
 
 	_event = nullptr;
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 770e1ea..0f6fbac 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -69,8 +69,6 @@ enum GameFeatures {
 	GF_WINDOWS_TRIAL = 1 << 1
 };
 
-#define ONESECOND      1000
-
 typedef Common::List<Button *> ButtonList;
 
 struct CrumbData {
@@ -148,7 +146,7 @@ public:
 	uint16 _numCrumbs;
 	uint16 _numInv;
 
-	uint32 _crumbSecs, _crumbMicros;
+	uint32 _crumbTimestamp;
 
 	const char *_curFileName;
 


Commit: 2e099750868fa3b6129f0212d7f8d8a24f6aaa50
    https://github.com/scummvm/scummvm/commit/2e099750868fa3b6129f0212d7f8d8a24f6aaa50
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:03+01:00

Commit Message:
LAB: Simplify the LabEngine destructor

Changed paths:
    engines/lab/lab.cpp



diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 1b62147..0c54e9c 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -149,6 +149,7 @@ LabEngine::~LabEngine() {
 	// Remove all of our debug levels here
 	DebugMan.clearAllDebugChannels();
 
+	freeMapData();
 	delete _event;
 	delete _resource;
 	delete _music;
@@ -157,22 +158,6 @@ LabEngine::~LabEngine() {
 	delete[] _rooms;
 	delete _tilePuzzle;
 	delete _utils;
-	delete _imgMap;
-	delete _imgRoom;
-	delete _imgUpArrowRoom;
-	delete _imgDownArrowRoom;
-	delete _imgBridge;
-	delete _imgHRoom;
-	delete _imgVRoom;
-	delete _imgMaze;
-	delete _imgHugeMaze;
-	delete _imgPath;
-	delete _imgMapNorth;
-	delete _imgMapEast;
-	delete _imgMapSouth;
-	delete _imgMapWest;
-	delete _imgXMark;
-	delete _maps;
 }
 
 Common::Error LabEngine::run() {


Commit: 99e09b2ca2615d9f5bbb682eb17920c8205af405
    https://github.com/scummvm/scummvm/commit/99e09b2ca2615d9f5bbb682eb17920c8205af405
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:03+01:00

Commit Message:
LAB: Merge the different X image maps

Changed paths:
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/map.cpp



diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 0c54e9c..9ff0cda 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -118,11 +118,8 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_imgMaze = nullptr;
 	_imgHugeMaze = nullptr;
 	_imgPath = nullptr;
-	_imgMapNorth = nullptr;
-	_imgMapEast = nullptr;
-	_imgMapSouth = nullptr;
-	_imgMapWest = nullptr;
-	_imgXMark = nullptr;
+	for (int i = 0; i < 4; i++)
+		_imgMapX[i] = nullptr;
 	_maps = nullptr;
 
 	_blankJournal = nullptr;
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 0f6fbac..37cd93f 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -118,8 +118,8 @@ private:
 	ButtonList _journalButtonList;
 	ButtonList _mapButtonList;
 	Image *_imgMap, *_imgRoom, *_imgUpArrowRoom, *_imgDownArrowRoom, *_imgBridge;
-	Image *_imgHRoom, *_imgVRoom, *_imgMaze, *_imgHugeMaze, *_imgPath, *_imgMapNorth;
-	Image *_imgMapEast, *_imgMapSouth, *_imgMapWest, *_imgXMark;
+	Image *_imgHRoom, *_imgVRoom, *_imgMaze, *_imgHugeMaze, *_imgPath;
+	Image *_imgMapX[4];
 	InventoryData *_inventory;
 	MapData *_maps;
 	byte *_blankJournal;
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 2258775..1861ccc 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -71,10 +71,10 @@ void LabEngine::loadMapData() {
 	_imgMaze = new Image(mapImages);
 	_imgHugeMaze = new Image(mapImages);
 
-	_imgMapNorth = new Image(mapImages);
-	_imgMapEast = new Image(mapImages);
-	_imgMapSouth = new Image(mapImages);
-	_imgMapWest = new Image(mapImages);
+	_imgMapX[NORTH] = new Image(mapImages);
+	_imgMapX[EAST] = new Image(mapImages);
+	_imgMapX[SOUTH] = new Image(mapImages);
+	_imgMapX[WEST] = new Image(mapImages);
 	_imgPath = new Image(mapImages);
 	_imgBridge = new Image(mapImages);
 
@@ -115,11 +115,8 @@ void LabEngine::freeMapData() {
 	delete _imgMaze;
 	delete _imgHugeMaze;
 	delete _imgPath;
-	delete _imgMapNorth;
-	delete _imgMapEast;
-	delete _imgMapSouth;
-	delete _imgMapWest;
-	// _imgXMark is a pointer to one of the four buffers above
+	for (int i = 0; i < 4; i++)
+		delete _imgMapX[i];
 	delete[] _maps;
 
 	_imgMap = nullptr;
@@ -132,11 +129,8 @@ void LabEngine::freeMapData() {
 	_imgMaze = nullptr;
 	_imgHugeMaze = nullptr;
 	_imgPath = nullptr;
-	_imgMapNorth = nullptr;
-	_imgMapEast = nullptr;
-	_imgMapSouth = nullptr;
-	_imgMapWest = nullptr;
-	_imgXMark = nullptr;
+	for (int i = 0; i < 4; i++)
+		_imgMapX[i] = nullptr;
 	_maps = nullptr;
 }
 
@@ -216,16 +210,16 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) {
 		if (WESTDOOR & flags)
 			_imgPath->drawImage(x - _imgPath->_width, y + offset);
 
-		drawX = x + (_imgRoom->_width - _imgXMark->_width) / 2;
-		drawY = y + (_imgRoom->_height - _imgXMark->_height) / 2;
+		drawX = x + (_imgRoom->_width - _imgMapX[_direction]->_width) / 2;
+		drawY = y + (_imgRoom->_height - _imgMapX[_direction]->_height) / 2;
 
 		break;
 
 	case BRIDGEROOM:
 		_imgBridge->drawImage(x, y);
 
-		drawX = x + (_imgBridge->_width - _imgXMark->_width) / 2;
-		drawY = y + (_imgBridge->_height - _imgXMark->_height) / 2;
+		drawX = x + (_imgBridge->_width - _imgMapX[_direction]->_width) / 2;
+		drawY = y + (_imgBridge->_height - _imgMapX[_direction]->_height) / 2;
 
 		break;
 
@@ -262,8 +256,8 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) {
 		if (WESTMDOOR & flags)
 			_imgPath->drawImage(x - _imgPath->_width, y - offset - _imgPath->_height + _imgVRoom->_height);
 
-		drawX = x + (_imgVRoom->_width - _imgXMark->_width) / 2;
-		drawY = y + (_imgVRoom->_height - _imgXMark->_height) / 2;
+		drawX = x + (_imgVRoom->_width - _imgMapX[_direction]->_width) / 2;
+		drawY = y + (_imgVRoom->_height - _imgMapX[_direction]->_height) / 2;
 
 		break;
 
@@ -300,8 +294,8 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) {
 		if (WESTDOOR & flags)
 			_imgPath->drawImage(x - _imgPath->_width, y + offset);
 
-		drawX = x + (_imgHRoom->_width - _imgXMark->_width) / 2;
-		drawY = y + (_imgHRoom->_height - _imgXMark->_height) / 2;
+		drawX = x + (_imgHRoom->_width - _imgMapX[_direction]->_width) / 2;
+		drawY = y + (_imgHRoom->_height - _imgMapX[_direction]->_height) / 2;
 
 		break;
 
@@ -310,7 +304,7 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) {
 	}
 
 	if (drawMarkFl)
-		_imgXMark->drawImage(drawX, drawY);
+		_imgMapX[_direction]->drawImage(drawX, drawY);
 }
 
 /**
@@ -603,16 +597,6 @@ void LabEngine::doMap(uint16 curRoom) {
 	_music->updateMusic();
 	loadMapData();
 	_graphics->blackAllScreen();
-
-	if (_direction == NORTH)
-		_imgXMark = _imgMapNorth;
-	else if (_direction == SOUTH)
-		_imgXMark = _imgMapSouth;
-	else if (_direction == EAST)
-		_imgXMark = _imgMapEast;
-	else if (_direction == WEST)
-		_imgXMark = _imgMapWest;
-
 	_event->attachButtonList(&_mapButtonList);
 	drawMap(curRoom, curRoom, _maps[curRoom]._pageNumber, false, true);
 	_event->mouseShow();


Commit: 2b91bf2f34c3e0ec4e83fa478f1e426d36719cb7
    https://github.com/scummvm/scummvm/commit/2b91bf2f34c3e0ec4e83fa478f1e426d36719cb7
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:03+01:00

Commit Message:
LAB: Some renaming in EventMan

Changed paths:
    engines/lab/engine.cpp
    engines/lab/eventman.cpp
    engines/lab/eventman.h
    engines/lab/interface.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 3d71d94..80ee0bf 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -147,7 +147,7 @@ void LabEngine::perFlipButton(uint16 buttonId) {
 
 			if (!_alternate) {
 				_event->mouseHide();
-				topButton->_image->drawImage(topButton->x, topButton->y);
+				topButton->_image->drawImage(topButton->_x, topButton->_y);
 				_event->mouseShow();
 			}
 
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 63ca63a..ab33e75 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -66,21 +66,21 @@ static const byte mouseData[] = {
 Button *EventManager::checkButtonHit(ButtonList *buttonList, Common::Point pos) {
 	for (ButtonList::iterator buttonItr = buttonList->begin(); buttonItr != buttonList->end(); ++buttonItr) {
 		Button *button = *buttonItr;
-		Common::Rect buttonRect(button->x, button->y, button->x + button->_image->_width - 1, button->y + button->_image->_height - 1);
+		Common::Rect buttonRect(button->_x, button->_y, button->_x + button->_image->_width - 1, button->_y + button->_image->_height - 1);
 
-		if (buttonRect.contains(pos) && button->isEnabled) {
+		if (buttonRect.contains(pos) && button->_isEnabled) {
 			if (_vm->_isHiRes) {
 				_hitButton = button;
 			} else {
 				mouseHide();
-				button->_altImage->drawImage(button->x, button->y);
+				button->_altImage->drawImage(button->_x, button->_y);
 				mouseShow();
 
 				for (uint16 i = 0; i < 3; i++)
 					_vm->waitTOF();
 
 				mouseHide();
-				button->_image->drawImage(button->x, button->y);
+				button->_image->drawImage(button->_x, button->_y);
 				mouseShow();
 			}
 
@@ -152,14 +152,14 @@ void EventManager::updateMouse() {
 
 	if (_hitButton) {
 		mouseHide();
-		_hitButton->_altImage->drawImage(_hitButton->x, _hitButton->y);
+		_hitButton->_altImage->drawImage(_hitButton->_x, _hitButton->_y);
 		mouseShow();
 
 		for (uint16 i = 0; i < 3; i++)
 			_vm->waitTOF();
 
 		mouseHide();
-		_hitButton->_image->drawImage(_hitButton->x, _hitButton->y);
+		_hitButton->_image->drawImage(_hitButton->_x, _hitButton->_y);
 		mouseShow();
 		doUpdateDisplay = true;
 		_hitButton = nullptr;
@@ -231,8 +231,8 @@ void EventManager::setMousePos(Common::Point pos) {
  * co-ordinates of the button press.  leftbutton tells whether to check the
  * left or right button.
  */
-bool EventManager::mouseButton(uint16 *x, uint16 *y, bool leftbutton) {
-	if (leftbutton) {
+bool EventManager::mouseButton(uint16 *x, uint16 *y, bool leftButton) {
+	if (leftButton) {
 		if (_leftClick) {
 			*x = (!_vm->_isHiRes) ? (uint16)_mousePos.x / 2 : (uint16)_mousePos.x;
 			*y = (uint16)_mousePos.y;
@@ -275,7 +275,7 @@ bool EventManager::haveNextChar() {
 	return _nextKeyIn != _nextKeyOut;
 }
 
-void EventManager::processInput(bool can_delay) {
+void EventManager::processInput(bool canDelay) {
 	Common::Event event;
 
 	if (1) { //!g_IgnoreProcessInput
@@ -358,21 +358,21 @@ void EventManager::processInput(bool can_delay) {
 		}
 	}
 
-	if (can_delay)
+	if (canDelay)
 		g_system->delayMillis(10);
 }
 
 uint16 EventManager::getNextChar() {
-	uint16 c = 0;
+	uint16 chr = 0;
 
 	processInput();
 	if (_nextKeyIn != _nextKeyOut) {
-		c = _keyBuf[_nextKeyOut];
+		chr = _keyBuf[_nextKeyOut];
 		_nextKeyOut = ((((unsigned int)((_nextKeyOut + 1) >> 31) >> 26) + (byte)_nextKeyOut + 1) & 0x3F)
 			- ((unsigned int)((_nextKeyOut + 1) >> 31) >> 26);
 	}
 
-	return c;
+	return chr;
 }
 
 Common::Point EventManager::updateAndGetMousePos() {
diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h
index 669866d..acfccb2 100644
--- a/engines/lab/eventman.h
+++ b/engines/lab/eventman.h
@@ -61,9 +61,9 @@ struct IntuiMessage {
 
 
 struct Button {
-	uint16 x, y, _buttonID;
+	uint16 _x, _y, _buttonID;
 	uint16 _keyEquiv; // if not zero, a key that activates button
-	bool isEnabled;
+	bool _isEnabled;
 	Image *_image, *_altImage;
 };
 
@@ -103,10 +103,10 @@ public:
 	EventManager (LabEngine *vm);
 
 	void attachButtonList(ButtonList *buttonList);
-	Button *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *im, Image *imalt);
-	void disableButton(Button *curgad, uint16 pencolor);
+	Button *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *image, Image *altImage);
+	void disableButton(Button *button, uint16 penColor);
 	void drawButtonList(ButtonList *buttonList);
-	void enableButton(Button *curgad);
+	void enableButton(Button *button);
 	void freeButtonList(ButtonList *buttonList);
 	Button *getButton(uint16 id);
 	Common::Point getMousePos();
@@ -114,7 +114,7 @@ public:
 	void initMouse();
 	void mouseShow();
 	void mouseHide();
-	void processInput(bool can_delay = false);
+	void processInput(bool canDelay = false);
 	void setMousePos(Common::Point pos);
 	void updateMouse();
 	Common::Point updateAndGetMousePos();
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index acc5a8a..f490188 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -43,13 +43,13 @@ Button *EventManager::createButton(uint16 x, uint16 y, uint16 id, uint16 key, Im
 	Button *button = new Button();
 
 	if (button) {
-		button->x = _vm->_utils->vgaScaleX(x);
-		button->y = y;
+		button->_x = _vm->_utils->vgaScaleX(x);
+		button->_y = y;
 		button->_buttonID = id;
 		button->_keyEquiv = key;
 		button->_image = image;
 		button->_altImage = altImage;
-		button->isEnabled = true;
+		button->_isEnabled = true;
 
 		return button;
 	} else
@@ -72,9 +72,9 @@ void EventManager::freeButtonList(ButtonList *buttonList) {
  */
 void EventManager::drawButtonList(ButtonList *buttonList) {
 	for (ButtonList::iterator button = buttonList->begin(); button != buttonList->end(); ++button) {
-		(*button)->_image->drawImage((*button)->x, (*button)->y);
+		(*button)->_image->drawImage((*button)->_x, (*button)->_y);
 
-		if (!(*button)->isEnabled)
+		if (!(*button)->_isEnabled)
 			disableButton((*button), 1);
 	}
 }
@@ -83,16 +83,16 @@ void EventManager::drawButtonList(ButtonList *buttonList) {
  * Dims a button, and makes it unavailable for using.
  */
 void EventManager::disableButton(Button *button, uint16 penColor) {
-	_vm->_graphics->overlayRect(penColor, button->x, button->y, button->x + button->_image->_width - 1, button->y + button->_image->_height - 1);
-	button->isEnabled = false;
+	_vm->_graphics->overlayRect(penColor, button->_x, button->_y, button->_x + button->_image->_width - 1, button->_y + button->_image->_height - 1);
+	button->_isEnabled = false;
 }
 
 /**
  * Undims a button, and makes it available again.
  */
 void EventManager::enableButton(Button *button) {
-	button->_image->drawImage(button->x, button->y);
-	button->isEnabled = true;
+	button->_image->drawImage(button->_x, button->_y);
+	button->_isEnabled = true;
 }
 
 /**
@@ -119,13 +119,13 @@ Button *EventManager::checkNumButtonHit(ButtonList *buttonList, uint16 key) {
 		Button *button = *buttonItr;
 		if ((gkey - 1 == button->_buttonID || (gkey == 0 && button->_buttonID == 9) ||
 			  (button->_keyEquiv != 0 && makeButtonKeyEquiv(key) == button->_keyEquiv))
-			  && button->isEnabled) {
+			  && button->_isEnabled) {
 			mouseHide();
-			button->_altImage->drawImage(button->x, button->y);
+			button->_altImage->drawImage(button->_x, button->_y);
 			mouseShow();
 			g_system->delayMillis(80);
 			mouseHide();
-			button->_image->drawImage(button->x, button->y);
+			button->_image->drawImage(button->_x, button->_y);
 			mouseShow();
 
 			return button;


Commit: ad54a75b853ada2c4ae4b99368ac3038dcd92d33
    https://github.com/scummvm/scummvm/commit/ad54a75b853ada2c4ae4b99368ac3038dcd92d33
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:03+01:00

Commit Message:
LAB: Add _vm to Image class

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/engine.cpp
    engines/lab/image.cpp
    engines/lab/image.h
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/special.cpp
    engines/lab/tilepuzzle.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 736b7ea..d449260 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -426,7 +426,7 @@ void DisplayMan::setUpScreens() {
 
 	Common::File *controlFile = _vm->_resource->openDataFile("P:Control");
 	for (uint16 i = 0; i < 20; i++)
-		_vm->_moveImages[i] = new Image(controlFile);
+		_vm->_moveImages[i] = new Image(controlFile, _vm);
 	delete controlFile;
 
 	// Creates the buttons for the movement control panel
@@ -449,10 +449,10 @@ void DisplayMan::setUpScreens() {
 	Common::File *invFile = _vm->_resource->openDataFile("P:Inv");
 	if (_vm->getPlatform() == Common::kPlatformWindows) {
 		for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++)
-			_vm->_invImages[imgIdx] = new Image(invFile);
+			_vm->_invImages[imgIdx] = new Image(invFile, _vm);
 	} else {
 		for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++)
-			_vm->_invImages[imgIdx] = new Image(invFile);
+			_vm->_invImages[imgIdx] = new Image(invFile, _vm);
 	}
 	_vm->_invButtonList.push_back(_vm->_event->createButton( 24, y, 0,          'm', _vm->_invImages[0],   _vm->_invImages[1]));
 	_vm->_invButtonList.push_back(_vm->_event->createButton( 56, y, 1,          'g', _vm->_invImages[2],   _vm->_invImages[3]));
@@ -772,7 +772,7 @@ void DisplayMan::doScrollBlack() {
 
 	_vm->_event->mouseHide();
 
-	Image img;
+	Image img(_vm);
 	img._width = width;
 	img._height = height;
 	img._imageData = mem;
@@ -1007,12 +1007,12 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, char *filename) {
 
 	setPalette(_vm->_anim->_diffPalette, 256);
 
-	Image imSource;
+	Image imSource(_vm);
 	imSource._width = _screenWidth;
 	imSource._height = lastY;
 	imSource._imageData = bitMapBuffer;
 
-	Image imDest;
+	Image imDest(_vm);
 	imDest._width = _screenWidth;
 	imDest._height = _screenHeight;
 	imDest._imageData = getCurrentDrawingBuffer();
@@ -1113,7 +1113,7 @@ void DisplayMan::blackAllScreen() {
  * function will fail.
  */
 void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer) {
-	Image im;
+	Image im(_vm);
 	im._imageData = buffer;
 
 	if (x1 > x2)
@@ -1147,7 +1147,7 @@ void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint1
  * Scrolls the display in the y direction by blitting.
  */
 void DisplayMan::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer) {
-	Image im;
+	Image im(_vm);
 	im._imageData = buffer;
 
 	if (x1 > x2)
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 80ee0bf..552bdf8 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -1184,10 +1184,10 @@ int LabEngine::followCrumbs() {
 	return moveDir;
 }
 
-byte dropCrumbs[] = { 0x00 };
-Image dropCrumbsImage(24, 24, dropCrumbs);
 
 void LabEngine::mayShowCrumbIndicator() {
+	static byte dropCrumbs[] = { 0x00 };
+	static Image dropCrumbsImage(24, 24, dropCrumbs, this);
 	if (getPlatform() != Common::kPlatformWindows)
 		return;
 
@@ -1198,10 +1198,10 @@ void LabEngine::mayShowCrumbIndicator() {
 	}
 }
 
-byte dropCrumbsOff[] = { 0x00 };
-Image dropCrumbsOffImage(24, 24, dropCrumbsOff);
-
 void LabEngine::mayShowCrumbIndicatorOff() {
+	static byte dropCrumbsOff[] = { 0x00 };
+	static Image dropCrumbsOffImage(24, 24, dropCrumbsOff, this);
+
 	if (getPlatform() != Common::kPlatformWindows)
 		return;
 
diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp
index 20c893d..a947ced 100644
--- a/engines/lab/image.cpp
+++ b/engines/lab/image.cpp
@@ -40,7 +40,7 @@ namespace Lab {
 /**
  * Reads in an image from disk.
  */
-Image::Image(Common::File *s) {
+Image::Image(Common::File *s, LabEngine *vm) : _vm(vm) {
 	_width = s->readUint16LE();
 	_height = s->readUint16LE();
 	s->skip(4);
@@ -60,9 +60,9 @@ void Image::blitBitmap(uint16 xs, uint16 ys, Image *imDest,
 	uint16 xd, uint16 yd, uint16 width, uint16 height, byte masked) {
 	int w = width;
 	int h = height;
-	int destWidth = (imDest) ? imDest->_width : g_lab->_graphics->_screenWidth;
-	int destHeight = (imDest) ? imDest->_height : g_lab->_graphics->_screenHeight;
-	byte *destBuffer = (imDest) ? imDest->_imageData : g_lab->_graphics->getCurrentDrawingBuffer();
+	int destWidth = (imDest) ? imDest->_width : _vm->_graphics->_screenWidth;
+	int destHeight = (imDest) ? imDest->_height : _vm->_graphics->_screenHeight;
+	byte *destBuffer = (imDest) ? imDest->_imageData : _vm->_graphics->getCurrentDrawingBuffer();
 
 	if (xd + w > destWidth)
 		w = destWidth - xd;
@@ -121,20 +121,20 @@ void Image::readScreenImage(uint16 x, uint16 y) {
 	int w = _width;
 	int h = _height;
 
-	if (x + w > g_lab->_graphics->_screenWidth)
-		w = g_lab->_graphics->_screenWidth - x;
+	if (x + w > _vm->_graphics->_screenWidth)
+		w = _vm->_graphics->_screenWidth - x;
 
-	if (y + h > g_lab->_graphics->_screenHeight)
-		h = g_lab->_graphics->_screenHeight - y;
+	if (y + h > _vm->_graphics->_screenHeight)
+		h = _vm->_graphics->_screenHeight - y;
 
 	if ((w > 0) && (h > 0)) {
 		byte *s = _imageData;
-		byte *d = g_lab->_graphics->getCurrentDrawingBuffer() + y * g_lab->_graphics->_screenWidth + x;
+		byte *d = _vm->_graphics->getCurrentDrawingBuffer() + y * _vm->_graphics->_screenWidth + x;
 
 		while (h-- > 0) {
 			memcpy(s, d, w);
 			s += _width;
-			d += g_lab->_graphics->_screenWidth;
+			d += _vm->_graphics->_screenWidth;
 		}
 	}
 }
diff --git a/engines/lab/image.h b/engines/lab/image.h
index 34e3d36..90ea1f3 100644
--- a/engines/lab/image.h
+++ b/engines/lab/image.h
@@ -37,15 +37,19 @@ namespace Common {
 
 namespace Lab {
 
+class LabEngine;
+
 class Image {
+	LabEngine *_vm;
+
 public:
 	uint16 _width;
 	uint16 _height;
 	byte *_imageData;
 
-	Image() : _width(0), _height(0), _imageData(0) {}
-	Image(int w, int h, byte *d) : _width(w), _height(h), _imageData(d) {}
-	Image(Common::File *s);
+	Image(LabEngine *vm) : _width(0), _height(0), _imageData(0), _vm(vm) {}
+	Image(int w, int h, byte *d, LabEngine *vm) : _width(w), _height(h), _imageData(d), _vm(vm) {}
+	Image(Common::File *s, LabEngine *vm);
 
 	void drawImage(uint16 x, uint16 y);
 	void drawMaskImage(uint16 x, uint16 y);
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 9ff0cda..19dbef3 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -88,6 +88,8 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_rooms = nullptr;
 	_tilePuzzle = nullptr;
 	_utils = nullptr;
+	journalBackImage = nullptr;
+	ScreenImage = nullptr;
 
 	_lastTooLong = false;
 	_interfaceOff = false;
@@ -96,9 +98,8 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	for (int i = 0; i < 20; i++)
 		_moveImages[i] = nullptr;
 
-	for (int i = 0; i < 10; i++) {
+	for (int i = 0; i < 10; i++)
 		_invImages[i] = nullptr;
-	}
 
 	_curFileName = nullptr;
 	_nextFileName = nullptr;
@@ -155,6 +156,8 @@ LabEngine::~LabEngine() {
 	delete[] _rooms;
 	delete _tilePuzzle;
 	delete _utils;
+	delete journalBackImage;
+	delete ScreenImage;
 }
 
 Common::Error LabEngine::run() {
@@ -170,6 +173,8 @@ Common::Error LabEngine::run() {
 	_anim = new Anim(this);
 	_tilePuzzle = new TilePuzzle(this);
 	_utils = new Utils(this);
+	journalBackImage = new Image(this);
+	ScreenImage = new Image(this);
 
 	if (getPlatform() == Common::kPlatformWindows) {
 		// Check if this is the Wyrmkeep trial
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 37cd93f..dbb083a 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -128,8 +128,8 @@ private:
 
 	Common::RandomSource _rnd;
 
-	Image journalBackImage;
-	Image ScreenImage;
+	Image *journalBackImage;
+	Image *ScreenImage;
 
 public:
 	bool _alternate;
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 1861ccc..f8207ad 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -62,25 +62,25 @@ enum MapFloor {
 void LabEngine::loadMapData() {
 	Common::File *mapImages = _resource->openDataFile("P:MapImage");
 
-	_imgMap = new Image(mapImages);
-	_imgRoom = new Image(mapImages);
-	_imgUpArrowRoom = new Image(mapImages);
-	_imgDownArrowRoom = new Image(mapImages);
-	_imgHRoom = new Image(mapImages);
-	_imgVRoom = new Image(mapImages);
-	_imgMaze = new Image(mapImages);
-	_imgHugeMaze = new Image(mapImages);
-
-	_imgMapX[NORTH] = new Image(mapImages);
-	_imgMapX[EAST] = new Image(mapImages);
-	_imgMapX[SOUTH] = new Image(mapImages);
-	_imgMapX[WEST] = new Image(mapImages);
-	_imgPath = new Image(mapImages);
-	_imgBridge = new Image(mapImages);
-
-	_mapButtonList.push_back(_event->createButton( 8,  _utils->vgaScaleY(105), 0, VKEY_LTARROW, new Image(mapImages), new Image(mapImages)));	// back
-	_mapButtonList.push_back(_event->createButton( 55, _utils->vgaScaleY(105), 1, VKEY_UPARROW, new Image(mapImages), new Image(mapImages)));	// up
-	_mapButtonList.push_back(_event->createButton(101, _utils->vgaScaleY(105), 2, VKEY_DNARROW, new Image(mapImages), new Image(mapImages)));	// down
+	_imgMap = new Image(mapImages, this);
+	_imgRoom = new Image(mapImages, this);
+	_imgUpArrowRoom = new Image(mapImages, this);
+	_imgDownArrowRoom = new Image(mapImages, this);
+	_imgHRoom = new Image(mapImages, this);
+	_imgVRoom = new Image(mapImages, this);
+	_imgMaze = new Image(mapImages, this);
+	_imgHugeMaze = new Image(mapImages, this);
+
+	_imgMapX[NORTH] = new Image(mapImages, this);
+	_imgMapX[EAST] = new Image(mapImages, this);
+	_imgMapX[SOUTH] = new Image(mapImages, this);
+	_imgMapX[WEST] = new Image(mapImages, this);
+	_imgPath = new Image(mapImages, this);
+	_imgBridge = new Image(mapImages, this);
+
+	_mapButtonList.push_back(_event->createButton( 8,  _utils->vgaScaleY(105), 0, VKEY_LTARROW, new Image(mapImages, this), new Image(mapImages, this)));	// back
+	_mapButtonList.push_back(_event->createButton( 55, _utils->vgaScaleY(105), 1, VKEY_UPARROW, new Image(mapImages, this), new Image(mapImages, this)));	// up
+	_mapButtonList.push_back(_event->createButton(101, _utils->vgaScaleY(105), 2, VKEY_DNARROW, new Image(mapImages, this), new Image(mapImages, this)));	// down
 
 	delete mapImages;
 
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 0f5e00b..a629fd9 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -106,7 +106,6 @@ void LabEngine::doWestPaper() {
  */
 void LabEngine::loadJournalData() {
 	_journalFont = _resource->getFont("P:Journal.fon");
-
 	_music->updateMusic();
 
 	char filename[20];
@@ -141,21 +140,21 @@ void LabEngine::loadJournalData() {
 
 	Common::File *journalFile = _resource->openDataFile("P:JImage");
 	Utils *utils = _utils;
-	_journalButtonList.push_back(_event->createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile), new Image(journalFile)));	// back
-	_journalButtonList.push_back(_event->createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2,            0, new Image(journalFile), new Image(journalFile)));	// cancel
-	_journalButtonList.push_back(_event->createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile), new Image(journalFile)));	// forward
+	_journalButtonList.push_back(_event->createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile, this), new Image(journalFile, this)));	// back
+	_journalButtonList.push_back(_event->createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2,            0, new Image(journalFile, this), new Image(journalFile, this)));	// cancel
+	_journalButtonList.push_back(_event->createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile, this), new Image(journalFile, this)));	// forward
 	delete journalFile;
 
 	_anim->_noPalChange = true;
-	journalBackImage._imageData = new byte[_graphics->_screenWidth * _graphics->_screenHeight];
-	_graphics->readPict("P:Journal.pic", true, false, journalBackImage._imageData);
+	journalBackImage->_imageData = new byte[_graphics->_screenWidth * _graphics->_screenHeight];
+	_graphics->readPict("P:Journal.pic", true, false, journalBackImage->_imageData);
 	_anim->_noPalChange = false;
 
 	// Keep a copy of the blank journal
 	_blankJournal = new byte[_graphics->_screenWidth * _graphics->_screenHeight];
-	memcpy(_blankJournal, journalBackImage._imageData, _graphics->_screenWidth * _graphics->_screenHeight);
+	memcpy(_blankJournal, journalBackImage->_imageData, _graphics->_screenWidth * _graphics->_screenHeight);
 
-	ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
+	ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer();
 }
 
 /**
@@ -181,16 +180,16 @@ void LabEngine::drawJournalText() {
 
 	if (_journalPage <= 1) {
 		curText = _journalTextTitle;
-		_graphics->flowTextToMem(&journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText);
+		_graphics->flowTextToMem(journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText);
 	} else {
 		curText = (char *)(_journalText + charsDrawn);
-		charsDrawn += _graphics->flowTextToMem(&journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText);
+		charsDrawn += _graphics->flowTextToMem(journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText);
 	}
 
 	_music->updateMusic();
 	curText = (char *)(_journalText + charsDrawn);
 	_lastPage = (*curText == 0);
-	_graphics->flowTextToMem(&journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(171), _utils->vgaScaleY(32), _utils->vgaScaleX(271), _utils->vgaScaleY(148), curText);
+	_graphics->flowTextToMem(journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(171), _utils->vgaScaleY(32), _utils->vgaScaleX(271), _utils->vgaScaleY(148), curText);
 
 	curText = (char *)(_journalText + charsDrawn);
 	_lastPage = _lastPage || (*curText == 0);
@@ -204,15 +203,15 @@ void LabEngine::turnPage(bool fromLeft) {
 		for (int i = 0; i < _graphics->_screenWidth; i += 8) {
 			_music->updateMusic();
 			waitTOF();
-			ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
-			journalBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, _graphics->_screenHeight, false);
+			ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer();
+			journalBackImage->blitBitmap(i, 0, ScreenImage, i, 0, 8, _graphics->_screenHeight, false);
 		}
 	} else {
 		for (int i = (_graphics->_screenWidth - 8); i > 0; i -= 8) {
 			_music->updateMusic();
 			waitTOF();
-			ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
-			journalBackImage.blitBitmap(i, 0, &ScreenImage, i, 0, 8, _graphics->_screenHeight, false);
+			ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer();
+			journalBackImage->blitBitmap(i, 0, ScreenImage, i, 0, 8, _graphics->_screenHeight, false);
 		}
 	}
 }
@@ -227,7 +226,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 	_graphics->loadBackPict("P:Journal.pic", _highPalette);
 
 	if (wipenum == 0)
-		journalBackImage.blitBitmap(0, 0, &ScreenImage, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false);
+		journalBackImage->blitBitmap(0, 0, ScreenImage, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false);
 	else
 		turnPage((bool)(wipenum == 1));
 
@@ -248,7 +247,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 		_graphics->fade(true, 0);
 
 	// Reset the journal background, so that all the text that has been blitted on it is erased
-	memcpy(journalBackImage._imageData, _blankJournal, _graphics->_screenWidth * _graphics->_screenHeight);
+	memcpy(journalBackImage->_imageData, _blankJournal, _graphics->_screenWidth * _graphics->_screenHeight);
 
 	eatMessages();
 	_event->mouseShow();
@@ -297,19 +296,15 @@ void LabEngine::processJournal() {
  */
 void LabEngine::doJournal() {
 	_graphics->blackAllScreen();
+	_lastPage = false;
 
-	_lastPage    = false;
-
-	journalBackImage._width = _graphics->_screenWidth;
-	journalBackImage._height = _graphics->_screenHeight;
-	journalBackImage._imageData = NULL;
-
-	ScreenImage = journalBackImage;
-	ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
+	ScreenImage->_width = journalBackImage->_width = _graphics->_screenWidth;
+	ScreenImage->_height = journalBackImage->_height = _graphics->_screenHeight;
+	journalBackImage->_imageData = nullptr;
+	ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer();
 
 	_music->updateMusic();
 	loadJournalData();
-
 	_event->attachButtonList(&_journalButtonList);
 	drawJournal(0, true);
 	_event->mouseShow();
@@ -319,11 +314,11 @@ void LabEngine::doJournal() {
 	_event->mouseHide();
 
 	delete[] _blankJournal;
-	delete[] journalBackImage._imageData;
+	delete[] journalBackImage->_imageData;
 	_event->freeButtonList(&_journalButtonList);
 	_graphics->closeFont(_journalFont);
 
-	ScreenImage._imageData = _graphics->getCurrentDrawingBuffer();
+	ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer();
 
 	_graphics->setAPen(0);
 	_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);
@@ -508,7 +503,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 
 	TextFont *monitorFont = _resource->getFont("P:Map.fon");
 	Common::File *buttonFile = _resource->openDataFile("P:MonImage");
-	_monitorButton = new Image(buttonFile);
+	_monitorButton = new Image(buttonFile, this);
 	delete buttonFile;
 
 	ntext = _resource->getText(textfile);
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index 4d461a8..1e227d3 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -264,7 +264,7 @@ void TilePuzzle::showTile(const char *filename, bool showSolution) {
 	Common::File *tileFile = _vm->_resource->openDataFile(showSolution ? "P:TileSolution" : "P:Tile");
 
 	for (uint16 curBit = start; curBit < 16; curBit++)
-		_tiles[curBit] = new Image(tileFile);
+		_tiles[curBit] = new Image(tileFile, _vm);
 
 	delete tileFile;
 
@@ -322,7 +322,7 @@ void TilePuzzle::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 void TilePuzzle::changeCombination(uint16 number) {
 	const int solution[6] = { 0, 4, 0, 8, 7, 2 };
 
-	Image display;
+	Image display(_vm);
 	uint16 combnum;
 	bool unlocked = true;
 
@@ -392,7 +392,7 @@ void TilePuzzle::showCombination(const char *filename) {
 	Common::File *numFile = _vm->_resource->openDataFile("P:Numbers");
 
 	for (uint16 CurBit = 0; CurBit < 10; CurBit++)
-		_numberImages[CurBit] = new Image(numFile);
+		_numberImages[CurBit] = new Image(numFile, _vm);
 
 	delete numFile;
 


Commit: 974740d3076984535f941afb18e0adfa7132aab7
    https://github.com/scummvm/scummvm/commit/974740d3076984535f941afb18e0adfa7132aab7
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:03+01:00

Commit Message:
LAB: Some renaming in LabEngine

Changed paths:
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/special.cpp



diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 19dbef3..18b8b3d 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -88,8 +88,8 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_rooms = nullptr;
 	_tilePuzzle = nullptr;
 	_utils = nullptr;
-	journalBackImage = nullptr;
-	ScreenImage = nullptr;
+	_journalBackImage = nullptr;
+	_screenImage = nullptr;
 
 	_lastTooLong = false;
 	_interfaceOff = false;
@@ -156,8 +156,8 @@ LabEngine::~LabEngine() {
 	delete[] _rooms;
 	delete _tilePuzzle;
 	delete _utils;
-	delete journalBackImage;
-	delete ScreenImage;
+	delete _journalBackImage;
+	delete _screenImage;
 }
 
 Common::Error LabEngine::run() {
@@ -173,8 +173,8 @@ Common::Error LabEngine::run() {
 	_anim = new Anim(this);
 	_tilePuzzle = new TilePuzzle(this);
 	_utils = new Utils(this);
-	journalBackImage = new Image(this);
-	ScreenImage = new Image(this);
+	_journalBackImage = new Image(this);
+	_screenImage = new Image(this);
 
 	if (getPlatform() == Common::kPlatformWindows) {
 		// Check if this is the Wyrmkeep trial
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index dbb083a..d968c18 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -97,6 +97,8 @@ private:
 	bool _noUpdateDiff;
 	bool _quitLab;
 
+	byte *_blankJournal;
+
 	int _lastWaitTOFTicks;
 
 	uint16 _direction;
@@ -122,15 +124,12 @@ private:
 	Image *_imgMapX[4];
 	InventoryData *_inventory;
 	MapData *_maps;
-	byte *_blankJournal;
 	Image *_monitorButton;
+	Image *_journalBackImage;
+	Image *_screenImage;
 	TextFont *_journalFont;
-
 	Common::RandomSource _rnd;
 
-	Image *journalBackImage;
-	Image *ScreenImage;
-
 public:
 	bool _alternate;
 	bool _droppingCrumbs;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index a629fd9..5bb9b17 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -146,15 +146,15 @@ void LabEngine::loadJournalData() {
 	delete journalFile;
 
 	_anim->_noPalChange = true;
-	journalBackImage->_imageData = new byte[_graphics->_screenWidth * _graphics->_screenHeight];
-	_graphics->readPict("P:Journal.pic", true, false, journalBackImage->_imageData);
+	_journalBackImage->_imageData = new byte[_graphics->_screenWidth * _graphics->_screenHeight];
+	_graphics->readPict("P:Journal.pic", true, false, _journalBackImage->_imageData);
 	_anim->_noPalChange = false;
 
 	// Keep a copy of the blank journal
 	_blankJournal = new byte[_graphics->_screenWidth * _graphics->_screenHeight];
-	memcpy(_blankJournal, journalBackImage->_imageData, _graphics->_screenWidth * _graphics->_screenHeight);
+	memcpy(_blankJournal, _journalBackImage->_imageData, _graphics->_screenWidth * _graphics->_screenHeight);
 
-	ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer();
+	_screenImage->_imageData = _graphics->getCurrentDrawingBuffer();
 }
 
 /**
@@ -180,16 +180,16 @@ void LabEngine::drawJournalText() {
 
 	if (_journalPage <= 1) {
 		curText = _journalTextTitle;
-		_graphics->flowTextToMem(journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText);
+		_graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText);
 	} else {
 		curText = (char *)(_journalText + charsDrawn);
-		charsDrawn += _graphics->flowTextToMem(journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText);
+		charsDrawn += _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText);
 	}
 
 	_music->updateMusic();
 	curText = (char *)(_journalText + charsDrawn);
 	_lastPage = (*curText == 0);
-	_graphics->flowTextToMem(journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(171), _utils->vgaScaleY(32), _utils->vgaScaleX(271), _utils->vgaScaleY(148), curText);
+	_graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(171), _utils->vgaScaleY(32), _utils->vgaScaleX(271), _utils->vgaScaleY(148), curText);
 
 	curText = (char *)(_journalText + charsDrawn);
 	_lastPage = _lastPage || (*curText == 0);
@@ -203,15 +203,15 @@ void LabEngine::turnPage(bool fromLeft) {
 		for (int i = 0; i < _graphics->_screenWidth; i += 8) {
 			_music->updateMusic();
 			waitTOF();
-			ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer();
-			journalBackImage->blitBitmap(i, 0, ScreenImage, i, 0, 8, _graphics->_screenHeight, false);
+			_screenImage->_imageData = _graphics->getCurrentDrawingBuffer();
+			_journalBackImage->blitBitmap(i, 0, _screenImage, i, 0, 8, _graphics->_screenHeight, false);
 		}
 	} else {
 		for (int i = (_graphics->_screenWidth - 8); i > 0; i -= 8) {
 			_music->updateMusic();
 			waitTOF();
-			ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer();
-			journalBackImage->blitBitmap(i, 0, ScreenImage, i, 0, 8, _graphics->_screenHeight, false);
+			_screenImage->_imageData = _graphics->getCurrentDrawingBuffer();
+			_journalBackImage->blitBitmap(i, 0, _screenImage, i, 0, 8, _graphics->_screenHeight, false);
 		}
 	}
 }
@@ -226,7 +226,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 	_graphics->loadBackPict("P:Journal.pic", _highPalette);
 
 	if (wipenum == 0)
-		journalBackImage->blitBitmap(0, 0, ScreenImage, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false);
+		_journalBackImage->blitBitmap(0, 0, _screenImage, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false);
 	else
 		turnPage((bool)(wipenum == 1));
 
@@ -247,7 +247,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 		_graphics->fade(true, 0);
 
 	// Reset the journal background, so that all the text that has been blitted on it is erased
-	memcpy(journalBackImage->_imageData, _blankJournal, _graphics->_screenWidth * _graphics->_screenHeight);
+	memcpy(_journalBackImage->_imageData, _blankJournal, _graphics->_screenWidth * _graphics->_screenHeight);
 
 	eatMessages();
 	_event->mouseShow();
@@ -298,10 +298,10 @@ void LabEngine::doJournal() {
 	_graphics->blackAllScreen();
 	_lastPage = false;
 
-	ScreenImage->_width = journalBackImage->_width = _graphics->_screenWidth;
-	ScreenImage->_height = journalBackImage->_height = _graphics->_screenHeight;
-	journalBackImage->_imageData = nullptr;
-	ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer();
+	_screenImage->_width = _journalBackImage->_width = _graphics->_screenWidth;
+	_screenImage->_height = _journalBackImage->_height = _graphics->_screenHeight;
+	_journalBackImage->_imageData = nullptr;
+	_screenImage->_imageData = _graphics->getCurrentDrawingBuffer();
 
 	_music->updateMusic();
 	loadJournalData();
@@ -314,11 +314,11 @@ void LabEngine::doJournal() {
 	_event->mouseHide();
 
 	delete[] _blankJournal;
-	delete[] journalBackImage->_imageData;
+	delete[] _journalBackImage->_imageData;
 	_event->freeButtonList(&_journalButtonList);
 	_graphics->closeFont(_journalFont);
 
-	ScreenImage->_imageData = _graphics->getCurrentDrawingBuffer();
+	_screenImage->_imageData = _graphics->getCurrentDrawingBuffer();
 
 	_graphics->setAPen(0);
 	_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);


Commit: a784e2bd5cb17e3abbc2bfd47e65b63ef13ec2fc
    https://github.com/scummvm/scummvm/commit/a784e2bd5cb17e3abbc2bfd47e65b63ef13ec2fc
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:03+01:00

Commit Message:
LAB: Finally get rid of g_lab

Changed paths:
  R engines/lab/savegame.h
    engines/lab/detection.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/savegame.cpp



diff --git a/engines/lab/detection.cpp b/engines/lab/detection.cpp
index afdf5a1..ff8679c 100644
--- a/engines/lab/detection.cpp
+++ b/engines/lab/detection.cpp
@@ -31,7 +31,6 @@
 #include "engines/advancedDetector.h"
 
 #include "lab/lab.h"
-#include "lab/savegame.h"
 
 static const PlainGameDescriptor lab_setting[] = {
 	{ "lab", "Labyrith of Time" },
@@ -184,9 +183,9 @@ SaveStateList LabMetaEngine::listSaves(const char *target) const {
 		if (slotNum >= 0 && slotNum <= 999) {
 			Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
 			if (in) {
-					if (Lab::readSaveGameHeader(in, header))
-						saveList.push_back(SaveStateDescriptor(slotNum, header._descr.getDescription()));
-					delete in;
+				if (Lab::readSaveGameHeader(in, header))
+					saveList.push_back(SaveStateDescriptor(slotNum, header._descr.getDescription()));
+				delete in;
 			}
 		}
 	}
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 18b8b3d..1decad0 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -47,13 +47,8 @@
 #include "lab/utils.h"
 
 namespace Lab {
-
-LabEngine *g_lab;
-
 LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
  : Engine(syst), _gameDescription(gameDesc), _extraGameFeatures(0), _rnd("lab") {
-	g_lab = this;
-
 	_lastWaitTOFTicks = 0;
 
 	_isHiRes = false;
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index d968c18..756f6e1 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -34,8 +34,9 @@
 #include "common/system.h"
 #include "common/random.h"
 #include "common/rect.h"
-
+#include "common/savefile.h"
 #include "engines/engine.h"
+#include "engines/savestate.h"
 
 #include "lab/image.h"
 
@@ -64,6 +65,13 @@ class Resource;
 class TilePuzzle;
 class Utils;
 
+struct SaveGameHeader {
+	byte _version;
+	SaveStateDescriptor _descr;
+	uint16 _roomNumber;
+	uint16 _direction;
+};
+
 enum GameFeatures {
 	GF_LOWRES = 1 << 0,
 	GF_WINDOWS_TRIAL = 1 << 1
@@ -244,9 +252,14 @@ private:
 	void setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, bool useAbsoluteCoords);
 	bool takeItem(uint16 x, uint16 y, CloseDataPtr *closePtrList);
 	void turnPage(bool fromLeft);
+
+private:
+	bool saveGame(int slot, Common::String desc);
+	bool loadGame(int slot);
+	void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName);
 };
 
-extern LabEngine *g_lab;
+bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header);
 
 } // End of namespace Lab
 
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 9ead742..957bfdb 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -38,12 +38,10 @@
 #include "engines/savestate.h"
 
 #include "lab/lab.h"
-
 #include "lab/dispman.h"
 #include "lab/labsets.h"
 #include "lab/music.h"
 #include "lab/processroom.h"
-#include "lab/savegame.h"
 #include "lab/tilepuzzle.h"
 
 namespace Lab {
@@ -51,7 +49,7 @@ namespace Lab {
 #define SAVEGAME_ID       MKTAG('L', 'O', 'T', 'S')
 #define SAVEGAME_VERSION  1
 
-void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName) {
+void LabEngine::writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName) {
 	out->writeUint32BE(SAVEGAME_ID);
 
 	// Write version
@@ -123,9 +121,9 @@ bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
 /**
  * Writes the game out to disk.
  */
-bool saveGame(int slot, Common::String desc) {
+bool LabEngine::saveGame(int slot, Common::String desc) {
 	uint16 i;
-	Common::String fileName = g_lab->generateSaveFileName(slot);
+	Common::String fileName = generateSaveFileName(slot);
 	Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
 	Common::OutSaveFile *file = saveFileManager->openForSaving(fileName);
 
@@ -134,27 +132,27 @@ bool saveGame(int slot, Common::String desc) {
 
 	// Load scene pic
 	CloseDataPtr closePtr = nullptr;
-	g_lab->_graphics->readPict(g_lab->getPictName(&closePtr), true);
+	_graphics->readPict(getPictName(&closePtr), true);
 
 	writeSaveGameHeader(file, desc);
-	file->writeUint16LE(g_lab->_roomNum);
-	file->writeUint16LE(g_lab->getDirection());
-	file->writeUint16LE(g_lab->getQuarters());
+	file->writeUint16LE(_roomNum);
+	file->writeUint16LE(getDirection());
+	file->writeUint16LE(getQuarters());
 
 	// Conditions
-	for (i = 0; i < g_lab->_conditions->_lastElement / (8 * 2); i++)
-		file->writeUint16LE(g_lab->_conditions->_array[i]);
+	for (i = 0; i < _conditions->_lastElement / (8 * 2); i++)
+		file->writeUint16LE(_conditions->_array[i]);
 
 	// Rooms found
-	for (i = 0; i < g_lab->_roomsFound->_lastElement / (8 * 2); i++)
-		file->writeUint16LE(g_lab->_roomsFound->_array[i]);
+	for (i = 0; i < _roomsFound->_lastElement / (8 * 2); i++)
+		file->writeUint16LE(_roomsFound->_array[i]);
 
-	g_lab->_tilePuzzle->save(file);
+	_tilePuzzle->save(file);
 
 	// Breadcrumbs
-	for (i = 0; i < sizeof(g_lab->_breadCrumbs); i++) {
-		file->writeUint16LE(g_lab->_breadCrumbs[i]._roomNum);
-		file->writeUint16LE(g_lab->_breadCrumbs[i]._direction);
+	for (i = 0; i < sizeof(_breadCrumbs); i++) {
+		file->writeUint16LE(_breadCrumbs[i]._roomNum);
+		file->writeUint16LE(_breadCrumbs[i]._direction);
 	}
 
 	file->flush();
@@ -167,9 +165,9 @@ bool saveGame(int slot, Common::String desc) {
 /**
  * Reads the game from disk.
  */
-bool loadGame(int slot) {
+bool LabEngine::loadGame(int slot) {
 	uint16 i;
-	Common::String fileName = g_lab->generateSaveFileName(slot);
+	Common::String fileName = generateSaveFileName(slot);
 	Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
 	Common::InSaveFile *file = saveFileManager->openForLoading(fileName);
 
@@ -178,33 +176,33 @@ bool loadGame(int slot) {
 
 	SaveGameHeader header;
 	readSaveGameHeader(file, header);
-	g_lab->_roomNum = file->readUint16LE();
-	g_lab->setDirection(file->readUint16LE());
-	g_lab->setQuarters(file->readUint16LE());
+	_roomNum = file->readUint16LE();
+	setDirection(file->readUint16LE());
+	setQuarters(file->readUint16LE());
 
 	// Conditions
-	for (i = 0; i < g_lab->_conditions->_lastElement / (8 * 2); i++)
-		g_lab->_conditions->_array[i] = file->readUint16LE();
+	for (i = 0; i < _conditions->_lastElement / (8 * 2); i++)
+		_conditions->_array[i] = file->readUint16LE();
 
 	// Rooms found
-	for (i = 0; i < g_lab->_roomsFound->_lastElement / (8 * 2); i++)
-		g_lab->_roomsFound->_array[i] = file->readUint16LE();
+	for (i = 0; i < _roomsFound->_lastElement / (8 * 2); i++)
+		_roomsFound->_array[i] = file->readUint16LE();
 
-	g_lab->_tilePuzzle->load(file);
+	_tilePuzzle->load(file);
 
 	// Breadcrumbs
 	for (i = 0; i < 128; i++) {
-		g_lab->_breadCrumbs[i]._roomNum = file->readUint16LE();
-		g_lab->_breadCrumbs[i]._direction = file->readUint16LE();
+		_breadCrumbs[i]._roomNum = file->readUint16LE();
+		_breadCrumbs[i]._direction = file->readUint16LE();
 	}
 
-	g_lab->_droppingCrumbs = (g_lab->_breadCrumbs[0]._roomNum != 0);
-	g_lab->_followingCrumbs = false;
+	_droppingCrumbs = (_breadCrumbs[0]._roomNum != 0);
+	_followingCrumbs = false;
 
 	for (i = 0; i < 128; i++) {
-		if (g_lab->_breadCrumbs[i]._roomNum == 0)
+		if (_breadCrumbs[i]._roomNum == 0)
 			break;
-		g_lab->_numCrumbs = i;
+		_numCrumbs = i;
 	}
 
 	delete file;
@@ -215,8 +213,6 @@ bool loadGame(int slot) {
 bool LabEngine::saveRestoreGame() {
 	bool isOK = false;
 
-	//g_lab->showMainMenu();
-
 	// The original had one screen for saving/loading. We have two.
 	// Ask the user which screen to use.
 	GUI::MessageDialog saveOrLoad(_("Would you like to save or restore a game?"), _("Save"), _("Restore"));
diff --git a/engines/lab/savegame.h b/engines/lab/savegame.h
deleted file mode 100644
index f4f08b6..0000000
--- a/engines/lab/savegame.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-/*
- * This code is based on Labyrinth of Time code with assistance of
- *
- * Copyright (c) 1993 Terra Nova Development
- * Copyright (c) 2004 The Wyrmkeep Entertainment Co.
- *
- */
-
-#ifndef LAB_SAVEGAME_H
-#define LAB_SAVEGAME_H
-
-#include "common/savefile.h"
-
-namespace Lab {
-
-class LabEngine;
-
-struct SaveGameHeader {
-	byte _version;
-	SaveStateDescriptor _descr;
-	uint16 _roomNumber;
-	uint16 _direction;
-};
-
-bool saveGame(int slot, Common::String desc);
-bool loadGame(int slot);
-bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header);
-
-} // End of namespace Lab
-
-#endif // LAB_SAVEGAME_H


Commit: 5d240e3493a16c96cbded4669ba40fe0e86a593d
    https://github.com/scummvm/scummvm/commit/5d240e3493a16c96cbded4669ba40fe0e86a593d
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:04+01:00

Commit Message:
LAB; Fix a couple of typos in game description

Changed paths:
    engines/lab/detection.cpp



diff --git a/engines/lab/detection.cpp b/engines/lab/detection.cpp
index ff8679c..4a01414 100644
--- a/engines/lab/detection.cpp
+++ b/engines/lab/detection.cpp
@@ -33,7 +33,7 @@
 #include "lab/lab.h"
 
 static const PlainGameDescriptor lab_setting[] = {
-	{ "lab", "Labyrith of Time" },
+	{ "lab", "Labyrinth of Time" },
 	{ 0, 0 }
 };
 
@@ -131,7 +131,7 @@ public:
 	}
 
 	virtual const char *getOriginalCopyright() const {
-		return "Labytinth of Time (c) 2004 The Wyrmkeep Entertainment Co.";
+		return "Labyrinth of Time (c) 2004 The Wyrmkeep Entertainment Co.";
 	}
 
 	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {


Commit: aa718e4c842722e76d035d7ed63e5e08ff6b67cf
    https://github.com/scummvm/scummvm/commit/aa718e4c842722e76d035d7ed63e5e08ff6b67cf
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:34:04+01:00

Commit Message:
LAB: Variable rename

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/intro.cpp
    engines/lab/map.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index d449260..c76a6ec 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -52,7 +52,7 @@ DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) {
 	_curBitmap = nullptr;
 	_displayBuffer = nullptr;
 	_currentDisplayBuffer = nullptr;
-	FadePalette = nullptr;
+	_fadePalette = nullptr;
 
 	_screenWidth = 0;
 	_screenHeight = 0;
@@ -79,7 +79,7 @@ void DisplayMan::loadPict(const char *filename) {
 }
 
 void DisplayMan::loadBackPict(const char *fileName, uint16 *highPal) {
-	FadePalette = highPal;
+	_fadePalette = highPal;
 	_vm->_anim->_noPalChange = true;
 	readPict(fileName, true);
 
@@ -1194,13 +1194,13 @@ void DisplayMan::fade(bool fadeIn, uint16 res) {
 	for (uint16 i = 0; i < 16; i++) {
 		for (uint16 palIdx = 0; palIdx < 16; palIdx++) {
 			if (fadeIn)
-				newPal[palIdx] = (0x00F & fadeNumIn(0x00F & FadePalette[palIdx], 0x00F & res, i)) +
-				(0x0F0 & fadeNumIn(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) +
-				(0xF00 & fadeNumIn(0xF00 & FadePalette[palIdx], 0xF00 & res, i));
+				newPal[palIdx] = (0x00F & fadeNumIn(0x00F & _fadePalette[palIdx], 0x00F & res, i)) +
+				(0x0F0 & fadeNumIn(0x0F0 & _fadePalette[palIdx], 0x0F0 & res, i)) +
+				(0xF00 & fadeNumIn(0xF00 & _fadePalette[palIdx], 0xF00 & res, i));
 			else
-				newPal[palIdx] = (0x00F & fadeNumOut(0x00F & FadePalette[palIdx], 0x00F & res, i)) +
-				(0x0F0 & fadeNumOut(0x0F0 & FadePalette[palIdx], 0x0F0 & res, i)) +
-				(0xF00 & fadeNumOut(0xF00 & FadePalette[palIdx], 0xF00 & res, i));
+				newPal[palIdx] = (0x00F & fadeNumOut(0x00F & _fadePalette[palIdx], 0x00F & res, i)) +
+				(0x0F0 & fadeNumOut(0x0F0 & _fadePalette[palIdx], 0x0F0 & res, i)) +
+				(0xF00 & fadeNumOut(0xF00 & _fadePalette[palIdx], 0xF00 & res, i));
 		}
 
 		setAmigaPal(newPal, 16);
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index 58a517e..8b77dc8 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -158,7 +158,7 @@ public:
 	byte *_displayBuffer;
 	byte *_currentDisplayBuffer;
 	bool _doNotDrawMessage;
-	uint16 *FadePalette;
+	uint16 *_fadePalette;
 	BitMap *_dispBitMap;
 };
 
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 7c77e8a..b085397 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -271,7 +271,7 @@ void Intro::introSequence() {
 		nReadPict("TNDcycle2.pic", true);
 	_vm->_anim->_noPalChange = false;
 
-	_vm->_graphics->FadePalette = palette;
+	_vm->_graphics->_fadePalette = palette;
 
 	for (uint16 i = 0; i < 16; i++) {
 		if (_quitIntro)
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index f8207ad..cb222ba 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -592,7 +592,7 @@ void LabEngine::doMap(uint16 curRoom) {
 		0x0AAA, 0x0ED0, 0x0EEE, 0x0694
 	};
 
-	_graphics->FadePalette = amigaMapPalette;
+	_graphics->_fadePalette = amigaMapPalette;
 
 	_music->updateMusic();
 	loadMapData();
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 5bb9b17..65a4a9d 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -499,7 +499,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 
 	_monitorPage = 0;
 	_lastPage = false;
-	_graphics->FadePalette = _highPalette;
+	_graphics->_fadePalette = _highPalette;
 
 	TextFont *monitorFont = _resource->getFont("P:Map.fon");
 	Common::File *buttonFile = _resource->openDataFile("P:MonImage");


Commit: 79eec20361530fa18577e89d1623948ca2a8d271
    https://github.com/scummvm/scummvm/commit/79eec20361530fa18577e89d1623948ca2a8d271
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:34:04+01:00

Commit Message:
LAB: Reduced variable scope. Renames

Changed paths:
    engines/lab/dispman.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index c76a6ec..9aa1834 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -69,7 +69,6 @@ DisplayMan::~DisplayMan() {
 }
 
 // From readPict.c.  Reads in pictures and animations from disk.
-
 void DisplayMan::loadPict(const char *filename) {
 	Common::File *bitmapFile = _vm->_resource->openDataFile(filename);
 	freePict();
@@ -191,12 +190,6 @@ uint32 DisplayMan::flowText(
 			uint16 x1, uint16 y1,  // Cords
 			uint16 x2, uint16 y2,
 			const char *str) {     // The text itself
-	TextFont *_msgFont = (TextFont *)font;
-	char linebuffer[256];
-	const char *temp;
-	uint16 numlines, actlines, fontheight, width;
-	uint16 x, y;
-
 	if (fillback) {
 		setAPen(backpen);
 		rectFill(x1, y1, x2, y2);
@@ -207,17 +200,20 @@ uint32 DisplayMan::flowText(
 
 	setAPen(pencolor);
 
-	fontheight = textHeight(_msgFont) + spacing;
-	numlines   = (y2 - y1 + 1) / fontheight;
-	width      = x2 - x1 + 1;
-	y          = y1;
+	TextFont *msgFont = (TextFont *)font;
+	uint16 fontheight = textHeight(msgFont) + spacing;
+	uint16 numlines   = (y2 - y1 + 1) / fontheight;
+	uint16 width      = x2 - x1 + 1;
+	uint16 y          = y1;
+	char linebuffer[256];
+	const char *temp;
 
 	if (centerv && output) {
 		temp = str;
-		actlines = 0;
+		uint16 actlines = 0;
 
 		while (temp[0]) {
-			getLine(_msgFont, linebuffer, &temp, width);
+			getLine(msgFont, linebuffer, &temp, width);
 			actlines++;
 		}
 
@@ -228,15 +224,15 @@ uint32 DisplayMan::flowText(
 	temp = str;
 
 	while (numlines && str[0]) {
-		getLine(_msgFont, linebuffer, &str, width);
+		getLine(msgFont, linebuffer, &str, width);
 
-		x = x1;
+		uint16 x = x1;
 
 		if (centerh)
-			x += (width - textLength(_msgFont, linebuffer, strlen(linebuffer))) / 2;
+			x += (width - textLength(msgFont, linebuffer, strlen(linebuffer))) / 2;
 
 		if (output)
-			text(_msgFont, x, y, pencolor, linebuffer, strlen(linebuffer));
+			text(msgFont, x, y, pencolor, linebuffer, strlen(linebuffer));
 
 		numlines--;
 		y += fontheight;
@@ -277,13 +273,13 @@ uint32 DisplayMan::flowTextToMem(Image *destIm,
 			uint16 x1, uint16 y1,  // Cords
 			uint16 x2, uint16 y2,
 			const char *str) {     // The text itself
-	uint32 res, vgabyte = _screenBytesPerPage;
 	byte *tmp = _currentDisplayBuffer;
+	uint32 vgabyte = _screenBytesPerPage;
 
 	_currentDisplayBuffer = destIm->_imageData;
 	_screenBytesPerPage = (uint32)destIm->_width * (int32)destIm->_height;
 
-	res = flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str);
+	uint32 res = flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str);
 
 	_screenBytesPerPage = vgabyte;
 	_currentDisplayBuffer = tmp;
@@ -307,13 +303,13 @@ void DisplayMan::createBox(uint16 y2) {
 }
 
 int32 DisplayMan::longDrawMessage(const char *str) {
-	char newText[512];
-
 	if (str == NULL)
 		return 0;
 
 	_vm->_event->attachButtonList(NULL);
 	_vm->_event->mouseHide();
+
+	char newText[512];
 	strcpy(newText, str);
 
 	if (!_longWinInFront) {
@@ -682,77 +678,73 @@ uint16 DisplayMan::textHeight(TextFont *tf) {
  * Draws the text to the screen.
  */
 void DisplayMan::text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numchars) {
-	byte *VGATop, *VGACur, *VGATemp, *VGATempLine, *cdata;
-	uint32 RealOffset, SegmentOffset;
-	int32 templeft, LeftInSegment;
-	uint16 bwidth, mask, curpage, data;
-
-	VGATop = getCurrentDrawingBuffer();
+	byte *vgaTop = getCurrentDrawingBuffer();
 
 	for (uint16 i = 0; i < numchars; i++) {
-		RealOffset = (_screenWidth * y) + x;
-		curpage    = RealOffset / _screenBytesPerPage;
-		SegmentOffset = RealOffset - (curpage * _screenBytesPerPage);
-		LeftInSegment = _screenBytesPerPage - SegmentOffset;
-		VGACur = VGATop + SegmentOffset;
+		uint32 realOffset = (_screenWidth * y) + x;
+		uint16 curpage    = realOffset / _screenBytesPerPage;
+		uint32 segmentOffset = realOffset - (curpage * _screenBytesPerPage);
+		int32 leftInSegment = _screenBytesPerPage - segmentOffset;
+		byte *vgaCur = vgaTop + segmentOffset;
 
 		if (tf->_widths[(uint)*text]) {
-			cdata = tf->_data + tf->_offsets[(uint)*text];
-			bwidth = *cdata++;
-			VGATemp = VGACur;
-			VGATempLine = VGACur;
+			byte *cdata = tf->_data + tf->_offsets[(uint)*text];
+			uint16 bwidth = *cdata++;
+			byte *vgaTemp = vgaCur;
+			byte *vgaTempLine = vgaCur;
 
 			for (uint16 rows = 0; rows < tf->_height; rows++) {
-				VGATemp = VGATempLine;
-				templeft = LeftInSegment;
+				int32 templeft = leftInSegment;
+
+				vgaTemp = vgaTempLine;
 
 				for (uint16 cols = 0; cols < bwidth; cols++) {
-					data = *cdata++;
+					uint16 data = *cdata++;
 
 					if (data && (templeft >= 8)) {
 						for (int j = 7; j >= 0; j--) {
 							if ((1 << j) & data)
-								*VGATemp = color;
-							VGATemp++;
+								*vgaTemp = color;
+							vgaTemp++;
 						}
 
 						templeft -= 8;
 					} else if (data) {
-						mask = 0x80;
-						templeft = LeftInSegment;
+						uint16 mask = 0x80;
+						templeft = leftInSegment;
 
 						for (uint16 counterb = 0; counterb < 8; counterb++) {
 							if (templeft <= 0) {
 								curpage++;
-								VGATemp = (byte *)(VGATop - templeft);
+								vgaTemp = (byte *)(vgaTop - templeft);
 								// Set up VGATempLine for next line
-								VGATempLine -= _screenBytesPerPage;
+								vgaTempLine -= _screenBytesPerPage;
 								// Set up LeftInSegment for next line
-								LeftInSegment += _screenBytesPerPage + templeft;
+								leftInSegment += _screenBytesPerPage + templeft;
 								templeft += _screenBytesPerPage;
 							}
 
 							if (mask & data)
-								*VGATemp = color;
+								*vgaTemp = color;
 
-							VGATemp++;
+							vgaTemp++;
 
 							mask = mask >> 1;
 							templeft--;
 						}
 					} else {
 						templeft -= 8;
-						VGATemp += 8;
+						vgaTemp += 8;
 					}
 				}
 
-				VGATempLine += _screenWidth;
-				LeftInSegment -= _screenWidth;
+				vgaTempLine += _screenWidth;
+				leftInSegment -= _screenWidth;
 
-				if (LeftInSegment <= 0) {
+				if (leftInSegment <= 0) {
 					curpage++;
-					VGATempLine -= _screenBytesPerPage;
-					LeftInSegment += _screenBytesPerPage;
+					vgaTempLine -= _screenBytesPerPage;
+					leftInSegment += _screenBytesPerPage;
 				}
 			}
 		}
@@ -861,8 +853,6 @@ void DisplayMan::copyPage(uint16 width, uint16 height, uint16 nheight, uint16 st
  * Scrolls the display to a new picture from a black screen.
  */
 void DisplayMan::doScrollWipe(char *filename) {
-	uint16 startLine = 0, onRow = 0;
-
 	_vm->_event->mouseHide();
 	uint16 width = _vm->_utils->vgaScaleX(320);
 	uint16 height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
@@ -879,6 +869,7 @@ void DisplayMan::doScrollWipe(char *filename) {
 	_vm->_music->updateMusic();
 	uint16 by = _vm->_utils->vgaScaleX(3);
 	uint16 nheight = height;
+	uint16 startLine = 0, onRow = 0;
 
 	while (onRow < _vm->_anim->_headerdata._height) {
 		_vm->_music->updateMusic();
@@ -962,7 +953,7 @@ void DisplayMan::doScrollBounce() {
  * Does the transporter wipe.
  */
 void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, char *filename) {
-	uint16 lastY, curY, linesDone = 0, linesLast;
+	uint16 lastY, linesLast;
 
 	if (_vm->_isHiRes) {
 		linesLast = 3;
@@ -972,9 +963,11 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, char *filename) {
 		lastY = 148;
 	}
 
+	uint16 linesDone = 0;
+
 	for (uint16 j = 0; j < 2; j++) {
 		for (uint16 i = 0; i < 2; i++) {
-			curY = i * 2;
+			uint16 curY = i * 2;
 
 			while (curY < lastY) {
 				if (linesDone >= linesLast) {
@@ -1019,7 +1012,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, char *filename) {
 
 	for (uint16 j = 0; j < 2; j++) {
 		for (uint16 i = 0; i < 2; i++) {
-			curY = i * 2;
+			uint16 curY = i * 2;
 
 			while (curY < lastY) {
 				if (linesDone >= linesLast) {


Commit: a7d5ae6b4b172e3f098358a5fb70175ebff5f056
    https://github.com/scummvm/scummvm/commit/a7d5ae6b4b172e3f098358a5fb70175ebff5f056
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:34:04+01:00

Commit Message:
LAB: Converted ifs into switch()

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 552bdf8..892634b 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -865,7 +865,8 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 
 		buttonId--;
 
-		if (buttonId == 0) {
+		switch (buttonId) {
+		case 0:
 			interfaceOff();
 			_anim->stopDiff();
 			_curFileName = " ";
@@ -887,7 +888,10 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 				g_system->delayMillis(1000);
 			}
 			_graphics->screenUpdate();
-		} else if (buttonId == 1) {
+
+			break;
+
+		case 1:
 			if (!doUse(curInv)) {
 				uint16 oldActionMode = actionMode;
 				// Use button
@@ -901,7 +905,10 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 
 				_graphics->screenUpdate();
 			}
-		} else if (buttonId == 2) {
+
+			break;
+
+		case 2:
 			_mainDisplay = !_mainDisplay;
 
 			if ((curInv == 0) || (curInv > _numInv)) {
@@ -915,7 +922,10 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 				_nextFileName = getInvName(curInv);
 
 			_graphics->screenUpdate();
-		} else if (buttonId == 3) {
+
+			break;
+
+		case 3:
 			// Left button
 			decIncInv(&curInv, true);
 			lastInv = curInv;
@@ -923,7 +933,10 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 			drawRoomMessage(curInv, _closeDataPtr);
 
 			_graphics->screenUpdate();
-		} else if (buttonId == 4) {
+
+			break;
+
+		case 4:
 			// Right button
 			decIncInv(&curInv, false);
 			lastInv = curInv;
@@ -931,14 +944,20 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 			drawRoomMessage(curInv, _closeDataPtr);
 
 			_graphics->screenUpdate();
-		} else if (buttonId == 5) {
+
+			break;
+
+		case 5:
 			// bread crumbs
 			_breadCrumbs[0]._roomNum = 0;
 			_numCrumbs = 0;
 			_droppingCrumbs = true;
 			mayShowCrumbIndicator();
 			_graphics->screenUpdate();
-		} else if (buttonId == 6) {
+
+			break;
+
+		case 6:
 			// follow crumbs
 			if (_droppingCrumbs) {
 				if (_numCrumbs > 0) {
@@ -968,6 +987,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 					_graphics->screenUpdate();
 				}
 			}
+			break;
 		}
 	} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier) && _mainDisplay) {
 		interfaceOff();


Commit: ee73e5ca15d4ee317b66d48d55790f4758fce84a
    https://github.com/scummvm/scummvm/commit/ee73e5ca15d4ee317b66d48d55790f4758fce84a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:34:04+01:00

Commit Message:
LAB: Simplified code

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 892634b..a9d952f 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -717,7 +717,6 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 				wrkClosePtr = nullptr;
 				_closeDataPtr = nullptr;
 				mayShowCrumbIndicator();
-				_graphics->screenUpdate();
 			} else if (buttonId == 5) {
 				eatMessages();
 
@@ -738,7 +737,6 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 				drawRoomMessage(curInv, _closeDataPtr);
 
 				mayShowCrumbIndicator();
-				_graphics->screenUpdate();
 			} else {
 				uint16 oldActionMode = actionMode;
 				actionMode = buttonId;
@@ -750,13 +748,11 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 
 				if (buttonId <= 4)
 					drawStaticMessage(kTextTakeWhat + buttonId);
-				_graphics->screenUpdate();
 			}
 		} else if (buttonId == 9) {
 			doUse(kItemMap);
 
 			mayShowCrumbIndicator();
-			_graphics->screenUpdate();
 		} else if (buttonId >= 6) {
 			// Arrow Buttons
 			_closeDataPtr = nullptr;
@@ -779,7 +775,6 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 				forceDraw = true;
 
 				mayShowCrumbIndicator();
-				_graphics->screenUpdate();
 			} else if (buttonId == 7) {
 				uint16 oldRoomNum = _roomNum;
 
@@ -842,9 +837,9 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 				}
 
 				mayShowCrumbIndicator();
-				_graphics->screenUpdate();
 			}
 		}
+		_graphics->screenUpdate();
 	} else if ((msgClass == BUTTONUP) && _alternate) {
 		_anim->_doBlack = true;
 
@@ -887,8 +882,6 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 				_graphics->setPalette(initcolors, 8);
 				g_system->delayMillis(1000);
 			}
-			_graphics->screenUpdate();
-
 			break;
 
 		case 1:
@@ -902,10 +895,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 
 				drawStaticMessage(kTextUseOnWhat);
 				_mainDisplay = true;
-
-				_graphics->screenUpdate();
 			}
-
 			break;
 
 		case 2:
@@ -921,8 +911,6 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 			if ((curInv <= _numInv) && _conditions->in(curInv) && _inventory[curInv]._bitmapName)
 				_nextFileName = getInvName(curInv);
 
-			_graphics->screenUpdate();
-
 			break;
 
 		case 3:
@@ -931,9 +919,6 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 			lastInv = curInv;
 			_graphics->_doNotDrawMessage = false;
 			drawRoomMessage(curInv, _closeDataPtr);
-
-			_graphics->screenUpdate();
-
 			break;
 
 		case 4:
@@ -942,9 +927,6 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 			lastInv = curInv;
 			_graphics->_doNotDrawMessage = false;
 			drawRoomMessage(curInv, _closeDataPtr);
-
-			_graphics->screenUpdate();
-
 			break;
 
 		case 5:
@@ -953,8 +935,6 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 			_numCrumbs = 0;
 			_droppingCrumbs = true;
 			mayShowCrumbIndicator();
-			_graphics->screenUpdate();
-
 			break;
 
 		case 6:
@@ -977,18 +957,17 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 					interfaceOn();
 					_graphics->drawPanel();
 					drawRoomMessage(curInv, _closeDataPtr);
-					_graphics->screenUpdate();
 				} else {
 					_breadCrumbs[0]._roomNum = 0;
 					_droppingCrumbs = false;
 
 					// Need to hide indicator!!!!
 					mayShowCrumbIndicatorOff();
-					_graphics->screenUpdate();
 				}
 			}
 			break;
 		}
+		_graphics->screenUpdate();
 	} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier) && _mainDisplay) {
 		interfaceOff();
 		_mainDisplay = true;


Commit: abb3e233bf334cda003a3831430e8b9c1e4d3e5c
    https://github.com/scummvm/scummvm/commit/abb3e233bf334cda003a3831430e8b9c1e4d3e5c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:34:04+01:00

Commit Message:
LAB: More code simplification

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index a9d952f..1391af2 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -843,7 +843,8 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 	} else if ((msgClass == BUTTONUP) && _alternate) {
 		_anim->_doBlack = true;
 
-		if (buttonId == 0) {
+		switch (buttonId) {
+		case 0:
 			eatMessages();
 			_alternate = false;
 			_anim->_doBlack = true;
@@ -854,14 +855,9 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 			interfaceOn();
 			_graphics->drawPanel();
 			drawRoomMessage(curInv, _closeDataPtr);
+			break;
 
-			_graphics->screenUpdate();
-		}
-
-		buttonId--;
-
-		switch (buttonId) {
-		case 0:
+		case 1:
 			interfaceOff();
 			_anim->stopDiff();
 			_curFileName = " ";
@@ -884,7 +880,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 			}
 			break;
 
-		case 1:
+		case 2:
 			if (!doUse(curInv)) {
 				uint16 oldActionMode = actionMode;
 				// Use button
@@ -898,7 +894,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 			}
 			break;
 
-		case 2:
+		case 3:
 			_mainDisplay = !_mainDisplay;
 
 			if ((curInv == 0) || (curInv > _numInv)) {
@@ -913,7 +909,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 
 			break;
 
-		case 3:
+		case 4:
 			// Left button
 			decIncInv(&curInv, true);
 			lastInv = curInv;
@@ -921,7 +917,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 			drawRoomMessage(curInv, _closeDataPtr);
 			break;
 
-		case 4:
+		case 5:
 			// Right button
 			decIncInv(&curInv, false);
 			lastInv = curInv;
@@ -929,7 +925,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 			drawRoomMessage(curInv, _closeDataPtr);
 			break;
 
-		case 5:
+		case 6:
 			// bread crumbs
 			_breadCrumbs[0]._roomNum = 0;
 			_numCrumbs = 0;
@@ -937,7 +933,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 			mayShowCrumbIndicator();
 			break;
 
-		case 6:
+		case 7:
 			// follow crumbs
 			if (_droppingCrumbs) {
 				if (_numCrumbs > 0) {


Commit: 5848a20af28e978e0c0b70c0e2fb3433966ae5de
    https://github.com/scummvm/scummvm/commit/5848a20af28e978e0c0b70c0e2fb3433966ae5de
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:34:04+01:00

Commit Message:
LAB: Turned another chain of ifs into a switch statement

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 1391af2..2308db3 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -992,7 +992,8 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 			wrkClosePtr = nullptr;
 			eatMessages();
 
-			if (actionMode == 0) {
+			switch (actionMode) {
+			case 0:
 				// Take something.
 				if (doActionRule(Common::Point(curPos.x, curPos.y), actionMode, _roomNum, &_closeDataPtr))
 					_curFileName = _newFileName;
@@ -1004,7 +1005,12 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 					_curFileName = _newFileName;
 				else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 					drawStaticMessage(kTextNothing);
-			} else if ((actionMode == 1) || (actionMode == 2) || (actionMode == 3)) {
+
+				break;
+
+			case 1:
+			case 2:
+			case 3:
 				// Manipulate an object, Open up a "door" or Close a "door"
 				if (doActionRule(curPos, actionMode, _roomNum, &_closeDataPtr))
 					_curFileName = _newFileName;
@@ -1012,31 +1018,38 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 					if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 						drawStaticMessage(kTextNothing);
 				}
-			} else if (actionMode == 4) {
-				// Look at closeups
-				CloseDataPtr tmpClosePtr = _closeDataPtr;
-				setCurrentClose(curPos, &tmpClosePtr, true);
+				break;
 
-				if (_closeDataPtr == tmpClosePtr) {
-					if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
-						drawStaticMessage(kTextNothing);
-				} else if (tmpClosePtr->_graphicName) {
-					if (*(tmpClosePtr->_graphicName)) {
-						_anim->_doBlack = true;
-						_closeDataPtr = tmpClosePtr;
+			case 4: {
+					// Look at closeups
+					CloseDataPtr tmpClosePtr = _closeDataPtr;
+					setCurrentClose(curPos, &tmpClosePtr, true);
+
+					if (_closeDataPtr == tmpClosePtr) {
+						if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
+							drawStaticMessage(kTextNothing);
+					} else if (tmpClosePtr->_graphicName) {
+						if (*(tmpClosePtr->_graphicName)) {
+							_anim->_doBlack = true;
+							_closeDataPtr = tmpClosePtr;
+						} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
+							drawStaticMessage(kTextNothing);
 					} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 						drawStaticMessage(kTextNothing);
-				} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
-					drawStaticMessage(kTextNothing);
-			} else if ((actionMode == 5)  && _conditions->in(curInv)) {
-				// Use an item on something else
-				if (doOperateRule(curPos, curInv, &_closeDataPtr)) {
-					_curFileName = _newFileName;
+				}
+				break;
 
-					if (!_conditions->in(curInv))
-						decIncInv(&curInv, false);
-				} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
-					drawStaticMessage(kTextNothing);
+			case 5:
+				if (_conditions->in(curInv)) {
+					// Use an item on something else
+					if (doOperateRule(curPos, curInv, &_closeDataPtr)) {
+						_curFileName = _newFileName;
+
+						if (!_conditions->in(curInv))
+							decIncInv(&curInv, false);
+					} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
+						drawStaticMessage(kTextNothing);
+				}
 			}
 		}
 


Commit: 1120958dac976fcd6634e4001af17fabbf6fd1b5
    https://github.com/scummvm/scummvm/commit/1120958dac976fcd6634e4001af17fabbf6fd1b5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:34:04+01:00

Commit Message:
LAB: Removed useless condition

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 2308db3..f101c74 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -745,9 +745,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 					perFlipButton(oldActionMode);
 
 				perFlipButton(actionMode);
-
-				if (buttonId <= 4)
-					drawStaticMessage(kTextTakeWhat + buttonId);
+				drawStaticMessage(kTextTakeWhat + buttonId);
 			}
 		} else if (buttonId == 9) {
 			doUse(kItemMap);


Commit: cbf4c876e52300cf1a8d54a166ceed3bebeb3016
    https://github.com/scummvm/scummvm/commit/cbf4c876e52300cf1a8d54a166ceed3bebeb3016
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:34:04+01:00

Commit Message:
LAB: Turned another if chain into switch

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index f101c74..51b20a7 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -709,7 +709,14 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 			_graphics->screenUpdate();
 		}
 	} else if ((msgClass == BUTTONUP) && !_alternate) {
-		if (buttonId <= 5) {
+		uint16 newDir;
+
+		switch (buttonId) {
+		case 0:
+		case 1:
+		case 2:
+		case 3:
+		case 4:
 			if ((actionMode == 4) && (buttonId == 4) && _closeDataPtr) {
 				doMainView(&_closeDataPtr);
 
@@ -717,26 +724,6 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 				wrkClosePtr = nullptr;
 				_closeDataPtr = nullptr;
 				mayShowCrumbIndicator();
-			} else if (buttonId == 5) {
-				eatMessages();
-
-				_alternate = true;
-				_anim->_doBlack = true;
-				_graphics->_doNotDrawMessage = false;
-				// Sets the correct button list
-				interfaceOn();
-				_mainDisplay = false;
-
-				if (lastInv && _conditions->in(lastInv)) {
-					curInv = lastInv;
-					_nextFileName = getInvName(curInv);
-				} else
-					decIncInv(&curInv, false);
-
-				_graphics->drawPanel();
-				drawRoomMessage(curInv, _closeDataPtr);
-
-				mayShowCrumbIndicator();
 			} else {
 				uint16 oldActionMode = actionMode;
 				actionMode = buttonId;
@@ -747,95 +734,123 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 				perFlipButton(actionMode);
 				drawStaticMessage(kTextTakeWhat + buttonId);
 			}
-		} else if (buttonId == 9) {
+			break;
+		case 5:
+			eatMessages();
+
+			_alternate = true;
+			_anim->_doBlack = true;
+			_graphics->_doNotDrawMessage = false;
+			// Sets the correct button list
+			interfaceOn();
+			_mainDisplay = false;
+
+			if (lastInv && _conditions->in(lastInv)) {
+				curInv = lastInv;
+				_nextFileName = getInvName(curInv);
+			} else
+				decIncInv(&curInv, false);
+
+			_graphics->drawPanel();
+			drawRoomMessage(curInv, _closeDataPtr);
+
+			mayShowCrumbIndicator();
+			break;
+
+		case 9:
 			doUse(kItemMap);
 
 			mayShowCrumbIndicator();
-		} else if (buttonId >= 6) {
+			break;
+
+		case 6:
+		case 8:
 			// Arrow Buttons
 			_closeDataPtr = nullptr;
 			wrkClosePtr = nullptr;
+			if (buttonId == 6)
+				drawStaticMessage(kTextTurnLeft);
+			else
+				drawStaticMessage(kTextTurnRight);
 
-			if ((buttonId == 6) || (buttonId == 8)) {
-				if (buttonId == 6)
-					drawStaticMessage(kTextTurnLeft);
-				else
-					drawStaticMessage(kTextTurnRight);
+			_curFileName = " ";
 
-				_curFileName = " ";
+			oldDirection = _direction;
 
-				oldDirection = _direction;
+			newDir = processArrow(_direction, buttonId - 6);
+			doTurn(_direction, newDir, &_closeDataPtr);
+			_anim->_doBlack = true;
+			_direction = newDir;
+			forceDraw = true;
 
-				uint16 newDir = processArrow(_direction, buttonId - 6);
-				doTurn(_direction, newDir, &_closeDataPtr);
-				_anim->_doBlack = true;
-				_direction = newDir;
-				forceDraw = true;
+			mayShowCrumbIndicator();
+			break;
 
-				mayShowCrumbIndicator();
-			} else if (buttonId == 7) {
-				uint16 oldRoomNum = _roomNum;
+		case 7:
+			_closeDataPtr = nullptr;
+			wrkClosePtr = nullptr;
+			uint16 oldRoomNum = _roomNum;
 
-				if (doGoForward(&_closeDataPtr)) {
-					if (oldRoomNum == _roomNum)
-						_anim->_doBlack = true;
+			if (doGoForward(&_closeDataPtr)) {
+				if (oldRoomNum == _roomNum)
+					_anim->_doBlack = true;
+			} else {
+				_anim->_doBlack = true;
+				_direction = processArrow(_direction, buttonId - 6);
+
+				if (oldRoomNum != _roomNum) {
+					drawStaticMessage(kTextGoForward);
+					// Potentially entered a new room
+					_roomsFound->inclElement(_roomNum);
+					_curFileName = " ";
+					forceDraw = true;
 				} else {
 					_anim->_doBlack = true;
-					_direction = processArrow(_direction, buttonId - 6);
-
-					if (oldRoomNum != _roomNum) {
-						drawStaticMessage(kTextGoForward);
-						// Potentially entered a new room
-						_roomsFound->inclElement(_roomNum);
-						_curFileName = " ";
-						forceDraw = true;
-					} else {
-						_anim->_doBlack = true;
-						drawStaticMessage(kTextNoPath);
-					}
+					drawStaticMessage(kTextNoPath);
 				}
+			}
 
-				if (_followingCrumbs) {
-					if (_isCrumbTurning) {
-						if (_direction == oldDirection) {
-							_followingCrumbs = false;
-						}
-					} else {
-						if (_roomNum == oldRoomNum) { // didn't get there?
-							_followingCrumbs = false;
-						}
+			if (_followingCrumbs) {
+				if (_isCrumbTurning) {
+					if (_direction == oldDirection) {
+						_followingCrumbs = false;
 					}
-				} else if (_droppingCrumbs && oldRoomNum != _roomNum) {
-					// If in surreal maze, turn off DroppingCrumbs.
-					if (_roomNum >= 245 && _roomNum <= 280) {
+				} else {
+					if (_roomNum == oldRoomNum) { // didn't get there?
 						_followingCrumbs = false;
-						_droppingCrumbs = false;
-						_numCrumbs = 0;
-						_breadCrumbs[0]._roomNum = 0;
-					} else {
-						bool intersect = false;
-						for (int idx = 0; idx < _numCrumbs; idx++) {
-							if (_breadCrumbs[idx]._roomNum == _roomNum) {
-								_numCrumbs = idx + 1;
-								_breadCrumbs[_numCrumbs]._roomNum = 0;
-								intersect = true;
-							}
+					}
+				}
+			} else if (_droppingCrumbs && oldRoomNum != _roomNum) {
+				// If in surreal maze, turn off DroppingCrumbs.
+				if (_roomNum >= 245 && _roomNum <= 280) {
+					_followingCrumbs = false;
+					_droppingCrumbs = false;
+					_numCrumbs = 0;
+					_breadCrumbs[0]._roomNum = 0;
+				} else {
+					bool intersect = false;
+					for (int idx = 0; idx < _numCrumbs; idx++) {
+						if (_breadCrumbs[idx]._roomNum == _roomNum) {
+							_numCrumbs = idx + 1;
+							_breadCrumbs[_numCrumbs]._roomNum = 0;
+							intersect = true;
 						}
+					}
 
-						if (!intersect) {
-							if (_numCrumbs == MAX_CRUMBS) {
-								_numCrumbs = MAX_CRUMBS - 1;
-								memcpy(&_breadCrumbs[0], &_breadCrumbs[1], _numCrumbs * sizeof _breadCrumbs[0]);
-							}
-
-							_breadCrumbs[_numCrumbs]._roomNum = _roomNum;
-							_breadCrumbs[_numCrumbs++]._direction = _direction;
+					if (!intersect) {
+						if (_numCrumbs == MAX_CRUMBS) {
+							_numCrumbs = MAX_CRUMBS - 1;
+							memcpy(&_breadCrumbs[0], &_breadCrumbs[1], _numCrumbs * sizeof _breadCrumbs[0]);
 						}
+
+						_breadCrumbs[_numCrumbs]._roomNum = _roomNum;
+						_breadCrumbs[_numCrumbs++]._direction = _direction;
 					}
 				}
-
-				mayShowCrumbIndicator();
 			}
+
+			mayShowCrumbIndicator();
+			break;
 		}
 		_graphics->screenUpdate();
 	} else if ((msgClass == BUTTONUP) && _alternate) {


Commit: 21e6f40301f358e8c16b3ed6ff32698cc5be6e9c
    https://github.com/scummvm/scummvm/commit/21e6f40301f358e8c16b3ed6ff32698cc5be6e9c
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:04+01:00

Commit Message:
LAB: Fix a regression related to random number generation, some renaming

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/processroom.cpp
    engines/lab/utils.cpp
    engines/lab/utils.h



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 9aa1834..9a3d686 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -48,7 +48,7 @@ DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) {
 	_doNotDrawMessage = false;
 
 	_screenBytesPerPage = 65536;
-	_curapen = 0;
+	_curPen = 0;
 	_curBitmap = nullptr;
 	_displayBuffer = nullptr;
 	_currentDisplayBuffer = nullptr;
@@ -179,7 +179,7 @@ void DisplayMan::getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer
  * each line less than 255 characters.
  */
 uint32 DisplayMan::flowText(
-			void *font,            // the TextAttr pointer
+			TextFont *font,        // the TextAttr pointer
 			int16 spacing,         // How much vertical spacing between the lines
 			byte pencolor,         // pen number to use for text
 			byte backpen,          // the background color
@@ -200,7 +200,7 @@ uint32 DisplayMan::flowText(
 
 	setAPen(pencolor);
 
-	TextFont *msgFont = (TextFont *)font;
+	TextFont *msgFont = font;
 	uint16 fontheight = textHeight(msgFont) + spacing;
 	uint16 numlines   = (y2 - y1 + 1) / fontheight;
 	uint16 width      = x2 - x1 + 1;
@@ -242,7 +242,7 @@ uint32 DisplayMan::flowText(
 }
 
 uint32 DisplayMan::flowTextScaled(
-	void *font,                // the TextAttr pointer
+	TextFont *font,            // the TextAttr pointer
 	int16 spacing,             // How much vertical spacing between the lines
 	byte penColor,             // pen number to use for text
 	byte backPen,              // the background color
@@ -262,7 +262,7 @@ uint32 DisplayMan::flowTextScaled(
  * Calls flowText, but flows it to memory.  Same restrictions as flowText.
  */
 uint32 DisplayMan::flowTextToMem(Image *destIm,
-			void *font,            // the TextAttr pointer
+			TextFont *font,        // the TextAttr pointer
 			int16 spacing,         // How much vertical spacing between the lines
 			byte pencolor,         // pen number to use for text
 			byte backpen,          // the background color
@@ -470,8 +470,8 @@ void DisplayMan::setUpScreens() {
 /**
  * Sets the pen number to use on all the drawing operations.
  */
-void DisplayMan::setAPen(byte pennum) {
-	_curapen = pennum;
+void DisplayMan::setAPen(byte penNum) {
+	_curPen = penNum;
 }
 
 /**
@@ -495,7 +495,7 @@ void DisplayMan::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 			int ww = w;
 
 			while (ww-- > 0) {
-				*dd++ = _curapen;
+				*dd++ = _curPen;
 			}
 
 			d += _screenWidth;
@@ -567,7 +567,7 @@ void DisplayMan::setAmigaPal(uint16 *pal, uint16 numColors) {
 /**
  * Writes any number of the 256 color registers.
  * first:    the number of the first color register to write.
- * numreg:   the number of registers to write
+ * numReg:   the number of registers to write
  * buf:      a char pointer which contains the selected color registers.
  *           Each value representing a color register occupies 3 bytes in
  *           the array.  The order is red, green then blue.  The first byte
@@ -575,21 +575,19 @@ void DisplayMan::setAmigaPal(uint16 *pal, uint16 numColors) {
  *           The length of the buffer is 3 times the number of registers
  *           selected.
  */
-void DisplayMan::writeColorRegs(byte *buf, uint16 first, uint16 numreg) {
+void DisplayMan::writeColorRegs(byte *buf, uint16 first, uint16 numReg) {
 	byte tmp[256 * 3];
 
-	for (int i = 0; i < 256 * 3; i++) {
+	for (int i = 0; i < 256 * 3; i++)
 		tmp[i] = buf[i] * 4;
-	}
-
-	g_system->getPaletteManager()->setPalette(tmp, first, numreg);
 
-	memcpy(&(_curvgapal[first * 3]), buf, numreg * 3);
+	g_system->getPaletteManager()->setPalette(tmp, first, numReg);
+	memcpy(&(_curvgapal[first * 3]), buf, numReg * 3);
 }
 
-void DisplayMan::setPalette(void *cmap, uint16 numcolors) {
-	if (memcmp(cmap, _curvgapal, numcolors * 3) != 0)
-		writeColorRegs((byte *)cmap, 0, numcolors);
+void DisplayMan::setPalette(void *cmap, uint16 numColors) {
+	if (memcmp(cmap, _curvgapal, numColors * 3) != 0)
+		writeColorRegs((byte *)cmap, 0, numColors);
 }
 
 /**
@@ -605,7 +603,7 @@ byte *DisplayMan::getCurrentDrawingBuffer() {
 /**
  * Overlays a region on the screen using the desired pen color.
  */
-void DisplayMan::overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+void DisplayMan::overlayRect(uint16 penColor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	int w = x2 - x1 + 1;
 	int h = y2 - y1 + 1;
 
@@ -628,7 +626,7 @@ void DisplayMan::overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, u
 			}
 
 			while (ww > 0) {
-				*dd = pencolor;
+				*dd = penColor;
 				dd += 2;
 				ww -= 2;
 			}
@@ -642,24 +640,24 @@ void DisplayMan::overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, u
 /**
  * Closes a font and frees all memory associated with it.
  */
-void DisplayMan::closeFont(TextFont *tf) {
-	if (tf) {
-		if (tf->_data && tf->_dataLength)
-			delete[] tf->_data;
+void DisplayMan::closeFont(TextFont *font) {
+	if (font) {
+		if (font->_data && font->_dataLength)
+			delete[] font->_data;
 
-		delete tf;
+		delete font;
 	}
 }
 
 /**
  * Returns the length of a text in the specified font.
  */
-uint16 DisplayMan::textLength(TextFont *tf, const char *text, uint16 numchars) {
+uint16 DisplayMan::textLength(TextFont *font, const char *text, uint16 numChars) {
 	uint16 length = 0;
 
-	if (tf) {
-		for (uint16 i = 0; i < numchars; i++) {
-			length += tf->_widths[(uint)*text];
+	if (font) {
+		for (uint16 i = 0; i < numChars; i++) {
+			length += font->_widths[(uint)*text];
 			text++;
 		}
 	}
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index 8b77dc8..7ed2e67 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -64,7 +64,7 @@ private:
 	uint16 fadeNumOut(uint16 num, uint16 res, uint16 counter);
 	void getWord(char *wordBuffer, const char *mainBuffer, uint16 *wordWidth);
 
-	byte _curapen;
+	byte _curPen;
 	byte *_curBitmap;
 	byte _curvgapal[256 * 3];
 
@@ -94,58 +94,58 @@ public:
 	void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void rectFillScaled(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	// Window text stuff
-	uint32 flowText(void *font,	// the TextAttr pointer
-				int16 spacing,				// How much vertical spacing between the lines
-				byte pencolor,				// pen number to use for text
-				byte backpen,					// the background color
-				bool fillback,				// Whether to fill the background
-				bool centerh,					// Whether to center the text horizontally
-				bool centerv,					// Whether to center the text vertically
-				bool output,					// Whether to output any text
+	uint32 flowText(TextFont *font,		// the TextAttr pointer
+				int16 spacing,			// How much vertical spacing between the lines
+				byte pencolor,			// pen number to use for text
+				byte backpen,			// the background color
+				bool fillback,			// Whether to fill the background
+				bool centerh,			// Whether to center the text horizontally
+				bool centerv,			// Whether to center the text vertically
+				bool output,			// Whether to output any text
 				uint16 x1, uint16 y1,	// Cords
 				uint16 x2, uint16 y2,
 				const char *text);		// The text itself
 
 	uint32 flowTextScaled(
-				void *font,						// the TextAttr pointer
-				int16 spacing,				// How much vertical spacing between the lines
-				byte pencolor,				// pen number to use for text
-				byte backpen,					// the background color
-				bool fillback,				// Whether to fill the background
-				bool centerh,					// Whether to center the text horizontally
-				bool centerv,					// Whether to center the text vertically
-				bool output,					// Whether to output any text
+				TextFont *font,			// the TextAttr pointer
+				int16 spacing,			// How much vertical spacing between the lines
+				byte pencolor,			// pen number to use for text
+				byte backpen,			// the background color
+				bool fillback,			// Whether to fill the background
+				bool centerh,			// Whether to center the text horizontally
+				bool centerv,			// Whether to center the text vertically
+				bool output,			// Whether to output any text
 				uint16 x1, uint16 y1,	// Cords
 				uint16 x2, uint16 y2,
 				const char *text);		// The text itself
 
 	uint32 flowTextToMem(Image *destIm,
-				void *font,						// the TextAttr pointer
-				int16 spacing,				// How much vertical spacing between the lines
-				byte pencolor,				// pen number to use for text
-				byte backpen,					// the background color
-				bool fillback,				// Whether to fill the background
-				bool centerh,					// Whether to center the text horizontally
-				bool centerv,					// Whether to center the text vertically
-				bool output,					// Whether to output any text
+				TextFont *font,			// the TextAttr pointer
+				int16 spacing,			// How much vertical spacing between the lines
+				byte pencolor,			// pen number to use for text
+				byte backpen,			// the background color
+				bool fillback,			// Whether to fill the background
+				bool centerh,			// Whether to center the text horizontally
+				bool centerv,			// Whether to center the text vertically
+				bool output,			// Whether to output any text
 				uint16 x1, uint16 y1,	// Cords
 				uint16 x2, uint16 y2,
-				const char *str);			// The text itself
+				const char *str);		// The text itself
 
 	void drawHLine(uint16 x, uint16 y1, uint16 y2);
 	void drawVLine(uint16 x1, uint16 y, uint16 x2);
 	void screenUpdate();
-	void createScreen(bool HiRes);
+	void createScreen(bool hiRes);
 	void setAmigaPal(uint16 *pal, uint16 numColors);
-	void writeColorRegs(byte *buf, uint16 first, uint16 numreg);
-	void setPalette(void *cmap, uint16 numcolors);
-	void overlayRect(uint16 pencolor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void writeColorRegs(byte *buf, uint16 first, uint16 numReg);
+	void setPalette(void *cmap, uint16 numColors);
+	void overlayRect(uint16 penColor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	byte *getCurrentDrawingBuffer();
 	void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer);
 	void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer);
 	void fade(bool fadein, uint16 res);
-	void closeFont(TextFont *tf);
-	uint16 textLength(TextFont *tf, const char *text, uint16 numchars);
+	void closeFont(TextFont *font);
+	uint16 textLength(TextFont *font, const char *text, uint16 numChars);
 	uint16 textHeight(TextFont *tf);
 	void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numchars);
 	void getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer, uint16 lineWidth);
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 1decad0..016dd72 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -48,7 +48,7 @@
 
 namespace Lab {
 LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
- : Engine(syst), _gameDescription(gameDesc), _extraGameFeatures(0), _rnd("lab") {
+ : Engine(syst), _gameDescription(gameDesc), _extraGameFeatures(0) {
 	_lastWaitTOFTicks = 0;
 
 	_isHiRes = false;
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 756f6e1..322a921 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -136,7 +136,6 @@ private:
 	Image *_journalBackImage;
 	Image *_screenImage;
 	TextFont *_journalFont;
-	Common::RandomSource _rnd;
 
 public:
 	bool _alternate;
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index e95b676..dc1b149 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -359,7 +359,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 		case SHOWMESSAGES: {
 				char **str = (char **)actionList->_data;
 				_graphics->_doNotDrawMessage = false;
-				_graphics->drawMessage(str[_rnd.getRandomNumber(actionList->_param1)]);
+				_graphics->drawMessage(str[_utils->getRandom(actionList->_param1)]);
 				_graphics->_doNotDrawMessage = true;
 			}
 			break;
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index ec69d81..f20a42c 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -34,7 +34,7 @@
 #include "lab/utils.h"
 
 namespace Lab {
-Utils::Utils(LabEngine *vm) : _vm(vm) {
+Utils::Utils(LabEngine *vm) : _vm(vm), _rnd("lab") {
 	_dataBytesPerRow = 0;
 }
 
@@ -427,4 +427,10 @@ void Utils::setBytesPerRow(int num) {
 	_dataBytesPerRow = num;
 }
 
+uint16 Utils::getRandom(uint16 max) {
+	if (max > 1)
+		return _rnd.getRandomNumber(max - 1);
+	else
+		return 0;
+}
 } // End of namespace Lab
diff --git a/engines/lab/utils.h b/engines/lab/utils.h
index b0aa58f..0c4118e 100644
--- a/engines/lab/utils.h
+++ b/engines/lab/utils.h
@@ -40,13 +40,15 @@ private:
 
 	void unDiffByteByte(byte *dest, byte *diff);
 	void unDiffByteWord(uint16 *dest, uint16 *diff);
-	void VUnDiffByteByte(byte *Dest, byte *diff, uint16 bytesperrow);
-	void VUnDiffByteWord(uint16 *Dest, uint16 *diff, uint16 bytesperrow);
-	void VUnDiffByteLong(uint32 *Dest, uint32 *diff, uint16 bytesperrow);
+	void VUnDiffByteByte(byte *dest, byte *diff, uint16 bytesPerRow);
+	void VUnDiffByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow);
+	void VUnDiffByteLong(uint32 *dest, uint32 *diff, uint16 bytesPerRow);
 
 public:
 	Utils(LabEngine *vm);
 
+	Common::RandomSource _rnd;
+
 	uint16 scaleX(uint16 x);
 	uint16 scaleY(uint16 y);
 	int16 vgaScaleX(int16 x);
@@ -55,10 +57,11 @@ public:
 	uint16 mapScaleX(uint16 x);
 	uint16 mapScaleY(uint16 y);
 	Common::Point vgaUnscale(Common::Point pos);
-	void unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesperrow, bool isV);
+	void unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesPerRow, bool isV);
 	void runLengthDecode(byte *dest, byte *source);
 	void VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow);
 	void setBytesPerRow(int num);
+	uint16 getRandom(uint16 max);
 };
 
 


Commit: 1d027704e0b3f75fa176d64a77f4744dd1ea3ee5
    https://github.com/scummvm/scummvm/commit/1d027704e0b3f75fa176d64a77f4744dd1ea3ee5
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:05+01:00

Commit Message:
LAB: Fix mouse cursor after save/load

Changed paths:
    engines/lab/savegame.cpp



diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 957bfdb..99382e9 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -39,6 +39,7 @@
 
 #include "lab/lab.h"
 #include "lab/dispman.h"
+#include "lab/eventman.h"
 #include "lab/labsets.h"
 #include "lab/music.h"
 #include "lab/processroom.h"
@@ -122,7 +123,6 @@ bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
  * Writes the game out to disk.
  */
 bool LabEngine::saveGame(int slot, Common::String desc) {
-	uint16 i;
 	Common::String fileName = generateSaveFileName(slot);
 	Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
 	Common::OutSaveFile *file = saveFileManager->openForSaving(fileName);
@@ -140,17 +140,17 @@ bool LabEngine::saveGame(int slot, Common::String desc) {
 	file->writeUint16LE(getQuarters());
 
 	// Conditions
-	for (i = 0; i < _conditions->_lastElement / (8 * 2); i++)
+	for (int i = 0; i < _conditions->_lastElement / (8 * 2); i++)
 		file->writeUint16LE(_conditions->_array[i]);
 
 	// Rooms found
-	for (i = 0; i < _roomsFound->_lastElement / (8 * 2); i++)
+	for (int i = 0; i < _roomsFound->_lastElement / (8 * 2); i++)
 		file->writeUint16LE(_roomsFound->_array[i]);
 
 	_tilePuzzle->save(file);
 
 	// Breadcrumbs
-	for (i = 0; i < sizeof(_breadCrumbs); i++) {
+	for (int i = 0; i < sizeof(_breadCrumbs); i++) {
 		file->writeUint16LE(_breadCrumbs[i]._roomNum);
 		file->writeUint16LE(_breadCrumbs[i]._direction);
 	}
@@ -245,6 +245,7 @@ bool LabEngine::saveRestoreGame() {
 
 	_alternate = false;
 	_mainDisplay = true;
+	_event->initMouse();
 	_graphics->screenUpdate();
 
 	return isOK;


Commit: 167d9c48a3d72c923616f18759b1ab7860e59a7d
    https://github.com/scummvm/scummvm/commit/167d9c48a3d72c923616f18759b1ab7860e59a7d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:34:05+01:00

Commit Message:
LAB: Reduced scope of a few more variables

Changed paths:
    engines/lab/resource.cpp
    engines/lab/savegame.cpp
    engines/lab/special.cpp
    engines/lab/tilepuzzle.cpp



diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index cb29bc6..8b7d26f 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -251,7 +251,6 @@ Action *Resource::readAction(Common::File *file) {
 	Action *action = NULL;
 	Action *prev = NULL;
 	Action *head = NULL;
-	char **messages;
 
 	do {
 		c = file->readByte();
@@ -268,7 +267,7 @@ Action *Resource::readAction(Common::File *file) {
 			action->_param3 = file->readSint16LE();
 
 			if (action->_actionType == SHOWMESSAGES) {
-				messages = (char **)malloc(action->_param1 * 4);
+				char **messages = (char **)malloc(action->_param1 * 4);
 
 				for (int i = 0; i < action->_param1; i++)
 					messages[i] = readString(file);
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 99382e9..d08dcbc 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -166,7 +166,6 @@ bool LabEngine::saveGame(int slot, Common::String desc) {
  * Reads the game from disk.
  */
 bool LabEngine::loadGame(int slot) {
-	uint16 i;
 	Common::String fileName = generateSaveFileName(slot);
 	Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
 	Common::InSaveFile *file = saveFileManager->openForLoading(fileName);
@@ -181,17 +180,17 @@ bool LabEngine::loadGame(int slot) {
 	setQuarters(file->readUint16LE());
 
 	// Conditions
-	for (i = 0; i < _conditions->_lastElement / (8 * 2); i++)
+	for (uint16 i = 0; i < _conditions->_lastElement / (8 * 2); i++)
 		_conditions->_array[i] = file->readUint16LE();
 
 	// Rooms found
-	for (i = 0; i < _roomsFound->_lastElement / (8 * 2); i++)
+	for (uint16 i = 0; i < _roomsFound->_lastElement / (8 * 2); i++)
 		_roomsFound->_array[i] = file->readUint16LE();
 
 	_tilePuzzle->load(file);
 
 	// Breadcrumbs
-	for (i = 0; i < 128; i++) {
+	for (uint16 i = 0; i < 128; i++) {
 		_breadCrumbs[i]._roomNum = file->readUint16LE();
 		_breadCrumbs[i]._direction = file->readUint16LE();
 	}
@@ -199,7 +198,7 @@ bool LabEngine::loadGame(int slot) {
 	_droppingCrumbs = (_breadCrumbs[0]._roomNum != 0);
 	_followingCrumbs = false;
 
-	for (i = 0; i < 128; i++) {
+	for (uint16 i = 0; i < 128; i++) {
 		if (_breadCrumbs[i]._roomNum == 0)
 			break;
 		_numCrumbs = i;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 65a4a9d..6fc8636 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -228,7 +228,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 	if (wipenum == 0)
 		_journalBackImage->blitBitmap(0, 0, _screenImage, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight, false);
 	else
-		turnPage((bool)(wipenum == 1));
+		turnPage((wipenum == 1));
 
 	Button *backButton = _event->getButton(0);
 	Button *forwardButton = _event->getButton(2);
@@ -329,7 +329,7 @@ void LabEngine::doJournal() {
  * Draws the text for the monitor.
  */
 void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) {
-	uint16 drawingToPage = 0, yspacing = 0, numlines, fheight;
+	uint16 drawingToPage = 0, yspacing = 0;
 	int32 charsDrawn    = 0L;
 	char *curText = text;
 
@@ -337,12 +337,12 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
 
 	if (*text == '%') {
 		text++;
-		numlines = (*text - '0') * 10;
+		uint16 numlines = (*text - '0') * 10;
 		text++;
 		numlines += (*text - '0');
 		text += 2;
 
-		fheight = _graphics->textHeight(monitorFont);
+		uint16 fheight = _graphics->textHeight(monitorFont);
 		x1 = _monitorButton->_width + _utils->vgaScaleX(3);
 		_monitorButtonHeight = _monitorButton->_height + _utils->vgaScaleY(3);
 
@@ -389,7 +389,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
  * Processes user input.
  */
 void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isInteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	const char *test = " ", *startFileName = _monitorTextFilename;
+	const char *startFileName = _monitorTextFilename;
 	CloseDataPtr startClosePtr = _closeDataPtr, lastClosePtr[10];
 	uint16 depth = 0;
 
@@ -400,6 +400,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 			if (_closeDataPtr == NULL)
 				_closeDataPtr = startClosePtr;
 
+			const char *test;
 			if (_closeDataPtr == startClosePtr)
 				test = startFileName;
 			else
@@ -433,7 +434,6 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) ||
 				  ((msgClass == RAWKEY) && (code == 27)))
 				return;
-
 			else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) {
 				if ((mouseY >= _utils->vgaScaleY(171)) && (mouseY <= _utils->vgaScaleY(200))) {
 					if ((mouseX >= _utils->vgaScaleX(259)) && (mouseX <= _utils->vgaScaleX(289))) {
@@ -481,8 +481,6 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
  * Does what's necessary for the monitor.
  */
 void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	char *ntext;
-
 	x1 = _utils->vgaScaleX(x1);
 	x2 = _utils->vgaScaleX(x2);
 	y1 = _utils->vgaScaleY(y1);
@@ -506,7 +504,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 	_monitorButton = new Image(buttonFile, this);
 	delete buttonFile;
 
-	ntext = _resource->getText(textfile);
+	char *ntext = _resource->getText(textfile);
 	_graphics->loadBackPict(background, _highPalette);
 	drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
 	_event->mouseShow();
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index 1e227d3..37cc031 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -89,7 +89,7 @@ TilePuzzle::~TilePuzzle() {
 	for (int i = 0; i < 16; i++)
 		delete _tiles[i];
 
-	for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++) {
+	for (int imgIdx = 0; imgIdx < 10; imgIdx++) {
 		delete _numberImages[imgIdx];
 		_numberImages[imgIdx] = nullptr;
 	}
@@ -253,8 +253,6 @@ void TilePuzzle::doTile(bool showsolution) {
  * Reads in a backdrop picture.
  */
 void TilePuzzle::showTile(const char *filename, bool showSolution) {
-	uint16 start = showSolution ? 0 : 1;
-
 	_vm->_anim->_doBlack = true;
 	_vm->_anim->_noPalChange = true;
 	_vm->_graphics->readPict(filename, true);
@@ -263,7 +261,9 @@ void TilePuzzle::showTile(const char *filename, bool showSolution) {
 
 	Common::File *tileFile = _vm->_resource->openDataFile(showSolution ? "P:TileSolution" : "P:Tile");
 
-	for (uint16 curBit = start; curBit < 16; curBit++)
+	int start = showSolution ? 0 : 1;
+
+	for (int curBit = start; curBit < 16; curBit++)
 		_tiles[curBit] = new Image(tileFile, _vm);
 
 	delete tileFile;
@@ -277,7 +277,7 @@ void TilePuzzle::showTile(const char *filename, bool showSolution) {
  */
 void TilePuzzle::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 	int16 dX = 0, dY = 0, dx = 0, dy = 0, sx = 0, sy = 0;
-	uint16 last = 0;
+	int last = 0;
 
 	if (scrolltype == kScrollLeft) {
 		dX = _vm->_utils->vgaScaleX(5);
@@ -306,7 +306,7 @@ void TilePuzzle::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 
 	byte *buffer = new byte[_tiles[1]->_width * _tiles[1]->_height * 2L];
 
-	for (uint16 i = 0; i < last; i++) {
+	for (int i = 0; i < last; i++) {
 		_vm->waitTOF();
 		scrollRaster(dX, dY, x1, y1, x1 + _vm->_utils->vgaScaleX(28) + sx, y1 + _vm->_utils->vgaScaleY(23) + sy, buffer);
 		x1 += dX;
@@ -323,15 +323,13 @@ void TilePuzzle::changeCombination(uint16 number) {
 	const int solution[6] = { 0, 4, 0, 8, 7, 2 };
 
 	Image display(_vm);
-	uint16 combnum;
-	bool unlocked = true;
 
 	if (_combination[number] < 9)
 		(_combination[number])++;
 	else
 		_combination[number] = 0;
 
-	combnum = _combination[number];
+	uint16 combnum = _combination[number];
 
 	display._imageData = _vm->_graphics->getCurrentDrawingBuffer();
 	display._width     = _vm->_graphics->_screenWidth;
@@ -353,7 +351,8 @@ void TilePuzzle::changeCombination(uint16 number) {
 
 	delete[] buffer;
 
-	for (uint16 i = 0; i < 6; i++)
+	bool unlocked = true;
+	for (int i = 0; i < 6; i++)
 		unlocked &= (_combination[i] == solution[i]);
 
 	if (unlocked)
@@ -374,7 +373,7 @@ void TilePuzzle::scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x
  * Draws the images of the combination lock to the display bitmap.
  */
 void TilePuzzle::doCombination() {
-	for (uint16 i = 0; i <= 5; i++)
+	for (int i = 0; i <= 5; i++)
 		_numberImages[_combination[i]]->drawImage(_vm->_utils->vgaScaleX(COMBINATION_X[i]), _vm->_utils->vgaScaleY(65));
 }
 
@@ -402,28 +401,24 @@ void TilePuzzle::showCombination(const char *filename) {
 }
 
 void TilePuzzle::save(Common::OutSaveFile *file) {
-	uint16 i, j;
-
 	// Combination lock and tile stuff
-	for (i = 0; i < 6; i++)
+	for (int i = 0; i < 6; i++)
 		file->writeByte(_combination[i]);
 
 	// Tiles
-	for (i = 0; i < 4; i++)
-		for (j = 0; j < 4; j++)
+	for (int i = 0; i < 4; i++)
+		for (int j = 0; j < 4; j++)
 			file->writeUint16LE(_curTile[i][j]);
 }
 
 void TilePuzzle::load(Common::InSaveFile *file) {
-	uint16 i, j;
-
 	// Combination lock and tile stuff
-	for (i = 0; i < 6; i++)
+	for (int i = 0; i < 6; i++)
 		_combination[i] = file->readByte();
 
 	// Tiles
-	for (i = 0; i < 4; i++)
-		for (j = 0; j < 4; j++)
+	for (int i = 0; i < 4; i++)
+		for (int j = 0; j < 4; j++)
 			_curTile[i][j] = file->readUint16LE();
 }
 


Commit: acaece288f4d6b903d1163d2906fa6d5c2ce84ad
    https://github.com/scummvm/scummvm/commit/acaece288f4d6b903d1163d2906fa6d5c2ce84ad
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2015-12-23T21:34:05+01:00

Commit Message:
LAB: More variable scope redux

Changed paths:
    engines/lab/utils.cpp



diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index f20a42c..032a74f 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -122,12 +122,10 @@ Common::Point Utils::vgaUnscale(Common::Point pos) {
  * is also a byte.
  */
 void Utils::unDiffByteByte(byte *dest, byte *diff) {
-	uint16 skip, copy;
-
 	while (1) {
-		skip = *diff;
+		uint16 skip = *diff;
 		diff++;
-		copy = *diff;
+		uint16 copy = *diff;
 		diff++;
 
 		if (skip == 255) {
@@ -152,11 +150,9 @@ void Utils::unDiffByteByte(byte *dest, byte *diff) {
  * is a word.
  */
 void Utils::unDiffByteWord(uint16 *dest, uint16 *diff) {
-	uint16 skip, copy;
-
 	while (1) {
-		skip = ((byte *)diff)[0];
-		copy = ((byte *)diff)[1];
+		uint16 skip = ((byte *)diff)[0];
+		uint16 copy = ((byte *)diff)[1];
 
 		diff++;
 
@@ -193,8 +189,7 @@ void Utils::unDiffByteWord(uint16 *dest, uint16 *diff) {
 		}
 
 		while (copy) {
-			*dest = READ_LE_UINT16(diff);
-			dest++;
+			*dest++ = READ_LE_UINT16(diff);
 			diff++;
 			copy--;
 		}
@@ -208,19 +203,12 @@ void Utils::unDiffByteWord(uint16 *dest, uint16 *diff) {
  * is a byte.
  */
 void Utils::VUnDiffByteByte(byte *dest, byte *diff, uint16 bytesPerRow) {
-	byte *curPtr;
-	uint16 skip, copy;
-	uint16 counter = 0;
-
-
-	while (counter < _dataBytesPerRow) {
-		curPtr = dest + counter;
+	for (uint16 counter = 0; counter < _dataBytesPerRow; ) {
+		byte *curPtr = dest + counter;
 
 		for (;;) {
-			skip = *diff;
-			diff++;
-			copy = *diff;
-			diff++;
+			uint16 skip = *diff++;
+			uint16 copy = *diff++;
 
 			if (skip == 255) {
 				counter += copy;
@@ -232,9 +220,8 @@ void Utils::VUnDiffByteByte(byte *dest, byte *diff, uint16 bytesPerRow) {
 
 				while (copy) {
 					copy--;
-					*curPtr = *diff;
+					*curPtr = *diff++;
 					curPtr += bytesPerRow;
-					diff++;
 				}
 			}
 		}
@@ -246,22 +233,18 @@ void Utils::VUnDiffByteByte(byte *dest, byte *diff, uint16 bytesPerRow) {
  * is a word.
  */
 void Utils::VUnDiffByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow) {
-	uint16 *curPtr;
-	uint16 skip, copy;
 	uint16 counter = 0;
-
 	uint16 wordsPerRow = bytesPerRow / 2;
 
 	while (counter < (_dataBytesPerRow >> 1)) {
-		curPtr = dest + counter;
+		uint16 *curPtr = dest + counter;
 
 		for (;;) {
-			skip = ((byte *)diff)[0];
-			copy = ((byte *)diff)[1];
+			uint16 skip = ((byte *)diff)[0];
+			uint16 copy = ((byte *)diff)[1];
 
 			diff++;
 
-
 			if (skip == 255) {
 				counter += copy;
 				break;
@@ -271,9 +254,8 @@ void Utils::VUnDiffByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow) {
 				curPtr += (skip * wordsPerRow);
 
 				while (copy) {
-					*curPtr = *diff; //swapUShort(*diff);
+					*curPtr = *diff++; //swapUShort(*diff);
 					curPtr += wordsPerRow;
-					diff++;
 					copy--;
 				}
 			}
@@ -286,24 +268,17 @@ void Utils::VUnDiffByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow) {
  * is a long.
  */
 void Utils::VUnDiffByteLong(uint32 *dest, uint32 *diff, uint16 bytesPerRow) {
-	uint32 *_curPtr;
-	uint16 skip, copy;
-
 	uint16 counter = 0;
 	byte *diff1 = (byte *)diff;
 
 	uint16 longsperrow = bytesPerRow / 4;
 
 	while (counter < (_dataBytesPerRow >> 2)) {
-		_curPtr = dest + counter;
+		uint32 *_curPtr = dest + counter;
 
 		for (;;) {
-			skip = *diff1;
-			diff1++;
-
-			copy = *diff1;
-			diff1++;
-
+			uint16 skip = *diff1++;
+			uint16 copy = *diff1++;
 
 			if (skip == 255) {
 				counter += copy;
@@ -332,8 +307,7 @@ void Utils::runLengthDecode(byte *dest, byte *source) {
 	int16 count;
 
 	while (1) {
-		num = (int8)*source;
-		source++;
+		num = (int8)*source++;
 
 		if (num == 127) {
 			return;
@@ -343,12 +317,10 @@ void Utils::runLengthDecode(byte *dest, byte *source) {
 			dest   += num;
 		} else {
 			count = (int16)(-num);
-			num   = *source;
-			source++;
+			num   = *source++;
 
 			while (count) {
-				*dest = num;
-				dest++;
+				*dest++ = num;
 				count--;
 			}
 		}
@@ -359,7 +331,6 @@ void Utils::runLengthDecode(byte *dest, byte *source) {
  * Does a vertical run length decode.
  */
 void Utils::VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow) {
-	int8 num;
 	int16 count;
 	byte *top = dest;
 
@@ -367,14 +338,13 @@ void Utils::VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow) {
 		dest = top;
 		dest += i;
 
-		num = (int8)*source;
+		int8 num = (int8)*source;
 		source++;
 
 		while (num != 127) {
 			if (num > '\0') {
 				while (num) {
-					*dest = *source;
-					source++;
+					*dest = *source++;
 					dest += bytesPerRow;
 					num--;
 				}
@@ -433,4 +403,5 @@ uint16 Utils::getRandom(uint16 max) {
 	else
 		return 0;
 }
+
 } // End of namespace Lab


Commit: 52d0243eff241d59397fe6237c1959e24d51dbb8
    https://github.com/scummvm/scummvm/commit/52d0243eff241d59397fe6237c1959e24d51dbb8
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:05+01:00

Commit Message:
LAB: Fix the coding style of a some if/else statements

Changed paths:
    engines/lab/engine.cpp
    engines/lab/image.cpp
    engines/lab/intro.cpp
    engines/lab/resource.cpp
    engines/lab/utils.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 51b20a7..d0412b6 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -315,8 +315,7 @@ bool LabEngine::doUse(uint16 curInv) {
 		if (_conditions->in(kCondLampOn)) {
 			drawStaticMessage(kTextTurnLampOff);
 			_conditions->exclElement(kCondLampOn);
-		}
-		else {
+		} else {
 			drawStaticMessage(kTextTurnkLampOn);
 			_conditions->inclElement(kCondLampOn);
 		}
diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp
index a947ced..23a7f8c 100644
--- a/engines/lab/image.cpp
+++ b/engines/lab/image.cpp
@@ -89,8 +89,10 @@ void Image::blitBitmap(uint16 xs, uint16 ys, Image *imDest,
 				while (ww-- > 0) {
 					byte c = *ss++;
 
-					if (c) *dd++ = c - 1;
-					else dd++;
+					if (c)
+						*dd++ = c - 1;
+					else
+						dd++;
 				}
 
 				s += _width;
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index b085397..5c1c837 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -57,14 +57,12 @@ void Intro::introEatMessages() {
 			return;
 		}
 
-		if (msg == NULL)
+		if (!msg)
 			return;
-		else {
-			if (((msg->_msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & msg->_qualifier)) ||
-				  ((msg->_msgClass == RAWKEY) && (msg->_code == 27))
-				)
-				_quitIntro = true;
-		}
+
+		if (((msg->_msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & msg->_qualifier))
+		 || ((msg->_msgClass == RAWKEY) && (msg->_code == 27)))
+			_quitIntro = true;
 	}
 }
 
@@ -164,9 +162,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 
 				delete[] textBuffer;
 				return;
-			}
-
-			else if (cls == MOUSEBUTTONS) {
+			} else if (cls == MOUSEBUTTONS) {
 				if (IEQUALIFIER_LEFTBUTTON & qualifier) {
 					if (end) {
 						if (isScreen)
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 8b7d26f..c09d1a6 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -159,8 +159,7 @@ Common::String Resource::translateFileName(Common::String filename) {
 			fileNameStrFinal = "GAME/SPICT/";
 		else
 			fileNameStrFinal = "GAME/PICT/";
-	}
-	else if (filename.hasPrefix("LAB:"))
+	} else if (filename.hasPrefix("LAB:"))
 		fileNameStrFinal = "GAME/";
 	else if (filename.hasPrefix("MUSIC:"))
 		fileNameStrFinal = "GAME/MUSIC/";
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index 032a74f..89af44e 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -60,7 +60,6 @@ uint16 Utils::scaleY(uint16 y) {
 		return ((y * 10) / 24);
 }
 
-
 uint16 Utils::mapScaleX(uint16 x) {
 	if (_vm->_isHiRes)
 		return (x - 45);
@@ -110,9 +109,8 @@ Common::Point Utils::vgaUnscale(Common::Point pos) {
 	if (_vm->_isHiRes) {
 		result.x = pos.x / 2;
 		result.y = (pos.y * 5) / 12;
-	} else {
+	} else
 		result = pos;
-	}
 
 	return result;
 }
@@ -213,9 +211,7 @@ void Utils::VUnDiffByteByte(byte *dest, byte *diff, uint16 bytesPerRow) {
 			if (skip == 255) {
 				counter += copy;
 				break;
-			}
-
-			else {
+			} else {
 				curPtr += (skip * bytesPerRow);
 
 				while (copy) {
@@ -248,9 +244,7 @@ void Utils::VUnDiffByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow) {
 			if (skip == 255) {
 				counter += copy;
 				break;
-			}
-
-			else {
+			} else {
 				curPtr += (skip * wordsPerRow);
 
 				while (copy) {
@@ -283,9 +277,7 @@ void Utils::VUnDiffByteLong(uint32 *dest, uint32 *diff, uint16 bytesPerRow) {
 			if (skip == 255) {
 				counter += copy;
 				break;
-			}
-
-			else {
+			} else {
 				_curPtr += (skip * longsperrow);
 
 				while (copy) {


Commit: e0de03463e0c8145bd7700cd2f4955dfc0676967
    https://github.com/scummvm/scummvm/commit/e0de03463e0c8145bd7700cd2f4955dfc0676967
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:05+01:00

Commit Message:
LAB: Use strlen to compute text length instead of a difference between start and end address. Some refactoring.

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/intro.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 9a3d686..cef02ea 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -178,10 +178,10 @@ void DisplayMan::getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer
  * Note: Every individual word MUST be int16 enough to fit on a line, and
  * each line less than 255 characters.
  */
-uint32 DisplayMan::flowText(
+int DisplayMan::flowText(
 			TextFont *font,        // the TextAttr pointer
 			int16 spacing,         // How much vertical spacing between the lines
-			byte pencolor,         // pen number to use for text
+			byte penColor,         // pen number to use for text
 			byte backpen,          // the background color
 			bool fillback,         // Whether to fill the background
 			bool centerh,          // Whether to center the text horizontally
@@ -195,17 +195,17 @@ uint32 DisplayMan::flowText(
 		rectFill(x1, y1, x2, y2);
 	}
 
-	if (str == NULL)
-		return 0L;
+	if (!str)
+		return 0;
 
-	setAPen(pencolor);
+	setAPen(penColor);
 
 	TextFont *msgFont = font;
 	uint16 fontheight = textHeight(msgFont) + spacing;
 	uint16 numlines   = (y2 - y1 + 1) / fontheight;
 	uint16 width      = x2 - x1 + 1;
 	uint16 y          = y1;
-	char linebuffer[256];
+	char lineBuffer[256];
 	const char *temp;
 
 	if (centerv && output) {
@@ -213,7 +213,7 @@ uint32 DisplayMan::flowText(
 		uint16 actlines = 0;
 
 		while (temp[0]) {
-			getLine(msgFont, linebuffer, &temp, width);
+			getLine(msgFont, lineBuffer, &temp, width);
 			actlines++;
 		}
 
@@ -222,26 +222,29 @@ uint32 DisplayMan::flowText(
 	}
 
 	temp = str;
-
+	int len = 0;
 	while (numlines && str[0]) {
-		getLine(msgFont, linebuffer, &str, width);
+		getLine(msgFont, lineBuffer, &str, width);
 
 		uint16 x = x1;
+		len += strlen(lineBuffer);
 
 		if (centerh)
-			x += (width - textLength(msgFont, linebuffer, strlen(linebuffer))) / 2;
+			x += (width - textLength(msgFont, lineBuffer, strlen(lineBuffer))) / 2;
 
 		if (output)
-			text(msgFont, x, y, pencolor, linebuffer, strlen(linebuffer));
+			text(msgFont, x, y, penColor, lineBuffer, strlen(lineBuffer));
 
 		numlines--;
 		y += fontheight;
 	}
 
-	return (str - temp);
+	len--;
+
+	return len;
 }
 
-uint32 DisplayMan::flowTextScaled(
+int DisplayMan::flowTextScaled(
 	TextFont *font,            // the TextAttr pointer
 	int16 spacing,             // How much vertical spacing between the lines
 	byte penColor,             // pen number to use for text
@@ -261,7 +264,7 @@ uint32 DisplayMan::flowTextScaled(
 /**
  * Calls flowText, but flows it to memory.  Same restrictions as flowText.
  */
-uint32 DisplayMan::flowTextToMem(Image *destIm,
+int DisplayMan::flowTextToMem(Image *destIm,
 			TextFont *font,        // the TextAttr pointer
 			int16 spacing,         // How much vertical spacing between the lines
 			byte pencolor,         // pen number to use for text
@@ -279,7 +282,7 @@ uint32 DisplayMan::flowTextToMem(Image *destIm,
 	_currentDisplayBuffer = destIm->_imageData;
 	_screenBytesPerPage = (uint32)destIm->_width * (int32)destIm->_height;
 
-	uint32 res = flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str);
+	int res = flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str);
 
 	_screenBytesPerPage = vgabyte;
 	_currentDisplayBuffer = tmp;
@@ -302,8 +305,8 @@ void DisplayMan::createBox(uint16 y2) {
 	drawVLine(_vm->_utils->vgaScaleX(2), _vm->_utils->vgaScaleY(152), _vm->_utils->vgaScaleY(y2));
 }
 
-int32 DisplayMan::longDrawMessage(const char *str) {
-	if (str == NULL)
+int DisplayMan::longDrawMessage(const char *str) {
+	if (!str)
 		return 0;
 
 	_vm->_event->attachButtonList(NULL);
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index 7ed2e67..fe2aa51 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -94,7 +94,7 @@ public:
 	void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void rectFillScaled(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	// Window text stuff
-	uint32 flowText(TextFont *font,		// the TextAttr pointer
+	int flowText(TextFont *font,		// the TextAttr pointer
 				int16 spacing,			// How much vertical spacing between the lines
 				byte pencolor,			// pen number to use for text
 				byte backpen,			// the background color
@@ -106,7 +106,7 @@ public:
 				uint16 x2, uint16 y2,
 				const char *text);		// The text itself
 
-	uint32 flowTextScaled(
+	int flowTextScaled(
 				TextFont *font,			// the TextAttr pointer
 				int16 spacing,			// How much vertical spacing between the lines
 				byte pencolor,			// pen number to use for text
@@ -119,7 +119,7 @@ public:
 				uint16 x2, uint16 y2,
 				const char *text);		// The text itself
 
-	uint32 flowTextToMem(Image *destIm,
+	int flowTextToMem(Image *destIm,
 				TextFont *font,			// the TextAttr pointer
 				int16 spacing,			// How much vertical spacing between the lines
 				byte pencolor,			// pen number to use for text
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 5c1c837..c739389 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -80,11 +80,9 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 		return;
 
 	uint32 lastMillis = 0;
-	IntuiMessage *msg;
-	bool drawNextText = true, end = false, begin = true;
-
-	int32 cls, code, Drawn;
-	int16 qualifier;
+	bool drawNextText = true;
+	bool doneFl = false;
+	bool begin = true;
 
 	Common::File *textFile = _vm->_resource->openDataFile(path);
 	byte *textBuffer = new byte[textFile->size()];
@@ -99,19 +97,18 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 			else if (isScreen)
 				_vm->_graphics->fade(false, 0);
 
+			int charDrawn = 0;
 			if (isScreen) {
 				_vm->_graphics->setAPen(7);
 				_vm->_graphics->rectFillScaled(10, 10, 310, 190);
 
-				Drawn = _vm->_graphics->flowTextScaled(msgFont, (!_vm->_isHiRes) * -1, 5, 7, false, false, true, true, 14, 11, 306, 189, (char *)curText);
+				charDrawn = _vm->_graphics->flowTextScaled(msgFont, (!_vm->_isHiRes) * -1, 5, 7, false, false, true, true, 14, 11, 306, 189, (char *)curText);
 				_vm->_graphics->fade(true, 0);
-			} else {
-				Drawn = _vm->_graphics->longDrawMessage((char *)curText);
-			}
-
-			curText += Drawn;
+			} else
+				charDrawn = _vm->_graphics->longDrawMessage((char *)curText);
 
-			end = (*curText == 0);
+			curText += charDrawn;
+			doneFl = (*curText == 0);
 
 			drawNextText = false;
 			introEatMessages();
@@ -127,7 +124,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 			lastMillis = g_system->getMillis();
 		}
 
-		msg = _vm->_event->getMsg();
+		IntuiMessage *msg = _vm->_event->getMsg();
 
 		if (msg == NULL) {
 			_vm->_music->updateMusic();
@@ -136,7 +133,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 			uint32 elapsedSeconds = (g_system->getMillis() - lastMillis) / 1000;
 
 			if (elapsedSeconds > timeDelay) {
-				if (end) {
+				if (doneFl) {
 					if (isScreen)
 						_vm->_graphics->fade(false, 0);
 
@@ -146,15 +143,14 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 					drawNextText = true;
 				}
 			}
-
 			_vm->waitTOF();
 		} else {
-			cls       = msg->_msgClass;
-			qualifier = msg->_qualifier;
-			code      = msg->_code;
+			uint32 msgClass = msg->_msgClass;
+			uint16 qualifier = msg->_qualifier;
+			uint16 code = msg->_code;
 
-			if (((cls == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) ||
-				  ((cls == RAWKEY) && (code == 27))) {
+			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) ||
+				  ((msgClass == RAWKEY) && (code == 27))) {
 				_quitIntro = true;
 
 				if (isScreen)
@@ -162,9 +158,9 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 
 				delete[] textBuffer;
 				return;
-			} else if (cls == MOUSEBUTTONS) {
+			} else if (msgClass == MOUSEBUTTONS) {
 				if (IEQUALIFIER_LEFTBUTTON & qualifier) {
-					if (end) {
+					if (doneFl) {
 						if (isScreen)
 							_vm->_graphics->fade(false, 0);
 
@@ -185,7 +181,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 				}
 			}
 
-			if (end) {
+			if (doneFl) {
 				if (isScreen)
 					_vm->_graphics->fade(false, 0);
 
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 6fc8636..c2c52b2 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -52,13 +52,12 @@ namespace Lab {
  */
 void LabEngine::doNotes() {
 	TextFont *noteFont = _resource->getFont("P:Note.fon");
-	char *ntext = _resource->getText("Lab:Rooms/Notes");
+	char *noteText = _resource->getText("Lab:Rooms/Notes");
 
-	_graphics->flowText(noteFont, -2 + _utils->svgaCord(1), 0, 0, false, false, true, true, _utils->vgaScaleX(25) + _utils->svgaCord(15), _utils->vgaScaleY(50), _utils->vgaScaleX(295) - _utils->svgaCord(15), _utils->vgaScaleY(148), ntext);
+	_graphics->flowText(noteFont, -2 + _utils->svgaCord(1), 0, 0, false, false, true, true, _utils->vgaScaleX(25) + _utils->svgaCord(15), _utils->vgaScaleY(50), _utils->vgaScaleX(295) - _utils->svgaCord(15), _utils->vgaScaleY(148), noteText);
 	_graphics->setPalette(_anim->_diffPalette, 256);
-
 	_graphics->closeFont(noteFont);
-	delete[] ntext;
+	delete[] noteText;
 }
 
 /**
@@ -67,35 +66,35 @@ void LabEngine::doNotes() {
  */
 void LabEngine::doWestPaper() {
 	TextFont *paperFont = _resource->getFont("P:News22.fon");
-	char *ntext = _resource->getText("Lab:Rooms/Date");
-	_graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(77) + _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(91), ntext);
+	char *paperText = _resource->getText("Lab:Rooms/Date");
+	_graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(77) + _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(91), paperText);
 	_graphics->closeFont(paperFont);
-	delete[] ntext;
+	delete[] paperText;
 
 	paperFont = _resource->getFont("P:News32.fon");
-	ntext = _resource->getText("Lab:Rooms/Headline");
+	paperText = _resource->getText("Lab:Rooms/Headline");
 
-	int fileLen = strlen(ntext) - 1;
-	int charsPrinted = _graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(118), ntext);
+	int fileLen = strlen(paperText) - 1;
+	int charsPrinted = _graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(118), paperText);
 
 	uint16 y;
 
 	if (charsPrinted < fileLen) {
 		y = 130 - _utils->svgaCord(5);
-		_graphics->flowText(paperFont, -8 - _utils->svgaCord(1), 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(132), ntext);
+		_graphics->flowText(paperFont, -8 - _utils->svgaCord(1), 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(132), paperText);
 	} else
 		y = 115 - _utils->svgaCord(5);
 
 	_graphics->closeFont(paperFont);
-	delete[] ntext;
+	delete[] paperText;
 
 	paperFont = _resource->getFont("P:Note.fon");
-	ntext = _resource->getText("Lab:Rooms/Col1");
-	charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 45, y, 158, 148, ntext);
-	delete[] ntext;
-	ntext = _resource->getText("Lab:Rooms/Col2");
-	charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 162, y, 275, 148, ntext);
-	delete[] ntext;
+	paperText = _resource->getText("Lab:Rooms/Col1");
+	charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 45, y, 158, 148, paperText);
+	delete[] paperText;
+	paperText = _resource->getText("Lab:Rooms/Col2");
+	charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 162, y, 275, 148, paperText);
+	delete[] paperText;
 	_graphics->closeFont(paperFont);
 
 	_graphics->setPalette(_anim->_diffPalette, 256);
@@ -162,7 +161,7 @@ void LabEngine::loadJournalData() {
  */
 void LabEngine::drawJournalText() {
 	uint16 drawingToPage = 1;
-	int32 charsDrawn = 0;
+	int charsDrawn = 0;
 	char *curText = _journalText;
 
 	while (drawingToPage < _journalPage) {
@@ -192,7 +191,7 @@ void LabEngine::drawJournalText() {
 	_graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(171), _utils->vgaScaleY(32), _utils->vgaScaleX(271), _utils->vgaScaleY(148), curText);
 
 	curText = (char *)(_journalText + charsDrawn);
-	_lastPage = _lastPage || (*curText == 0);
+	_lastPage |= (*curText == 0);
 }
 
 /**
@@ -330,7 +329,7 @@ void LabEngine::doJournal() {
  */
 void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) {
 	uint16 drawingToPage = 0, yspacing = 0;
-	int32 charsDrawn    = 0L;
+	int charsDrawn = 0;
 	char *curText = text;
 
 	_event->mouseHide();
@@ -380,7 +379,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
 	_lastPage = (*curText == 0);
 	charsDrawn = _graphics->flowText(monitorFont, yspacing, 2, 0, false, false, false, true, x1, y1, x2, y2, curText);
 	curText += charsDrawn;
-	_lastPage = _lastPage || (*curText == 0);
+	_lastPage |= (*curText == 0);
 
 	_event->mouseShow();
 }


Commit: 69294eccb0636439157b60ee4b85bf3b985acb63
    https://github.com/scummvm/scummvm/commit/69294eccb0636439157b60ee4b85bf3b985acb63
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:05+01:00

Commit Message:
LAB: Some renaming in DisplayMan

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/intro.cpp
    engines/lab/map.cpp
    engines/lab/special.cpp
    engines/lab/tilepuzzle.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index cef02ea..f35db01 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -182,27 +182,27 @@ int DisplayMan::flowText(
 			TextFont *font,        // the TextAttr pointer
 			int16 spacing,         // How much vertical spacing between the lines
 			byte penColor,         // pen number to use for text
-			byte backpen,          // the background color
-			bool fillback,         // Whether to fill the background
+			byte backPen,          // the background color
+			bool fillBack,         // Whether to fill the background
 			bool centerh,          // Whether to center the text horizontally
 			bool centerv,          // Whether to center the text vertically
 			bool output,           // Whether to output any text
 			uint16 x1, uint16 y1,  // Cords
 			uint16 x2, uint16 y2,
 			const char *str) {     // The text itself
-	if (fillback) {
-		setAPen(backpen);
+	if (fillBack) {
+		setPen(backPen);
 		rectFill(x1, y1, x2, y2);
 	}
 
 	if (!str)
 		return 0;
 
-	setAPen(penColor);
+	setPen(penColor);
 
 	TextFont *msgFont = font;
-	uint16 fontheight = textHeight(msgFont) + spacing;
-	uint16 numlines   = (y2 - y1 + 1) / fontheight;
+	uint16 fontHeight = textHeight(msgFont) + spacing;
+	uint16 numLines   = (y2 - y1 + 1) / fontHeight;
 	uint16 width      = x2 - x1 + 1;
 	uint16 y          = y1;
 	char lineBuffer[256];
@@ -217,13 +217,13 @@ int DisplayMan::flowText(
 			actlines++;
 		}
 
-		if (actlines <= numlines)
-			y += ((y2 - y1 + 1) - (actlines * fontheight)) / 2;
+		if (actlines <= numLines)
+			y += ((y2 - y1 + 1) - (actlines * fontHeight)) / 2;
 	}
 
 	temp = str;
 	int len = 0;
-	while (numlines && str[0]) {
+	while (numLines && str[0]) {
 		getLine(msgFont, lineBuffer, &str, width);
 
 		uint16 x = x1;
@@ -235,8 +235,8 @@ int DisplayMan::flowText(
 		if (output)
 			text(msgFont, x, y, penColor, lineBuffer, strlen(lineBuffer));
 
-		numlines--;
-		y += fontheight;
+		numLines--;
+		y += fontHeight;
 	}
 
 	len--;
@@ -267,25 +267,25 @@ int DisplayMan::flowTextScaled(
 int DisplayMan::flowTextToMem(Image *destIm,
 			TextFont *font,        // the TextAttr pointer
 			int16 spacing,         // How much vertical spacing between the lines
-			byte pencolor,         // pen number to use for text
-			byte backpen,          // the background color
-			bool fillback,         // Whether to fill the background
+			byte penColor,         // pen number to use for text
+			byte backPen,          // the background color
+			bool fillBack,         // Whether to fill the background
 			bool centerh,          // Whether to center the text horizontally
 			bool centerv,          // Whether to center the text vertically
 			bool output,           // Whether to output any text
 			uint16 x1, uint16 y1,  // Cords
 			uint16 x2, uint16 y2,
 			const char *str) {     // The text itself
-	byte *tmp = _currentDisplayBuffer;
-	uint32 vgabyte = _screenBytesPerPage;
+	byte *saveDisplayBuffer = _currentDisplayBuffer;
+	uint32 bytesPerPage = _screenBytesPerPage;
 
 	_currentDisplayBuffer = destIm->_imageData;
 	_screenBytesPerPage = (uint32)destIm->_width * (int32)destIm->_height;
 
-	int res = flowText(font, spacing, pencolor, backpen, fillback, centerh, centerv, output, x1, y1, x2, y2, str);
+	int res = flowText(font, spacing, penColor, backPen, fillBack, centerh, centerv, output, x1, y1, x2, y2, str);
 
-	_screenBytesPerPage = vgabyte;
-	_currentDisplayBuffer = tmp;
+	_screenBytesPerPage = bytesPerPage;
+	_currentDisplayBuffer = saveDisplayBuffer;
 
 	return res;
 }
@@ -294,11 +294,11 @@ int DisplayMan::flowTextToMem(Image *destIm,
 
 void DisplayMan::createBox(uint16 y2) {
 	// Message box area
-	setAPen(7);
+	setPen(7);
 	rectFillScaled(4, 154, 315, y2 - 2);
 
 	// Box around message area
-	setAPen(0);
+	setPen(0);
 	drawHLine(_vm->_utils->vgaScaleX(2), _vm->_utils->vgaScaleY(152), _vm->_utils->vgaScaleX(317));
 	drawVLine(_vm->_utils->vgaScaleX(317), _vm->_utils->vgaScaleY(152), _vm->_utils->vgaScaleY(y2));
 	drawHLine(_vm->_utils->vgaScaleX(2), _vm->_utils->vgaScaleY(y2), _vm->_utils->vgaScaleX(317));
@@ -318,7 +318,7 @@ int DisplayMan::longDrawMessage(const char *str) {
 	if (!_longWinInFront) {
 		_longWinInFront = true;
 		// Clear Area
-		setAPen(3);
+		setPen(3);
 		rectFill(0, _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319), _vm->_utils->vgaScaleY(199));
 	}
 
@@ -363,22 +363,22 @@ void DisplayMan::drawPanel() {
 	_vm->_event->mouseHide();
 
 	// Clear Area
-	setAPen(3);
+	setPen(3);
 	rectFill(0, _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319), _vm->_utils->vgaScaleY(199));
 
 	// First Line
-	setAPen(0);
+	setPen(0);
 	drawHLine(0, _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319));
 	// Second Line
-	setAPen(5);
+	setPen(5);
 	drawHLine(0, _vm->_utils->vgaScaleY(149) + 1 + _vm->_utils->svgaCord(2), _vm->_utils->vgaScaleX(319));
 	// Button Separators
-	setAPen(0);
+	setPen(0);
 	// First black line to separate buttons
 	drawHLine(0, _vm->_utils->vgaScaleY(170), _vm->_utils->vgaScaleX(319));
 
 	if (!_vm->_alternate) {
-		setAPen(4);
+		setPen(4);
 		// The horizontal lines under the black one
 		drawHLine(0, _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(319));
 		_vm->_event->drawButtonList(&_vm->_moveButtonList);
@@ -394,7 +394,7 @@ void DisplayMan::drawPanel() {
 			drawVLine(_vm->_utils->vgaScaleX(230), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleY(199));
 		}
 
-		setAPen(4);
+		setPen(4);
 		// The horizontal lines under the black one
 		drawHLine(0, _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(122));
 		drawHLine(_vm->_utils->vgaScaleX(126), _vm->_utils->vgaScaleY(170) + 1, _vm->_utils->vgaScaleX(192));
@@ -461,7 +461,7 @@ void DisplayMan::setUpScreens() {
 	_vm->_invButtonList.push_back(_vm->_event->createButton(196, y, 5, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]));
 
 	// The windows version has 2 extra buttons for breadcrumb trail
-	// TODO: the game is really hard to play without those, maybe we could add something to enable that.
+	// CHECKME: the game is really hard to play without those, maybe we could add something to enable that.
 	if (_vm->getPlatform() == Common::kPlatformWindows) {
 		_vm->_invButtonList.push_back(_vm->_event->createButton(234, y, 6, 'b', _vm->_invImages[6], _vm->_invImages[7]));
 		_vm->_invButtonList.push_back(_vm->_event->createButton(266, y, 7, 'f', _vm->_invImages[8], _vm->_invImages[9]));
@@ -473,7 +473,7 @@ void DisplayMan::setUpScreens() {
 /**
  * Sets the pen number to use on all the drawing operations.
  */
-void DisplayMan::setAPen(byte penNum) {
+void DisplayMan::setPen(byte penNum) {
 	_curPen = penNum;
 }
 
@@ -588,9 +588,9 @@ void DisplayMan::writeColorRegs(byte *buf, uint16 first, uint16 numReg) {
 	memcpy(&(_curvgapal[first * 3]), buf, numReg * 3);
 }
 
-void DisplayMan::setPalette(void *cmap, uint16 numColors) {
-	if (memcmp(cmap, _curvgapal, numColors * 3) != 0)
-		writeColorRegs((byte *)cmap, 0, numColors);
+void DisplayMan::setPalette(void *newPal, uint16 numColors) {
+	if (memcmp(newPal, _curvgapal, numColors * 3) != 0)
+		writeColorRegs((byte *)newPal, 0, numColors);
 }
 
 /**
@@ -678,13 +678,13 @@ uint16 DisplayMan::textHeight(TextFont *tf) {
 /**
  * Draws the text to the screen.
  */
-void DisplayMan::text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numchars) {
+void DisplayMan::text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numChars) {
 	byte *vgaTop = getCurrentDrawingBuffer();
 
-	for (uint16 i = 0; i < numchars; i++) {
+	for (uint16 i = 0; i < numChars; i++) {
 		uint32 realOffset = (_screenWidth * y) + x;
-		uint16 curpage    = realOffset / _screenBytesPerPage;
-		uint32 segmentOffset = realOffset - (curpage * _screenBytesPerPage);
+		uint16 curPage    = realOffset / _screenBytesPerPage;
+		uint32 segmentOffset = realOffset - (curPage * _screenBytesPerPage);
 		int32 leftInSegment = _screenBytesPerPage - segmentOffset;
 		byte *vgaCur = vgaTop + segmentOffset;
 
@@ -716,7 +716,7 @@ void DisplayMan::text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char
 
 						for (uint16 counterb = 0; counterb < 8; counterb++) {
 							if (templeft <= 0) {
-								curpage++;
+								curPage++;
 								vgaTemp = (byte *)(vgaTop - templeft);
 								// Set up VGATempLine for next line
 								vgaTempLine -= _screenBytesPerPage;
@@ -743,7 +743,7 @@ void DisplayMan::text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char
 				leftInSegment -= _screenWidth;
 
 				if (leftInSegment <= 0) {
-					curpage++;
+					curPage++;
 					vgaTempLine -= _screenBytesPerPage;
 					leftInSegment += _screenBytesPerPage;
 				}
@@ -790,23 +790,23 @@ void DisplayMan::doScrollBlack() {
 
 		mem += by * width;
 		nheight -= by;
-		uint32 copysize;
+		uint32 copySize;
 		uint32 size = (int32)nheight * (int32)width;
-		byte *tempmem = mem;
+		byte *tempMem = mem;
 
 		while (size) {
 			if (size > _screenBytesPerPage)
-				copysize = _screenBytesPerPage;
+				copySize = _screenBytesPerPage;
 			else
-				copysize = size;
+				copySize = size;
 
-			size -= copysize;
+			size -= copySize;
 
-			memcpy(baseAddr, tempmem, copysize);
-			tempmem += copysize;
+			memcpy(baseAddr, tempMem, copySize);
+			tempMem += copySize;
 		}
 
-		setAPen(0);
+		setPen(0);
 		rectFill(0, nheight, width - 1, nheight + by - 1);
 
 		screenUpdate();
@@ -986,7 +986,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, char *filename) {
 			}	// while
 		}	// for i
 
-		setAPen(0);
+		setPen(0);
 	}	// for j
 
 	if (filename == NULL)
@@ -1123,7 +1123,7 @@ void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint1
 		im.readScreenImage(x1, y1);
 		im.drawImage(x1 + dx, y1);
 
-		setAPen(0);
+		setPen(0);
 		rectFill(x1, y1, x1 + dx - 1, y2);
 	} else if (dx < 0) {
 		im._width = x2 - x1 + 1 + dx;
@@ -1132,7 +1132,7 @@ void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint1
 		im.readScreenImage(x1 - dx, y1);
 		im.drawImage(x1, y1);
 
-		setAPen(0);
+		setPen(0);
 		rectFill(x2 + dx + 1, y1, x2, y2);
 	}
 }
@@ -1157,7 +1157,7 @@ void DisplayMan::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint1
 		im.readScreenImage(x1, y1);
 		im.drawImage(x1, y1 + dy);
 
-		setAPen(0);
+		setPen(0);
 		rectFill(x1, y1, x2, y1 + dy - 1);
 	} else if (dy < 0) {
 		im._width = x2 - x1 + 1;
@@ -1166,7 +1166,7 @@ void DisplayMan::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint1
 		im.readScreenImage(x1, y1 - dy);
 		im.drawImage(x1, y1);
 
-		setAPen(0);
+		setPen(0);
 		rectFill(x1, y2 + dy + 1, x2, y2);
 	}
 }
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index fe2aa51..92a09c1 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -90,15 +90,15 @@ public:
 	void setUpScreens();
 	int32 longDrawMessage(const char *str);
 	void drawMessage(const char *str);
-	void setAPen(byte pennum);
+	void setPen(byte pennum);
 	void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void rectFillScaled(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	// Window text stuff
 	int flowText(TextFont *font,		// the TextAttr pointer
 				int16 spacing,			// How much vertical spacing between the lines
-				byte pencolor,			// pen number to use for text
-				byte backpen,			// the background color
-				bool fillback,			// Whether to fill the background
+				byte penColor,			// pen number to use for text
+				byte backPen,			// the background color
+				bool fillBack,			// Whether to fill the background
 				bool centerh,			// Whether to center the text horizontally
 				bool centerv,			// Whether to center the text vertically
 				bool output,			// Whether to output any text
@@ -109,9 +109,9 @@ public:
 	int flowTextScaled(
 				TextFont *font,			// the TextAttr pointer
 				int16 spacing,			// How much vertical spacing between the lines
-				byte pencolor,			// pen number to use for text
-				byte backpen,			// the background color
-				bool fillback,			// Whether to fill the background
+				byte penColor,			// pen number to use for text
+				byte backPen,			// the background color
+				bool fillBack,			// Whether to fill the background
 				bool centerh,			// Whether to center the text horizontally
 				bool centerv,			// Whether to center the text vertically
 				bool output,			// Whether to output any text
@@ -122,9 +122,9 @@ public:
 	int flowTextToMem(Image *destIm,
 				TextFont *font,			// the TextAttr pointer
 				int16 spacing,			// How much vertical spacing between the lines
-				byte pencolor,			// pen number to use for text
-				byte backpen,			// the background color
-				bool fillback,			// Whether to fill the background
+				byte penColor,			// pen number to use for text
+				byte backPen,			// the background color
+				bool fillBack,			// Whether to fill the background
 				bool centerh,			// Whether to center the text horizontally
 				bool centerv,			// Whether to center the text vertically
 				bool output,			// Whether to output any text
@@ -138,7 +138,7 @@ public:
 	void createScreen(bool hiRes);
 	void setAmigaPal(uint16 *pal, uint16 numColors);
 	void writeColorRegs(byte *buf, uint16 first, uint16 numReg);
-	void setPalette(void *cmap, uint16 numColors);
+	void setPalette(void *newPal, uint16 numColors);
 	void overlayRect(uint16 penColor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	byte *getCurrentDrawingBuffer();
 	void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer);
@@ -147,7 +147,7 @@ public:
 	void closeFont(TextFont *font);
 	uint16 textLength(TextFont *font, const char *text, uint16 numChars);
 	uint16 textHeight(TextFont *tf);
-	void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numchars);
+	void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numChars);
 	void getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer, uint16 lineWidth);
 
 	bool _longWinInFront;
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index c739389..e841eda 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -99,7 +99,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 
 			int charDrawn = 0;
 			if (isScreen) {
-				_vm->_graphics->setAPen(7);
+				_vm->_graphics->setPen(7);
 				_vm->_graphics->rectFillScaled(10, 10, 310, 190);
 
 				charDrawn = _vm->_graphics->flowTextScaled(msgFont, (!_vm->_isHiRes) * -1, 5, 7, false, false, true, true, 14, 11, 306, 189, (char *)curText);
@@ -431,7 +431,7 @@ void Intro::introSequence() {
 	nReadPict("SubX", true);
 
 	if (_quitIntro) {
-		_vm->_graphics->setAPen(0);
+		_vm->_graphics->setPen(0);
 		_vm->_graphics->rectFill(0, 0, _vm->_graphics->_screenWidth - 1, _vm->_graphics->_screenHeight - 1);
 		_vm->_anim->_doBlack = true;
 	}
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index cb222ba..a248544 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -358,7 +358,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad
 	if (fadeOut)
 		_graphics->fade(false, 0);
 
-	_graphics->setAPen(0);
+	_graphics->setPen(0);
 	_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);
 
 	_imgMap->drawImage(0, 0);
@@ -552,7 +552,7 @@ void LabEngine::processMap(uint16 curRoom) {
 						char *sptr;
 						if ((sptr = _rooms[curMsg]._roomMsg)) {
 							_event->mouseHide();
-							_graphics->setAPen(3);
+							_graphics->setPen(3);
 							_graphics->rectFillScaled(13, 148, 135, 186);
 							_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr);
 
@@ -566,7 +566,7 @@ void LabEngine::processMap(uint16 curRoom) {
 							top = bottom = (curCoords.top + curCoords.bottom) / 2;
 
 							if ((curMsg != curRoom) && (_maps[curMsg]._pageNumber == curFloor)) {
-								_graphics->setAPen(1);
+								_graphics->setPen(1);
 								_graphics->rectFill(left, top, right, bottom);
 							}
 
@@ -606,7 +606,7 @@ void LabEngine::doMap(uint16 curRoom) {
 	_graphics->fade(false, 0);
 	_graphics->blackAllScreen();
 	_event->mouseHide();
-	_graphics->setAPen(0);
+	_graphics->setPen(0);
 	_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);
 	freeMapData();
 	_graphics->blackAllScreen();
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index c2c52b2..3cad962 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -319,7 +319,7 @@ void LabEngine::doJournal() {
 
 	_screenImage->_imageData = _graphics->getCurrentDrawingBuffer();
 
-	_graphics->setAPen(0);
+	_graphics->setPen(0);
 	_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);
 	_graphics->blackScreen();
 }
@@ -350,16 +350,16 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
 		else
 			_monitorButtonHeight = fheight;
 
-		_graphics->setAPen(0);
+		_graphics->setPen(0);
 		_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2);
 
 		for (uint16 i = 0; i < numlines; i++)
 			_monitorButton->drawImage(0, i * _monitorButtonHeight);
 	} else if (isinteractive) {
-		_graphics->setAPen(0);
+		_graphics->setPen(0);
 		_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2);
 	} else {
-		_graphics->setAPen(0);
+		_graphics->setPen(0);
 		_graphics->rectFill(x1, y1, x2, y2);
 	}
 
@@ -514,7 +514,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 	delete[] ntext;
 	_graphics->closeFont(monitorFont);
 
-	_graphics->setAPen(0);
+	_graphics->setPen(0);
 	_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);
 	_graphics->blackAllScreen();
 	_graphics->freePict();
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index 37cc031..df46a57 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -221,7 +221,7 @@ void TilePuzzle::doTile(bool showsolution) {
 		rows = _vm->_utils->vgaScaleY(31);
 		cols = _vm->_utils->vgaScaleX(105);
 	} else {
-		_vm->_graphics->setAPen(0);
+		_vm->_graphics->setPen(0);
 		_vm->_graphics->rectFillScaled(97, 22, 220, 126);
 
 		rowm = _vm->_utils->vgaScaleY(25);


Commit: 521652e436f91cbbe32f2a5bc98a79ee1633f9af
    https://github.com/scummvm/scummvm/commit/521652e436f91cbbe32f2a5bc98a79ee1633f9af
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:05+01:00

Commit Message:
LAB: Move some code from fromCrumbs() into separate functions

This makes this huge function a bit easier to read and understand

Changed paths:
    engines/lab/engine.cpp
    engines/lab/lab.h



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index d0412b6..e9afb7d 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -603,104 +603,21 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 	uint16 lastInv = kItemMap;
 	CloseDataPtr wrkClosePtr = nullptr;
 	bool doit;
+	bool leftButtonClick = false;
+	bool rightButtonClick = false;
 
 	_anim->_doBlack = false;
 
 	if ((msgClass == RAWKEY) && (!_graphics->_longWinInFront)) {
-		byte codeLower = tolower(code);
-
-		if (code == 13) {
-			// The return key
-			msgClass = MOUSEBUTTONS;
-			qualifier = IEQUALIFIER_LEFTBUTTON;
-			curPos = _event->getMousePos();
-		} else if (getPlatform() == Common::kPlatformWindows && codeLower == 'b') {
-			// Start bread crumbs
-			_breadCrumbs[0]._roomNum = 0;
-			_numCrumbs = 0;
-			_droppingCrumbs = true;
-			mayShowCrumbIndicator();
-			_graphics->screenUpdate();
-		} else if (codeLower == 'f' || codeLower == 'r') {
-			// Follow bread crumbs
-			if (_droppingCrumbs) {
-				if (_numCrumbs > 0) {
-					_followingCrumbs = true;
-					_followCrumbsFast = (codeLower == 'r');
-					_isCrumbTurning = false;
-					_isCrumbWaiting = false;
-					_crumbTimestamp = g_system->getMillis();
-
-					if (_alternate) {
-						eatMessages();
-						_alternate = false;
-						_anim->_doBlack = true;
-						_graphics->_doNotDrawMessage = false;
-
-						_mainDisplay = true;
-						// Sets the correct button list
-						interfaceOn();
-						_graphics->drawPanel();
-						drawRoomMessage(curInv, _closeDataPtr);
-						_graphics->screenUpdate();
-					}
-				} else {
-					_breadCrumbs[0]._roomNum = 0;
-					_droppingCrumbs = false;
-
-					// Need to hide indicator!!!!
-					mayShowCrumbIndicatorOff();
-					_graphics->screenUpdate();
-				}
-			}
-		} else if (code == 315 || codeLower == 'x' || codeLower == 'q') {
-			// Quit?
-			_graphics->_doNotDrawMessage = false;
-			_graphics->drawMessage("Do you want to quit? (Y/N)");
-			eatMessages();
-			interfaceOff();
-
-			while (1) {
-				// Make sure we check the music at least after every message
-				_music->updateMusic();
-				curMsg = _event->getMsg();
-
-				if (!curMsg) {
-					// Does music load and next animation frame when you've run out of messages
-					_music->updateMusic();
-					_anim->diffNextFrame();
-				} else {
-					if (curMsg->_msgClass == RAWKEY) {
-						codeLower = tolower(curMsg->_code);
-						if (codeLower == 'y' || codeLower == 'q') {
-							_anim->stopDiff();
-							return false;
-						} else if (curMsg->_code < 128) {
-							break;
-						}
-					} else if (curMsg->_msgClass == MOUSEBUTTONS) {
-						break;
-					}
-				}
-			}
-
-			forceDraw = true;
-			interfaceOn();
-		} else if (code == 9) {
-			// TAB key
-			msgClass = DELTAMOVE;
-		} else if (code == 27) {
-			// ESC key
-			_closeDataPtr = nullptr;
-		}
-
-		eatMessages();
+		if (!processKey(curMsg, msgClass, qualifier, curPos, curInv, forceDraw, code))
+			return false;
 	}
 
+	leftButtonClick = (msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier);
+	rightButtonClick = (msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier);
+
 	if (_graphics->_longWinInFront) {
-		if ((msgClass == RAWKEY) || ((msgClass == MOUSEBUTTONS) &&
-			  ((IEQUALIFIER_LEFTBUTTON & qualifier) ||
-				(IEQUALIFIER_RIGHTBUTTON & qualifier)))) {
+		if ((msgClass == RAWKEY) || (leftButtonClick || rightButtonClick)) {
 			_graphics->_longWinInFront = false;
 			_graphics->_doNotDrawMessage = false;
 			_graphics->drawPanel();
@@ -708,275 +625,10 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 			_graphics->screenUpdate();
 		}
 	} else if ((msgClass == BUTTONUP) && !_alternate) {
-		uint16 newDir;
-
-		switch (buttonId) {
-		case 0:
-		case 1:
-		case 2:
-		case 3:
-		case 4:
-			if ((actionMode == 4) && (buttonId == 4) && _closeDataPtr) {
-				doMainView(&_closeDataPtr);
-
-				_anim->_doBlack = true;
-				wrkClosePtr = nullptr;
-				_closeDataPtr = nullptr;
-				mayShowCrumbIndicator();
-			} else {
-				uint16 oldActionMode = actionMode;
-				actionMode = buttonId;
-
-				if (oldActionMode < 5)
-					perFlipButton(oldActionMode);
-
-				perFlipButton(actionMode);
-				drawStaticMessage(kTextTakeWhat + buttonId);
-			}
-			break;
-		case 5:
-			eatMessages();
-
-			_alternate = true;
-			_anim->_doBlack = true;
-			_graphics->_doNotDrawMessage = false;
-			// Sets the correct button list
-			interfaceOn();
-			_mainDisplay = false;
-
-			if (lastInv && _conditions->in(lastInv)) {
-				curInv = lastInv;
-				_nextFileName = getInvName(curInv);
-			} else
-				decIncInv(&curInv, false);
-
-			_graphics->drawPanel();
-			drawRoomMessage(curInv, _closeDataPtr);
-
-			mayShowCrumbIndicator();
-			break;
-
-		case 9:
-			doUse(kItemMap);
-
-			mayShowCrumbIndicator();
-			break;
-
-		case 6:
-		case 8:
-			// Arrow Buttons
-			_closeDataPtr = nullptr;
-			wrkClosePtr = nullptr;
-			if (buttonId == 6)
-				drawStaticMessage(kTextTurnLeft);
-			else
-				drawStaticMessage(kTextTurnRight);
-
-			_curFileName = " ";
-
-			oldDirection = _direction;
-
-			newDir = processArrow(_direction, buttonId - 6);
-			doTurn(_direction, newDir, &_closeDataPtr);
-			_anim->_doBlack = true;
-			_direction = newDir;
-			forceDraw = true;
-
-			mayShowCrumbIndicator();
-			break;
-
-		case 7:
-			_closeDataPtr = nullptr;
-			wrkClosePtr = nullptr;
-			uint16 oldRoomNum = _roomNum;
-
-			if (doGoForward(&_closeDataPtr)) {
-				if (oldRoomNum == _roomNum)
-					_anim->_doBlack = true;
-			} else {
-				_anim->_doBlack = true;
-				_direction = processArrow(_direction, buttonId - 6);
-
-				if (oldRoomNum != _roomNum) {
-					drawStaticMessage(kTextGoForward);
-					// Potentially entered a new room
-					_roomsFound->inclElement(_roomNum);
-					_curFileName = " ";
-					forceDraw = true;
-				} else {
-					_anim->_doBlack = true;
-					drawStaticMessage(kTextNoPath);
-				}
-			}
-
-			if (_followingCrumbs) {
-				if (_isCrumbTurning) {
-					if (_direction == oldDirection) {
-						_followingCrumbs = false;
-					}
-				} else {
-					if (_roomNum == oldRoomNum) { // didn't get there?
-						_followingCrumbs = false;
-					}
-				}
-			} else if (_droppingCrumbs && oldRoomNum != _roomNum) {
-				// If in surreal maze, turn off DroppingCrumbs.
-				if (_roomNum >= 245 && _roomNum <= 280) {
-					_followingCrumbs = false;
-					_droppingCrumbs = false;
-					_numCrumbs = 0;
-					_breadCrumbs[0]._roomNum = 0;
-				} else {
-					bool intersect = false;
-					for (int idx = 0; idx < _numCrumbs; idx++) {
-						if (_breadCrumbs[idx]._roomNum == _roomNum) {
-							_numCrumbs = idx + 1;
-							_breadCrumbs[_numCrumbs]._roomNum = 0;
-							intersect = true;
-						}
-					}
-
-					if (!intersect) {
-						if (_numCrumbs == MAX_CRUMBS) {
-							_numCrumbs = MAX_CRUMBS - 1;
-							memcpy(&_breadCrumbs[0], &_breadCrumbs[1], _numCrumbs * sizeof _breadCrumbs[0]);
-						}
-
-						_breadCrumbs[_numCrumbs]._roomNum = _roomNum;
-						_breadCrumbs[_numCrumbs++]._direction = _direction;
-					}
-				}
-			}
-
-			mayShowCrumbIndicator();
-			break;
-		}
-		_graphics->screenUpdate();
+		processMainButton(wrkClosePtr, curInv, lastInv, oldDirection, forceDraw, buttonId, actionMode);
 	} else if ((msgClass == BUTTONUP) && _alternate) {
-		_anim->_doBlack = true;
-
-		switch (buttonId) {
-		case 0:
-			eatMessages();
-			_alternate = false;
-			_anim->_doBlack = true;
-			_graphics->_doNotDrawMessage = false;
-
-			_mainDisplay = true;
-			// Sets the correct button list
-			interfaceOn();
-			_graphics->drawPanel();
-			drawRoomMessage(curInv, _closeDataPtr);
-			break;
-
-		case 1:
-			interfaceOff();
-			_anim->stopDiff();
-			_curFileName = " ";
-
-			doit = !saveRestoreGame();
-			_closeDataPtr = nullptr;
-			_mainDisplay = true;
-
-			curInv = kItemMap;
-			lastInv = kItemMap;
-
-			_nextFileName = getInvName(curInv);
-
-			_graphics->drawPanel();
-
-			if (doit) {
-				_graphics->drawMessage("Disk operation failed.");
-				_graphics->setPalette(initcolors, 8);
-				g_system->delayMillis(1000);
-			}
-			break;
-
-		case 2:
-			if (!doUse(curInv)) {
-				uint16 oldActionMode = actionMode;
-				// Use button
-				actionMode = 5;
-
-				if (oldActionMode < 5)
-					perFlipButton(oldActionMode);
-
-				drawStaticMessage(kTextUseOnWhat);
-				_mainDisplay = true;
-			}
-			break;
-
-		case 3:
-			_mainDisplay = !_mainDisplay;
-
-			if ((curInv == 0) || (curInv > _numInv)) {
-				curInv = 1;
-
-				while ((curInv <= _numInv) && (!_conditions->in(curInv)))
-					curInv++;
-			}
-
-			if ((curInv <= _numInv) && _conditions->in(curInv) && _inventory[curInv]._bitmapName)
-				_nextFileName = getInvName(curInv);
-
-			break;
-
-		case 4:
-			// Left button
-			decIncInv(&curInv, true);
-			lastInv = curInv;
-			_graphics->_doNotDrawMessage = false;
-			drawRoomMessage(curInv, _closeDataPtr);
-			break;
-
-		case 5:
-			// Right button
-			decIncInv(&curInv, false);
-			lastInv = curInv;
-			_graphics->_doNotDrawMessage = false;
-			drawRoomMessage(curInv, _closeDataPtr);
-			break;
-
-		case 6:
-			// bread crumbs
-			_breadCrumbs[0]._roomNum = 0;
-			_numCrumbs = 0;
-			_droppingCrumbs = true;
-			mayShowCrumbIndicator();
-			break;
-
-		case 7:
-			// follow crumbs
-			if (_droppingCrumbs) {
-				if (_numCrumbs > 0) {
-					_followingCrumbs = true;
-					_followCrumbsFast = false;
-					_isCrumbTurning = false;
-					_isCrumbWaiting = false;
-					_crumbTimestamp = g_system->getMillis();
-
-					eatMessages();
-					_alternate = false;
-					_anim->_doBlack = true;
-					_graphics->_doNotDrawMessage = false;
-
-					_mainDisplay = true;
-					// Sets the correct button list
-					interfaceOn();
-					_graphics->drawPanel();
-					drawRoomMessage(curInv, _closeDataPtr);
-				} else {
-					_breadCrumbs[0]._roomNum = 0;
-					_droppingCrumbs = false;
-
-					// Need to hide indicator!!!!
-					mayShowCrumbIndicatorOff();
-				}
-			}
-			break;
-		}
-		_graphics->screenUpdate();
-	} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier) && _mainDisplay) {
+		processAltButton(curInv, lastInv, buttonId, actionMode);
+	} else if (leftButtonClick && _mainDisplay) {
 		interfaceOff();
 		_mainDisplay = true;
 
@@ -1067,6 +719,27 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 
 		mayShowCrumbIndicator();
 		_graphics->screenUpdate();
+	} else if (rightButtonClick) {
+		eatMessages();
+		_alternate = !_alternate;
+		_anim->_doBlack = true;
+		_graphics->_doNotDrawMessage = false;
+		_mainDisplay = true;
+		// Sets the correct button list
+		interfaceOn();
+
+		if (_alternate) {
+			if (lastInv && _conditions->in(lastInv))
+				curInv = lastInv;
+			else
+				decIncInv(&curInv, false);
+		}
+
+		_graphics->drawPanel();
+		drawRoomMessage(curInv, _closeDataPtr);
+
+		mayShowCrumbIndicator();
+		_graphics->screenUpdate();
 	} else if (msgClass == DELTAMOVE) {
 		ViewData *vptr = getViewData(_roomNum, _direction);
 		CloseDataPtr oldClosePtr = vptr->_closeUps;
@@ -1095,29 +768,394 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 
 		if (wrkClosePtr)
 			_event->setMousePos(Common::Point(_utils->scaleX((wrkClosePtr->_x1 + wrkClosePtr->_x2) / 2), _utils->scaleY((wrkClosePtr->_y1 + wrkClosePtr->_y2) / 2)));
-	} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) {
+	}
+
+	return true;
+}
+
+bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &qualifier, Common::Point &curPos, uint16 &curInv, bool &forceDraw, uint16 code) {
+	byte codeLower = tolower(code);
+
+	if (code == 13) {
+		// The return key
+		msgClass = MOUSEBUTTONS;
+		qualifier = IEQUALIFIER_LEFTBUTTON;
+		curPos = _event->getMousePos();
+	}
+	else if (getPlatform() == Common::kPlatformWindows && codeLower == 'b') {
+		// Start bread crumbs
+		_breadCrumbs[0]._roomNum = 0;
+		_numCrumbs = 0;
+		_droppingCrumbs = true;
+		mayShowCrumbIndicator();
+		_graphics->screenUpdate();
+	}
+	else if (codeLower == 'f' || codeLower == 'r') {
+		// Follow bread crumbs
+		if (_droppingCrumbs) {
+			if (_numCrumbs > 0) {
+				_followingCrumbs = true;
+				_followCrumbsFast = (codeLower == 'r');
+				_isCrumbTurning = false;
+				_isCrumbWaiting = false;
+				_crumbTimestamp = g_system->getMillis();
+
+				if (_alternate) {
+					eatMessages();
+					_alternate = false;
+					_anim->_doBlack = true;
+					_graphics->_doNotDrawMessage = false;
+
+					_mainDisplay = true;
+					// Sets the correct button list
+					interfaceOn();
+					_graphics->drawPanel();
+					drawRoomMessage(curInv, _closeDataPtr);
+					_graphics->screenUpdate();
+				}
+			}
+			else {
+				_breadCrumbs[0]._roomNum = 0;
+				_droppingCrumbs = false;
+
+				// Need to hide indicator!!!!
+				mayShowCrumbIndicatorOff();
+				_graphics->screenUpdate();
+			}
+		}
+	}
+	else if (code == 315 || codeLower == 'x' || codeLower == 'q') {
+		// Quit?
+		_graphics->_doNotDrawMessage = false;
+		_graphics->drawMessage("Do you want to quit? (Y/N)");
 		eatMessages();
-		_alternate = !_alternate;
+		interfaceOff();
+
+		while (1) {
+			// Make sure we check the music at least after every message
+			_music->updateMusic();
+			curMsg = _event->getMsg();
+
+			if (!curMsg) {
+				// Does music load and next animation frame when you've run out of messages
+				_music->updateMusic();
+				_anim->diffNextFrame();
+			}
+			else {
+				if (curMsg->_msgClass == RAWKEY) {
+					codeLower = tolower(curMsg->_code);
+					if (codeLower == 'y' || codeLower == 'q') {
+						_anim->stopDiff();
+						return false;
+					}
+					else if (curMsg->_code < 128) {
+						break;
+					}
+				}
+				else if (curMsg->_msgClass == MOUSEBUTTONS) {
+					break;
+				}
+			}
+		}
+
+		forceDraw = true;
+		interfaceOn();
+	}
+	else if (code == 9) {
+		// TAB key
+		msgClass = DELTAMOVE;
+	}
+	else if (code == 27) {
+		// ESC key
+		_closeDataPtr = nullptr;
+	}
+
+	eatMessages();
+
+	return true;
+}
+
+void LabEngine::processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint16 &lastInv, uint16 &oldDirection, bool &forceDraw, uint16 buttonId, uint16 &actionMode) {
+	uint16 newDir;
+
+	switch (buttonId) {
+	case 0:
+	case 1:
+	case 2:
+	case 3:
+	case 4:
+		if ((actionMode == 4) && (buttonId == 4) && _closeDataPtr) {
+			doMainView(&_closeDataPtr);
+
+			_anim->_doBlack = true;
+			wrkClosePtr = nullptr;
+			_closeDataPtr = nullptr;
+			mayShowCrumbIndicator();
+		}
+		else {
+			uint16 oldActionMode = actionMode;
+			actionMode = buttonId;
+
+			if (oldActionMode < 5)
+				perFlipButton(oldActionMode);
+
+			perFlipButton(actionMode);
+			drawStaticMessage(kTextTakeWhat + buttonId);
+		}
+		break;
+	case 5:
+		eatMessages();
+
+		_alternate = true;
 		_anim->_doBlack = true;
 		_graphics->_doNotDrawMessage = false;
-		_mainDisplay = true;
 		// Sets the correct button list
 		interfaceOn();
+		_mainDisplay = false;
 
-		if (_alternate) {
-			if (lastInv && _conditions->in(lastInv))
-				curInv = lastInv;
-			else
-				decIncInv(&curInv, false);
+		if (lastInv && _conditions->in(lastInv)) {
+			curInv = lastInv;
+			_nextFileName = getInvName(curInv);
 		}
+		else
+			decIncInv(&curInv, false);
 
 		_graphics->drawPanel();
 		drawRoomMessage(curInv, _closeDataPtr);
 
 		mayShowCrumbIndicator();
-		_graphics->screenUpdate();
+		break;
+
+	case 9:
+		doUse(kItemMap);
+
+		mayShowCrumbIndicator();
+		break;
+
+	case 6:
+	case 8:
+		// Arrow Buttons
+		_closeDataPtr = nullptr;
+		wrkClosePtr = nullptr;
+		if (buttonId == 6)
+			drawStaticMessage(kTextTurnLeft);
+		else
+			drawStaticMessage(kTextTurnRight);
+
+		_curFileName = " ";
+
+		oldDirection = _direction;
+
+		newDir = processArrow(_direction, buttonId - 6);
+		doTurn(_direction, newDir, &_closeDataPtr);
+		_anim->_doBlack = true;
+		_direction = newDir;
+		forceDraw = true;
+
+		mayShowCrumbIndicator();
+		break;
+
+	case 7:
+		_closeDataPtr = nullptr;
+		wrkClosePtr = nullptr;
+		uint16 oldRoomNum = _roomNum;
+
+		if (doGoForward(&_closeDataPtr)) {
+			if (oldRoomNum == _roomNum)
+				_anim->_doBlack = true;
+		}
+		else {
+			_anim->_doBlack = true;
+			_direction = processArrow(_direction, buttonId - 6);
+
+			if (oldRoomNum != _roomNum) {
+				drawStaticMessage(kTextGoForward);
+				// Potentially entered a new room
+				_roomsFound->inclElement(_roomNum);
+				_curFileName = " ";
+				forceDraw = true;
+			}
+			else {
+				_anim->_doBlack = true;
+				drawStaticMessage(kTextNoPath);
+			}
+		}
+
+		if (_followingCrumbs) {
+			if (_isCrumbTurning) {
+				if (_direction == oldDirection) {
+					_followingCrumbs = false;
+				}
+			}
+			else {
+				if (_roomNum == oldRoomNum) { // didn't get there?
+					_followingCrumbs = false;
+				}
+			}
+		}
+		else if (_droppingCrumbs && oldRoomNum != _roomNum) {
+			// If in surreal maze, turn off DroppingCrumbs.
+			if (_roomNum >= 245 && _roomNum <= 280) {
+				_followingCrumbs = false;
+				_droppingCrumbs = false;
+				_numCrumbs = 0;
+				_breadCrumbs[0]._roomNum = 0;
+			}
+			else {
+				bool intersect = false;
+				for (int idx = 0; idx < _numCrumbs; idx++) {
+					if (_breadCrumbs[idx]._roomNum == _roomNum) {
+						_numCrumbs = idx + 1;
+						_breadCrumbs[_numCrumbs]._roomNum = 0;
+						intersect = true;
+					}
+				}
+
+				if (!intersect) {
+					if (_numCrumbs == MAX_CRUMBS) {
+						_numCrumbs = MAX_CRUMBS - 1;
+						memcpy(&_breadCrumbs[0], &_breadCrumbs[1], _numCrumbs * sizeof _breadCrumbs[0]);
+					}
+
+					_breadCrumbs[_numCrumbs]._roomNum = _roomNum;
+					_breadCrumbs[_numCrumbs++]._direction = _direction;
+				}
+			}
+		}
+
+		mayShowCrumbIndicator();
+		break;
 	}
-	return true;
+	_graphics->screenUpdate();
+}
+
+void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonId, uint16 &actionMode) {
+	bool doit;
+
+	_anim->_doBlack = true;
+
+	switch (buttonId) {
+	case 0:
+		eatMessages();
+		_alternate = false;
+		_anim->_doBlack = true;
+		_graphics->_doNotDrawMessage = false;
+
+		_mainDisplay = true;
+		// Sets the correct button list
+		interfaceOn();
+		_graphics->drawPanel();
+		drawRoomMessage(curInv, _closeDataPtr);
+		break;
+
+	case 1:
+		interfaceOff();
+		_anim->stopDiff();
+		_curFileName = " ";
+
+		doit = !saveRestoreGame();
+		_closeDataPtr = nullptr;
+		_mainDisplay = true;
+
+		curInv = kItemMap;
+		lastInv = kItemMap;
+
+		_nextFileName = getInvName(curInv);
+
+		_graphics->drawPanel();
+
+		if (doit) {
+			_graphics->drawMessage("Disk operation failed.");
+			_graphics->setPalette(initcolors, 8);
+			g_system->delayMillis(1000);
+		}
+		break;
+
+	case 2:
+		if (!doUse(curInv)) {
+			uint16 oldActionMode = actionMode;
+			// Use button
+			actionMode = 5;
+
+			if (oldActionMode < 5)
+				perFlipButton(oldActionMode);
+
+			drawStaticMessage(kTextUseOnWhat);
+			_mainDisplay = true;
+		}
+		break;
+
+	case 3:
+		_mainDisplay = !_mainDisplay;
+
+		if ((curInv == 0) || (curInv > _numInv)) {
+			curInv = 1;
+
+			while ((curInv <= _numInv) && (!_conditions->in(curInv)))
+				curInv++;
+		}
+
+		if ((curInv <= _numInv) && _conditions->in(curInv) && _inventory[curInv]._bitmapName)
+			_nextFileName = getInvName(curInv);
+
+		break;
+
+	case 4:
+		// Left button
+		decIncInv(&curInv, true);
+		lastInv = curInv;
+		_graphics->_doNotDrawMessage = false;
+		drawRoomMessage(curInv, _closeDataPtr);
+		break;
+
+	case 5:
+		// Right button
+		decIncInv(&curInv, false);
+		lastInv = curInv;
+		_graphics->_doNotDrawMessage = false;
+		drawRoomMessage(curInv, _closeDataPtr);
+		break;
+
+	case 6:
+		// bread crumbs
+		_breadCrumbs[0]._roomNum = 0;
+		_numCrumbs = 0;
+		_droppingCrumbs = true;
+		mayShowCrumbIndicator();
+		break;
+
+	case 7:
+		// follow crumbs
+		if (_droppingCrumbs) {
+			if (_numCrumbs > 0) {
+				_followingCrumbs = true;
+				_followCrumbsFast = false;
+				_isCrumbTurning = false;
+				_isCrumbWaiting = false;
+				_crumbTimestamp = g_system->getMillis();
+
+				eatMessages();
+				_alternate = false;
+				_anim->_doBlack = true;
+				_graphics->_doNotDrawMessage = false;
+
+				_mainDisplay = true;
+				// Sets the correct button list
+				interfaceOn();
+				_graphics->drawPanel();
+				drawRoomMessage(curInv, _closeDataPtr);
+			}
+			else {
+				_breadCrumbs[0]._roomNum = 0;
+				_droppingCrumbs = false;
+
+				// Need to hide indicator!!!!
+				mayShowCrumbIndicatorOff();
+			}
+		}
+		break;
+	}
+	_graphics->screenUpdate();
 }
 
 void LabEngine::go() {
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 322a921..0a7a9d6 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -251,6 +251,9 @@ private:
 	void setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, bool useAbsoluteCoords);
 	bool takeItem(uint16 x, uint16 y, CloseDataPtr *closePtrList);
 	void turnPage(bool fromLeft);
+	bool processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &qualifier, Common::Point &curPos, uint16 &curInv, bool &forceDraw, uint16 code);
+	void processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint16 &lastInv, uint16 &oldDirection, bool &forceDraw, uint16 buttonId, uint16 &actionMode);
+	void processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonId, uint16 &actionMode);
 
 private:
 	bool saveGame(int slot, Common::String desc);


Commit: b661f2f8e69986ce93bea14847fc8f00208888e0
    https://github.com/scummvm/scummvm/commit/b661f2f8e69986ce93bea14847fc8f00208888e0
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:05+01:00

Commit Message:
LAB: Use enums for the interface buttons

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index e9afb7d..00df1eb 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -81,6 +81,30 @@ enum Monitors {
 	//kMonitorLevers = 82
 };
 
+enum MainButtons {
+	kButtonPickup,
+	kButtonUse,
+	kButtonOpen,
+	kButtonClose,
+	kButtonLook,
+	kButtonInventory,
+	kButtonLeft,
+	kButtonForward,
+	kButtonRight,
+	kButtonMap
+};
+
+enum AltButtons {
+	kButtonMainDisplay,
+	kButtonSaveLoad,
+	kButtonUseItem,
+	kButtonLookAtItem,
+	kButtonPrevItem,
+	kButtonNextItem,
+	kButtonBreadCrumbs,
+	kButtonFollowCrumbs
+};
+
 static char initcolors[] = { '\x00', '\x00', '\x00', '\x30',
 							 '\x30', '\x30', '\x10', '\x10',
 							 '\x10', '\x14', '\x14', '\x14',
@@ -879,11 +903,11 @@ void LabEngine::processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint
 	uint16 newDir;
 
 	switch (buttonId) {
-	case 0:
-	case 1:
-	case 2:
-	case 3:
-	case 4:
+	case kButtonPickup:
+	case kButtonUse:
+	case kButtonOpen:
+	case kButtonClose:
+	case kButtonLook:
 		if ((actionMode == 4) && (buttonId == 4) && _closeDataPtr) {
 			doMainView(&_closeDataPtr);
 
@@ -903,7 +927,7 @@ void LabEngine::processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint
 			drawStaticMessage(kTextTakeWhat + buttonId);
 		}
 		break;
-	case 5:
+	case kButtonInventory:
 		eatMessages();
 
 		_alternate = true;
@@ -926,15 +950,8 @@ void LabEngine::processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint
 		mayShowCrumbIndicator();
 		break;
 
-	case 9:
-		doUse(kItemMap);
-
-		mayShowCrumbIndicator();
-		break;
-
-	case 6:
-	case 8:
-		// Arrow Buttons
+	case kButtonLeft:
+	case kButtonRight:
 		_closeDataPtr = nullptr;
 		wrkClosePtr = nullptr;
 		if (buttonId == 6)
@@ -955,7 +972,7 @@ void LabEngine::processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint
 		mayShowCrumbIndicator();
 		break;
 
-	case 7:
+	case kButtonForward:
 		_closeDataPtr = nullptr;
 		wrkClosePtr = nullptr;
 		uint16 oldRoomNum = _roomNum;
@@ -1025,7 +1042,13 @@ void LabEngine::processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint
 
 		mayShowCrumbIndicator();
 		break;
+	case kButtonMap:
+		doUse(kItemMap);
+
+		mayShowCrumbIndicator();
+		break;
 	}
+
 	_graphics->screenUpdate();
 }
 
@@ -1035,7 +1058,7 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 	_anim->_doBlack = true;
 
 	switch (buttonId) {
-	case 0:
+	case kButtonMainDisplay:
 		eatMessages();
 		_alternate = false;
 		_anim->_doBlack = true;
@@ -1048,7 +1071,7 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 		drawRoomMessage(curInv, _closeDataPtr);
 		break;
 
-	case 1:
+	case kButtonSaveLoad:
 		interfaceOff();
 		_anim->stopDiff();
 		_curFileName = " ";
@@ -1071,7 +1094,7 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 		}
 		break;
 
-	case 2:
+	case kButtonUseItem:
 		if (!doUse(curInv)) {
 			uint16 oldActionMode = actionMode;
 			// Use button
@@ -1085,7 +1108,7 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 		}
 		break;
 
-	case 3:
+	case kButtonLookAtItem:
 		_mainDisplay = !_mainDisplay;
 
 		if ((curInv == 0) || (curInv > _numInv)) {
@@ -1100,32 +1123,28 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 
 		break;
 
-	case 4:
-		// Left button
+	case kButtonPrevItem:
 		decIncInv(&curInv, true);
 		lastInv = curInv;
 		_graphics->_doNotDrawMessage = false;
 		drawRoomMessage(curInv, _closeDataPtr);
 		break;
 
-	case 5:
-		// Right button
+	case kButtonNextItem:
 		decIncInv(&curInv, false);
 		lastInv = curInv;
 		_graphics->_doNotDrawMessage = false;
 		drawRoomMessage(curInv, _closeDataPtr);
 		break;
 
-	case 6:
-		// bread crumbs
+	case kButtonBreadCrumbs:
 		_breadCrumbs[0]._roomNum = 0;
 		_numCrumbs = 0;
 		_droppingCrumbs = true;
 		mayShowCrumbIndicator();
 		break;
 
-	case 7:
-		// follow crumbs
+	case kButtonFollowCrumbs:
 		if (_droppingCrumbs) {
 			if (_numCrumbs > 0) {
 				_followingCrumbs = true;
@@ -1155,6 +1174,7 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 		}
 		break;
 	}
+
 	_graphics->screenUpdate();
 }
 


Commit: 2cfac1c4b07c9cffc80afbb825eb7d517f8d2446
    https://github.com/scummvm/scummvm/commit/2cfac1c4b07c9cffc80afbb825eb7d517f8d2446
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:05+01:00

Commit Message:
LAB: Fix compilation

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 00df1eb..fc32cba 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -901,6 +901,7 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &quali
 
 void LabEngine::processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint16 &lastInv, uint16 &oldDirection, bool &forceDraw, uint16 buttonId, uint16 &actionMode) {
 	uint16 newDir;
+	uint16 oldRoomNum;
 
 	switch (buttonId) {
 	case kButtonPickup:
@@ -975,7 +976,7 @@ void LabEngine::processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint
 	case kButtonForward:
 		_closeDataPtr = nullptr;
 		wrkClosePtr = nullptr;
-		uint16 oldRoomNum = _roomNum;
+		oldRoomNum = _roomNum;
 
 		if (doGoForward(&_closeDataPtr)) {
 			if (oldRoomNum == _roomNum)


Commit: e71f28d0ba319bca35056b7e88d8ebfe0ea92017
    https://github.com/scummvm/scummvm/commit/e71f28d0ba319bca35056b7e88d8ebfe0ea92017
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:05+01:00

Commit Message:
LAB: Reorder mouse position check in processMonitor in order to avoid duplicate checks

Changed paths:
    engines/lab/special.cpp



diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 3cad962..38921ea 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -435,19 +435,9 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 				return;
 			else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) {
 				if ((mouseY >= _utils->vgaScaleY(171)) && (mouseY <= _utils->vgaScaleY(200))) {
-					if ((mouseX >= _utils->vgaScaleX(259)) && (mouseX <= _utils->vgaScaleX(289))) {
-						if (!_lastPage) {
-							_monitorPage += 1;
-							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive);
-						}
-					} else if ((mouseX >= _utils->vgaScaleX(0)) && (mouseX <= _utils->vgaScaleX(31))) {
+					if (mouseX <= _utils->vgaScaleX(31)) {
 						return;
-					} else if ((mouseX >= _utils->vgaScaleX(290)) && (mouseX <= _utils->vgaScaleX(320))) {
-						if (_monitorPage >= 1) {
-							_monitorPage -= 1;
-							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive);
-						}
-					} else if ((mouseX >= _utils->vgaScaleX(31)) && (mouseX <= _utils->vgaScaleX(59))) {
+					} else if (mouseX <= _utils->vgaScaleX(59)) {
 						if (isInteractive) {
 							_monitorPage = 0;
 
@@ -459,6 +449,17 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 							_monitorPage = 0;
 							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive);
 						}
+					} else if (mouseX < _utils->vgaScaleX(259)) {
+						return;
+					} else if (mouseX <= _utils->vgaScaleX(289)) {
+						if (!_lastPage) {
+							_monitorPage += 1;
+							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive);
+						}
+					} else if (_monitorPage >= 1) {
+						// mouseX between 290 and 320 (scaled)
+						_monitorPage -= 1;
+						drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive);
 					}
 				} else if (isInteractive) {
 					CloseDataPtr tmpClosePtr = _closeDataPtr;


Commit: f791d690b2f97d5a1c49f28ef53ecf1a508b8ff6
    https://github.com/scummvm/scummvm/commit/f791d690b2f97d5a1c49f28ef53ecf1a508b8ff6
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:05+01:00

Commit Message:
LAB: Use Common::Rect in a couple of position checks to make it a bit more readable

Changed paths:
    engines/lab/processroom.cpp



diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index dc1b149..8c52d75 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -94,9 +94,10 @@ CloseData *LabEngine::getObject(Common::Point pos, CloseDataPtr closePtr) {
 	else
 		wrkClosePtr = closePtr->_subCloseUps;
 
+	Common::Rect objRect;
 	while (wrkClosePtr) {
-		if ((pos.x >= _utils->scaleX(wrkClosePtr->_x1)) && (pos.y >= _utils->scaleY(wrkClosePtr->_y1)) &&
-			  (pos.x <= _utils->scaleX(wrkClosePtr->_x2)) && (pos.y <= _utils->scaleY(wrkClosePtr->_y2)))
+		objRect = Common::Rect(_utils->scaleX(wrkClosePtr->_x1), _utils->scaleX(wrkClosePtr->_y1), _utils->scaleX(wrkClosePtr->_x2), _utils->scaleX(wrkClosePtr->_y2));
+		if (objRect.contains(pos))
 			return wrkClosePtr;
 
 		wrkClosePtr = wrkClosePtr->_nextCloseUp;
@@ -250,10 +251,11 @@ bool LabEngine::takeItem(uint16 x, uint16 y, CloseDataPtr *closePtrList) {
 	} else
 		closePtr = (*closePtrList)->_subCloseUps;
 
+	Common::Point pos = Common::Point(x, y);
+	Common::Rect objRect;
 	while (closePtr) {
-		if ((x >= _utils->scaleX(closePtr->_x1)) && (y >= _utils->scaleY(closePtr->_y1)) &&
-			  (x <= _utils->scaleX(closePtr->_x2)) && (y <= _utils->scaleY(closePtr->_y2)) &&
-			  (closePtr->_closeUpType < 0)) {
+		objRect = Common::Rect(_utils->scaleX(closePtr->_x1), _utils->scaleX(closePtr->_y1), _utils->scaleX(closePtr->_x2), _utils->scaleX(closePtr->_y2));
+		if (objRect.contains(pos) && (closePtr->_closeUpType < 0)) {
 			_conditions->inclElement(abs(closePtr->_closeUpType));
 			return true;
 		}


Commit: 75d1a3a22a03e6379a50c82811a52d35ab8d26c5
    https://github.com/scummvm/scummvm/commit/75d1a3a22a03e6379a50c82811a52d35ab8d26c5
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:05+01:00

Commit Message:
LAB: Fix freePict as pointed by eriktorbjorn

Changed paths:
    engines/lab/dispman.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index f35db01..28d691a 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -114,8 +114,8 @@ void DisplayMan::readPict(const char *filename, bool playOnce, bool onlyDiffData
 }
 
 void DisplayMan::freePict() {
-	delete _curBitmap;
-	_curBitmap = NULL;
+	delete[] _curBitmap;
+	_curBitmap = nullptr;
 }
 
 //---------------------------------------------------------------------------


Commit: fbff6313b58bda9101d858154c88c8302e0074bf
    https://github.com/scummvm/scummvm/commit/fbff6313b58bda9101d858154c88c8302e0074bf
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:06+01:00

Commit Message:
LAB: Initialize a variable. This should fix a Valgrind warning.

Changed paths:
    engines/lab/intro.cpp



diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index e841eda..86007c0 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -42,6 +42,7 @@ namespace Lab {
 
 Intro::Intro(LabEngine *vm) : _vm(vm) {
 	_quitIntro = false;
+	_introDoBlack = false;
 }
 
 /**


Commit: 6193626f7cb7d5776fb8f20d159f0e9fcb1a1843
    https://github.com/scummvm/scummvm/commit/6193626f7cb7d5776fb8f20d159f0e9fcb1a1843
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:06+01:00

Commit Message:
LAB: Fix two deletes

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index fc32cba..cd9af7a 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -588,10 +588,10 @@ void LabEngine::mainGameLoop() {
 	if (_inventory) {
 		for (int i = 1; i <= _numInv; i++) {
 			if (_inventory[i]._name)
-				delete _inventory[i]._name;
+				delete[] _inventory[i]._name;
 
 			if (_inventory[i]._bitmapName)
-				delete _inventory[i]._bitmapName;
+				delete[] _inventory[i]._bitmapName;
 		}
 
 		delete[] _inventory;


Commit: b42ed683b839d3fc35bf427082aa1f96ee13a553
    https://github.com/scummvm/scummvm/commit/b42ed683b839d3fc35bf427082aa1f96ee13a553
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:06+01:00

Commit Message:
LAB: Fix the style of some if/else statements

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index cd9af7a..2b06a5d 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -805,16 +805,14 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &quali
 		msgClass = MOUSEBUTTONS;
 		qualifier = IEQUALIFIER_LEFTBUTTON;
 		curPos = _event->getMousePos();
-	}
-	else if (getPlatform() == Common::kPlatformWindows && codeLower == 'b') {
+	} else if (getPlatform() == Common::kPlatformWindows && codeLower == 'b') {
 		// Start bread crumbs
 		_breadCrumbs[0]._roomNum = 0;
 		_numCrumbs = 0;
 		_droppingCrumbs = true;
 		mayShowCrumbIndicator();
 		_graphics->screenUpdate();
-	}
-	else if (codeLower == 'f' || codeLower == 'r') {
+	} else if (codeLower == 'f' || codeLower == 'r') {
 		// Follow bread crumbs
 		if (_droppingCrumbs) {
 			if (_numCrumbs > 0) {
@@ -837,8 +835,7 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &quali
 					drawRoomMessage(curInv, _closeDataPtr);
 					_graphics->screenUpdate();
 				}
-			}
-			else {
+			} else {
 				_breadCrumbs[0]._roomNum = 0;
 				_droppingCrumbs = false;
 
@@ -847,8 +844,7 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &quali
 				_graphics->screenUpdate();
 			}
 		}
-	}
-	else if (code == 315 || codeLower == 'x' || codeLower == 'q') {
+	} else if (code == 315 || codeLower == 'x' || codeLower == 'q') {
 		// Quit?
 		_graphics->_doNotDrawMessage = false;
 		_graphics->drawMessage("Do you want to quit? (Y/N)");
@@ -864,32 +860,25 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &quali
 				// Does music load and next animation frame when you've run out of messages
 				_music->updateMusic();
 				_anim->diffNextFrame();
-			}
-			else {
+			} else {
 				if (curMsg->_msgClass == RAWKEY) {
 					codeLower = tolower(curMsg->_code);
 					if (codeLower == 'y' || codeLower == 'q') {
 						_anim->stopDiff();
 						return false;
-					}
-					else if (curMsg->_code < 128) {
+					} else if (curMsg->_code < 128)
 						break;
-					}
-				}
-				else if (curMsg->_msgClass == MOUSEBUTTONS) {
+				} else if (curMsg->_msgClass == MOUSEBUTTONS)
 					break;
-				}
 			}
 		}
 
 		forceDraw = true;
 		interfaceOn();
-	}
-	else if (code == 9) {
+	} else if (code == 9) {
 		// TAB key
 		msgClass = DELTAMOVE;
-	}
-	else if (code == 27) {
+	} else if (code == 27) {
 		// ESC key
 		_closeDataPtr = nullptr;
 	}
@@ -916,8 +905,7 @@ void LabEngine::processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint
 			wrkClosePtr = nullptr;
 			_closeDataPtr = nullptr;
 			mayShowCrumbIndicator();
-		}
-		else {
+		} else {
 			uint16 oldActionMode = actionMode;
 			actionMode = buttonId;
 
@@ -941,8 +929,7 @@ void LabEngine::processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint
 		if (lastInv && _conditions->in(lastInv)) {
 			curInv = lastInv;
 			_nextFileName = getInvName(curInv);
-		}
-		else
+		} else
 			decIncInv(&curInv, false);
 
 		_graphics->drawPanel();
@@ -981,8 +968,7 @@ void LabEngine::processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint
 		if (doGoForward(&_closeDataPtr)) {
 			if (oldRoomNum == _roomNum)
 				_anim->_doBlack = true;
-		}
-		else {
+		} else {
 			_anim->_doBlack = true;
 			_direction = processArrow(_direction, buttonId - 6);
 
@@ -992,8 +978,7 @@ void LabEngine::processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint
 				_roomsFound->inclElement(_roomNum);
 				_curFileName = " ";
 				forceDraw = true;
-			}
-			else {
+			} else {
 				_anim->_doBlack = true;
 				drawStaticMessage(kTextNoPath);
 			}
@@ -1001,25 +986,19 @@ void LabEngine::processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint
 
 		if (_followingCrumbs) {
 			if (_isCrumbTurning) {
-				if (_direction == oldDirection) {
+				if (_direction == oldDirection)
 					_followingCrumbs = false;
-				}
-			}
-			else {
-				if (_roomNum == oldRoomNum) { // didn't get there?
-					_followingCrumbs = false;
-				}
+			} else if (_roomNum == oldRoomNum) { // didn't get there?
+				_followingCrumbs = false;
 			}
-		}
-		else if (_droppingCrumbs && oldRoomNum != _roomNum) {
+		} else if (_droppingCrumbs && oldRoomNum != _roomNum) {
 			// If in surreal maze, turn off DroppingCrumbs.
 			if (_roomNum >= 245 && _roomNum <= 280) {
 				_followingCrumbs = false;
 				_droppingCrumbs = false;
 				_numCrumbs = 0;
 				_breadCrumbs[0]._roomNum = 0;
-			}
-			else {
+			} else {
 				bool intersect = false;
 				for (int idx = 0; idx < _numCrumbs; idx++) {
 					if (_breadCrumbs[idx]._roomNum == _roomNum) {
@@ -1164,8 +1143,7 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 				interfaceOn();
 				_graphics->drawPanel();
 				drawRoomMessage(curInv, _closeDataPtr);
-			}
-			else {
+			} else {
 				_breadCrumbs[0]._roomNum = 0;
 				_droppingCrumbs = false;
 


Commit: 3f1bb66959dbe72444d7cd1bc36609bf1e3e2f77
    https://github.com/scummvm/scummvm/commit/3f1bb66959dbe72444d7cd1bc36609bf1e3e2f77
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:06+01:00

Commit Message:
LAB: Fix memory leak

Changed paths:
    engines/lab/dispman.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 28d691a..fd7486e 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -66,6 +66,7 @@ DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) {
 DisplayMan::~DisplayMan() {
 	freePict();
 	delete _dispBitMap;
+	delete[]_displayBuffer;
 }
 
 // From readPict.c.  Reads in pictures and animations from disk.
@@ -543,7 +544,10 @@ void DisplayMan::createScreen(bool hiRes) {
 		_screenHeight = 200;
 	}
 	_screenBytesPerPage = _screenWidth * _screenHeight;
-	_displayBuffer = new byte[_screenBytesPerPage];	// FIXME: Memory leak!
+
+	if (_displayBuffer)
+		delete[] _displayBuffer;
+	_displayBuffer = new byte[_screenBytesPerPage];
 }
 
 /**


Commit: eab6682929d47d09c0ac81921f479e46a06e93bd
    https://github.com/scummvm/scummvm/commit/eab6682929d47d09c0ac81921f479e46a06e93bd
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:06+01:00

Commit Message:
LAB: Add some checks to quit the game quickly when closing ScummVM

Changed paths:
    engines/lab/engine.cpp
    engines/lab/intro.cpp
    engines/lab/map.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 2b06a5d..cce5aef 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -188,7 +188,7 @@ void LabEngine::eatMessages() {
 
 	do {
 		msg = _event->getMsg();
-	} while (msg);
+	} while (msg && !g_engine->shouldQuit());
 }
 
 /**
@@ -527,6 +527,10 @@ void LabEngine::mainGameLoop() {
 		_music->updateMusic();
 		interfaceOn();
 		IntuiMessage *curMsg = _event->getMsg();
+		if (g_engine->shouldQuit()) {
+			_quitLab = true;
+			return;
+		}
 
 		if (!curMsg) {
 			// Does music load and next animation frame when you've run out of messages
@@ -632,6 +636,9 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 
 	_anim->_doBlack = false;
 
+	if (g_engine->shouldQuit())
+		return false;
+
 	if ((msgClass == RAWKEY) && (!_graphics->_longWinInFront)) {
 		if (!processKey(curMsg, msgClass, qualifier, curPos, curInv, forceDraw, code))
 			return false;
@@ -856,21 +863,22 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &quali
 			_music->updateMusic();
 			curMsg = _event->getMsg();
 
+			if (g_engine->shouldQuit())
+				return false;
+
 			if (!curMsg) {
 				// Does music load and next animation frame when you've run out of messages
 				_music->updateMusic();
 				_anim->diffNextFrame();
-			} else {
-				if (curMsg->_msgClass == RAWKEY) {
-					codeLower = tolower(curMsg->_code);
-					if (codeLower == 'y' || codeLower == 'q') {
-						_anim->stopDiff();
-						return false;
-					} else if (curMsg->_code < 128)
-						break;
-				} else if (curMsg->_msgClass == MOUSEBUTTONS)
+			} else if (curMsg->_msgClass == RAWKEY) {
+				codeLower = tolower(curMsg->_code);
+				if (codeLower == 'y' || codeLower == 'q') {
+					_anim->stopDiff();
+					return false;
+				} else if (curMsg->_code < 128)
 					break;
-			}
+			} else if (curMsg->_msgClass == MOUSEBUTTONS)
+				break;
 		}
 
 		forceDraw = true;
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 86007c0..f49a860 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -126,8 +126,12 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 		}
 
 		IntuiMessage *msg = _vm->_event->getMsg();
+		if (g_engine->shouldQuit()) {
+			_quitIntro = true;
+			return;
+		}
 
-		if (msg == NULL) {
+		if (!msg) {
 			_vm->_music->updateMusic();
 			_vm->_anim->diffNextFrame();
 
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index a248544..927bfd0 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -426,7 +426,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad
  * Processes the map.
  */
 void LabEngine::processMap(uint16 curRoom) {
-	uint32 place = 1;
+	byte place = 1;
 	uint16 curMsg = curRoom;
 	uint16 curFloor = _maps[curRoom]._pageNumber;
 
@@ -434,6 +434,10 @@ void LabEngine::processMap(uint16 curRoom) {
 		// Make sure we check the music at least after every message
 		_music->updateMusic();
 		IntuiMessage *msg = _event->getMsg();
+		if (g_engine->shouldQuit()) {
+			_quitLab = true;
+			return;
+		}
 
 		if (!msg) {
 			_music->updateMusic();
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 38921ea..02bbdf4 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -260,10 +260,14 @@ void LabEngine::processJournal() {
 		// Make sure we check the music at least after every message
 		_music->updateMusic();
 		IntuiMessage *msg = _event->getMsg();
+		if (g_engine->shouldQuit()) {
+			_quitLab = true;
+			return;
+		}
 
-		if (msg == NULL) {
+		if (!msg)
 			_music->updateMusic();
-		} else {
+		else {
 			uint32 msgClass  = msg->_msgClass;
 			uint16 qualifier = msg->_qualifier;
 			uint16 gadID     = msg->_code;
@@ -420,8 +424,12 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 		// Make sure we check the music at least after every message
 		_music->updateMusic();
 		IntuiMessage *msg = _event->getMsg();
+		if (g_engine->shouldQuit()) {
+			_quitLab = true;
+			return;
+		}
 
-		if (msg == NULL) {
+		if (!msg) {
 			_music->updateMusic();
 		} else {
 			uint32 msgClass  = msg->_msgClass;


Commit: 802a0d09dc782314079da14d5afede357f8c4a90
    https://github.com/scummvm/scummvm/commit/802a0d09dc782314079da14d5afede357f8c4a90
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:06+01:00

Commit Message:
LAB: Use Common::KEYCODE in several places

Changed paths:
    engines/lab/engine.cpp
    engines/lab/intro.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index cce5aef..4e1b974 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -807,7 +807,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &qualifier, Common::Point &curPos, uint16 &curInv, bool &forceDraw, uint16 code) {
 	byte codeLower = tolower(code);
 
-	if (code == 13) {
+	if (code == Common::KEYCODE_RETURN) {
 		// The return key
 		msgClass = MOUSEBUTTONS;
 		qualifier = IEQUALIFIER_LEFTBUTTON;
@@ -883,13 +883,10 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &quali
 
 		forceDraw = true;
 		interfaceOn();
-	} else if (code == 9) {
-		// TAB key
+	} else if (code == Common::KEYCODE_TAB)
 		msgClass = DELTAMOVE;
-	} else if (code == 27) {
-		// ESC key
+	else if (code == Common::KEYCODE_ESCAPE)
 		_closeDataPtr = nullptr;
-	}
 
 	eatMessages();
 
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index f49a860..992d237 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -62,7 +62,7 @@ void Intro::introEatMessages() {
 			return;
 
 		if (((msg->_msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & msg->_qualifier))
-		 || ((msg->_msgClass == RAWKEY) && (msg->_code == 27)))
+		 || ((msg->_msgClass == RAWKEY) && (msg->_code == Common::KEYCODE_ESCAPE)))
 			_quitIntro = true;
 	}
 }


Commit: de6de51e8be6d79c7649796d91f2e4d4efce83cc
    https://github.com/scummvm/scummvm/commit/de6de51e8be6d79c7649796d91f2e4d4efce83cc
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:06+01:00

Commit Message:
LAB: More use of Common::KEYCODEs

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 4e1b974..f9533e9 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -805,26 +805,24 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 }
 
 bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &qualifier, Common::Point &curPos, uint16 &curInv, bool &forceDraw, uint16 code) {
-	byte codeLower = tolower(code);
-
 	if (code == Common::KEYCODE_RETURN) {
 		// The return key
 		msgClass = MOUSEBUTTONS;
 		qualifier = IEQUALIFIER_LEFTBUTTON;
 		curPos = _event->getMousePos();
-	} else if (getPlatform() == Common::kPlatformWindows && codeLower == 'b') {
+	} else if ((getPlatform() == Common::kPlatformWindows) && (code == Common::KEYCODE_b)) {
 		// Start bread crumbs
 		_breadCrumbs[0]._roomNum = 0;
 		_numCrumbs = 0;
 		_droppingCrumbs = true;
 		mayShowCrumbIndicator();
 		_graphics->screenUpdate();
-	} else if (codeLower == 'f' || codeLower == 'r') {
+	} else if ((code == Common::KEYCODE_f) || (code == Common::KEYCODE_r)) {
 		// Follow bread crumbs
 		if (_droppingCrumbs) {
 			if (_numCrumbs > 0) {
 				_followingCrumbs = true;
-				_followCrumbsFast = (codeLower == 'r');
+				_followCrumbsFast = (code == Common::KEYCODE_r);
 				_isCrumbTurning = false;
 				_isCrumbWaiting = false;
 				_crumbTimestamp = g_system->getMillis();
@@ -851,7 +849,7 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &quali
 				_graphics->screenUpdate();
 			}
 		}
-	} else if (code == 315 || codeLower == 'x' || codeLower == 'q') {
+	} else if ((code == Common::KEYCODE_x) || (code == Common::KEYCODE_q)) {
 		// Quit?
 		_graphics->_doNotDrawMessage = false;
 		_graphics->drawMessage("Do you want to quit? (Y/N)");
@@ -871,8 +869,7 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &quali
 				_music->updateMusic();
 				_anim->diffNextFrame();
 			} else if (curMsg->_msgClass == RAWKEY) {
-				codeLower = tolower(curMsg->_code);
-				if (codeLower == 'y' || codeLower == 'q') {
+				if ((curMsg->_code == Common::KEYCODE_y) || (curMsg->_code == Common::KEYCODE_q)) {
 					_anim->stopDiff();
 					return false;
 				} else if (curMsg->_code < 128)


Commit: dd06c8328079f296153e4ceb444d1b1760c414ff
    https://github.com/scummvm/scummvm/commit/dd06c8328079f296153e4ceb444d1b1760c414ff
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:06+01:00

Commit Message:
LAB: Make more use of kButton enum

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index f9533e9..3c632d2 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -546,13 +546,13 @@ void LabEngine::mainGameLoop() {
 					uint16 code = 0;
 					switch (result) {
 					case VKEY_UPARROW:
-						code = 7;
+						code = kButtonForward;
 						break;
 					case VKEY_LTARROW:
-						code = 6;
+						code = kButtonLeft;
 						break;
 					case VKEY_RTARROW:
-						code = 8;
+						code = kButtonRight;
 						break;
 					default:
 						break;
@@ -900,7 +900,7 @@ void LabEngine::processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint
 	case kButtonOpen:
 	case kButtonClose:
 	case kButtonLook:
-		if ((actionMode == 4) && (buttonId == 4) && _closeDataPtr) {
+		if ((actionMode == 4) && (buttonId == kButtonLook) && _closeDataPtr) {
 			doMainView(&_closeDataPtr);
 
 			_anim->_doBlack = true;
@@ -944,13 +944,12 @@ void LabEngine::processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint
 	case kButtonRight:
 		_closeDataPtr = nullptr;
 		wrkClosePtr = nullptr;
-		if (buttonId == 6)
+		if (buttonId == kButtonLeft)
 			drawStaticMessage(kTextTurnLeft);
 		else
 			drawStaticMessage(kTextTurnRight);
 
 		_curFileName = " ";
-
 		oldDirection = _direction;
 
 		newDir = processArrow(_direction, buttonId - 6);
@@ -958,7 +957,6 @@ void LabEngine::processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint
 		_anim->_doBlack = true;
 		_direction = newDir;
 		forceDraw = true;
-
 		mayShowCrumbIndicator();
 		break;
 


Commit: 9c7e372a2156fd9695d04175dfdeb3fdafbf8402
    https://github.com/scummvm/scummvm/commit/9c7e372a2156fd9695d04175dfdeb3fdafbf8402
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:06+01:00

Commit Message:
LAB: make takeItem use Common::Point, some refactoring

Changed paths:
    engines/lab/engine.cpp
    engines/lab/lab.h
    engines/lab/processroom.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 3c632d2..251595f 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -630,7 +630,6 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 	uint16 oldDirection = 0;
 	uint16 lastInv = kItemMap;
 	CloseDataPtr wrkClosePtr = nullptr;
-	bool doit;
 	bool leftButtonClick = false;
 	bool rightButtonClick = false;
 
@@ -663,7 +662,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 		interfaceOff();
 		_mainDisplay = true;
 
-		doit = false;
+		bool doit = false;
 
 		if (_closeDataPtr) {
 			switch (_closeDataPtr->_closeUpType) {
@@ -690,9 +689,9 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 			switch (actionMode) {
 			case 0:
 				// Take something.
-				if (doActionRule(Common::Point(curPos.x, curPos.y), actionMode, _roomNum, &_closeDataPtr))
+				if (doActionRule(curPos, actionMode, _roomNum, &_closeDataPtr))
 					_curFileName = _newFileName;
-				else if (takeItem(curPos.x, curPos.y, &_closeDataPtr))
+				else if (takeItem(curPos, &_closeDataPtr))
 					drawStaticMessage(kTextTakeItem);
 				else if (doActionRule(curPos, TAKEDEF - 1, _roomNum, &_closeDataPtr))
 					_curFileName = _newFileName;
@@ -1060,9 +1059,7 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 		_closeDataPtr = nullptr;
 		_mainDisplay = true;
 
-		curInv = kItemMap;
-		lastInv = kItemMap;
-
+		curInv = lastInv = kItemMap;
 		_nextFileName = getInvName(curInv);
 
 		_graphics->drawPanel();
@@ -1212,7 +1209,6 @@ int LabEngine::followCrumbs() {
 	}
 
 	int exitDir;
-
 	// which direction is last crumb
 	if (_breadCrumbs[_numCrumbs]._direction == EAST)
 		exitDir = WEST;
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 0a7a9d6..d888fbb 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -249,7 +249,7 @@ private:
 	Common::Rect roomCoords(uint16 curRoom);
 	bool saveRestoreGame();
 	void setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, bool useAbsoluteCoords);
-	bool takeItem(uint16 x, uint16 y, CloseDataPtr *closePtrList);
+	bool takeItem(Common::Point pos, CloseDataPtr *closePtrList);
 	void turnPage(bool fromLeft);
 	bool processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &qualifier, Common::Point &curPos, uint16 &curInv, bool &forceDraw, uint16 code);
 	void processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint16 &lastInv, uint16 &oldDirection, bool &forceDraw, uint16 buttonId, uint16 &actionMode);
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 8c52d75..c21dce7 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -240,7 +240,7 @@ void LabEngine::setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, b
 /**
  * Takes the currently selected item.
  */
-bool LabEngine::takeItem(uint16 x, uint16 y, CloseDataPtr *closePtrList) {
+bool LabEngine::takeItem(Common::Point pos, CloseDataPtr *closePtrList) {
 	CloseDataPtr closePtr;
 
 	if (!*closePtrList) {
@@ -251,7 +251,6 @@ bool LabEngine::takeItem(uint16 x, uint16 y, CloseDataPtr *closePtrList) {
 	} else
 		closePtr = (*closePtrList)->_subCloseUps;
 
-	Common::Point pos = Common::Point(x, y);
 	Common::Rect objRect;
 	while (closePtr) {
 		objRect = Common::Rect(_utils->scaleX(closePtr->_x1), _utils->scaleX(closePtr->_y1), _utils->scaleX(closePtr->_x2), _utils->scaleX(closePtr->_y2));


Commit: 83126e84eefc2493732bb2a158c6c41cae15ece4
    https://github.com/scummvm/scummvm/commit/83126e84eefc2493732bb2a158c6c41cae15ece4
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:06+01:00

Commit Message:
LAB: Make the use of nullptr consistent through the engine

Changed paths:
    engines/lab/anim.cpp
    engines/lab/dispman.cpp
    engines/lab/eventman.cpp
    engines/lab/image.cpp
    engines/lab/music.cpp
    engines/lab/resource.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 04da59e..532b242 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -345,7 +345,7 @@ void Anim::readDiff(byte *buffer, bool playOnce, bool onlyDiffData) {
 		return;
 
 	for (_header = 0; _header < 8; _header++)
-		_rawDiffBM._planes[_header] = NULL;
+		_rawDiffBM._planes[_header] = nullptr;
 
 	if (_headerdata._fps)
 		_delayMicros = 1000 / _headerdata._fps;
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index fd7486e..5eae12d 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -310,7 +310,7 @@ int DisplayMan::longDrawMessage(const char *str) {
 	if (!str)
 		return 0;
 
-	_vm->_event->attachButtonList(NULL);
+	_vm->_event->attachButtonList(nullptr);
 	_vm->_event->mouseHide();
 
 	char newText[512];
@@ -993,7 +993,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, char *filename) {
 		setPen(0);
 	}	// for j
 
-	if (filename == NULL)
+	if (!filename)
 		_vm->_curFileName = _vm->getPictName(closePtrList);
 	else if (filename[0] > ' ')
 		_vm->_curFileName = filename;
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index ab33e75..ba473fc 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -88,7 +88,7 @@ Button *EventManager::checkButtonHit(ButtonList *buttonList, Common::Point pos)
 		}
 	}
 
-	return NULL;
+	return nullptr;
 }
 
 void EventManager::attachButtonList(ButtonList *buttonList) {
@@ -129,7 +129,7 @@ EventManager::EventManager(LabEngine *vm) : _vm(vm) {
 void EventManager::mouseHandler(int flag, Common::Point pos) {
 	if (flag & 0x02) {
 		// Left mouse button click
-		Button *tmp = NULL;
+		Button *tmp = nullptr;
 		if (_screenButtonList)
 			tmp = checkButtonHit(_screenButtonList, _vm->_isHiRes ? pos : Common::Point(pos.x / 2, pos.y));
 
diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp
index 23a7f8c..1a0383f 100644
--- a/engines/lab/image.cpp
+++ b/engines/lab/image.cpp
@@ -106,14 +106,14 @@ void Image::blitBitmap(uint16 xs, uint16 ys, Image *imDest,
  * Draws an image to the screen.
  */
 void Image::drawImage(uint16 x, uint16 y) {
-	blitBitmap(0, 0, NULL, x, y, _width, _height, false);
+	blitBitmap(0, 0, nullptr, x, y, _width, _height, false);
 }
 
 /**
  * Draws an image to the screen with transparency.
  */
 void Image::drawMaskImage(uint16 x, uint16 y) {
-	blitBitmap(0, 0, NULL, x, y, _width, _height, true);
+	blitBitmap(0, 0, nullptr, x, y, _width, _height, true);
 }
 
 /**
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index b9a3f10..34b7004 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -57,7 +57,7 @@ Music::Music(LabEngine *vm) : _vm(vm) {
 
 	_musicOn = false;
 	_loopSoundEffect = false;
-	_queuingAudioStream = NULL;
+	_queuingAudioStream = nullptr;
 	_lastMusicRoom = 1;
 	_doReset = true;
 	_waitTillFinished = false;
@@ -180,12 +180,11 @@ void Music::freeMusic() {
 	_musicOn = false;
 
 	_vm->_mixer->stopHandle(_musicHandle);
-	_queuingAudioStream = NULL;
-
+	_queuingAudioStream = nullptr;
 	_vm->_mixer->stopHandle(_sfxHandle);
 
 	delete _file;
-	_file = NULL;
+	_file = nullptr;
 }
 
 /**
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index c09d1a6..932ed8c 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -53,10 +53,10 @@ void Resource::readStaticText() {
 TextFont *Resource::getFont(const char *fileName) {
 	Common::File *dataFile = openDataFile(fileName, MKTAG('V', 'G', 'A', 'F'));
 
-	uint32 headerSize = 4L + 2L + 256 * 3 + 4L;
+	uint32 headerSize = 4 + 2 + 256 * 3 + 4;
 	uint32 fileSize = dataFile->size();
 	if (fileSize <= headerSize)
-		return NULL;
+		return nullptr;
 
 	_vm->_music->updateMusic();
 
@@ -247,9 +247,9 @@ RuleList *Resource::readRule(Common::File *file) {
 
 Action *Resource::readAction(Common::File *file) {
 	char c;
-	Action *action = NULL;
-	Action *prev = NULL;
-	Action *head = NULL;
+	Action *action = nullptr;
+	Action *prev = nullptr;
+	Action *head = nullptr;
 
 	do {
 		c = file->readByte();
@@ -276,7 +276,7 @@ Action *Resource::readAction(Common::File *file) {
 				action->_data = (byte *)readString(file);
 			}
 
-			action->_nextAction = NULL;
+			action->_nextAction = nullptr;
 			prev = action;
 		}
 	} while (c == 1);
@@ -286,9 +286,9 @@ Action *Resource::readAction(Common::File *file) {
 
 CloseData *Resource::readCloseUps(uint16 depth, Common::File *file) {
 	char c;
-	CloseData *closeup = NULL;
-	CloseData *prev = NULL;
-	CloseData *head = NULL;
+	CloseData *closeup = nullptr;
+	CloseData *prev = nullptr;
+	CloseData *head = nullptr;
 
 	do {
 		c = file->readByte();
@@ -308,7 +308,7 @@ CloseData *Resource::readCloseUps(uint16 depth, Common::File *file) {
 			closeup->_graphicName = readString(file);
 			closeup->_message = readString(file);
 			closeup->_subCloseUps = readCloseUps(depth + 1, file);
-			closeup->_nextCloseUp = NULL;
+			closeup->_nextCloseUp = nullptr;
 			prev = closeup;
 		}
 	} while (c != '\0');
@@ -318,9 +318,9 @@ CloseData *Resource::readCloseUps(uint16 depth, Common::File *file) {
 
 ViewData *Resource::readView(Common::File *file) {
 	char c;
-	ViewData *view = NULL;
-	ViewData *prev = NULL;
-	ViewData *head = NULL;
+	ViewData *view = nullptr;
+	ViewData *prev = nullptr;
+	ViewData *head = nullptr;
 
 	do {
 		c = file->readByte();
@@ -334,7 +334,7 @@ ViewData *Resource::readView(Common::File *file) {
 			view->_condition = readConditions(file);
 			view->_graphicName = readString(file);
 			view->_closeUps = readCloseUps(0, file);
-			view->_nextCondition = NULL;
+			view->_nextCondition = nullptr;
 			prev = view;
 		}
 	} while (c == 1);
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 02bbdf4..1008314 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -312,7 +312,7 @@ void LabEngine::doJournal() {
 	drawJournal(0, true);
 	_event->mouseShow();
 	processJournal();
-	_event->attachButtonList(NULL);
+	_event->attachButtonList(nullptr);
 	_graphics->fade(false, 0);
 	_event->mouseHide();
 
@@ -400,7 +400,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 
 	while (1) {
 		if (isInteractive) {
-			if (_closeDataPtr == NULL)
+			if (!_closeDataPtr)
 				_closeDataPtr = startClosePtr;
 
 			const char *test;
@@ -410,7 +410,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 				test = _closeDataPtr->_graphicName;
 
 			if (strcmp(test, _monitorTextFilename)) {
-				_monitorPage      = 0;
+				_monitorPage = 0;
 				_monitorTextFilename = test;
 
 				ntext = _resource->getText(_monitorTextFilename);


Commit: 5ed11d721c170a762cea775580fef5eef175c53a
    https://github.com/scummvm/scummvm/commit/5ed11d721c170a762cea775580fef5eef175c53a
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:06+01:00

Commit Message:
LAB: Verify the appropriate use of parenthesis in if statements

Changed paths:
    engines/lab/anim.cpp
    engines/lab/detection.cpp
    engines/lab/engine.cpp
    engines/lab/image.cpp
    engines/lab/interface.cpp
    engines/lab/map.cpp
    engines/lab/music.cpp
    engines/lab/resource.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 532b242..db5e3b3 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -118,7 +118,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 
 			_frameNum++;
 
-			if ((_frameNum == 1) && (_continuous || (!_playOnce)))
+			if ((_frameNum == 1) && (_continuous || !_playOnce))
 				_diffFileStart = _diffFile;
 
 			_isAnim = (_frameNum >= 3) && (!_playOnce);
diff --git a/engines/lab/detection.cpp b/engines/lab/detection.cpp
index 4a01414..52d2845 100644
--- a/engines/lab/detection.cpp
+++ b/engines/lab/detection.cpp
@@ -180,7 +180,7 @@ SaveStateList LabMetaEngine::listSaves(const char *target) const {
 		// Obtain the last 3 digits of the filename, since they correspond to the save slot
 		int slotNum = atoi(file->c_str() + file->size() - 3);
 
-		if (slotNum >= 0 && slotNum <= 999) {
+		if ((slotNum >= 0) && (slotNum <= 999)) {
 			Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
 			if (in) {
 				if (Lab::readSaveGameHeader(in, header))
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 251595f..83beb03 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -638,7 +638,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 	if (g_engine->shouldQuit())
 		return false;
 
-	if ((msgClass == RAWKEY) && (!_graphics->_longWinInFront)) {
+	if ((msgClass == RAWKEY) && !_graphics->_longWinInFront) {
 		if (!processKey(curMsg, msgClass, qualifier, curPos, curInv, forceDraw, code))
 			return false;
 	}
@@ -990,9 +990,9 @@ void LabEngine::processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint
 			} else if (_roomNum == oldRoomNum) { // didn't get there?
 				_followingCrumbs = false;
 			}
-		} else if (_droppingCrumbs && oldRoomNum != _roomNum) {
+		} else if (_droppingCrumbs && (oldRoomNum != _roomNum)) {
 			// If in surreal maze, turn off DroppingCrumbs.
-			if (_roomNum >= 245 && _roomNum <= 280) {
+			if ((_roomNum >= 245) && (_roomNum <= 280)) {
 				_followingCrumbs = false;
 				_droppingCrumbs = false;
 				_numCrumbs = 0;
@@ -1091,7 +1091,7 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 		if ((curInv == 0) || (curInv > _numInv)) {
 			curInv = 1;
 
-			while ((curInv <= _numInv) && (!_conditions->in(curInv)))
+			while ((curInv <= _numInv) && !_conditions->in(curInv))
 				curInv++;
 		}
 
diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp
index 1a0383f..6ace005 100644
--- a/engines/lab/image.cpp
+++ b/engines/lab/image.cpp
@@ -70,7 +70,7 @@ void Image::blitBitmap(uint16 xs, uint16 ys, Image *imDest,
 	if (yd + h > destHeight)
 		h = destHeight - yd;
 
-	if (w > 0 && h > 0) {
+	if ((w > 0) && (h > 0)) {
 		byte *s = _imageData + ys * _width + xs;
 		byte *d = destBuffer + yd * destWidth + xd;
 
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index f490188..c52933d 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -117,8 +117,8 @@ Button *EventManager::checkNumButtonHit(ButtonList *buttonList, uint16 key) {
 
 	for (ButtonList::iterator buttonItr = buttonList->begin(); buttonItr != buttonList->end(); ++buttonItr) {
 		Button *button = *buttonItr;
-		if ((gkey - 1 == button->_buttonID || (gkey == 0 && button->_buttonID == 9) ||
-			  (button->_keyEquiv != 0 && makeButtonKeyEquiv(key) == button->_keyEquiv))
+		if (((gkey - 1 == button->_buttonID) || ((gkey == 0) && (button->_buttonID == 9))
+		 || ((button->_keyEquiv != 0) && (makeButtonKeyEquiv(key) == button->_keyEquiv)))
 			  && button->_isEnabled) {
 			mouseHide();
 			button->_altImage->drawImage(button->_x, button->_y);
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 927bfd0..1222e1a 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -324,7 +324,7 @@ bool LabEngine::floorVisited(uint16 floorNum) {
  * Note: The original did not show all the visited floors, but we do
  */
 uint16 LabEngine::getUpperFloor(uint16 floorNum) {
-	if (floorNum == kFloorCarnival || floorNum == kFloorNone)
+	if ((floorNum == kFloorCarnival) || (floorNum == kFloorNone))
 		return kFloorNone;
 
 	for (uint16 i = floorNum; i < kFloorCarnival; i++)
@@ -339,7 +339,7 @@ uint16 LabEngine::getUpperFloor(uint16 floorNum) {
  * Note: The original did not show all the visited floors, but we do
  */
 uint16 LabEngine::getLowerFloor(uint16 floorNum) {
-	if (floorNum == kFloorLower || floorNum == kFloorNone)
+	if ((floorNum == kFloorLower) || (floorNum == kFloorNone))
 		return kFloorNone;
 
 	for (uint16 i = floorNum; i > kFloorLower; i--)
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 34b7004..61d9fd0 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -71,7 +71,7 @@ void Music::updateMusic() {
 	_vm->_event->processInput();
 	_vm->_event->updateMouse();
 
-	if (_musicOn && getPlayingBufferCount() < MAXBUFFERS) {
+	if (_musicOn && (getPlayingBufferCount() < MAXBUFFERS)) {
 		// NOTE: We need to use malloc(), cause this will be freed with free()
 		// by the music code
 		byte *musicBuffer = (byte *)malloc(MUSICBUFSIZE);
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 932ed8c..668b31b 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -82,7 +82,7 @@ char *Resource::getText(const char *fileName) {
 	byte *text = buffer;
 	dataFile->read(buffer, count);
 
-	while (text && *text != '\0')
+	while (text && (*text != '\0'))
 		*text++ -= (byte)95;
 
 	delete dataFile;


Commit: eb6854e2c75fe0abd4abc1aca0ad7567804900a0
    https://github.com/scummvm/scummvm/commit/eb6854e2c75fe0abd4abc1aca0ad7567804900a0
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:07+01:00

Commit Message:
LAB: Add a short delay when changing screen so that the text is readable when changing screens

Changed paths:
    engines/lab/anim.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index db5e3b3..d1b79a2 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -317,9 +317,14 @@ void Anim::readDiff(byte *buffer, bool playOnce, bool onlyDiffData) {
 		_headerdata._depth = *_diffFile;
 		_diffFile++;
 		_headerdata._fps = *_diffFile;
+
 		// HACK: The original game defines a 1 second delay when changing screens, which is
-		// very annoying. In this case, we just set it to no delay, to make the game a bit
-		// less frustrating
+		// very annoying. We first removed the delay, but it looked wrong when changing screens
+		// as it was possible to see that something was displayed, without being able to tell
+		// what it was. A shorter delay (150ms) makes it acceptable during gameplay and
+		// readable. The big question is: do we need that message?
+		g_system->delayMillis(150);
+
 		if (_headerdata._fps == 1)
 			_headerdata._fps = 0;
 		_diffFile++;


Commit: f932f392149ec0d82d659cc8c3e0e2e3b8752ba0
    https://github.com/scummvm/scummvm/commit/f932f392149ec0d82d659cc8c3e0e2e3b8752ba0
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:07+01:00

Commit Message:
LAB: reduce a variable scope, remove useless code

Changed paths:
    engines/lab/dispman.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 5eae12d..b9d5802 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -207,10 +207,9 @@ int DisplayMan::flowText(
 	uint16 width      = x2 - x1 + 1;
 	uint16 y          = y1;
 	char lineBuffer[256];
-	const char *temp;
 
 	if (centerv && output) {
-		temp = str;
+		const char *temp = str;
 		uint16 actlines = 0;
 
 		while (temp[0]) {
@@ -222,7 +221,6 @@ int DisplayMan::flowText(
 			y += ((y2 - y1 + 1) - (actlines * fontHeight)) / 2;
 	}
 
-	temp = str;
 	int len = 0;
 	while (numLines && str[0]) {
 		getLine(msgFont, lineBuffer, &str, width);


Commit: 005e077551fd3d324b99a37a27a37646864b2188
    https://github.com/scummvm/scummvm/commit/005e077551fd3d324b99a37a27a37646864b2188
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:07+01:00

Commit Message:
LAB: Some renames

Changed paths:
    engines/lab/engine.cpp
    engines/lab/eventman.cpp
    engines/lab/eventman.h
    engines/lab/interface.cpp
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 83beb03..f43f1fa 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -164,7 +164,7 @@ void LabEngine::freeScreens() {
 void LabEngine::perFlipButton(uint16 buttonId) {
 	for (ButtonList::iterator button = _moveButtonList.begin(); button != _moveButtonList.end(); ++button) {
 		Button *topButton = *button;
-		if (topButton->_buttonID == buttonId) {
+		if (topButton->_buttonId == buttonId) {
 			Image *tmpImage = topButton->_image;
 			topButton->_image = topButton->_altImage;
 			topButton->_altImage = tmpImage;
@@ -576,7 +576,7 @@ void LabEngine::mainGameLoop() {
 			curPos.y  = curMsg->_mouseY;
 
 			_followingCrumbs = false;
-			if (!fromCrumbs(curMsg->_msgClass, curMsg->_code, curMsg->_qualifier, curPos, curInv, curMsg, forceDraw, curMsg->_buttonID, actionMode))
+			if (!fromCrumbs(curMsg->_msgClass, curMsg->_code, curMsg->_qualifier, curPos, curInv, curMsg, forceDraw, curMsg->_buttonId, actionMode))
 				break;
 		}
 	}
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index ba473fc..001e429 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -101,7 +101,7 @@ void EventManager::attachButtonList(ButtonList *buttonList) {
 Button *EventManager::getButton(uint16 id) {
 	for (ButtonList::iterator buttonItr = _screenButtonList->begin(); buttonItr != _screenButtonList->end(); ++buttonItr) {
 		Button *button = *buttonItr;
-		if (button->_buttonID == id)
+		if (button->_buttonId == id)
 			return button;
 	}
 
diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h
index acfccb2..68b441a 100644
--- a/engines/lab/eventman.h
+++ b/engines/lab/eventman.h
@@ -55,13 +55,13 @@ class Image;
 
 struct IntuiMessage {
 	uint32 _msgClass;
-	uint16 _code, _qualifier, _mouseX, _mouseY, _buttonID;
+	uint16 _code, _qualifier, _mouseX, _mouseY, _buttonId;
 	uint32 _seconds, _micros;
 };
 
 
 struct Button {
-	uint16 _x, _y, _buttonID;
+	uint16 _x, _y, _buttonId;
 	uint16 _keyEquiv; // if not zero, a key that activates button
 	bool _isEnabled;
 	Image *_image, *_altImage;
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index c52933d..fea9f5a 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -45,7 +45,7 @@ Button *EventManager::createButton(uint16 x, uint16 y, uint16 id, uint16 key, Im
 	if (button) {
 		button->_x = _vm->_utils->vgaScaleX(x);
 		button->_y = y;
-		button->_buttonID = id;
+		button->_buttonId = id;
 		button->_keyEquiv = key;
 		button->_image = image;
 		button->_altImage = altImage;
@@ -117,7 +117,7 @@ Button *EventManager::checkNumButtonHit(ButtonList *buttonList, uint16 key) {
 
 	for (ButtonList::iterator buttonItr = buttonList->begin(); buttonItr != buttonList->end(); ++buttonItr) {
 		Button *button = *buttonItr;
-		if (((gkey - 1 == button->_buttonID) || ((gkey == 0) && (button->_buttonID == 9))
+		if (((gkey - 1 == button->_buttonId) || ((gkey == 0) && (button->_buttonId == 9))
 		 || ((button->_keyEquiv != 0) && (makeButtonKeyEquiv(key) == button->_keyEquiv)))
 			  && button->_isEnabled) {
 			mouseHide();
@@ -141,13 +141,13 @@ IntuiMessage *EventManager::getMsg() {
 	updateMouse();
 
 	int qualifiers = _keyPressed.flags;
-	Button *curgad  = mouseButton();
+	Button *curButton  = mouseButton();
 
-	if (curgad) {
+	if (curButton) {
 		updateMouse();
 		message._msgClass = BUTTONUP;
-		message._code  = curgad->_buttonID;
-		message._buttonID = curgad->_buttonID;
+		message._code = curButton->_buttonId;
+		message._buttonId = curButton->_buttonId;
 		message._qualifier = qualifiers;
 		return &message;
 	} else if (mouseButton(&message._mouseX, &message._mouseY, true)) {
@@ -162,12 +162,12 @@ IntuiMessage *EventManager::getMsg() {
 		return &message;
 	} else if (keyPress(&message._code)) {
 		// Keyboard key
-		curgad = checkNumButtonHit(_screenButtonList, message._code);
+		curButton = checkNumButtonHit(_screenButtonList, message._code);
 
-		if (curgad) {
+		if (curButton) {
 			message._msgClass = BUTTONUP;
-			message._code  = curgad->_buttonID;
-			message._buttonID = curgad->_buttonID;
+			message._code = curButton->_buttonId;
+			message._buttonId = curButton->_buttonId;
 		} else
 			message._msgClass = RAWKEY;
 
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index d888fbb..4cd681e 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -241,7 +241,7 @@ private:
 	void showLab2Teaser();
 	void mayShowCrumbIndicator();
 	void mayShowCrumbIndicatorOff();
-	void perFlipButton(uint16 gadID);
+	void perFlipButton(uint16 buttonId);
 	uint16 processArrow(uint16 curDirection, uint16 arrow);
 	void processJournal();
 	void processMap(uint16 curRoom);
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 1222e1a..09d8988 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -472,7 +472,7 @@ void LabEngine::processMap(uint16 curRoom) {
 		} else {
 			uint32 msgClass  = msg->_msgClass;
 			uint16 msgCode   = msg->_code;
-			uint16 buttonID  = msg->_buttonID;
+			uint16 buttonId  = msg->_buttonId;
 			uint16 qualifier = msg->_qualifier;
 			uint16 mouseX    = msg->_mouseX;
 			uint16 mouseY    = msg->_mouseY;
@@ -481,10 +481,10 @@ void LabEngine::processMap(uint16 curRoom) {
 				return;
 
 			if (msgClass == BUTTONUP) {
-				if (buttonID == 0) {
+				if (buttonId == 0) {
 					// Quit menu button
 					return;
-				} else if (buttonID == 1) {
+				} else if (buttonId == 1) {
 					// Up arrow
 					uint16 upperFloor = getUpperFloor(curFloor);
 					if (upperFloor != kFloorNone) {
@@ -493,7 +493,7 @@ void LabEngine::processMap(uint16 curRoom) {
 						drawMap(curRoom, curMsg, curFloor, false, false);
 						_graphics->fade(true, 0);
 					}
-				} else if (buttonID == 2) {
+				} else if (buttonId == 2) {
 					// Down arrow
 					uint16 lowerFloor = getLowerFloor(curFloor);
 					if (lowerFloor != kFloorNone) {
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 1008314..d61ddcb 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -270,20 +270,20 @@ void LabEngine::processJournal() {
 		else {
 			uint32 msgClass  = msg->_msgClass;
 			uint16 qualifier = msg->_qualifier;
-			uint16 gadID     = msg->_code;
+			uint16 buttonId  = msg->_code;
 
 			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) ||
-				  ((msgClass == RAWKEY) && (gadID == 27)))
+				  ((msgClass == RAWKEY) && (buttonId == 27)))
 				return;
 			else if (msgClass == BUTTONUP) {
-				if (gadID == 0) {
+				if (buttonId == 0) {
 					if (_journalPage >= 2) {
 						_journalPage -= 2;
 						drawJournal(1, false);
 					}
-				} else if (gadID == 1) {
+				} else if (buttonId == 1) {
 					return;
-				} else if (gadID == 2) {
+				} else if (buttonId == 2) {
 					if (!_lastPage) {
 						_journalPage += 2;
 						drawJournal(2, false);


Commit: 5aef1367e26ce056d8e54a3fc2b3734090660f56
    https://github.com/scummvm/scummvm/commit/5aef1367e26ce056d8e54a3fc2b3734090660f56
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:07+01:00

Commit Message:
LAB: Remove useless checks, and clean up the mouse processing code

Changed paths:
    engines/lab/engine.cpp
    engines/lab/eventman.cpp
    engines/lab/eventman.h



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index f43f1fa..f82c7cc 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -454,7 +454,8 @@ void LabEngine::mainGameLoop() {
 
 	// Set up initial picture.
 	while (1) {
-		_event->processInput(true);
+		_event->processInput();
+		g_system->delayMillis(10);
 
 		if (gotMessage) {
 			if (_quitLab || g_engine->shouldQuit()) {
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 001e429..2537412 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -119,31 +119,12 @@ EventManager::EventManager(LabEngine *vm) : _vm(vm) {
 	_nextKeyIn = 0;
 	_nextKeyOut = 0;
 	_mousePos = Common::Point(0, 0);
-	_mouseAtEdge = false;
 
 	for (int i = 0; i < 64; i++)
 		_keyBuf[i] = 0;
 
 }
 
-void EventManager::mouseHandler(int flag, Common::Point pos) {
-	if (flag & 0x02) {
-		// Left mouse button click
-		Button *tmp = nullptr;
-		if (_screenButtonList)
-			tmp = checkButtonHit(_screenButtonList, _vm->_isHiRes ? pos : Common::Point(pos.x / 2, pos.y));
-
-		if (tmp)
-			_lastButtonHit = tmp;
-		else
-			_leftClick = true;
-	}
-
-	if (flag & 0x08)
-		// Right mouse button click
-		_rightClick = true;
-}
-
 void EventManager::updateMouse() {
 	bool doUpdateDisplay = false;
 
@@ -275,91 +256,56 @@ bool EventManager::haveNextChar() {
 	return _nextKeyIn != _nextKeyOut;
 }
 
-void EventManager::processInput(bool canDelay) {
+void EventManager::processInput() {
 	Common::Event event;
 
-	if (1) { //!g_IgnoreProcessInput
-		int flags = 0;
-		while (g_system->getEventManager()->pollEvent(event)) {
-			switch (event.type) {
-			case Common::EVENT_RBUTTONDOWN:
-				flags |= 8;
-				mouseHandler(flags, _mousePos);
+	while (g_system->getEventManager()->pollEvent(event)) {
+		switch (event.type) {
+		case Common::EVENT_LBUTTONDOWN:
+			if (_screenButtonList)
+				_lastButtonHit = checkButtonHit(_screenButtonList, _vm->_isHiRes ? _mousePos : Common::Point(_mousePos.x / 2, _mousePos.y));
+			else
+				_leftClick = true;
+			break;
+		case Common::EVENT_RBUTTONDOWN:
+			_rightClick = true;
+			break;
+		case Common::EVENT_MOUSEMOVE:
+			_mousePos = event.mouse;
+			break;
+		case Common::EVENT_KEYDOWN:
+			switch (event.kbd.keycode) {
+			case Common::KEYCODE_LEFTBRACKET:
+				_vm->changeVolume(-1);
 				break;
 
-			case Common::EVENT_LBUTTONDOWN:
-				flags |= 2;
-				mouseHandler(flags, _mousePos);
+			case Common::KEYCODE_RIGHTBRACKET:
+				_vm->changeVolume(1);
 				break;
 
-			case Common::EVENT_MOUSEMOVE: {
-				int lastMouseAtEdge = _mouseAtEdge;
-				_mouseAtEdge = false;
-				_mousePos.x = event.mouse.x;
-				if (event.mouse.x <= 0) {
-					_mousePos.x = 0;
-					_mouseAtEdge = true;
-				}
-
-				if (_mousePos.x >= _vm->_graphics->_screenWidth) {
-					_mousePos.x = _vm->_graphics->_screenWidth;
-					_mouseAtEdge = true;
-				}
-
-				_mousePos.y = event.mouse.y;
-				if (event.mouse.y <= 0) {
-					_mousePos.y = 0;
-					_mouseAtEdge = true;
-				}
-
-				if (_mousePos.y >= _vm->_graphics->_screenHeight) {
-					_mousePos.y = _vm->_graphics->_screenHeight;
-					_mouseAtEdge = true;
-				}
-
-				if (!lastMouseAtEdge || !_mouseAtEdge)
-					mouseHandler(1, _mousePos);
-				}
+			case Common::KEYCODE_z:
+				//saveSettings();
 				break;
 
-			case Common::EVENT_KEYDOWN:
-				switch (event.kbd.keycode) {
-				case Common::KEYCODE_LEFTBRACKET:
-					_vm->changeVolume(-1);
-					break;
-
-				case Common::KEYCODE_RIGHTBRACKET:
-					_vm->changeVolume(1);
-					break;
-
-				case Common::KEYCODE_z:
-					//saveSettings();
-					break;
-
-				default: {
-					int n = ((((unsigned int)((_nextKeyIn + 1) >> 31) >> 26) + (byte)_nextKeyIn + 1) & 0x3F)
-						- ((unsigned int)((_nextKeyIn + 1) >> 31) >> 26);
-					if (n != _nextKeyOut) {
-						_keyBuf[_nextKeyIn] = event.kbd.keycode;
-						_nextKeyIn = n;
-					}
-					}
+			default: {
+				int n = ((((unsigned int)((_nextKeyIn + 1) >> 31) >> 26) + (byte)_nextKeyIn + 1) & 0x3F)
+					- ((unsigned int)((_nextKeyIn + 1) >> 31) >> 26);
+				if (n != _nextKeyOut) {
+					_keyBuf[_nextKeyIn] = event.kbd.keycode;
+					_nextKeyIn = n;
+				}
 				}
-				break;
-
-			case Common::EVENT_QUIT:
-			case Common::EVENT_RTL:
-			default:
-				break;
 			}
-
-			g_system->copyRectToScreen(_vm->_graphics->_displayBuffer, _vm->_graphics->_screenWidth, 0, 0, _vm->_graphics->_screenWidth, _vm->_graphics->_screenHeight);
-			g_system->updateScreen();
+			break;
+		case Common::EVENT_QUIT:
+		case Common::EVENT_RTL:
+		default:
+			break;
 		}
-	}
 
-	if (canDelay)
-		g_system->delayMillis(10);
+		g_system->copyRectToScreen(_vm->_graphics->_displayBuffer, _vm->_graphics->_screenWidth, 0, 0, _vm->_graphics->_screenWidth, _vm->_graphics->_screenHeight);
+		g_system->updateScreen();
+	}
 }
 
 uint16 EventManager::getNextChar() {
diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h
index 68b441a..354d4ee 100644
--- a/engines/lab/eventman.h
+++ b/engines/lab/eventman.h
@@ -76,7 +76,6 @@ private:
 	bool _leftClick;
 	bool _rightClick;
 	bool _mouseHidden;
-	bool _mouseAtEdge;
 
 	uint16 _nextKeyIn;
 	uint16 _nextKeyOut;
@@ -92,7 +91,6 @@ private:
 	Button *checkButtonHit(ButtonList *buttonList, Common::Point pos);
 	bool mouseButton(uint16 *x, uint16 *y, bool leftButton);
 	Button *mouseButton();
-	void mouseHandler(int flag, Common::Point pos);
 	bool keyPress(uint16 *keyCode);
 	bool haveNextChar();
 	uint16 getNextChar();
@@ -114,7 +112,7 @@ public:
 	void initMouse();
 	void mouseShow();
 	void mouseHide();
-	void processInput(bool canDelay = false);
+	void processInput();
 	void setMousePos(Common::Point pos);
 	void updateMouse();
 	Common::Point updateAndGetMousePos();


Commit: 09539d76ac702577213ed9a2678f847d6683bba8
    https://github.com/scummvm/scummvm/commit/09539d76ac702577213ed9a2678f847d6683bba8
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:07+01:00

Commit Message:
LAB: Remove superfluous function

Changed paths:
    engines/lab/eventman.cpp
    engines/lab/eventman.h
    engines/lab/interface.cpp



diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 2537412..0a60809 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -232,13 +232,6 @@ bool EventManager::mouseButton(uint16 *x, uint16 *y, bool leftButton) {
 	return false;
 }
 
-Button *EventManager::mouseButton() {
-	Button *temp = _lastButtonHit;
-
-	_lastButtonHit = nullptr;
-	return temp;
-}
-
 /**
  * Checks whether or not a key has been pressed.
  */
diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h
index 354d4ee..85de4b3 100644
--- a/engines/lab/eventman.h
+++ b/engines/lab/eventman.h
@@ -90,7 +90,6 @@ private:
 private:
 	Button *checkButtonHit(ButtonList *buttonList, Common::Point pos);
 	bool mouseButton(uint16 *x, uint16 *y, bool leftButton);
-	Button *mouseButton();
 	bool keyPress(uint16 *keyCode);
 	bool haveNextChar();
 	uint16 getNextChar();
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index fea9f5a..b63acca 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -141,7 +141,8 @@ IntuiMessage *EventManager::getMsg() {
 	updateMouse();
 
 	int qualifiers = _keyPressed.flags;
-	Button *curButton  = mouseButton();
+	Button *curButton = _lastButtonHit;
+	_lastButtonHit = nullptr;
 
 	if (curButton) {
 		updateMouse();


Commit: 8b16ccbea1b686f49d78e3337683ad45789b22e9
    https://github.com/scummvm/scummvm/commit/8b16ccbea1b686f49d78e3337683ad45789b22e9
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:07+01:00

Commit Message:
LAB: Get rid of mouseButton()

Changed paths:
    engines/lab/eventman.cpp
    engines/lab/eventman.h
    engines/lab/interface.cpp



diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 0a60809..c67250d 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -208,31 +208,6 @@ void EventManager::setMousePos(Common::Point pos) {
 }
 
 /**
- * Checks whether or not the mouse buttons have been pressed, and the last
- * co-ordinates of the button press.  leftbutton tells whether to check the
- * left or right button.
- */
-bool EventManager::mouseButton(uint16 *x, uint16 *y, bool leftButton) {
-	if (leftButton) {
-		if (_leftClick) {
-			*x = (!_vm->_isHiRes) ? (uint16)_mousePos.x / 2 : (uint16)_mousePos.x;
-			*y = (uint16)_mousePos.y;
-			_leftClick = false;
-			return true;
-		}
-	} else {
-		if (_rightClick) {
-			*x = (!_vm->_isHiRes) ? (uint16)_mousePos.x / 2 : (uint16)_mousePos.x;
-			*y = (uint16)_mousePos.y;
-			_rightClick = false;
-			return true;
-		}
-	}
-
-	return false;
-}
-
-/**
  * Checks whether or not a key has been pressed.
  */
 bool EventManager::keyPress(uint16 *keyCode) {
diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h
index 85de4b3..d2c5782 100644
--- a/engines/lab/eventman.h
+++ b/engines/lab/eventman.h
@@ -89,7 +89,6 @@ private:
 
 private:
 	Button *checkButtonHit(ButtonList *buttonList, Common::Point pos);
-	bool mouseButton(uint16 *x, uint16 *y, bool leftButton);
 	bool keyPress(uint16 *keyCode);
 	bool haveNextChar();
 	uint16 getNextChar();
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index b63acca..fd47fc7 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -151,18 +151,14 @@ IntuiMessage *EventManager::getMsg() {
 		message._buttonId = curButton->_buttonId;
 		message._qualifier = qualifiers;
 		return &message;
-	} else if (mouseButton(&message._mouseX, &message._mouseY, true)) {
-		// Left Button
-		message._qualifier = IEQUALIFIER_LEFTBUTTON | qualifiers;
-		message._msgClass = MOUSEBUTTONS;
-		return &message;
-	} else if (mouseButton(&message._mouseX, &message._mouseY, false)) {
-		// Right Button
-		message._qualifier = IEQUALIFIER_RIGHTBUTTON | qualifiers;
+	} else if (_leftClick || _rightClick) {
+		message._qualifier = (_leftClick) ? (IEQUALIFIER_LEFTBUTTON | qualifiers) : (IEQUALIFIER_RIGHTBUTTON | qualifiers);
 		message._msgClass = MOUSEBUTTONS;
+		message._mouseX = (!_vm->_isHiRes) ? (uint16)_mousePos.x / 2 : (uint16)_mousePos.x;
+		message._mouseY = (uint16)_mousePos.y;
+		_leftClick = _rightClick = false;
 		return &message;
 	} else if (keyPress(&message._code)) {
-		// Keyboard key
 		curButton = checkNumButtonHit(_screenButtonList, message._code);
 
 		if (curButton) {


Commit: 605c2e553bd9b8421af643491a7855d8c2cd4710
    https://github.com/scummvm/scummvm/commit/605c2e553bd9b8421af643491a7855d8c2cd4710
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:07+01:00

Commit Message:
LAB: Use common keycodes instead of direct keycode values

Changed paths:
    engines/lab/intro.cpp
    engines/lab/map.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 992d237..e26f182 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -155,7 +155,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 			uint16 code = msg->_code;
 
 			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) ||
-				  ((msgClass == RAWKEY) && (code == 27))) {
+				((msgClass == RAWKEY) && (code == Common::KEYCODE_ESCAPE))) {
 				_quitIntro = true;
 
 				if (isScreen)
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 09d8988..63ea353 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -477,7 +477,7 @@ void LabEngine::processMap(uint16 curRoom) {
 			uint16 mouseX    = msg->_mouseX;
 			uint16 mouseY    = msg->_mouseY;
 
-			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || ((msgClass == RAWKEY) && (msgCode == 27)))
+			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || ((msgClass == RAWKEY) && (msgCode == Common::KEYCODE_ESCAPE)))
 				return;
 
 			if (msgClass == BUTTONUP) {
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index d61ddcb..2f071da 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -273,7 +273,7 @@ void LabEngine::processJournal() {
 			uint16 buttonId  = msg->_code;
 
 			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) ||
-				  ((msgClass == RAWKEY) && (buttonId == 27)))
+				((msgClass == RAWKEY) && (buttonId == Common::KEYCODE_ESCAPE)))
 				return;
 			else if (msgClass == BUTTONUP) {
 				if (buttonId == 0) {
@@ -439,7 +439,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 			uint16 code      = msg->_code;
 
 			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) ||
-				  ((msgClass == RAWKEY) && (code == 27)))
+				  ((msgClass == RAWKEY) && (code == Common::KEYCODE_ESCAPE)))
 				return;
 			else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) {
 				if ((mouseY >= _utils->vgaScaleY(171)) && (mouseY <= _utils->vgaScaleY(200))) {


Commit: 054a7a1e19ffb3d5f5d298c0af3e0e33435d5ed7
    https://github.com/scummvm/scummvm/commit/054a7a1e19ffb3d5f5d298c0af3e0e33435d5ed7
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:07+01:00

Commit Message:
LAB: Use Common::Rect in functions related to flowText (WIP)

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/engine.cpp
    engines/lab/intro.cpp
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/special.cpp
    engines/lab/utils.cpp
    engines/lab/utils.h



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index b9d5802..2db2bc1 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -188,12 +188,11 @@ int DisplayMan::flowText(
 			bool centerh,          // Whether to center the text horizontally
 			bool centerv,          // Whether to center the text vertically
 			bool output,           // Whether to output any text
-			uint16 x1, uint16 y1,  // Cords
-			uint16 x2, uint16 y2,
+			Common::Rect textRect,	// Cords
 			const char *str) {     // The text itself
 	if (fillBack) {
 		setPen(backPen);
-		rectFill(x1, y1, x2, y2);
+		rectFill(textRect);
 	}
 
 	if (!str)
@@ -203,9 +202,9 @@ int DisplayMan::flowText(
 
 	TextFont *msgFont = font;
 	uint16 fontHeight = textHeight(msgFont) + spacing;
-	uint16 numLines   = (y2 - y1 + 1) / fontHeight;
-	uint16 width      = x2 - x1 + 1;
-	uint16 y          = y1;
+	uint16 numLines   = (textRect.height() + 1) / fontHeight;
+	uint16 width      = textRect.width() + 1;
+	uint16 y          = textRect.top;
 	char lineBuffer[256];
 
 	if (centerv && output) {
@@ -218,14 +217,14 @@ int DisplayMan::flowText(
 		}
 
 		if (actlines <= numLines)
-			y += ((y2 - y1 + 1) - (actlines * fontHeight)) / 2;
+			y += ((textRect.height() + 1) - (actlines * fontHeight)) / 2;
 	}
 
 	int len = 0;
 	while (numLines && str[0]) {
 		getLine(msgFont, lineBuffer, &str, width);
 
-		uint16 x = x1;
+		uint16 x = textRect.left;
 		len += strlen(lineBuffer);
 
 		if (centerh)
@@ -252,12 +251,10 @@ int DisplayMan::flowTextScaled(
 	bool centerX,              // Whether to center the text horizontally
 	bool centerY,              // Whether to center the text vertically
 	bool output,               // Whether to output any text
-	uint16 x1, uint16 y1,      // Cords
-	uint16 x2, uint16 y2,
+	Common::Rect textRect,     // Cords
 	const char *str) {
-	return flowText(font, spacing, penColor, backPen, fillBack, centerX, centerY, output,
-					_vm->_utils->vgaScaleX(x1), _vm->_utils->vgaScaleY(y1),
-					_vm->_utils->vgaScaleX(x2), _vm->_utils->vgaScaleY(y2), str);
+	Common::Rect scaledRect = _vm->_utils->vgaRectScale(textRect.left, textRect.top, textRect.right, textRect.bottom);
+	return flowText(font, spacing, penColor, backPen, fillBack, centerX, centerY, output, scaledRect, str);
 }
 
 /**
@@ -272,8 +269,7 @@ int DisplayMan::flowTextToMem(Image *destIm,
 			bool centerh,          // Whether to center the text horizontally
 			bool centerv,          // Whether to center the text vertically
 			bool output,           // Whether to output any text
-			uint16 x1, uint16 y1,  // Cords
-			uint16 x2, uint16 y2,
+			Common::Rect textRect,  // Cords
 			const char *str) {     // The text itself
 	byte *saveDisplayBuffer = _currentDisplayBuffer;
 	uint32 bytesPerPage = _screenBytesPerPage;
@@ -281,7 +277,7 @@ int DisplayMan::flowTextToMem(Image *destIm,
 	_currentDisplayBuffer = destIm->_imageData;
 	_screenBytesPerPage = (uint32)destIm->_width * (int32)destIm->_height;
 
-	int res = flowText(font, spacing, penColor, backPen, fillBack, centerh, centerv, output, x1, y1, x2, y2, str);
+	int res = flowText(font, spacing, penColor, backPen, fillBack, centerh, centerv, output, textRect, str);
 
 	_screenBytesPerPage = bytesPerPage;
 	_currentDisplayBuffer = saveDisplayBuffer;
@@ -324,7 +320,7 @@ int DisplayMan::longDrawMessage(const char *str) {
 	createBox(198);
 	_vm->_event->mouseShow();
 
-	return flowTextScaled(_vm->_msgFont, 0, 1, 7, false, true, true, true, 6, 155, 313, 195, str);
+	return flowTextScaled(_vm->_msgFont, 0, 1, 7, false, true, true, true, Common::Rect(6, 155, 313, 195), str);
 }
 
 /**
@@ -479,22 +475,22 @@ void DisplayMan::setPen(byte penNum) {
 /**
  * Fills in a rectangle.
  */
-void DisplayMan::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	int w = x2 - x1 + 1;
-	int h = y2 - y1 + 1;
+void DisplayMan::rectFill(Common::Rect fillRect) {
+	int width = fillRect.width() + 1;
+	int height = fillRect.height() + 1;
 
-	if (x1 + w > _screenWidth)
-		w = _screenWidth - x1;
+	if (fillRect.left + width > _screenWidth)
+		width = _screenWidth - fillRect.left;
 
-	if (y1 + h > _screenHeight)
-		h = _screenHeight - y1;
+	if (fillRect.top + height > _screenHeight)
+		height = _screenHeight - fillRect.top;
 
-	if ((w > 0) && (h > 0)) {
-		char *d = (char *)getCurrentDrawingBuffer() + y1 * _screenWidth + x1;
+	if ((width > 0) && (height > 0)) {
+		char *d = (char *)getCurrentDrawingBuffer() + fillRect.top * _screenWidth + fillRect.left;
 
-		while (h-- > 0) {
+		while (height-- > 0) {
 			char *dd = d;
-			int ww = w;
+			int ww = width;
 
 			while (ww-- > 0) {
 				*dd++ = _curPen;
@@ -505,8 +501,12 @@ void DisplayMan::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	}
 }
 
+void DisplayMan::rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+	rectFill(Common::Rect(x1, y1, x2, y2));
+}
+
 void DisplayMan::rectFillScaled(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	rectFill(_vm->_utils->vgaScaleX(x1), _vm->_utils->vgaScaleY(y1), _vm->_utils->vgaScaleX(x2), _vm->_utils->vgaScaleY(y2));
+	rectFill(_vm->_utils->vgaRectScale(x1, y1, x2, y2));
 }
 
 /**
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index 92a09c1..c00f18d 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -92,6 +92,7 @@ public:
 	void drawMessage(const char *str);
 	void setPen(byte pennum);
 	void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void rectFill(Common::Rect fillRect);
 	void rectFillScaled(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	// Window text stuff
 	int flowText(TextFont *font,		// the TextAttr pointer
@@ -102,8 +103,7 @@ public:
 				bool centerh,			// Whether to center the text horizontally
 				bool centerv,			// Whether to center the text vertically
 				bool output,			// Whether to output any text
-				uint16 x1, uint16 y1,	// Cords
-				uint16 x2, uint16 y2,
+				Common::Rect textRect,	// Cords
 				const char *text);		// The text itself
 
 	int flowTextScaled(
@@ -115,8 +115,7 @@ public:
 				bool centerh,			// Whether to center the text horizontally
 				bool centerv,			// Whether to center the text vertically
 				bool output,			// Whether to output any text
-				uint16 x1, uint16 y1,	// Cords
-				uint16 x2, uint16 y2,
+				Common::Rect textRect,	// Cords
 				const char *text);		// The text itself
 
 	int flowTextToMem(Image *destIm,
@@ -128,8 +127,7 @@ public:
 				bool centerh,			// Whether to center the text horizontally
 				bool centerv,			// Whether to center the text vertically
 				bool output,			// Whether to output any text
-				uint16 x1, uint16 y1,	// Cords
-				uint16 x2, uint16 y2,
+				Common::Rect textRect,	// Cords
 				const char *str);		// The text itself
 
 	void drawHLine(uint16 x, uint16 y1, uint16 y2);
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index f82c7cc..c79197a 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -198,46 +198,55 @@ bool LabEngine::doCloseUp(CloseDataPtr closePtr) {
 	if (!closePtr)
 		return false;
 
-	int monltmargin, monrtmargin, montopmargin, lutertmargin;
+	int luteRight;
+	Common::Rect textRect;
 
 	if (getPlatform() != Common::kPlatformWindows) {
-		monltmargin = 0;
-		monrtmargin = 319;
-		montopmargin = 0;
-		lutertmargin = 124;
+		textRect.left = 0;
+		textRect.right = 319;
+		textRect.top = 0;
+		textRect.bottom = 165;
+		luteRight = 124;
 	} else {
-		monltmargin = 2;
-		monrtmargin = 317;
-		montopmargin = 2;
-		lutertmargin = 128;
+		textRect.left = 2;
+		textRect.right = 317;
+		textRect.top = 2;
+		textRect.bottom = 165;
+		luteRight = 128;
 	}
 
 	switch (closePtr->_closeUpType) {
 	case kMonitorMuseum:
 	case kMonitorLibrary:
 	case kMonitorWindow:
-		doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, monrtmargin, 165);
+		doMonitor(closePtr->_graphicName, closePtr->_message, false, textRect);
 		break;
 	case kMonitorGramophone:
-		doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, 171, 165);
+		textRect.right = 171;
+		doMonitor(closePtr->_graphicName, closePtr->_message, false, textRect);
 		break;
 	case kMonitorUnicycle:
-		doMonitor(closePtr->_graphicName, closePtr->_message, false, 100, montopmargin, monrtmargin, 165);
+		textRect.left = 100;
+		doMonitor(closePtr->_graphicName, closePtr->_message, false, textRect);
 		break;
 	case kMonitorStatue:
-		doMonitor(closePtr->_graphicName, closePtr->_message, false, 117, montopmargin, monrtmargin, 165);
+		textRect.left = 117;
+		doMonitor(closePtr->_graphicName, closePtr->_message, false, textRect);
 		break;
 	case kMonitorTalisman:
-		doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, 184, 165);
+		textRect.right = 184;
+		doMonitor(closePtr->_graphicName, closePtr->_message, false, textRect);
 		break;
 	case kMonitorLute:
-		doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, lutertmargin, 165);
+		textRect.right = luteRight;
+		doMonitor(closePtr->_graphicName, closePtr->_message, false, textRect);
 		break;
 	case kMonitorClock:
-		doMonitor(closePtr->_graphicName, closePtr->_message, false, monltmargin, montopmargin, 206, 165);
+		textRect.right = 206;
+		doMonitor(closePtr->_graphicName, closePtr->_message, false, textRect);
 		break;
 	case kMonitorTerminal:
-		doMonitor(closePtr->_graphicName, closePtr->_message, true, monltmargin, montopmargin, monrtmargin, 165);
+		doMonitor(closePtr->_graphicName, closePtr->_message, true, textRect);
 		break;
 	default:
 		return false;
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index e26f182..b2fa0b0 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -103,7 +103,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 				_vm->_graphics->setPen(7);
 				_vm->_graphics->rectFillScaled(10, 10, 310, 190);
 
-				charDrawn = _vm->_graphics->flowTextScaled(msgFont, (!_vm->_isHiRes) * -1, 5, 7, false, false, true, true, 14, 11, 306, 189, (char *)curText);
+				charDrawn = _vm->_graphics->flowTextScaled(msgFont, (!_vm->_isHiRes) * -1, 5, 7, false, false, true, true, Common::Rect(14, 11, 306, 189), (char *)curText);
 				_vm->_graphics->fade(true, 0);
 			} else
 				charDrawn = _vm->_graphics->longDrawMessage((char *)curText);
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 4cd681e..dcde9f9 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -205,7 +205,7 @@ private:
 	void doJournal();
 	bool doMainView(CloseDataPtr *closePtrList);
 	void doMap(uint16 curRoom);
-	void doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void doMonitor(char *background, char *textfile, bool isinteractive, Common::Rect textRect);
 	void doNotes();
 	bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults);
 	bool doOperateRule(Common::Point pos, int16 ItemNum, CloseDataPtr *closePtrList);
@@ -216,7 +216,7 @@ private:
 	void drawJournal(uint16 wipenum, bool needFade);
 	void drawJournalText();
 	void drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fadeOut, bool fadeIn);
-	void drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive);
+	void drawMonText(char *text, TextFont *monitorFont, Common::Rect textRect, bool isinteractive);
 	void drawRoomMap(uint16 curRoom, bool drawMarkFl);
 	void drawRoomMessage(uint16 curInv, CloseDataPtr closePtr);
 	void drawStaticMessage(byte index);
@@ -245,7 +245,7 @@ private:
 	uint16 processArrow(uint16 curDirection, uint16 arrow);
 	void processJournal();
 	void processMap(uint16 curRoom);
-	void processMonitor(char *ntext, TextFont *monitorFont, bool isInteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void processMonitor(char *ntext, TextFont *monitorFont, bool isInteractive, Common::Rect textRect);
 	Common::Rect roomCoords(uint16 curRoom);
 	bool saveRestoreGame();
 	void setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, bool useAbsoluteCoords);
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 63ea353..cbd664e 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -405,16 +405,17 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad
 			_imgHugeMaze->drawImage(_utils->mapScaleX(524), _utils->mapScaleY(97));
 	} else if (floorNum == kFloorSurMaze) {
 		char *sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str();
-		_graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, _utils->mapScaleX(360), 0, _utils->mapScaleX(660), _utils->mapScaleY(450), sptr);
+		Common::Rect textRect = Common::Rect(_utils->mapScaleX(360), 0, _utils->mapScaleX(660), _utils->mapScaleY(450));
+		_graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, textRect, sptr);
 	}
 
 	if ((floorNum >= kFloorLower) && (floorNum <= kFloorCarnival)) {
 		char *sptr = (char *)_resource->getStaticText(floorNum - 1).c_str();
-		_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 75, 134, 97, sptr);
+		_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, Common::Rect(14, 75, 134, 97), sptr);
 	}
 
 	if (_rooms[curMsg]._roomMsg)
-		_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, _rooms[curMsg]._roomMsg);
+		_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, Common::Rect(14, 148, 134, 186), _rooms[curMsg]._roomMsg);
 
 	if (fadeIn)
 		_graphics->fade(true, 0);
@@ -558,7 +559,7 @@ void LabEngine::processMap(uint16 curRoom) {
 							_event->mouseHide();
 							_graphics->setPen(3);
 							_graphics->rectFillScaled(13, 148, 135, 186);
-							_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, 14, 148, 134, 186, sptr);
+							_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, Common::Rect(14, 148, 134, 186), sptr);
 
 							if (_maps[oldMsg]._pageNumber == curFloor)
 								drawRoomMap(oldMsg, (bool)(oldMsg == curRoom));
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 2f071da..c8cc616 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -54,7 +54,8 @@ void LabEngine::doNotes() {
 	TextFont *noteFont = _resource->getFont("P:Note.fon");
 	char *noteText = _resource->getText("Lab:Rooms/Notes");
 
-	_graphics->flowText(noteFont, -2 + _utils->svgaCord(1), 0, 0, false, false, true, true, _utils->vgaScaleX(25) + _utils->svgaCord(15), _utils->vgaScaleY(50), _utils->vgaScaleX(295) - _utils->svgaCord(15), _utils->vgaScaleY(148), noteText);
+	Common::Rect textRect = Common::Rect(_utils->vgaScaleX(25) + _utils->svgaCord(15), _utils->vgaScaleY(50), _utils->vgaScaleX(295) - _utils->svgaCord(15), _utils->vgaScaleY(148));
+	_graphics->flowText(noteFont, -2 + _utils->svgaCord(1), 0, 0, false, false, true, true, textRect, noteText);
 	_graphics->setPalette(_anim->_diffPalette, 256);
 	_graphics->closeFont(noteFont);
 	delete[] noteText;
@@ -67,7 +68,9 @@ void LabEngine::doNotes() {
 void LabEngine::doWestPaper() {
 	TextFont *paperFont = _resource->getFont("P:News22.fon");
 	char *paperText = _resource->getText("Lab:Rooms/Date");
-	_graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(77) + _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(91), paperText);
+
+	Common::Rect textRect = Common::Rect(_utils->vgaScaleX(57), _utils->vgaScaleY(77) + _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(91));
+	_graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, textRect, paperText);
 	_graphics->closeFont(paperFont);
 	delete[] paperText;
 
@@ -75,13 +78,15 @@ void LabEngine::doWestPaper() {
 	paperText = _resource->getText("Lab:Rooms/Headline");
 
 	int fileLen = strlen(paperText) - 1;
-	int charsPrinted = _graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(118), paperText);
+	textRect = Common::Rect(_utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(118));
+	int charsPrinted = _graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, textRect, paperText);
 
 	uint16 y;
 
 	if (charsPrinted < fileLen) {
 		y = 130 - _utils->svgaCord(5);
-		_graphics->flowText(paperFont, -8 - _utils->svgaCord(1), 0, 0, false, true, false, true, _utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(132), paperText);
+		textRect = Common::Rect(_utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(132));
+		_graphics->flowText(paperFont, -8 - _utils->svgaCord(1), 0, 0, false, true, false, true, textRect, paperText);
 	} else
 		y = 115 - _utils->svgaCord(5);
 
@@ -90,10 +95,10 @@ void LabEngine::doWestPaper() {
 
 	paperFont = _resource->getFont("P:Note.fon");
 	paperText = _resource->getText("Lab:Rooms/Col1");
-	charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 45, y, 158, 148, paperText);
+	charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, Common::Rect(45, y, 158, 148), paperText);
 	delete[] paperText;
 	paperText = _resource->getText("Lab:Rooms/Col2");
-	charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, 162, y, 275, 148, paperText);
+	charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, Common::Rect(162, y, 275, 148), paperText);
 	delete[] paperText;
 	_graphics->closeFont(paperFont);
 
@@ -167,7 +172,7 @@ void LabEngine::drawJournalText() {
 	while (drawingToPage < _journalPage) {
 		_music->updateMusic();
 		curText = (char *)(_journalText + charsDrawn);
-		charsDrawn += _graphics->flowTextScaled(_journalFont, -2, 2, 0, false, false, false, false, 52, 32, 152, 148, curText);
+		charsDrawn += _graphics->flowTextScaled(_journalFont, -2, 2, 0, false, false, false, false, Common::Rect(52, 32, 152, 148), curText);
 
 		_lastPage = (*curText == 0);
 
@@ -179,16 +184,16 @@ void LabEngine::drawJournalText() {
 
 	if (_journalPage <= 1) {
 		curText = _journalTextTitle;
-		_graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText);
+		_graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaRectScale(52, 32, 152, 148), curText);
 	} else {
 		curText = (char *)(_journalText + charsDrawn);
-		charsDrawn += _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(52), _utils->vgaScaleY(32), _utils->vgaScaleX(152), _utils->vgaScaleY(148), curText);
+		charsDrawn += _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(52, 32, 152, 148), curText);
 	}
 
 	_music->updateMusic();
 	curText = (char *)(_journalText + charsDrawn);
 	_lastPage = (*curText == 0);
-	_graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaScaleX(171), _utils->vgaScaleY(32), _utils->vgaScaleX(271), _utils->vgaScaleY(148), curText);
+	_graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(171, 32, 271, 148), curText);
 
 	curText = (char *)(_journalText + charsDrawn);
 	_lastPage |= (*curText == 0);
@@ -331,7 +336,7 @@ void LabEngine::doJournal() {
 /**
  * Draws the text for the monitor.
  */
-void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16 y1, uint16 x2, uint16 y2, bool isinteractive) {
+void LabEngine::drawMonText(char *text, TextFont *monitorFont, Common::Rect textRect, bool isinteractive) {
 	uint16 drawingToPage = 0, yspacing = 0;
 	int charsDrawn = 0;
 	char *curText = text;
@@ -346,7 +351,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
 		text += 2;
 
 		uint16 fheight = _graphics->textHeight(monitorFont);
-		x1 = _monitorButton->_width + _utils->vgaScaleX(3);
+		textRect.left = _monitorButton->_width + _utils->vgaScaleX(3);
 		_monitorButtonHeight = _monitorButton->_height + _utils->vgaScaleY(3);
 
 		if (_monitorButtonHeight > fheight)
@@ -355,22 +360,22 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
 			_monitorButtonHeight = fheight;
 
 		_graphics->setPen(0);
-		_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2);
+		_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, textRect.bottom);
 
 		for (uint16 i = 0; i < numlines; i++)
 			_monitorButton->drawImage(0, i * _monitorButtonHeight);
 	} else if (isinteractive) {
 		_graphics->setPen(0);
-		_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, y2);
+		_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, textRect.bottom);
 	} else {
 		_graphics->setPen(0);
-		_graphics->rectFill(x1, y1, x2, y2);
+		_graphics->rectFill(textRect);
 	}
 
 	while (drawingToPage < _monitorPage) {
 		_music->updateMusic();
 		curText = (char *)(text + charsDrawn);
-		charsDrawn += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, x1, y1, x2, y2, curText);
+		charsDrawn += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, textRect, curText);
 		_lastPage = (*curText == 0);
 
 		if (_lastPage)
@@ -381,7 +386,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
 
 	curText = (char *)(text + charsDrawn);
 	_lastPage = (*curText == 0);
-	charsDrawn = _graphics->flowText(monitorFont, yspacing, 2, 0, false, false, false, true, x1, y1, x2, y2, curText);
+	charsDrawn = _graphics->flowText(monitorFont, yspacing, 2, 0, false, false, false, true, textRect, curText);
 	curText += charsDrawn;
 	_lastPage |= (*curText == 0);
 
@@ -391,7 +396,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, uint16 x1, uint16
 /**
  * Processes user input.
  */
-void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isInteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isInteractive, Common::Rect textRect) {
 	const char *startFileName = _monitorTextFilename;
 	CloseDataPtr startClosePtr = _closeDataPtr, lastClosePtr[10];
 	uint16 depth = 0;
@@ -415,7 +420,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 
 				ntext = _resource->getText(_monitorTextFilename);
 				_graphics->fade(false, 0);
-				drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive);
+				drawMonText(ntext, monitorFont, textRect, isInteractive);
 				_graphics->fade(true, 0);
 				delete[] ntext;
 			}
@@ -455,19 +460,19 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 							}
 						} else if (_monitorPage > 0) {
 							_monitorPage = 0;
-							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive);
+							drawMonText(ntext, monitorFont, textRect, isInteractive);
 						}
 					} else if (mouseX < _utils->vgaScaleX(259)) {
 						return;
 					} else if (mouseX <= _utils->vgaScaleX(289)) {
 						if (!_lastPage) {
 							_monitorPage += 1;
-							drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive);
+							drawMonText(ntext, monitorFont, textRect, isInteractive);
 						}
 					} else if (_monitorPage >= 1) {
 						// mouseX between 290 and 320 (scaled)
 						_monitorPage -= 1;
-						drawMonText(ntext, monitorFont, x1, y1, x2, y2, isInteractive);
+						drawMonText(ntext, monitorFont, textRect, isInteractive);
 					}
 				} else if (isInteractive) {
 					CloseDataPtr tmpClosePtr = _closeDataPtr;
@@ -488,12 +493,8 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 /**
  * Does what's necessary for the monitor.
  */
-void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
-	x1 = _utils->vgaScaleX(x1);
-	x2 = _utils->vgaScaleX(x2);
-	y1 = _utils->vgaScaleY(y1);
-	y2 = _utils->vgaScaleY(y2);
-
+void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, Common::Rect textRect) {
+	Common::Rect scaledRect = _utils->vgaRectScale(textRect.left, textRect.top, textRect.right, textRect.bottom);
 	_monitorTextFilename = textfile;
 
 	_graphics->blackAllScreen();
@@ -514,10 +515,10 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 
 	char *ntext = _resource->getText(textfile);
 	_graphics->loadBackPict(background, _highPalette);
-	drawMonText(ntext, monitorFont, x1, y1, x2, y2, isinteractive);
+	drawMonText(ntext, monitorFont, scaledRect, isinteractive);
 	_event->mouseShow();
 	_graphics->fade(true, 0);
-	processMonitor(ntext, monitorFont, isinteractive, x1, y1, x2, y2);
+	processMonitor(ntext, monitorFont, isinteractive, scaledRect);
 	_graphics->fade(false, 0);
 	_event->mouseHide();
 	delete[] ntext;
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index 89af44e..7360558 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -94,6 +94,10 @@ int16 Utils::vgaScaleY(int16 y) {
 		return y;
 }
 
+Common::Rect Utils::vgaRectScale(int16 x1, int16 y1, int16 x2, int16 y2) {
+	return Common::Rect(vgaScaleX(x1), vgaScaleY(y1), vgaScaleX(x2), vgaScaleY(y2));
+}
+
 uint16 Utils::svgaCord(uint16 cord) {
 	if (_vm->_isHiRes)
 		return cord;
diff --git a/engines/lab/utils.h b/engines/lab/utils.h
index 0c4118e..c6337c7 100644
--- a/engines/lab/utils.h
+++ b/engines/lab/utils.h
@@ -53,6 +53,7 @@ public:
 	uint16 scaleY(uint16 y);
 	int16 vgaScaleX(int16 x);
 	int16 vgaScaleY(int16 y);
+	Common::Rect vgaRectScale(int16 x1, int16 y1, int16 x2, int16 y2);
 	uint16 svgaCord(uint16 cord);
 	uint16 mapScaleX(uint16 x);
 	uint16 mapScaleY(uint16 y);


Commit: 25509777aa1770c07ab66729c371d28c825894ea
    https://github.com/scummvm/scummvm/commit/25509777aa1770c07ab66729c371d28c825894ea
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:07+01:00

Commit Message:
LAB: Get rid of flowTextScaled

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/intro.cpp
    engines/lab/map.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 2db2bc1..f2b3b46 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -242,21 +242,6 @@ int DisplayMan::flowText(
 	return len;
 }
 
-int DisplayMan::flowTextScaled(
-	TextFont *font,            // the TextAttr pointer
-	int16 spacing,             // How much vertical spacing between the lines
-	byte penColor,             // pen number to use for text
-	byte backPen,              // the background color
-	bool fillBack,             // Whether to fill the background
-	bool centerX,              // Whether to center the text horizontally
-	bool centerY,              // Whether to center the text vertically
-	bool output,               // Whether to output any text
-	Common::Rect textRect,     // Cords
-	const char *str) {
-	Common::Rect scaledRect = _vm->_utils->vgaRectScale(textRect.left, textRect.top, textRect.right, textRect.bottom);
-	return flowText(font, spacing, penColor, backPen, fillBack, centerX, centerY, output, scaledRect, str);
-}
-
 /**
  * Calls flowText, but flows it to memory.  Same restrictions as flowText.
  */
@@ -320,7 +305,7 @@ int DisplayMan::longDrawMessage(const char *str) {
 	createBox(198);
 	_vm->_event->mouseShow();
 
-	return flowTextScaled(_vm->_msgFont, 0, 1, 7, false, true, true, true, Common::Rect(6, 155, 313, 195), str);
+	return flowText(_vm->_msgFont, 0, 1, 7, false, true, true, true, _vm->_utils->vgaRectScale(6, 155, 313, 195), str);
 }
 
 /**
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index c00f18d..2a86e34 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -106,18 +106,6 @@ public:
 				Common::Rect textRect,	// Cords
 				const char *text);		// The text itself
 
-	int flowTextScaled(
-				TextFont *font,			// the TextAttr pointer
-				int16 spacing,			// How much vertical spacing between the lines
-				byte penColor,			// pen number to use for text
-				byte backPen,			// the background color
-				bool fillBack,			// Whether to fill the background
-				bool centerh,			// Whether to center the text horizontally
-				bool centerv,			// Whether to center the text vertically
-				bool output,			// Whether to output any text
-				Common::Rect textRect,	// Cords
-				const char *text);		// The text itself
-
 	int flowTextToMem(Image *destIm,
 				TextFont *font,			// the TextAttr pointer
 				int16 spacing,			// How much vertical spacing between the lines
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index b2fa0b0..45119f4 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -103,7 +103,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 				_vm->_graphics->setPen(7);
 				_vm->_graphics->rectFillScaled(10, 10, 310, 190);
 
-				charDrawn = _vm->_graphics->flowTextScaled(msgFont, (!_vm->_isHiRes) * -1, 5, 7, false, false, true, true, Common::Rect(14, 11, 306, 189), (char *)curText);
+				charDrawn = _vm->_graphics->flowText(msgFont, (!_vm->_isHiRes) * -1, 5, 7, false, false, true, true, _vm->_utils->vgaRectScale(14, 11, 306, 189), (char *)curText);
 				_vm->_graphics->fade(true, 0);
 			} else
 				charDrawn = _vm->_graphics->longDrawMessage((char *)curText);
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index cbd664e..78eaaf0 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -411,11 +411,11 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad
 
 	if ((floorNum >= kFloorLower) && (floorNum <= kFloorCarnival)) {
 		char *sptr = (char *)_resource->getStaticText(floorNum - 1).c_str();
-		_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, Common::Rect(14, 75, 134, 97), sptr);
+		_graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 75, 134, 97), sptr);
 	}
 
 	if (_rooms[curMsg]._roomMsg)
-		_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, Common::Rect(14, 148, 134, 186), _rooms[curMsg]._roomMsg);
+		_graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 148, 134, 186), _rooms[curMsg]._roomMsg);
 
 	if (fadeIn)
 		_graphics->fade(true, 0);
@@ -559,7 +559,7 @@ void LabEngine::processMap(uint16 curRoom) {
 							_event->mouseHide();
 							_graphics->setPen(3);
 							_graphics->rectFillScaled(13, 148, 135, 186);
-							_graphics->flowTextScaled(_msgFont, 0, 5, 3, true, true, true, true, Common::Rect(14, 148, 134, 186), sptr);
+							_graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 148, 134, 186), sptr);
 
 							if (_maps[oldMsg]._pageNumber == curFloor)
 								drawRoomMap(oldMsg, (bool)(oldMsg == curRoom));
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index c8cc616..5ed0919 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -95,10 +95,10 @@ void LabEngine::doWestPaper() {
 
 	paperFont = _resource->getFont("P:Note.fon");
 	paperText = _resource->getText("Lab:Rooms/Col1");
-	charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, Common::Rect(45, y, 158, 148), paperText);
+	charsPrinted = _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(45, y, 158, 148), paperText);
 	delete[] paperText;
 	paperText = _resource->getText("Lab:Rooms/Col2");
-	charsPrinted = _graphics->flowTextScaled(paperFont, -4, 0, 0, false, false, false, true, Common::Rect(162, y, 275, 148), paperText);
+	charsPrinted = _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(162, y, 275, 148), paperText);
 	delete[] paperText;
 	_graphics->closeFont(paperFont);
 
@@ -172,7 +172,7 @@ void LabEngine::drawJournalText() {
 	while (drawingToPage < _journalPage) {
 		_music->updateMusic();
 		curText = (char *)(_journalText + charsDrawn);
-		charsDrawn += _graphics->flowTextScaled(_journalFont, -2, 2, 0, false, false, false, false, Common::Rect(52, 32, 152, 148), curText);
+		charsDrawn += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, false, _utils->vgaRectScale(52, 32, 152, 148), curText);
 
 		_lastPage = (*curText == 0);
 


Commit: 540173de3693eb78b07fed6a1bac8db1f3049829
    https://github.com/scummvm/scummvm/commit/540173de3693eb78b07fed6a1bac8db1f3049829
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:07+01:00

Commit Message:
LAB: constify 2 variables in drawMap

Changed paths:
    engines/lab/map.cpp



diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 78eaaf0..0136bf4f 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -404,14 +404,14 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad
 		if (floorVisited(kFloorHedgeMaze))
 			_imgHugeMaze->drawImage(_utils->mapScaleX(524), _utils->mapScaleY(97));
 	} else if (floorNum == kFloorSurMaze) {
-		char *sptr = (char *)_resource->getStaticText(kTextSurmazeMessage).c_str();
 		Common::Rect textRect = Common::Rect(_utils->mapScaleX(360), 0, _utils->mapScaleX(660), _utils->mapScaleY(450));
-		_graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, textRect, sptr);
+		const char *textPtr = _resource->getStaticText(kTextSurmazeMessage).c_str();
+		_graphics->flowText(_msgFont, 0, 7, 0, true, true, true, true, textRect, textPtr);
 	}
 
 	if ((floorNum >= kFloorLower) && (floorNum <= kFloorCarnival)) {
-		char *sptr = (char *)_resource->getStaticText(floorNum - 1).c_str();
-		_graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 75, 134, 97), sptr);
+		const char *textPrt = _resource->getStaticText(floorNum - 1).c_str();
+		_graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 75, 134, 97), textPrt);
 	}
 
 	if (_rooms[curMsg]._roomMsg)


Commit: 361aab82dc22e391b333daa0cf7ffc56850f9450
    https://github.com/scummvm/scummvm/commit/361aab82dc22e391b333daa0cf7ffc56850f9450
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:07+01:00

Commit Message:
LAB: Fix regression in left click handling

A regression of 326d9b5872177a1fea3fe24048286bd7c66242d8

Changed paths:
    engines/lab/eventman.cpp



diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index c67250d..f346fd5 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -226,12 +226,16 @@ bool EventManager::haveNextChar() {
 
 void EventManager::processInput() {
 	Common::Event event;
+	Button *curButton = nullptr;
 
 	while (g_system->getEventManager()->pollEvent(event)) {
 		switch (event.type) {
 		case Common::EVENT_LBUTTONDOWN:
 			if (_screenButtonList)
-				_lastButtonHit = checkButtonHit(_screenButtonList, _vm->_isHiRes ? _mousePos : Common::Point(_mousePos.x / 2, _mousePos.y));
+				curButton = checkButtonHit(_screenButtonList, _vm->_isHiRes ? _mousePos : Common::Point(_mousePos.x / 2, _mousePos.y));
+
+			if (curButton)
+				_lastButtonHit = curButton;
 			else
 				_leftClick = true;
 			break;


Commit: fdf09a63851cf51dc4c07a65e5fbc82c2d56512c
    https://github.com/scummvm/scummvm/commit/fdf09a63851cf51dc4c07a65e5fbc82c2d56512c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:08+01:00

Commit Message:
LAB: Some simplification of the mouse handling code

Changed paths:
    engines/lab/interface.cpp



diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index fd47fc7..afaec28 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -120,14 +120,9 @@ Button *EventManager::checkNumButtonHit(ButtonList *buttonList, uint16 key) {
 		if (((gkey - 1 == button->_buttonId) || ((gkey == 0) && (button->_buttonId == 9))
 		 || ((button->_keyEquiv != 0) && (makeButtonKeyEquiv(key) == button->_keyEquiv)))
 			  && button->_isEnabled) {
-			mouseHide();
 			button->_altImage->drawImage(button->_x, button->_y);
-			mouseShow();
 			g_system->delayMillis(80);
-			mouseHide();
 			button->_image->drawImage(button->_x, button->_y);
-			mouseShow();
-
 			return button;
 		}
 	}
@@ -140,35 +135,31 @@ IntuiMessage *EventManager::getMsg() {
 
 	updateMouse();
 
-	int qualifiers = _keyPressed.flags;
-	Button *curButton = _lastButtonHit;
-	_lastButtonHit = nullptr;
-
-	if (curButton) {
+	if (_lastButtonHit) {
 		updateMouse();
 		message._msgClass = BUTTONUP;
-		message._code = curButton->_buttonId;
-		message._buttonId = curButton->_buttonId;
-		message._qualifier = qualifiers;
+		message._code = _lastButtonHit->_buttonId;
+		message._buttonId = _lastButtonHit->_buttonId;
+		message._qualifier = _keyPressed.flags;
+		_lastButtonHit = nullptr;
 		return &message;
 	} else if (_leftClick || _rightClick) {
-		message._qualifier = (_leftClick) ? (IEQUALIFIER_LEFTBUTTON | qualifiers) : (IEQUALIFIER_RIGHTBUTTON | qualifiers);
+		message._qualifier = (_leftClick) ? IEQUALIFIER_LEFTBUTTON : IEQUALIFIER_RIGHTBUTTON;
 		message._msgClass = MOUSEBUTTONS;
 		message._mouseX = (!_vm->_isHiRes) ? (uint16)_mousePos.x / 2 : (uint16)_mousePos.x;
 		message._mouseY = (uint16)_mousePos.y;
 		_leftClick = _rightClick = false;
 		return &message;
 	} else if (keyPress(&message._code)) {
-		curButton = checkNumButtonHit(_screenButtonList, message._code);
+		Button *curButton = checkNumButtonHit(_screenButtonList, message._code);
 
 		if (curButton) {
 			message._msgClass = BUTTONUP;
-			message._code = curButton->_buttonId;
-			message._buttonId = curButton->_buttonId;
+			message._code = message._buttonId = curButton->_buttonId;
 		} else
 			message._msgClass = RAWKEY;
 
-		message._qualifier = qualifiers;
+		message._qualifier = _keyPressed.flags;
 		return &message;
 	} else
 		return nullptr;


Commit: b6bed0aed72bb45e88dd363a9a34a26ad9f03f6d
    https://github.com/scummvm/scummvm/commit/b6bed0aed72bb45e88dd363a9a34a26ad9f03f6d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:08+01:00

Commit Message:
LAB: Simplify mouse button handling

Changed paths:
    engines/lab/engine.cpp
    engines/lab/eventman.h
    engines/lab/interface.cpp
    engines/lab/intro.cpp
    engines/lab/map.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index c79197a..66d0f46 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -571,7 +571,7 @@ void LabEngine::mainGameLoop() {
 					gotMessage = true;
 					mayShowCrumbIndicator();
 					_graphics->screenUpdate();
-					if (!fromCrumbs(BUTTONUP, code, 0, _event->updateAndGetMousePos(), curInv, curMsg, forceDraw, code, actionMode))
+					if (!fromCrumbs(kMessageButtonUp, code, 0, _event->updateAndGetMousePos(), curInv, curMsg, forceDraw, code, actionMode))
 						break;
 				}
 			}
@@ -586,7 +586,7 @@ void LabEngine::mainGameLoop() {
 			curPos.y  = curMsg->_mouseY;
 
 			_followingCrumbs = false;
-			if (!fromCrumbs(curMsg->_msgClass, curMsg->_code, curMsg->_qualifier, curPos, curInv, curMsg, forceDraw, curMsg->_buttonId, actionMode))
+			if (!fromCrumbs(curMsg->_msgClass, curMsg->_code, curMsg->_qualifier, curPos, curInv, curMsg, forceDraw, curMsg->_code, actionMode))
 				break;
 		}
 	}
@@ -648,25 +648,25 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 	if (g_engine->shouldQuit())
 		return false;
 
-	if ((msgClass == RAWKEY) && !_graphics->_longWinInFront) {
+	if ((msgClass == kMessageRawKey) && !_graphics->_longWinInFront) {
 		if (!processKey(curMsg, msgClass, qualifier, curPos, curInv, forceDraw, code))
 			return false;
 	}
 
-	leftButtonClick = (msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier);
-	rightButtonClick = (msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier);
+	leftButtonClick = (msgClass == kMessageLeftClick);
+	rightButtonClick = (msgClass == kMessageRightClick);
 
 	if (_graphics->_longWinInFront) {
-		if ((msgClass == RAWKEY) || (leftButtonClick || rightButtonClick)) {
+		if ((msgClass == kMessageRawKey) || (leftButtonClick || rightButtonClick)) {
 			_graphics->_longWinInFront = false;
 			_graphics->_doNotDrawMessage = false;
 			_graphics->drawPanel();
 			drawRoomMessage(curInv, _closeDataPtr);
 			_graphics->screenUpdate();
 		}
-	} else if ((msgClass == BUTTONUP) && !_alternate) {
+	} else if ((msgClass == kMessageButtonUp) && !_alternate) {
 		processMainButton(wrkClosePtr, curInv, lastInv, oldDirection, forceDraw, buttonId, actionMode);
-	} else if ((msgClass == BUTTONUP) && _alternate) {
+	} else if ((msgClass == kMessageButtonUp) && _alternate) {
 		processAltButton(curInv, lastInv, buttonId, actionMode);
 	} else if (leftButtonClick && _mainDisplay) {
 		interfaceOff();
@@ -780,7 +780,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 
 		mayShowCrumbIndicator();
 		_graphics->screenUpdate();
-	} else if (msgClass == DELTAMOVE) {
+	} else if (msgClass == kMessageDeltaMove) {
 		ViewData *vptr = getViewData(_roomNum, _direction);
 		CloseDataPtr oldClosePtr = vptr->_closeUps;
 
@@ -816,8 +816,8 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &qualifier, Common::Point &curPos, uint16 &curInv, bool &forceDraw, uint16 code) {
 	if (code == Common::KEYCODE_RETURN) {
 		// The return key
-		msgClass = MOUSEBUTTONS;
-		qualifier = IEQUALIFIER_LEFTBUTTON;
+		msgClass = kMessageLeftClick;
+		qualifier = 0;
 		curPos = _event->getMousePos();
 	} else if ((getPlatform() == Common::kPlatformWindows) && (code == Common::KEYCODE_b)) {
 		// Start bread crumbs
@@ -877,20 +877,20 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &quali
 				// Does music load and next animation frame when you've run out of messages
 				_music->updateMusic();
 				_anim->diffNextFrame();
-			} else if (curMsg->_msgClass == RAWKEY) {
+			} else if (curMsg->_msgClass == kMessageRawKey) {
 				if ((curMsg->_code == Common::KEYCODE_y) || (curMsg->_code == Common::KEYCODE_q)) {
 					_anim->stopDiff();
 					return false;
 				} else if (curMsg->_code < 128)
 					break;
-			} else if (curMsg->_msgClass == MOUSEBUTTONS)
+			} else if ((curMsg->_msgClass == kMessageLeftClick) || (curMsg->_msgClass == kMessageRightClick))
 				break;
 		}
 
 		forceDraw = true;
 		interfaceOn();
 	} else if (code == Common::KEYCODE_TAB)
-		msgClass = DELTAMOVE;
+		msgClass = kMessageDeltaMove;
 	else if (code == Common::KEYCODE_ESCAPE)
 		_closeDataPtr = nullptr;
 
diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h
index d2c5782..20b4ddc 100644
--- a/engines/lab/eventman.h
+++ b/engines/lab/eventman.h
@@ -38,15 +38,13 @@ namespace Lab {
 class LabEngine;
 class Image;
 
-// Defines for the Class variable in IntuiMessage
-#define MOUSEBUTTONS    0x00000008
-#define BUTTONUP		0x00000040
-#define RAWKEY			0x00000400
-#define DELTAMOVE		0x00100000
-
-// Defines for the Qualifier variable in IntuiMessage
-#define IEQUALIFIER_RIGHTBUTTON     0x2000
-#define IEQUALIFIER_LEFTBUTTON      0x4000
+enum MessageClasses {
+	kMessageLeftClick,
+	kMessageRightClick,
+	kMessageButtonUp,
+	kMessageRawKey,
+	kMessageDeltaMove
+};
 
 #define VKEY_UPARROW    273
 #define VKEY_DNARROW    274
@@ -55,7 +53,7 @@ class Image;
 
 struct IntuiMessage {
 	uint32 _msgClass;
-	uint16 _code, _qualifier, _mouseX, _mouseY, _buttonId;
+	uint16 _code, _qualifier, _mouseX, _mouseY;
 	uint32 _seconds, _micros;
 };
 
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index afaec28..d14b283 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -137,15 +137,14 @@ IntuiMessage *EventManager::getMsg() {
 
 	if (_lastButtonHit) {
 		updateMouse();
-		message._msgClass = BUTTONUP;
+		message._msgClass = kMessageButtonUp;
 		message._code = _lastButtonHit->_buttonId;
-		message._buttonId = _lastButtonHit->_buttonId;
 		message._qualifier = _keyPressed.flags;
 		_lastButtonHit = nullptr;
 		return &message;
 	} else if (_leftClick || _rightClick) {
-		message._qualifier = (_leftClick) ? IEQUALIFIER_LEFTBUTTON : IEQUALIFIER_RIGHTBUTTON;
-		message._msgClass = MOUSEBUTTONS;
+		message._msgClass = (_leftClick) ? kMessageLeftClick : kMessageRightClick;
+		message._qualifier = 0;
 		message._mouseX = (!_vm->_isHiRes) ? (uint16)_mousePos.x / 2 : (uint16)_mousePos.x;
 		message._mouseY = (uint16)_mousePos.y;
 		_leftClick = _rightClick = false;
@@ -154,10 +153,10 @@ IntuiMessage *EventManager::getMsg() {
 		Button *curButton = checkNumButtonHit(_screenButtonList, message._code);
 
 		if (curButton) {
-			message._msgClass = BUTTONUP;
-			message._code = message._buttonId = curButton->_buttonId;
+			message._msgClass = kMessageButtonUp;
+			message._code = curButton->_buttonId;
 		} else
-			message._msgClass = RAWKEY;
+			message._msgClass = kMessageRawKey;
 
 		message._qualifier = _keyPressed.flags;
 		return &message;
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 45119f4..e4c84dc 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -61,8 +61,8 @@ void Intro::introEatMessages() {
 		if (!msg)
 			return;
 
-		if (((msg->_msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & msg->_qualifier))
-		 || ((msg->_msgClass == RAWKEY) && (msg->_code == Common::KEYCODE_ESCAPE)))
+		if ((msg->_msgClass == kMessageRightClick)
+		 || ((msg->_msgClass == kMessageRawKey) && (msg->_code == Common::KEYCODE_ESCAPE)))
 			_quitIntro = true;
 	}
 }
@@ -151,11 +151,10 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 			_vm->waitTOF();
 		} else {
 			uint32 msgClass = msg->_msgClass;
-			uint16 qualifier = msg->_qualifier;
 			uint16 code = msg->_code;
 
-			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) ||
-				((msgClass == RAWKEY) && (code == Common::KEYCODE_ESCAPE))) {
+			if ((msgClass == kMessageRightClick) ||
+				((msgClass == kMessageRawKey) && (code == Common::KEYCODE_ESCAPE))) {
 				_quitIntro = true;
 
 				if (isScreen)
@@ -163,8 +162,8 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 
 				delete[] textBuffer;
 				return;
-			} else if (msgClass == MOUSEBUTTONS) {
-				if (IEQUALIFIER_LEFTBUTTON & qualifier) {
+			} else if ((msgClass == kMessageLeftClick) || (msgClass == kMessageRightClick)) {
+				if (msgClass == kMessageLeftClick) {
 					if (doneFl) {
 						if (isScreen)
 							_vm->_graphics->fade(false, 0);
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 0136bf4f..81068ed 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -473,19 +473,17 @@ void LabEngine::processMap(uint16 curRoom) {
 		} else {
 			uint32 msgClass  = msg->_msgClass;
 			uint16 msgCode   = msg->_code;
-			uint16 buttonId  = msg->_buttonId;
-			uint16 qualifier = msg->_qualifier;
 			uint16 mouseX    = msg->_mouseX;
 			uint16 mouseY    = msg->_mouseY;
 
-			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) || ((msgClass == RAWKEY) && (msgCode == Common::KEYCODE_ESCAPE)))
+			if ((msgClass == kMessageRightClick) || ((msgClass == kMessageRawKey) && (msgCode == Common::KEYCODE_ESCAPE)))
 				return;
 
-			if (msgClass == BUTTONUP) {
-				if (buttonId == 0) {
+			if (msgClass == kMessageButtonUp) {
+				if (msgCode == 0) {
 					// Quit menu button
 					return;
-				} else if (buttonId == 1) {
+				} else if (msgCode == 1) {
 					// Up arrow
 					uint16 upperFloor = getUpperFloor(curFloor);
 					if (upperFloor != kFloorNone) {
@@ -494,7 +492,7 @@ void LabEngine::processMap(uint16 curRoom) {
 						drawMap(curRoom, curMsg, curFloor, false, false);
 						_graphics->fade(true, 0);
 					}
-				} else if (buttonId == 2) {
+				} else if (msgCode == 2) {
 					// Down arrow
 					uint16 lowerFloor = getLowerFloor(curFloor);
 					if (lowerFloor != kFloorNone) {
@@ -504,7 +502,7 @@ void LabEngine::processMap(uint16 curRoom) {
 						_graphics->fade(true, 0);
 					}
 				}
-			} else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) {
+			} else if (msgClass == kMessageLeftClick) {
 				if ((curFloor == kFloorLower) && (mouseX >= _utils->mapScaleX(538)) && (mouseY >= _utils->mapScaleY(277))
 					  && (mouseX <= _utils->mapScaleX(633)) && (mouseY <= _utils->mapScaleY(352))
 					  && floorVisited(kFloorSurMaze)) {
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 5ed0919..820455a 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -277,10 +277,10 @@ void LabEngine::processJournal() {
 			uint16 qualifier = msg->_qualifier;
 			uint16 buttonId  = msg->_code;
 
-			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) ||
-				((msgClass == RAWKEY) && (buttonId == Common::KEYCODE_ESCAPE)))
+			if ((msgClass == kMessageRightClick) ||
+				((msgClass == kMessageRawKey) && (buttonId == Common::KEYCODE_ESCAPE)))
 				return;
-			else if (msgClass == BUTTONUP) {
+			else if (msgClass == kMessageButtonUp) {
 				if (buttonId == 0) {
 					if (_journalPage >= 2) {
 						_journalPage -= 2;
@@ -443,10 +443,10 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 			uint16 mouseY    = msg->_mouseY;
 			uint16 code      = msg->_code;
 
-			if (((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_RIGHTBUTTON & qualifier)) ||
-				  ((msgClass == RAWKEY) && (code == Common::KEYCODE_ESCAPE)))
+			if ((msgClass == kMessageRightClick) ||
+				  ((msgClass == kMessageRawKey) && (code == Common::KEYCODE_ESCAPE)))
 				return;
-			else if ((msgClass == MOUSEBUTTONS) && (IEQUALIFIER_LEFTBUTTON & qualifier)) {
+			else if (msgClass == kMessageLeftClick) {
 				if ((mouseY >= _utils->vgaScaleY(171)) && (mouseY <= _utils->vgaScaleY(200))) {
 					if (mouseX <= _utils->vgaScaleX(31)) {
 						return;


Commit: 318dc59382e014aaac5126b9e3b39ae2f6b0df0b
    https://github.com/scummvm/scummvm/commit/318dc59382e014aaac5126b9e3b39ae2f6b0df0b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:08+01:00

Commit Message:
LAB: Make setUpScreens() a bit easier to read

Changed paths:
    engines/lab/dispman.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index f2b3b46..c74302d 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -401,6 +401,12 @@ void DisplayMan::drawPanel() {
  * Sets up the Labyrinth screens, and opens up the initial windows.
  */
 void DisplayMan::setUpScreens() {
+	EventManager *e = _vm->_event;
+	ButtonList *moveButtonList = &_vm->_moveButtonList;
+	ButtonList *invButtonList = &_vm->_invButtonList;
+	Image **moveImages = _vm->_moveImages;
+	Image **invImages = _vm->_invImages;
+
 	createScreen(_vm->_isHiRes);
 
 	Common::File *controlFile = _vm->_resource->openDataFile("P:Control");
@@ -409,21 +415,20 @@ void DisplayMan::setUpScreens() {
 	delete controlFile;
 
 	// Creates the buttons for the movement control panel
-	uint16 y = _vm->_utils->vgaScaleY(173) - _vm->_utils->svgaCord(2);
-
 	// The key mapping was only set for the Windows version.
 	// It's very convenient to have those shortcut, so I added them
 	// for all versions. (Strangerke)
-	_vm->_moveButtonList.push_back(_vm->_event->createButton(  1, y, 0,          't', _vm->_moveImages[0],  _vm->_moveImages[1]));
-	_vm->_moveButtonList.push_back(_vm->_event->createButton( 33, y, 1,          'm', _vm->_moveImages[2],  _vm->_moveImages[3]));
-	_vm->_moveButtonList.push_back(_vm->_event->createButton( 65, y, 2,          'o', _vm->_moveImages[4],  _vm->_moveImages[5]));
-	_vm->_moveButtonList.push_back(_vm->_event->createButton( 97, y, 3,          'c', _vm->_moveImages[6],  _vm->_moveImages[7]));
-	_vm->_moveButtonList.push_back(_vm->_event->createButton(129, y, 4,          'l', _vm->_moveImages[8],  _vm->_moveImages[9]));
-	_vm->_moveButtonList.push_back(_vm->_event->createButton(161, y, 5,          'i', _vm->_moveImages[12], _vm->_moveImages[13]));
-	_vm->_moveButtonList.push_back(_vm->_event->createButton(193, y, 6, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]));
-	_vm->_moveButtonList.push_back(_vm->_event->createButton(225, y, 7, VKEY_UPARROW, _vm->_moveImages[16], _vm->_moveImages[17]));
-	_vm->_moveButtonList.push_back(_vm->_event->createButton(257, y, 8, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]));
-	_vm->_moveButtonList.push_back(_vm->_event->createButton(289, y, 9,          'p', _vm->_moveImages[10], _vm->_moveImages[11]));
+	uint16 y = _vm->_utils->vgaScaleY(173) - _vm->_utils->svgaCord(2);
+	moveButtonList->push_back(e->createButton(  1, y, 0,          't', moveImages[0],  moveImages[1]));
+	moveButtonList->push_back(e->createButton( 33, y, 1,          'm', moveImages[2],  moveImages[3]));
+	moveButtonList->push_back(e->createButton( 65, y, 2,          'o', moveImages[4],  moveImages[5]));
+	moveButtonList->push_back(e->createButton( 97, y, 3,          'c', moveImages[6],  moveImages[7]));
+	moveButtonList->push_back(e->createButton(129, y, 4,          'l', moveImages[8],  moveImages[9]));
+	moveButtonList->push_back(e->createButton(161, y, 5,          'i', moveImages[12], moveImages[13]));
+	moveButtonList->push_back(e->createButton(193, y, 6, VKEY_LTARROW, moveImages[14], moveImages[15]));
+	moveButtonList->push_back(e->createButton(225, y, 7, VKEY_UPARROW, moveImages[16], moveImages[17]));
+	moveButtonList->push_back(e->createButton(257, y, 8, VKEY_RTARROW, moveImages[18], moveImages[19]));
+	moveButtonList->push_back(e->createButton(289, y, 9,          'p', moveImages[10], moveImages[11]));
 
 	Common::File *invFile = _vm->_resource->openDataFile("P:Inv");
 	if (_vm->getPlatform() == Common::kPlatformWindows) {
@@ -433,18 +438,18 @@ void DisplayMan::setUpScreens() {
 		for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++)
 			_vm->_invImages[imgIdx] = new Image(invFile, _vm);
 	}
-	_vm->_invButtonList.push_back(_vm->_event->createButton( 24, y, 0,          'm', _vm->_invImages[0],   _vm->_invImages[1]));
-	_vm->_invButtonList.push_back(_vm->_event->createButton( 56, y, 1,          'g', _vm->_invImages[2],   _vm->_invImages[3]));
-	_vm->_invButtonList.push_back(_vm->_event->createButton( 94, y, 2,          'u', _vm->_invImages[4],   _vm->_invImages[5]));
-	_vm->_invButtonList.push_back(_vm->_event->createButton(126, y, 3,          'l', _vm->_moveImages[8],  _vm->_moveImages[9]));
-	_vm->_invButtonList.push_back(_vm->_event->createButton(164, y, 4, VKEY_LTARROW, _vm->_moveImages[14], _vm->_moveImages[15]));
-	_vm->_invButtonList.push_back(_vm->_event->createButton(196, y, 5, VKEY_RTARROW, _vm->_moveImages[18], _vm->_moveImages[19]));
+	invButtonList->push_back(e->createButton( 24, y, 0,          'm', invImages[0],   invImages[1]));
+	invButtonList->push_back(e->createButton( 56, y, 1,          'g', invImages[2],   invImages[3]));
+	invButtonList->push_back(e->createButton( 94, y, 2,          'u', invImages[4],   invImages[5]));
+	invButtonList->push_back(e->createButton(126, y, 3,          'l', moveImages[8],  moveImages[9]));
+	invButtonList->push_back(e->createButton(164, y, 4, VKEY_LTARROW, moveImages[14], moveImages[15]));
+	invButtonList->push_back(e->createButton(196, y, 5, VKEY_RTARROW, moveImages[18], moveImages[19]));
 
 	// The windows version has 2 extra buttons for breadcrumb trail
 	// CHECKME: the game is really hard to play without those, maybe we could add something to enable that.
 	if (_vm->getPlatform() == Common::kPlatformWindows) {
-		_vm->_invButtonList.push_back(_vm->_event->createButton(234, y, 6, 'b', _vm->_invImages[6], _vm->_invImages[7]));
-		_vm->_invButtonList.push_back(_vm->_event->createButton(266, y, 7, 'f', _vm->_invImages[8], _vm->_invImages[9]));
+		invButtonList->push_back(e->createButton(234, y, 6, 'b', invImages[6], invImages[7]));
+		invButtonList->push_back(e->createButton(266, y, 7, 'f', invImages[8], invImages[9]));
 	}
 
 	delete invFile;


Commit: 832d87e0bf1cb7dbfd2d3e7217b5d8fe0fefa8b7
    https://github.com/scummvm/scummvm/commit/832d87e0bf1cb7dbfd2d3e7217b5d8fe0fefa8b7
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:08+01:00

Commit Message:
LAB: Use Common::Point in IntuiMessage

Changed paths:
    engines/lab/engine.cpp
    engines/lab/eventman.h
    engines/lab/interface.cpp
    engines/lab/map.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 66d0f46..21849e1 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -580,13 +580,8 @@ void LabEngine::mainGameLoop() {
 			_graphics->screenUpdate();
 		} else {
 			gotMessage = true;
-
-			Common::Point curPos;
-			curPos.x  = curMsg->_mouseX;
-			curPos.y  = curMsg->_mouseY;
-
 			_followingCrumbs = false;
-			if (!fromCrumbs(curMsg->_msgClass, curMsg->_code, curMsg->_qualifier, curPos, curInv, curMsg, forceDraw, curMsg->_code, actionMode))
+			if (!fromCrumbs(curMsg->_msgClass, curMsg->_code, curMsg->_qualifier, curMsg->_mouse, curInv, curMsg, forceDraw, curMsg->_code, actionMode))
 				break;
 		}
 	}
diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h
index 20b4ddc..7b5f2dd 100644
--- a/engines/lab/eventman.h
+++ b/engines/lab/eventman.h
@@ -53,8 +53,8 @@ enum MessageClasses {
 
 struct IntuiMessage {
 	uint32 _msgClass;
-	uint16 _code, _qualifier, _mouseX, _mouseY;
-	uint32 _seconds, _micros;
+	uint16 _code, _qualifier;
+	Common::Point _mouse;
 };
 
 
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index d14b283..949db06 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -145,8 +145,9 @@ IntuiMessage *EventManager::getMsg() {
 	} else if (_leftClick || _rightClick) {
 		message._msgClass = (_leftClick) ? kMessageLeftClick : kMessageRightClick;
 		message._qualifier = 0;
-		message._mouseX = (!_vm->_isHiRes) ? (uint16)_mousePos.x / 2 : (uint16)_mousePos.x;
-		message._mouseY = (uint16)_mousePos.y;
+		message._mouse = _mousePos;
+		if (!_vm->_isHiRes)
+			message._mouse.x /= 2;
 		_leftClick = _rightClick = false;
 		return &message;
 	} else if (keyPress(&message._code)) {
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 81068ed..0d8b89a 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -473,8 +473,8 @@ void LabEngine::processMap(uint16 curRoom) {
 		} else {
 			uint32 msgClass  = msg->_msgClass;
 			uint16 msgCode   = msg->_code;
-			uint16 mouseX    = msg->_mouseX;
-			uint16 mouseY    = msg->_mouseY;
+			uint16 mouseX    = msg->_mouse.x;
+			uint16 mouseY    = msg->_mouse.y;
 
 			if ((msgClass == kMessageRightClick) || ((msgClass == kMessageRawKey) && (msgCode == Common::KEYCODE_ESCAPE)))
 				return;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 820455a..68fbcd4 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -274,7 +274,6 @@ void LabEngine::processJournal() {
 			_music->updateMusic();
 		else {
 			uint32 msgClass  = msg->_msgClass;
-			uint16 qualifier = msg->_qualifier;
 			uint16 buttonId  = msg->_code;
 
 			if ((msgClass == kMessageRightClick) ||
@@ -439,8 +438,8 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 		} else {
 			uint32 msgClass  = msg->_msgClass;
 			uint16 qualifier = msg->_qualifier;
-			uint16 mouseX    = msg->_mouseX;
-			uint16 mouseY    = msg->_mouseY;
+			uint16 mouseX    = msg->_mouse.x;
+			uint16 mouseY    = msg->_mouse.y;
 			uint16 code      = msg->_code;
 
 			if ((msgClass == kMessageRightClick) ||


Commit: bc25b6be552a929c4b3221538ebbfb256de5ecf6
    https://github.com/scummvm/scummvm/commit/bc25b6be552a929c4b3221538ebbfb256de5ecf6
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:08+01:00

Commit Message:
LAB: Change the graphics and audio code to use Common::File directly

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/music.cpp
    engines/lab/music.h
    engines/lab/utils.cpp
    engines/lab/utils.h



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index d1b79a2..75a9af3 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -56,7 +56,7 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 	_frameNum = 0;
 	_playOnce = false;
 	_diffFile = nullptr;
-	_diffFileStart = nullptr;
+	_diffFileStart = 0;
 	_size = 0;
 	_rawDiffBM._bytesPerRow = 0;
 	_rawDiffBM._drawOnScreen = false;
@@ -119,7 +119,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 			_frameNum++;
 
 			if ((_frameNum == 1) && (_continuous || !_playOnce))
-				_diffFileStart = _diffFile;
+				_diffFileStart = _diffFile->pos();
 
 			_isAnim = (_frameNum >= 3) && (!_playOnce);
 			_curBit = 0;
@@ -132,55 +132,52 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 		}
 
 		_vm->_music->updateMusic();
-		_header = READ_LE_UINT32(_diffFile);
-		_diffFile += 4;
+		_header = _diffFile->readUint32LE();
+		_size = _diffFile->readUint32LE();
 
-		_size = READ_LE_UINT32(_diffFile);
-		_diffFile += 4;
+		uint32 curPos = 0;
 
 		switch (_header) {
 		case 8:
-			memcpy(_diffPalette, _diffFile, _size);
-			_diffFile += _size;
+			_diffFile->read(_diffPalette, _size);
 			_isPal = true;
 			break;
 
 		case 10:
-			_rawDiffBM._planes[_curBit] = _diffFile;
-
-			if (onlyDiffData) {
-				_diffFile += _size;
-			} else {
-				memcpy(DrawBitMap->_planes[_curBit], _diffFile, _size);
-				_diffFile += _size;
-			}
+			if (onlyDiffData)
+				warning("Boom");
+			_diffFile->read(DrawBitMap->_planes[_curBit], _size);
 			_curBit++;
 			break;
 
 		case 11:
-			_diffFile += 4;
+			curPos = _diffFile->pos();
+			_diffFile->skip(4);
 			_vm->_utils->runLengthDecode(DrawBitMap->_planes[_curBit], _diffFile);
 			_curBit++;
-			_diffFile += _size - 4;
+			_diffFile->seek(curPos + _size, SEEK_SET);
 			break;
 
 		case 12:
-			_diffFile += 4;
+			curPos = _diffFile->pos();
+			_diffFile->skip(4);
 			_vm->_utils->VRunLengthDecode(DrawBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow);
 			_curBit++;
-			_diffFile += _size - 4;
+			_diffFile->seek(curPos + _size, SEEK_SET);
 			break;
 
 		case 20:
+			curPos = _diffFile->pos();
 			_vm->_utils->unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, false);
 			_curBit++;
-			_diffFile += _size;
+			_diffFile->seek(curPos + _size, SEEK_SET);
 			break;
 
 		case 21:
+			curPos = _diffFile->pos();
 			_vm->_utils->unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, true);
 			_curBit++;
-			_diffFile += _size;
+			_diffFile->seek(curPos + _size, SEEK_SET);
 			break;
 
 		case 25:
@@ -202,12 +199,11 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 
 			_size -= 8;
 
-			_diffFile += 4;
-			_sampleSpeed = READ_LE_UINT16(_diffFile);
-			_diffFile += 4;
+			_diffFile->skip(4);
+			_sampleSpeed = _diffFile->readUint16LE();
+			_diffFile->skip(2);
 
 			_vm->_music->playSoundEffect(_sampleSpeed, _size, _diffFile);
-			_diffFile += _size;
 			break;
 
 		case 65535:
@@ -235,11 +231,11 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 
 			// Random frame number so it never gets back to 2
 			_frameNum = 4;
-			_diffFile = _diffFileStart;
+			_diffFile->seek(_diffFileStart, SEEK_SET);
 			break;
 
 		default:
-			_diffFile += _size;
+			_diffFile->skip(_size);
 			break;
 		}
 	}
@@ -270,7 +266,7 @@ void Anim::stopDiffEnd() {
 /**
  * Reads in a DIFF file.
  */
-void Anim::readDiff(byte *buffer, bool playOnce, bool onlyDiffData) {
+void Anim::readDiff(Common::File *diffFile, bool playOnce, bool onlyDiffData) {
 	_playOnce = playOnce;
 	_delayMicros = 0;
 	_header = 0;
@@ -286,37 +282,27 @@ void Anim::readDiff(byte *buffer, bool playOnce, bool onlyDiffData) {
 		_vm->_graphics->blackScreen();
 	}
 
-	_diffFile = _diffFileStart = buffer;
+	_diffFile = diffFile;
 
 	_continuous = false;
-	uint32 signature = READ_BE_UINT32(_diffFile);
-	_diffFile += 4;
-
-	_header = READ_LE_UINT32(_diffFile);
-	_diffFile += 4;
+	uint32 signature = _diffFile->readUint32BE();
+	_header = _diffFile->readUint32LE();
 
 	if ((signature != MKTAG('D', 'I', 'F', 'F')) || (_header != 1219009121L)) {
 		_isPlaying = false;
 		return;
 	}
 
-	_header = READ_LE_UINT32(_diffFile);
-	_diffFile += 4;
-
-	_size = READ_LE_UINT32(_diffFile);
-	_diffFile += 4;
+	_header = _diffFile->readUint32LE();
+	_size = _diffFile->readUint32LE();
 
 	if (_header == 0) {
 		// sizeof(headerdata) != 18, but the padding might be at the end
-		_headerdata._version = READ_LE_UINT16(_diffFile);
-		_diffFile += 2;
-		_headerdata._width = READ_LE_UINT16(_diffFile);
-		_diffFile += 2;
-		_headerdata._height = READ_LE_UINT16(_diffFile);
-		_diffFile += 2;
-		_headerdata._depth = *_diffFile;
-		_diffFile++;
-		_headerdata._fps = *_diffFile;
+		_headerdata._version = _diffFile->readUint16LE();
+		_headerdata._width = _diffFile->readUint16LE();
+		_headerdata._height = _diffFile->readUint16LE();
+		_headerdata._depth = _diffFile->readByte();
+		_headerdata._fps = _diffFile->readByte();
 
 		// HACK: The original game defines a 1 second delay when changing screens, which is
 		// very annoying. We first removed the delay, but it looked wrong when changing screens
@@ -327,15 +313,11 @@ void Anim::readDiff(byte *buffer, bool playOnce, bool onlyDiffData) {
 
 		if (_headerdata._fps == 1)
 			_headerdata._fps = 0;
-		_diffFile++;
-		_headerdata._bufferSize = READ_LE_UINT32(_diffFile);
-		_diffFile += 4;
-		_headerdata._machine = READ_LE_UINT16(_diffFile);
-		_diffFile += 2;
-		_headerdata._flags = READ_LE_UINT32(_diffFile);
-		_diffFile += 4;
-
-		_diffFile += _size - 18;
+		_headerdata._bufferSize = _diffFile->readUint32LE();
+		_headerdata._machine = _diffFile->readUint16LE();
+		_headerdata._flags = _diffFile->readUint32LE();
+
+		_diffFile->skip(_size - 18);
 
 		_continuous = CONTINUOUS & _headerdata._flags;
 		_diffWidth = _headerdata._width;
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 6e568a4..0d2497b 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -69,8 +69,8 @@ private:
 	bool _donePal;
 	uint16 _frameNum;
 	bool _playOnce;
-	byte *_diffFile;
-	byte *_diffFileStart;
+	Common::File *_diffFile;
+	uint32 _diffFileStart;
 	uint32 _size;
 	bool _stopPlayingEnd;
 	uint16 _sampleSpeed;
@@ -88,7 +88,7 @@ public:
 	bool _noPalChange;   // Don't change the palette.
 	BitMap _rawDiffBM;
 
-	void readDiff(byte *buffer, bool playOnce, bool onlyDiffData = false);
+	void readDiff(Common::File *diffFile, bool playOnce, bool onlyDiffData = false);
 	void diffNextFrame(bool onlyDiffData = false);
 	void stopDiff();
 	void stopDiffEnd();
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index c74302d..d230225 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -71,11 +71,8 @@ DisplayMan::~DisplayMan() {
 
 // From readPict.c.  Reads in pictures and animations from disk.
 void DisplayMan::loadPict(const char *filename) {
-	Common::File *bitmapFile = _vm->_resource->openDataFile(filename);
 	freePict();
-	_curBitmap = new byte[bitmapFile->size()];
-	bitmapFile->read(_curBitmap, bitmapFile->size());
-	delete bitmapFile;
+	_curBitmap = _vm->_resource->openDataFile(filename);
 }
 
 void DisplayMan::loadBackPict(const char *fileName, uint16 *highPal) {
@@ -115,7 +112,7 @@ void DisplayMan::readPict(const char *filename, bool playOnce, bool onlyDiffData
 }
 
 void DisplayMan::freePict() {
-	delete[] _curBitmap;
+	delete _curBitmap;
 	_curBitmap = nullptr;
 }
 
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index 2a86e34..ca686de 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -65,7 +65,7 @@ private:
 	void getWord(char *wordBuffer, const char *mainBuffer, uint16 *wordWidth);
 
 	byte _curPen;
-	byte *_curBitmap;
+	Common::File *_curBitmap;
 	byte _curvgapal[256 * 3];
 
 public:
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 61d9fd0..aa34b7f 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -102,7 +102,7 @@ uint16 Music::getPlayingBufferCount() {
 	return (_queuingAudioStream) ? _queuingAudioStream->numQueuedStreams() : 0;
 }
 
-void Music::playSoundEffect(uint16 sampleSpeed, uint32 length, void *data) {
+void Music::playSoundEffect(uint16 sampleSpeed, uint32 length, Common::File *dataFile) {
 	pauseBackMusic();
 	stopSoundEffect();
 
@@ -115,7 +115,12 @@ void Music::playSoundEffect(uint16 sampleSpeed, uint32 length, void *data) {
 	else
 		soundFlags |= Audio::FLAG_UNSIGNED;
 
-	Audio::SeekableAudioStream *audioStream = Audio::makeRawStream((const byte *)data, length, sampleSpeed, soundFlags, DisposeAfterUse::NO);
+	// NOTE: We need to use malloc(), cause this will be freed with free()
+	// by the music code
+	byte *soundData = (byte *)malloc(length);
+	dataFile->read(soundData, length);
+
+	Audio::SeekableAudioStream *audioStream = Audio::makeRawStream((const byte *)soundData, length, sampleSpeed, soundFlags, DisposeAfterUse::NO);
 	uint loops = (_loopSoundEffect) ? 0 : 1;
 	Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, loops);
 	_vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, loopingAudioStream);
@@ -352,11 +357,7 @@ void Music::readSound(bool waitTillFinished, Common::File *file) {
 
 			uint16 sampleRate = file->readUint16LE();
 			file->skip(2);
-			// NOTE: We need to use malloc(), cause this will be freed with free()
-			// by the music code
-			byte *soundData = (byte *)malloc(soundSize);
-			file->read(soundData, soundSize);
-			playSoundEffect(sampleRate, soundSize, soundData);
+			playSoundEffect(sampleRate, soundSize, file);
 		} else if (soundTag == 65535L) {
 			if (waitTillFinished) {
 				while (isSoundEffectActive()) {
diff --git a/engines/lab/music.h b/engines/lab/music.h
index d5dd241..4ea075e 100644
--- a/engines/lab/music.h
+++ b/engines/lab/music.h
@@ -85,7 +85,7 @@ public:
 	void freeMusic();
 	bool initMusic(const char *filename);
 	bool isSoundEffectActive() const;
-	void playSoundEffect(uint16 sampleSpeed, uint32 length, void *data);
+	void playSoundEffect(uint16 sampleSpeed, uint32 length, Common::File *dataFile);
 	bool readMusic(const char *filename, bool waitTillFinished);
 	void resetMusic();
 	void resumeBackMusic();
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index 7360558..71fce81 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -123,27 +123,22 @@ Common::Point Utils::vgaUnscale(Common::Point pos) {
  * Undiffs a piece of memory when header size is a byte, and copy/skip size
  * is also a byte.
  */
-void Utils::unDiffByteByte(byte *dest, byte *diff) {
+void Utils::unDiffByteByte(byte *dest, Common::File *sourceFile) {
 	while (1) {
-		uint16 skip = *diff;
-		diff++;
-		uint16 copy = *diff;
-		diff++;
+		uint16 skip = sourceFile->readByte();
+		uint16 copy = sourceFile->readByte();
 
 		if (skip == 255) {
 			if (copy == 0) {
-				skip = READ_LE_UINT16(diff);
-				diff += 2;
-				copy = READ_LE_UINT16(diff);
-				diff += 2;
+				skip = sourceFile->readUint16LE();
+				copy = sourceFile->readUint16LE();
 			} else if (copy == 255)
 				return;
 		}
 
 		dest += skip;
-		memcpy(dest, diff, copy);
+		sourceFile->read(dest, copy);
 		dest += copy;
-		diff += copy;
 	}
 }
 
@@ -151,19 +146,15 @@ void Utils::unDiffByteByte(byte *dest, byte *diff) {
  * Undiffs a piece of memory when header size is a byte, and copy/skip size
  * is a word.
  */
-void Utils::unDiffByteWord(uint16 *dest, uint16 *diff) {
+void Utils::unDiffByteWord(uint16 *dest, Common::File *sourceFile) {
 	while (1) {
-		uint16 skip = ((byte *)diff)[0];
-		uint16 copy = ((byte *)diff)[1];
-
-		diff++;
+		uint16 skip = sourceFile->readByte();
+		uint16 copy = sourceFile->readByte();
 
 		if (skip == 255) {
 			if (copy == 0) {
-				skip = READ_LE_UINT16(diff);
-				diff++;
-				copy = READ_LE_UINT16(diff);
-				diff++;
+				skip = sourceFile->readUint16LE();
+				copy = sourceFile->readUint16LE();
 			} else if (copy == 255)
 				return;
 		}
@@ -171,28 +162,16 @@ void Utils::unDiffByteWord(uint16 *dest, uint16 *diff) {
 		dest += skip;
 
 		while (copy > 3) {
-			*dest = READ_LE_UINT16(diff);
-			dest++;
-			diff++;
-
-			*dest = READ_LE_UINT16(diff);
-			dest++;
-			diff++;
-
-			*dest = READ_LE_UINT16(diff);
-			dest++;
-			diff++;
-
-			*dest = READ_LE_UINT16(diff);
-			dest++;
-			diff++;
+			for (int i = 0; i < 4; i++) {
+				*dest = sourceFile->readUint16LE();
+				dest++;
+			}
 
 			copy -= 4;
 		}
 
 		while (copy) {
-			*dest++ = READ_LE_UINT16(diff);
-			diff++;
+			*dest++ = sourceFile->readUint16LE();
 			copy--;
 		}
 	}
@@ -204,13 +183,13 @@ void Utils::unDiffByteWord(uint16 *dest, uint16 *diff) {
  * Undiffs a piece of memory when header size is a byte, and copy/skip size
  * is a byte.
  */
-void Utils::VUnDiffByteByte(byte *dest, byte *diff, uint16 bytesPerRow) {
+void Utils::VUnDiffByteByte(byte *dest, Common::File *sourceFile, uint16 bytesPerRow) {
 	for (uint16 counter = 0; counter < _dataBytesPerRow; ) {
 		byte *curPtr = dest + counter;
 
 		for (;;) {
-			uint16 skip = *diff++;
-			uint16 copy = *diff++;
+			uint16 skip = sourceFile->readByte();
+			uint16 copy = sourceFile->readByte();
 
 			if (skip == 255) {
 				counter += copy;
@@ -220,7 +199,7 @@ void Utils::VUnDiffByteByte(byte *dest, byte *diff, uint16 bytesPerRow) {
 
 				while (copy) {
 					copy--;
-					*curPtr = *diff++;
+					*curPtr = sourceFile->readByte();
 					curPtr += bytesPerRow;
 				}
 			}
@@ -232,7 +211,7 @@ void Utils::VUnDiffByteByte(byte *dest, byte *diff, uint16 bytesPerRow) {
  * Undiffs a piece of memory when header size is a byte, and copy/skip size
  * is a word.
  */
-void Utils::VUnDiffByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow) {
+void Utils::VUnDiffByteWord(uint16 *dest, Common::File *sourceFile, uint16 bytesPerRow) {
 	uint16 counter = 0;
 	uint16 wordsPerRow = bytesPerRow / 2;
 
@@ -240,10 +219,8 @@ void Utils::VUnDiffByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow) {
 		uint16 *curPtr = dest + counter;
 
 		for (;;) {
-			uint16 skip = ((byte *)diff)[0];
-			uint16 copy = ((byte *)diff)[1];
-
-			diff++;
+			uint16 skip = sourceFile->readByte();
+			uint16 copy = sourceFile->readByte();
 
 			if (skip == 255) {
 				counter += copy;
@@ -252,7 +229,7 @@ void Utils::VUnDiffByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow) {
 				curPtr += (skip * wordsPerRow);
 
 				while (copy) {
-					*curPtr = *diff++; //swapUShort(*diff);
+					*curPtr = sourceFile->readUint16LE();
 					curPtr += wordsPerRow;
 					copy--;
 				}
@@ -265,29 +242,26 @@ void Utils::VUnDiffByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow) {
  * Undiffs a piece of memory when header size is a byte, and copy/skip size
  * is a long.
  */
-void Utils::VUnDiffByteLong(uint32 *dest, uint32 *diff, uint16 bytesPerRow) {
+void Utils::VUnDiffByteLong(uint32 *dest, Common::File *sourceFile, uint16 bytesPerRow) {
 	uint16 counter = 0;
-	byte *diff1 = (byte *)diff;
-
 	uint16 longsperrow = bytesPerRow / 4;
 
 	while (counter < (_dataBytesPerRow >> 2)) {
-		uint32 *_curPtr = dest + counter;
+		uint32 *curPtr = dest + counter;
 
 		for (;;) {
-			uint16 skip = *diff1++;
-			uint16 copy = *diff1++;
+			uint16 skip = sourceFile->readByte();
+			uint16 copy = sourceFile->readByte();
 
 			if (skip == 255) {
 				counter += copy;
 				break;
 			} else {
-				_curPtr += (skip * longsperrow);
+				curPtr += (skip * longsperrow);
 
 				while (copy) {
-					*_curPtr = *(uint32 *)diff1; //swapULong(*diff);
-					_curPtr += longsperrow;
-					diff1 += 4;
+					*curPtr = sourceFile->readUint32LE();
+					curPtr += longsperrow;
 					copy--;
 				}
 			}
@@ -298,22 +272,21 @@ void Utils::VUnDiffByteLong(uint32 *dest, uint32 *diff, uint16 bytesPerRow) {
 /**
  * Runlength decodes a chunk of memory.
  */
-void Utils::runLengthDecode(byte *dest, byte *source) {
+void Utils::runLengthDecode(byte *dest, Common::File *sourceFile) {
 	int8 num;
 	int16 count;
 
 	while (1) {
-		num = (int8)*source++;
+		num = sourceFile->readSByte();
 
 		if (num == 127) {
 			return;
 		} else if (num > '\0') {
-			memcpy(dest, source, num);
-			source += num;
+			sourceFile->read(dest, num);
 			dest   += num;
 		} else {
 			count = (int16)(-num);
-			num   = *source++;
+			num = sourceFile->readSByte();
 
 			while (count) {
 				*dest++ = num;
@@ -326,7 +299,7 @@ void Utils::runLengthDecode(byte *dest, byte *source) {
 /**
  * Does a vertical run length decode.
  */
-void Utils::VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow) {
+void Utils::VRunLengthDecode(byte *dest, Common::File *sourceFile, uint16 bytesPerRow) {
 	int16 count;
 	byte *top = dest;
 
@@ -334,20 +307,18 @@ void Utils::VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow) {
 		dest = top;
 		dest += i;
 
-		int8 num = (int8)*source;
-		source++;
+		int8 num = sourceFile->readSByte();
 
 		while (num != 127) {
 			if (num > '\0') {
 				while (num) {
-					*dest = *source++;
+					*dest = sourceFile->readByte();
 					dest += bytesPerRow;
 					num--;
 				}
 			} else {
 				count = (int16)(-num);
-				num   = (int8)*source;
-				source++;
+				num = sourceFile->readSByte();
 
 				while (count) {
 					*dest = num;
@@ -356,8 +327,7 @@ void Utils::VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow) {
 				}
 			}
 
-			num = *source;
-			source++;
+			num = sourceFile->readSByte();
 		}
 	}
 }
@@ -365,25 +335,24 @@ void Utils::VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow) {
 /**
  * Does the undiffing between the bitmaps.
  */
-void Utils::unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesPerRow, bool isV) {
-	diffData++;
-	byte bufType = *diffData;
-	diffData++;
+void Utils::unDiff(byte *newBuf, byte *oldBuf, Common::File *sourceFile, uint16 bytesPerRow, bool isV) {
+	sourceFile->skip(1);
+	byte bufType = sourceFile->readByte();
 
 	if (isV) {
 		if (bufType == 0)
-			VUnDiffByteByte(newBuf, diffData, bytesPerRow);
+			VUnDiffByteByte(newBuf, sourceFile, bytesPerRow);
 		else if (bufType == 1)
-			VUnDiffByteWord((uint16 *)newBuf, (uint16 *)diffData, bytesPerRow);
+			VUnDiffByteWord((uint16 *)newBuf, sourceFile, bytesPerRow);
 		else if (bufType == 3)
-			VUnDiffByteLong((uint32 *)newBuf, (uint32 *)diffData, bytesPerRow);
+			VUnDiffByteLong((uint32 *)newBuf, sourceFile, bytesPerRow);
 		else
 			error("Unexpected variable compression scheme %d", bufType);
 	} else {
 		if (bufType == 0)
-			unDiffByteByte(newBuf, diffData);
+			unDiffByteByte(newBuf, sourceFile);
 		else if (bufType == 1)
-			unDiffByteWord((uint16 *)newBuf, (uint16 *)diffData);
+			unDiffByteWord((uint16 *)newBuf, sourceFile);
 		else
 			error("Unexpected compression scheme %d", bufType);
 	}
diff --git a/engines/lab/utils.h b/engines/lab/utils.h
index c6337c7..0d4f649 100644
--- a/engines/lab/utils.h
+++ b/engines/lab/utils.h
@@ -38,11 +38,11 @@ private:
 	LabEngine *_vm;
 	uint16 _dataBytesPerRow;
 
-	void unDiffByteByte(byte *dest, byte *diff);
-	void unDiffByteWord(uint16 *dest, uint16 *diff);
-	void VUnDiffByteByte(byte *dest, byte *diff, uint16 bytesPerRow);
-	void VUnDiffByteWord(uint16 *dest, uint16 *diff, uint16 bytesPerRow);
-	void VUnDiffByteLong(uint32 *dest, uint32 *diff, uint16 bytesPerRow);
+	void unDiffByteByte(byte *dest, Common::File *sourceFile);
+	void unDiffByteWord(uint16 *dest, Common::File *sourceFile);
+	void VUnDiffByteByte(byte *dest, Common::File *sourceFile, uint16 bytesPerRow);
+	void VUnDiffByteWord(uint16 *dest, Common::File *sourceFile, uint16 bytesPerRow);
+	void VUnDiffByteLong(uint32 *dest, Common::File *sourceFile, uint16 bytesPerRow);
 
 public:
 	Utils(LabEngine *vm);
@@ -58,9 +58,9 @@ public:
 	uint16 mapScaleX(uint16 x);
 	uint16 mapScaleY(uint16 y);
 	Common::Point vgaUnscale(Common::Point pos);
-	void unDiff(byte *newBuf, byte *oldBuf, byte *diffData, uint16 bytesPerRow, bool isV);
-	void runLengthDecode(byte *dest, byte *source);
-	void VRunLengthDecode(byte *dest, byte *source, uint16 bytesPerRow);
+	void unDiff(byte *newBuf, byte *oldBuf, Common::File *sourceFile, uint16 bytesPerRow, bool isV);
+	void runLengthDecode(byte *dest, Common::File *sourceFile);
+	void VRunLengthDecode(byte *dest, Common::File *sourceFile, uint16 bytesPerRow);
 	void setBytesPerRow(int num);
 	uint16 getRandom(uint16 max);
 };


Commit: 69680808d0acb9583f7e60f259f9c70b9e7ed6c5
    https://github.com/scummvm/scummvm/commit/69680808d0acb9583f7e60f259f9c70b9e7ed6c5
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:08+01:00

Commit Message:
LAB: Remove unused variable

Changed paths:
    engines/lab/special.cpp



diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 68fbcd4..194564c 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -437,7 +437,6 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 			_music->updateMusic();
 		} else {
 			uint32 msgClass  = msg->_msgClass;
-			uint16 qualifier = msg->_qualifier;
 			uint16 mouseX    = msg->_mouse.x;
 			uint16 mouseY    = msg->_mouse.y;
 			uint16 code      = msg->_code;


Commit: f452834f7067c63357c5f45d9e15e53d6b178b4b
    https://github.com/scummvm/scummvm/commit/f452834f7067c63357c5f45d9e15e53d6b178b4b
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:08+01:00

Commit Message:
LAB: Remove unused variables in DIFFHeader and BitMap

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h
    engines/lab/dispman.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 75a9af3..648634b 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -62,7 +62,6 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 	_rawDiffBM._drawOnScreen = false;
 	for (int i = 0; i < 16; i++)
 		_rawDiffBM._planes[i] = nullptr;
-	_rawDiffBM._rows = 0;
 	_waitForEffect = false;
 	_stopPlayingEnd = false;
 	_sampleSpeed = 0;
@@ -298,10 +297,12 @@ void Anim::readDiff(Common::File *diffFile, bool playOnce, bool onlyDiffData) {
 
 	if (_header == 0) {
 		// sizeof(headerdata) != 18, but the padding might be at the end
-		_headerdata._version = _diffFile->readUint16LE();
+		// 2 bytes, version, unused.
+		_diffFile->skip(2);
 		_headerdata._width = _diffFile->readUint16LE();
 		_headerdata._height = _diffFile->readUint16LE();
-		_headerdata._depth = _diffFile->readByte();
+		// 1 byte, depth, unused
+		_diffFile->skip(1);
 		_headerdata._fps = _diffFile->readByte();
 
 		// HACK: The original game defines a 1 second delay when changing screens, which is
@@ -313,8 +314,9 @@ void Anim::readDiff(Common::File *diffFile, bool playOnce, bool onlyDiffData) {
 
 		if (_headerdata._fps == 1)
 			_headerdata._fps = 0;
-		_headerdata._bufferSize = _diffFile->readUint32LE();
-		_headerdata._machine = _diffFile->readUint16LE();
+
+		// 4 + 2 bytes, buffer size and machine, unused
+		_diffFile->skip(6);
 		_headerdata._flags = _diffFile->readUint32LE();
 
 		_diffFile->skip(_size - 18);
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 0d2497b..7e21567 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -37,19 +37,14 @@ class LabEngine;
 #define CONTINUOUS      0xFFFF
 
 struct DIFFHeader {
-	uint16 _version;    // unused
 	uint16 _width;
 	uint16 _height;
-	char _depth;        // unused
 	char _fps;
-	uint32 _bufferSize; // unused
-	uint16 _machine;    // unused
 	uint32 _flags;
 };
 
 struct BitMap {
 	uint16 _bytesPerRow;
-	uint16 _rows;       // unused
 	bool _drawOnScreen;
 	byte *_planes[16];
 };
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index d230225..77245ef 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -103,7 +103,6 @@ void DisplayMan::readPict(const char *filename, bool playOnce, bool onlyDiffData
 		_vm->_music->stopSoundEffect();
 
 	_dispBitMap->_bytesPerRow  = _screenWidth;
-	_dispBitMap->_rows         = (maxHeight > 0) ? maxHeight : _screenHeight;
 	_dispBitMap->_drawOnScreen = (memoryBuffer == nullptr);
 	if (memoryBuffer)
 		_dispBitMap->_planes[0] = memoryBuffer;


Commit: b1fc7852253e372c931d674cd7e2c4cb56bfd5b6
    https://github.com/scummvm/scummvm/commit/b1fc7852253e372c931d674cd7e2c4cb56bfd5b6
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:08+01:00

Commit Message:
LAB: Use templates for the undiff functions

Changed paths:
    engines/lab/anim.cpp
    engines/lab/utils.cpp
    engines/lab/utils.h



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 648634b..4b06096 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -160,7 +160,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 		case 12:
 			curPos = _diffFile->pos();
 			_diffFile->skip(4);
-			_vm->_utils->VRunLengthDecode(DrawBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow);
+			_vm->_utils->verticalRunLengthDecode(DrawBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow);
 			_curBit++;
 			_diffFile->seek(curPos + _size, SEEK_SET);
 			break;
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index 71fce81..1ddb454 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -121,32 +121,12 @@ Common::Point Utils::vgaUnscale(Common::Point pos) {
 
 /**
  * Undiffs a piece of memory when header size is a byte, and copy/skip size
- * is also a byte.
+ * is also a byte or a word.
  */
-void Utils::unDiffByteByte(byte *dest, Common::File *sourceFile) {
-	while (1) {
-		uint16 skip = sourceFile->readByte();
-		uint16 copy = sourceFile->readByte();
-
-		if (skip == 255) {
-			if (copy == 0) {
-				skip = sourceFile->readUint16LE();
-				copy = sourceFile->readUint16LE();
-			} else if (copy == 255)
-				return;
-		}
+template<typename T>
+void Utils::unDiff(T *dest, Common::File *sourceFile) {
+	byte bytesPerWord = sizeof(T);
 
-		dest += skip;
-		sourceFile->read(dest, copy);
-		dest += copy;
-	}
-}
-
-/**
- * Undiffs a piece of memory when header size is a byte, and copy/skip size
- * is a word.
- */
-void Utils::unDiffByteWord(uint16 *dest, Common::File *sourceFile) {
 	while (1) {
 		uint16 skip = sourceFile->readByte();
 		uint16 copy = sourceFile->readByte();
@@ -161,18 +141,15 @@ void Utils::unDiffByteWord(uint16 *dest, Common::File *sourceFile) {
 
 		dest += skip;
 
-		while (copy > 3) {
-			for (int i = 0; i < 4; i++) {
+		if (bytesPerWord == 1) {
+			sourceFile->read(dest, copy);
+			dest += copy;
+		} else {
+			while (copy) {
 				*dest = sourceFile->readUint16LE();
 				dest++;
+				copy--;
 			}
-
-			copy -= 4;
-		}
-
-		while (copy) {
-			*dest++ = sourceFile->readUint16LE();
-			copy--;
 		}
 	}
 }
@@ -181,42 +158,16 @@ void Utils::unDiffByteWord(uint16 *dest, Common::File *sourceFile) {
 
 /**
  * Undiffs a piece of memory when header size is a byte, and copy/skip size
- * is a byte.
+ * is a byte or a word or a double word.
  */
-void Utils::VUnDiffByteByte(byte *dest, Common::File *sourceFile, uint16 bytesPerRow) {
-	for (uint16 counter = 0; counter < _dataBytesPerRow; ) {
-		byte *curPtr = dest + counter;
-
-		for (;;) {
-			uint16 skip = sourceFile->readByte();
-			uint16 copy = sourceFile->readByte();
-
-			if (skip == 255) {
-				counter += copy;
-				break;
-			} else {
-				curPtr += (skip * bytesPerRow);
-
-				while (copy) {
-					copy--;
-					*curPtr = sourceFile->readByte();
-					curPtr += bytesPerRow;
-				}
-			}
-		}
-	}
-}
-
-/**
- * Undiffs a piece of memory when header size is a byte, and copy/skip size
- * is a word.
- */
-void Utils::VUnDiffByteWord(uint16 *dest, Common::File *sourceFile, uint16 bytesPerRow) {
+template<typename T>
+void Utils::verticalUnDiff(T *dest, Common::File *sourceFile, uint16 bytesPerRow) {
 	uint16 counter = 0;
-	uint16 wordsPerRow = bytesPerRow / 2;
+	byte bytesPerWord = sizeof(T);
+	uint16 wordsPerRow = bytesPerRow / bytesPerWord;
 
-	while (counter < (_dataBytesPerRow >> 1)) {
-		uint16 *curPtr = dest + counter;
+	while (counter < wordsPerRow) {
+		T *curPtr = dest + counter;
 
 		for (;;) {
 			uint16 skip = sourceFile->readByte();
@@ -229,7 +180,14 @@ void Utils::VUnDiffByteWord(uint16 *dest, Common::File *sourceFile, uint16 bytes
 				curPtr += (skip * wordsPerRow);
 
 				while (copy) {
-					*curPtr = sourceFile->readUint16LE();
+					if (bytesPerWord == 1)
+						*curPtr++ = sourceFile->readByte();
+					else if (bytesPerWord == 2)
+						*curPtr = sourceFile->readUint16LE();
+					else if (bytesPerWord == 4)
+						*curPtr = sourceFile->readUint32LE();
+					else
+						error("verticalUnDiff: Invalid bytesPerWord (%d)", bytesPerWord);
 					curPtr += wordsPerRow;
 					copy--;
 				}
@@ -238,40 +196,6 @@ void Utils::VUnDiffByteWord(uint16 *dest, Common::File *sourceFile, uint16 bytes
 	}
 }
 
-/**
- * Undiffs a piece of memory when header size is a byte, and copy/skip size
- * is a long.
- */
-void Utils::VUnDiffByteLong(uint32 *dest, Common::File *sourceFile, uint16 bytesPerRow) {
-	uint16 counter = 0;
-	uint16 longsperrow = bytesPerRow / 4;
-
-	while (counter < (_dataBytesPerRow >> 2)) {
-		uint32 *curPtr = dest + counter;
-
-		for (;;) {
-			uint16 skip = sourceFile->readByte();
-			uint16 copy = sourceFile->readByte();
-
-			if (skip == 255) {
-				counter += copy;
-				break;
-			} else {
-				curPtr += (skip * longsperrow);
-
-				while (copy) {
-					*curPtr = sourceFile->readUint32LE();
-					curPtr += longsperrow;
-					copy--;
-				}
-			}
-		}
-	}
-}
-
-/**
- * Runlength decodes a chunk of memory.
- */
 void Utils::runLengthDecode(byte *dest, Common::File *sourceFile) {
 	int8 num;
 	int16 count;
@@ -289,17 +213,15 @@ void Utils::runLengthDecode(byte *dest, Common::File *sourceFile) {
 			num = sourceFile->readSByte();
 
 			while (count) {
-				*dest++ = num;
+				*dest = num;
+				dest++;
 				count--;
 			}
 		}
 	}
 }
 
-/**
- * Does a vertical run length decode.
- */
-void Utils::VRunLengthDecode(byte *dest, Common::File *sourceFile, uint16 bytesPerRow) {
+void Utils::verticalRunLengthDecode(byte *dest, Common::File *sourceFile, uint16 bytesPerRow) {
 	int16 count;
 	byte *top = dest;
 
@@ -335,24 +257,24 @@ void Utils::VRunLengthDecode(byte *dest, Common::File *sourceFile, uint16 bytesP
 /**
  * Does the undiffing between the bitmaps.
  */
-void Utils::unDiff(byte *newBuf, byte *oldBuf, Common::File *sourceFile, uint16 bytesPerRow, bool isV) {
+void Utils::unDiff(byte *newBuf, byte *oldBuf, Common::File *sourceFile, uint16 bytesPerRow, bool isVertical) {
 	sourceFile->skip(1);
 	byte bufType = sourceFile->readByte();
 
-	if (isV) {
+	if (isVertical) {
 		if (bufType == 0)
-			VUnDiffByteByte(newBuf, sourceFile, bytesPerRow);
+			verticalUnDiff<byte>(newBuf, sourceFile, bytesPerRow);
 		else if (bufType == 1)
-			VUnDiffByteWord((uint16 *)newBuf, sourceFile, bytesPerRow);
+			verticalUnDiff<uint16>((uint16 *)newBuf, sourceFile, bytesPerRow);
 		else if (bufType == 3)
-			VUnDiffByteLong((uint32 *)newBuf, sourceFile, bytesPerRow);
+			verticalUnDiff<uint32>((uint32 *)newBuf, sourceFile, bytesPerRow);
 		else
 			error("Unexpected variable compression scheme %d", bufType);
 	} else {
 		if (bufType == 0)
-			unDiffByteByte(newBuf, sourceFile);
+			unDiff<byte>(newBuf, sourceFile);
 		else if (bufType == 1)
-			unDiffByteWord((uint16 *)newBuf, sourceFile);
+			unDiff<uint16>((uint16 *)newBuf, sourceFile);
 		else
 			error("Unexpected compression scheme %d", bufType);
 	}
diff --git a/engines/lab/utils.h b/engines/lab/utils.h
index 0d4f649..4bd29b9 100644
--- a/engines/lab/utils.h
+++ b/engines/lab/utils.h
@@ -38,11 +38,11 @@ private:
 	LabEngine *_vm;
 	uint16 _dataBytesPerRow;
 
-	void unDiffByteByte(byte *dest, Common::File *sourceFile);
-	void unDiffByteWord(uint16 *dest, Common::File *sourceFile);
-	void VUnDiffByteByte(byte *dest, Common::File *sourceFile, uint16 bytesPerRow);
-	void VUnDiffByteWord(uint16 *dest, Common::File *sourceFile, uint16 bytesPerRow);
-	void VUnDiffByteLong(uint32 *dest, Common::File *sourceFile, uint16 bytesPerRow);
+	template<typename T>
+	void unDiff(T *dest, Common::File *sourceFile);
+
+	template<typename T>
+	void verticalUnDiff(T *dest, Common::File *sourceFile, uint16 bytesPerRow);
 
 public:
 	Utils(LabEngine *vm);
@@ -58,9 +58,9 @@ public:
 	uint16 mapScaleX(uint16 x);
 	uint16 mapScaleY(uint16 y);
 	Common::Point vgaUnscale(Common::Point pos);
-	void unDiff(byte *newBuf, byte *oldBuf, Common::File *sourceFile, uint16 bytesPerRow, bool isV);
+	void unDiff(byte *newBuf, byte *oldBuf, Common::File *sourceFile, uint16 bytesPerRow, bool isVertical);
 	void runLengthDecode(byte *dest, Common::File *sourceFile);
-	void VRunLengthDecode(byte *dest, Common::File *sourceFile, uint16 bytesPerRow);
+	void verticalRunLengthDecode(byte *dest, Common::File *sourceFile, uint16 bytesPerRow);
 	void setBytesPerRow(int num);
 	uint16 getRandom(uint16 max);
 };


Commit: 15889e6fd25dd0010dd2b5488cbabae46621954b
    https://github.com/scummvm/scummvm/commit/15889e6fd25dd0010dd2b5488cbabae46621954b
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:08+01:00

Commit Message:
LAB: Make processMap a bit more readable by using Rects

Changed paths:
    engines/lab/map.cpp
    engines/lab/utils.cpp
    engines/lab/utils.h



diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 0d8b89a..bdd9eaf 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -503,33 +503,29 @@ void LabEngine::processMap(uint16 curRoom) {
 					}
 				}
 			} else if (msgClass == kMessageLeftClick) {
-				if ((curFloor == kFloorLower) && (mouseX >= _utils->mapScaleX(538)) && (mouseY >= _utils->mapScaleY(277))
-					  && (mouseX <= _utils->mapScaleX(633)) && (mouseY <= _utils->mapScaleY(352))
+				if ((curFloor == kFloorLower) && _utils->mapRectScale(538, 277, 633, 352).contains(mouseX, mouseY)
 					  && floorVisited(kFloorSurMaze)) {
 					curFloor = kFloorSurMaze;
 
 					_graphics->fade(false, 0);
 					drawMap(curRoom, curMsg, curFloor, false, false);
 					_graphics->fade(true, 0);
-				} else if ((curFloor == kFloorMiddle) && (mouseX >= _utils->mapScaleX(358)) && (mouseY >= _utils->mapScaleY(71))
-							  && (mouseX <= _utils->mapScaleX(452)) && (mouseY <= _utils->mapScaleY(147))
-							  && floorVisited(kFloorCarnival)) {
+				} else if ((curFloor == kFloorMiddle) && _utils->mapRectScale(358, 71, 452, 147).contains(mouseX, mouseY)
+							&& floorVisited(kFloorCarnival)) {
 					curFloor = kFloorCarnival;
 
 					_graphics->fade(false, 0);
 					drawMap(curRoom, curMsg, curFloor, false, false);
 					_graphics->fade(true, 0);
-				} else if ((curFloor == kFloorMiddle) && (mouseX >= _utils->mapScaleX(557)) && (mouseY >= _utils->mapScaleY(325))
-						  && (mouseX <= _utils->mapScaleX(653)) && (mouseY <= _utils->mapScaleY(401))
-						  && floorVisited(kFloorMedMaze)) {
+				} else if ((curFloor == kFloorMiddle) && _utils->mapRectScale(557, 325, 653, 401).contains(mouseX, mouseY)
+							&& floorVisited(kFloorMedMaze)) {
 					curFloor = kFloorMedMaze;
 
 					_graphics->fade(false, 0);
 					drawMap(curRoom, curMsg, curFloor, false, false);
 					_graphics->fade(true, 0);
-				} else if ((curFloor == kFloorUpper) && (mouseX >= _utils->mapScaleX(524)) && (mouseY >=  _utils->mapScaleY(97))
-						  && (mouseX <= _utils->mapScaleX(645)) && (mouseY <= _utils->mapScaleY(207))
-						  && floorVisited(kFloorHedgeMaze)) {
+				} else if ((curFloor == kFloorUpper) && _utils->mapRectScale(524, 97, 645, 207).contains(mouseX, mouseY)
+							&& floorVisited(kFloorHedgeMaze)) {
 					curFloor = kFloorHedgeMaze;
 
 					_graphics->fade(false, 0);
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index 1ddb454..3bd3057 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -74,6 +74,10 @@ uint16 Utils::mapScaleY(uint16 y) {
 		return ((y - 35) >> 1) - (y >> 6);
 }
 
+Common::Rect Utils::mapRectScale(int16 x1, int16 y1, int16 x2, int16 y2) {
+	return Common::Rect(mapScaleX(x1), mapScaleY(y1), mapScaleX(x2), mapScaleY(y2));
+}
+
 /**
  * Scales the VGA coords to SVGA if necessary; otherwise, returns VGA coords.
  */
diff --git a/engines/lab/utils.h b/engines/lab/utils.h
index 4bd29b9..f9a36ba 100644
--- a/engines/lab/utils.h
+++ b/engines/lab/utils.h
@@ -57,6 +57,7 @@ public:
 	uint16 svgaCord(uint16 cord);
 	uint16 mapScaleX(uint16 x);
 	uint16 mapScaleY(uint16 y);
+	Common::Rect mapRectScale(int16 x1, int16 y1, int16 x2, int16 y2);
 	Common::Point vgaUnscale(Common::Point pos);
 	void unDiff(byte *newBuf, byte *oldBuf, Common::File *sourceFile, uint16 bytesPerRow, bool isVertical);
 	void runLengthDecode(byte *dest, Common::File *sourceFile);


Commit: 12572a9c4b503e6c9e947301d4610626c152f902
    https://github.com/scummvm/scummvm/commit/12572a9c4b503e6c9e947301d4610626c152f902
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:08+01:00

Commit Message:
LAB: Merge enableButton() and disableButton()

Changed paths:
    engines/lab/eventman.h
    engines/lab/interface.cpp
    engines/lab/map.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h
index 7b5f2dd..342f859 100644
--- a/engines/lab/eventman.h
+++ b/engines/lab/eventman.h
@@ -98,9 +98,8 @@ public:
 
 	void attachButtonList(ButtonList *buttonList);
 	Button *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *image, Image *altImage);
-	void disableButton(Button *button, uint16 penColor);
+	void toggleButton(Button *button, uint16 penColor, bool enable);
 	void drawButtonList(ButtonList *buttonList);
-	void enableButton(Button *button);
 	void freeButtonList(ButtonList *buttonList);
 	Button *getButton(uint16 id);
 	Common::Point getMousePos();
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 949db06..c47339c 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -72,27 +72,20 @@ void EventManager::freeButtonList(ButtonList *buttonList) {
  */
 void EventManager::drawButtonList(ButtonList *buttonList) {
 	for (ButtonList::iterator button = buttonList->begin(); button != buttonList->end(); ++button) {
-		(*button)->_image->drawImage((*button)->_x, (*button)->_y);
+		toggleButton((*button), 1, true);
 
 		if (!(*button)->_isEnabled)
-			disableButton((*button), 1);
+			toggleButton((*button), 1, false);
 	}
 }
 
-/**
- * Dims a button, and makes it unavailable for using.
- */
-void EventManager::disableButton(Button *button, uint16 penColor) {
-	_vm->_graphics->overlayRect(penColor, button->_x, button->_y, button->_x + button->_image->_width - 1, button->_y + button->_image->_height - 1);
-	button->_isEnabled = false;
-}
+void EventManager::toggleButton(Button *button, uint16 disabledPenColor, bool enable) {
+	if (!enable)
+		_vm->_graphics->overlayRect(disabledPenColor, button->_x, button->_y, button->_x + button->_image->_width - 1, button->_y + button->_image->_height - 1);
+	else
+		button->_image->drawImage(button->_x, button->_y);
 
-/**
- * Undims a button, and makes it available again.
- */
-void EventManager::enableButton(Button *button) {
-	button->_image->drawImage(button->_x, button->_y);
-	button->_isEnabled = true;
+	button->_isEnabled = enable;
 }
 
 /**
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index bdd9eaf..4c2bfe2 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -377,18 +377,8 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad
 	if ((_maps[curRoom]._pageNumber == floorNum) && _roomsFound->in(curRoom) && _maps[curRoom]._x)
 		drawRoomMap(curRoom, true);
 
-	Button *upButton = _event->getButton(1);
-	Button *downButton = _event->getButton(2);
-
-	if (getUpperFloor(floorNum) != kFloorNone)
-		_event->enableButton(upButton);
-	else
-		_event->disableButton(upButton, 12);
-
-	if (getLowerFloor(floorNum) != kFloorNone)
-		_event->enableButton(downButton);
-	else
-		_event->disableButton(downButton, 12);
+	_event->toggleButton(_event->getButton(1), 12, (getUpperFloor(floorNum) != kFloorNone));	// up button
+	_event->toggleButton(_event->getButton(2), 12, (getLowerFloor(floorNum) != kFloorNone));	// down button
 
 	// Labyrinth specific code
 	if (floorNum == kFloorLower) {
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 194564c..bf0938b 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -234,18 +234,8 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 	else
 		turnPage((wipenum == 1));
 
-	Button *backButton = _event->getButton(0);
-	Button *forwardButton = _event->getButton(2);
-
-	if (_journalPage == 0)
-		_event->disableButton(backButton, 15);
-	else
-		_event->enableButton(backButton);
-
-	if (_lastPage)
-		_event->disableButton(forwardButton, 15);
-	else
-		_event->enableButton(forwardButton);
+	_event->toggleButton(_event->getButton(0), 15, (_journalPage > 0));	// back button
+	_event->toggleButton(_event->getButton(2), 15, (!_lastPage));	// forward button
 
 	if (needFade)
 		_graphics->fade(true, 0);


Commit: 0004488441224b172e9f785478af30572e53302c
    https://github.com/scummvm/scummvm/commit/0004488441224b172e9f785478af30572e53302c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:09+01:00

Commit Message:
LAB: Simplify decIncInv() and move action handling out of fromCrumbs()

Changed paths:
    engines/lab/engine.cpp
    engines/lab/lab.h



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 21849e1..9b6ab6f 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -389,12 +389,10 @@ bool LabEngine::doUse(uint16 curInv) {
  * Decrements the current inventory number.
  */
 void LabEngine::decIncInv(uint16 *curInv, bool decreaseFl) {
+	int8 step = (decreaseFl) ? -1 : 1;
 	interfaceOff();
-
-	if (decreaseFl)
-		(*curInv)--;
-	else
-		(*curInv)++;
+	
+	(*curInv) += step;
 
 	while (*curInv && (*curInv <= _numInv)) {
 		if (_conditions->in(*curInv) && _inventory[*curInv]._bitmapName) {
@@ -402,17 +400,11 @@ void LabEngine::decIncInv(uint16 *curInv, bool decreaseFl) {
 			break;
 		}
 
-		if (decreaseFl)
-			(*curInv)--;
-		else
-			(*curInv)++;
+		(*curInv) += step;
 	}
 
 	if ((*curInv == 0) || (*curInv > _numInv)) {
-		if (decreaseFl)
-			*curInv = _numInv;
-		else
-			*curInv = 1;
+		(*curInv) += step;
 
 		while (*curInv && (*curInv <= _numInv)) {
 			if (_conditions->in(*curInv) && _inventory[*curInv]._bitmapName) {
@@ -420,10 +412,7 @@ void LabEngine::decIncInv(uint16 *curInv, bool decreaseFl) {
 				break;
 			}
 
-			if (decreaseFl)
-				(*curInv)--;
-			else
-				(*curInv)++;
+			(*curInv) += step;
 		}
 	}
 }
@@ -667,8 +656,6 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 		interfaceOff();
 		_mainDisplay = true;
 
-		bool doit = false;
-
 		if (_closeDataPtr) {
 			switch (_closeDataPtr->_closeUpType) {
 			case SPECIALLOCK:
@@ -680,77 +667,11 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 					_tilePuzzle->mouseTile(curPos);
 				break;
 			default:
-				doit = true;
+				performAction(wrkClosePtr, actionMode, curPos, curInv);
 				break;
 			}
 		} else
-			doit = true;
-
-
-		if (doit) {
-			wrkClosePtr = nullptr;
-			eatMessages();
-
-			switch (actionMode) {
-			case 0:
-				// Take something.
-				if (doActionRule(curPos, actionMode, _roomNum, &_closeDataPtr))
-					_curFileName = _newFileName;
-				else if (takeItem(curPos, &_closeDataPtr))
-					drawStaticMessage(kTextTakeItem);
-				else if (doActionRule(curPos, TAKEDEF - 1, _roomNum, &_closeDataPtr))
-					_curFileName = _newFileName;
-				else if (doActionRule(curPos, TAKE - 1, 0, &_closeDataPtr))
-					_curFileName = _newFileName;
-				else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
-					drawStaticMessage(kTextNothing);
-
-				break;
-
-			case 1:
-			case 2:
-			case 3:
-				// Manipulate an object, Open up a "door" or Close a "door"
-				if (doActionRule(curPos, actionMode, _roomNum, &_closeDataPtr))
-					_curFileName = _newFileName;
-				else if (!doActionRule(curPos, actionMode, 0, &_closeDataPtr)) {
-					if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
-						drawStaticMessage(kTextNothing);
-				}
-				break;
-
-			case 4: {
-					// Look at closeups
-					CloseDataPtr tmpClosePtr = _closeDataPtr;
-					setCurrentClose(curPos, &tmpClosePtr, true);
-
-					if (_closeDataPtr == tmpClosePtr) {
-						if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
-							drawStaticMessage(kTextNothing);
-					} else if (tmpClosePtr->_graphicName) {
-						if (*(tmpClosePtr->_graphicName)) {
-							_anim->_doBlack = true;
-							_closeDataPtr = tmpClosePtr;
-						} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
-							drawStaticMessage(kTextNothing);
-					} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
-						drawStaticMessage(kTextNothing);
-				}
-				break;
-
-			case 5:
-				if (_conditions->in(curInv)) {
-					// Use an item on something else
-					if (doOperateRule(curPos, curInv, &_closeDataPtr)) {
-						_curFileName = _newFileName;
-
-						if (!_conditions->in(curInv))
-							decIncInv(&curInv, false);
-					} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
-						drawStaticMessage(kTextNothing);
-				}
-			}
-		}
+			performAction(wrkClosePtr, actionMode, curPos, curInv);
 
 		mayShowCrumbIndicator();
 		_graphics->screenUpdate();
@@ -1159,6 +1080,75 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 	_graphics->screenUpdate();
 }
 
+void LabEngine::performAction(CloseDataPtr wrkClosePtr, uint16 actionMode, Common::Point curPos, uint16 &curInv) {
+	wrkClosePtr = nullptr;
+	eatMessages();
+
+	switch (actionMode) {
+	case 0:
+		// Take something.
+		if (doActionRule(curPos, actionMode, _roomNum, &_closeDataPtr))
+			_curFileName = _newFileName;
+		else if (takeItem(curPos, &_closeDataPtr))
+			drawStaticMessage(kTextTakeItem);
+		else if (doActionRule(curPos, TAKEDEF - 1, _roomNum, &_closeDataPtr))
+			_curFileName = _newFileName;
+		else if (doActionRule(curPos, TAKE - 1, 0, &_closeDataPtr))
+			_curFileName = _newFileName;
+		else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
+			drawStaticMessage(kTextNothing);
+
+		break;
+
+	case 1:
+	case 2:
+	case 3:
+		// Manipulate an object, Open up a "door" or Close a "door"
+		if (doActionRule(curPos, actionMode, _roomNum, &_closeDataPtr))
+			_curFileName = _newFileName;
+		else if (!doActionRule(curPos, actionMode, 0, &_closeDataPtr)) {
+			if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
+				drawStaticMessage(kTextNothing);
+		}
+		break;
+
+	case 4: {
+		// Look at closeups
+		CloseDataPtr tmpClosePtr = _closeDataPtr;
+		setCurrentClose(curPos, &tmpClosePtr, true);
+
+		if (_closeDataPtr == tmpClosePtr) {
+			if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
+				drawStaticMessage(kTextNothing);
+		}
+		else if (tmpClosePtr->_graphicName) {
+			if (*(tmpClosePtr->_graphicName)) {
+				_anim->_doBlack = true;
+				_closeDataPtr = tmpClosePtr;
+			}
+			else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
+				drawStaticMessage(kTextNothing);
+		}
+		else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
+			drawStaticMessage(kTextNothing);
+	}
+			break;
+
+	case 5:
+		if (_conditions->in(curInv)) {
+			// Use an item on something else
+			if (doOperateRule(curPos, curInv, &_closeDataPtr)) {
+				_curFileName = _newFileName;
+
+				if (!_conditions->in(curInv))
+					decIncInv(&curInv, false);
+			}
+			else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
+				drawStaticMessage(kTextNothing);
+		}
+	}
+}
+
 void LabEngine::go() {
 	_isHiRes = ((getFeatures() & GF_LOWRES) == 0);
 	_graphics->setUpScreens();
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index dcde9f9..33d8db5 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -254,6 +254,7 @@ private:
 	bool processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &qualifier, Common::Point &curPos, uint16 &curInv, bool &forceDraw, uint16 code);
 	void processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint16 &lastInv, uint16 &oldDirection, bool &forceDraw, uint16 buttonId, uint16 &actionMode);
 	void processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonId, uint16 &actionMode);
+	void performAction(CloseDataPtr wrkClosePtr, uint16 actionMode, Common::Point curPos, uint16 &curInv);
 
 private:
 	bool saveGame(int slot, Common::String desc);


Commit: 1c02487a00e100dcae1755742d2ab4412688c5aa
    https://github.com/scummvm/scummvm/commit/1c02487a00e100dcae1755742d2ab4412688c5aa
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:09+01:00

Commit Message:
LAB: Fix the intro of the DOS version

Changed paths:
    engines/lab/intro.cpp



diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index e4c84dc..abd7018 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -338,8 +338,10 @@ void Intro::introSequence() {
 	}
 
 	doPictText("i.1", msgFont, true);
-	doPictText("i.2A", msgFont, true);
-	doPictText("i.2B", msgFont, true);
+	if (_vm->getPlatform() == Common::kPlatformWindows) {
+		doPictText("i.2A", msgFont, true);
+		doPictText("i.2B", msgFont, true);
+	}
 
 	_vm->_graphics->blackAllScreen();
 	_vm->_music->updateMusic();
@@ -357,7 +359,10 @@ void Intro::introSequence() {
 	nReadPict("Stiles3", true);
 	doPictText("i.6", msgFont, false);
 
-	nReadPict("Platform2", true);
+	if (_vm->getPlatform() == Common::kPlatformWindows)
+		nReadPict("Platform2", true);
+	else
+		nReadPict("Platform", true);
 	doPictText("i.7", msgFont, false);
 
 	nReadPict("Subway.1", true);


Commit: c5528a631d63e47b830c89258507ebb681d5b261
    https://github.com/scummvm/scummvm/commit/c5528a631d63e47b830c89258507ebb681d5b261
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:09+01:00

Commit Message:
LAB: Handle some differences of the Amiga version

The Amiga version is still not working, as the CONTROL and INV files
are missing, and the format of the font files is different

Changed paths:
    engines/lab/detection.cpp
    engines/lab/dispman.cpp
    engines/lab/engine.cpp
    engines/lab/intro.cpp
    engines/lab/resource.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/detection.cpp b/engines/lab/detection.cpp
index 52d2845..7bb9821 100644
--- a/engines/lab/detection.cpp
+++ b/engines/lab/detection.cpp
@@ -87,7 +87,7 @@ static const ADGameDescription labDescriptions[] = {
 		AD_ENTRY1s("doors", "7bf458df6ec30cc8ef4665e4d7c77f59", 2537), // game/doors
 		Common::EN_ANY,
 		Common::kPlatformAmiga,
-		ADGF_NO_FLAGS,
+		Lab::GF_LOWRES,
 		GUIO0()
 	},
 	AD_TABLE_END_MARKER
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 77245ef..3702e70 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -405,6 +405,7 @@ void DisplayMan::setUpScreens() {
 
 	createScreen(_vm->_isHiRes);
 
+	// TODO: The CONTROL file is not present in the Amiga version
 	Common::File *controlFile = _vm->_resource->openDataFile("P:Control");
 	for (uint16 i = 0; i < 20; i++)
 		_vm->_moveImages[i] = new Image(controlFile, _vm);
@@ -426,6 +427,7 @@ void DisplayMan::setUpScreens() {
 	moveButtonList->push_back(e->createButton(257, y, 8, VKEY_RTARROW, moveImages[18], moveImages[19]));
 	moveButtonList->push_back(e->createButton(289, y, 9,          'p', moveImages[10], moveImages[11]));
 
+	// TODO: The INV file is not present in the Amiga version
 	Common::File *invFile = _vm->_resource->openDataFile("P:Inv");
 	if (_vm->getPlatform() == Common::kPlatformWindows) {
 		for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++)
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 9b6ab6f..70fe2fa 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -1154,7 +1154,10 @@ void LabEngine::go() {
 	_graphics->setUpScreens();
 
 	_event->initMouse();
-	_msgFont = _resource->getFont("P:AvanteG.12");
+	if (getPlatform() != Common::kPlatformAmiga)
+		_msgFont = _resource->getFont("F:AvanteG.12");
+	else
+		_msgFont = _resource->getFont("F:Map.fon");
 	_event->mouseHide();
 
 	Intro *intro = new Intro(this);
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index abd7018..22ad25a 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -325,7 +325,7 @@ void Intro::introSequence() {
 	_vm->_graphics->blackAllScreen();
 	_vm->_music->updateMusic();
 
-	TextFont *msgFont = _vm->_resource->getFont("P:Map.fon");
+	TextFont *msgFont = _vm->_resource->getFont("F:Map.fon");
 
 	_vm->_anim->_noPalChange = true;
 	nReadPict("Intro.1", true);
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 668b31b..7629d0c 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -51,6 +51,7 @@ void Resource::readStaticText() {
 }
 
 TextFont *Resource::getFont(const char *fileName) {
+	// TODO: Add support for the font format of the Amiga version
 	Common::File *dataFile = openDataFile(fileName, MKTAG('V', 'G', 'A', 'F'));
 
 	uint32 headerSize = 4 + 2 + 256 * 3 + 4;
@@ -154,15 +155,29 @@ Common::String Resource::translateFileName(Common::String filename) {
 	filename.toUppercase();
 	Common::String fileNameStrFinal;
 
-	if (filename.hasPrefix("P:")) {
+	if (filename.hasPrefix("P:") || filename.hasPrefix("F:")) {
 		if (_vm->_isHiRes)
 			fileNameStrFinal = "GAME/SPICT/";
 		else
 			fileNameStrFinal = "GAME/PICT/";
-	} else if (filename.hasPrefix("LAB:"))
-		fileNameStrFinal = "GAME/";
-	else if (filename.hasPrefix("MUSIC:"))
-		fileNameStrFinal = "GAME/MUSIC/";
+
+		if (_vm->getPlatform() == Common::kPlatformAmiga) {
+			if (filename.hasPrefix("P:")) {
+				fileNameStrFinal = "PICT/";
+			} else {
+				fileNameStrFinal = "LABFONTS/";
+				filename += "T";	// all the Amiga fonts have a ".FONT" suffix
+			}
+		}
+	} else if (filename.hasPrefix("LAB:")) {
+		if (_vm->getPlatform() != Common::kPlatformAmiga)
+			fileNameStrFinal = "GAME/";
+	} else if (filename.hasPrefix("MUSIC:")) {
+		if (_vm->getPlatform() != Common::kPlatformAmiga)
+			fileNameStrFinal = "GAME/MUSIC/";
+		else
+			fileNameStrFinal = "MUSIC/";
+	}
 
 	if (filename.contains(':')) {
 		while (filename[0] != ':') {
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index bf0938b..6e69578 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -51,7 +51,7 @@ namespace Lab {
  * Does the things to properly set up the detective notes.
  */
 void LabEngine::doNotes() {
-	TextFont *noteFont = _resource->getFont("P:Note.fon");
+	TextFont *noteFont = _resource->getFont("F:Note.fon");
 	char *noteText = _resource->getText("Lab:Rooms/Notes");
 
 	Common::Rect textRect = Common::Rect(_utils->vgaScaleX(25) + _utils->svgaCord(15), _utils->vgaScaleY(50), _utils->vgaScaleX(295) - _utils->svgaCord(15), _utils->vgaScaleY(148));
@@ -66,7 +66,7 @@ void LabEngine::doNotes() {
  * OpenHiRes already called.
  */
 void LabEngine::doWestPaper() {
-	TextFont *paperFont = _resource->getFont("P:News22.fon");
+	TextFont *paperFont = _resource->getFont("F:News22.fon");
 	char *paperText = _resource->getText("Lab:Rooms/Date");
 
 	Common::Rect textRect = Common::Rect(_utils->vgaScaleX(57), _utils->vgaScaleY(77) + _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(91));
@@ -74,7 +74,7 @@ void LabEngine::doWestPaper() {
 	_graphics->closeFont(paperFont);
 	delete[] paperText;
 
-	paperFont = _resource->getFont("P:News32.fon");
+	paperFont = _resource->getFont("F:News32.fon");
 	paperText = _resource->getText("Lab:Rooms/Headline");
 
 	int fileLen = strlen(paperText) - 1;
@@ -93,7 +93,7 @@ void LabEngine::doWestPaper() {
 	_graphics->closeFont(paperFont);
 	delete[] paperText;
 
-	paperFont = _resource->getFont("P:Note.fon");
+	paperFont = _resource->getFont("F:Note.fon");
 	paperText = _resource->getText("Lab:Rooms/Col1");
 	charsPrinted = _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(45, y, 158, 148), paperText);
 	delete[] paperText;
@@ -109,7 +109,7 @@ void LabEngine::doWestPaper() {
  * Loads in the data for the journal.
  */
 void LabEngine::loadJournalData() {
-	_journalFont = _resource->getFont("P:Journal.fon");
+	_journalFont = _resource->getFont("F:Journal.fon");
 	_music->updateMusic();
 
 	char filename[20];
@@ -496,7 +496,7 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 	_lastPage = false;
 	_graphics->_fadePalette = _highPalette;
 
-	TextFont *monitorFont = _resource->getFont("P:Map.fon");
+	TextFont *monitorFont = _resource->getFont("F:Map.fon");
 	Common::File *buttonFile = _resource->openDataFile("P:MonImage");
 	_monitorButton = new Image(buttonFile, this);
 	delete buttonFile;


Commit: 691d9e7e2ed8c5b5df62268f232c417410111a0e
    https://github.com/scummvm/scummvm/commit/691d9e7e2ed8c5b5df62268f232c417410111a0e
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:09+01:00

Commit Message:
LAB: Fix memory leaks in savegame code

Changed paths:
    engines/lab/savegame.cpp



diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index d08dcbc..9802fc5 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -231,6 +231,7 @@ bool LabEngine::saveRestoreGame() {
 
 			isOK = saveGame(slot, desc);
 		}
+		delete dialog;
 	} else {
 		// Restore
 		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
@@ -240,6 +241,7 @@ bool LabEngine::saveRestoreGame() {
 			if (isOK)
 				_music->resetMusic();
 		}
+		delete dialog;
 	}
 
 	_alternate = false;


Commit: e94b18aec7592f7b5a0a8cc76ae4b6e951a35a96
    https://github.com/scummvm/scummvm/commit/e94b18aec7592f7b5a0a8cc76ae4b6e951a35a96
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-23T21:34:09+01:00

Commit Message:
LAB: Correct engine name spelling. No functional change.

Changed paths:
    engines/lab/configure.engine



diff --git a/engines/lab/configure.engine b/engines/lab/configure.engine
index df154b4..18091b1 100644
--- a/engines/lab/configure.engine
+++ b/engines/lab/configure.engine
@@ -1,3 +1,3 @@
 # This file is included from the main "configure" script
 # add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
-add_engine lab "Labirynth of Time" no
+add_engine lab "Labyrinth of Time" no


Commit: 9048d08a0573e97af10822976c0988546780b3db
    https://github.com/scummvm/scummvm/commit/9048d08a0573e97af10822976c0988546780b3db
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-23T21:34:09+01:00

Commit Message:
LAB: Correct compiler warning in savegame code.

Changed paths:
    engines/lab/savegame.cpp



diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 9802fc5..26ced8d 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -150,7 +150,7 @@ bool LabEngine::saveGame(int slot, Common::String desc) {
 	_tilePuzzle->save(file);
 
 	// Breadcrumbs
-	for (int i = 0; i < sizeof(_breadCrumbs); i++) {
+	for (uint i = 0; i < sizeof(_breadCrumbs); i++) {
 		file->writeUint16LE(_breadCrumbs[i]._roomNum);
 		file->writeUint16LE(_breadCrumbs[i]._direction);
 	}


Commit: 28bfce3de7e9b0ee043b4da88975f71cd72c347b
    https://github.com/scummvm/scummvm/commit/28bfce3de7e9b0ee043b4da88975f71cd72c347b
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-23T21:34:09+01:00

Commit Message:
LAB: Correct variable shadows function compiler warning.

Changed paths:
    engines/lab/music.cpp



diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index aa34b7f..18a5cc3 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -78,11 +78,11 @@ void Music::updateMusic() {
 		fillbuffer(musicBuffer);
 
 		// Queue a music block, and start the music, if needed
-		bool startMusic = false;
+		bool startMusicFlag = false;
 
 		if (!_queuingAudioStream) {
 			_queuingAudioStream = Audio::makeQueuingAudioStream(SAMPLESPEED, false);
-			startMusic = true;
+			startMusicFlag = true;
 		}
 
 		byte soundFlags = Audio::FLAG_LITTLE_ENDIAN;
@@ -93,7 +93,7 @@ void Music::updateMusic() {
 
 		_queuingAudioStream->queueBuffer(musicBuffer, MUSICBUFSIZE, DisposeAfterUse::YES, soundFlags);
 
-		if (startMusic)
+		if (startMusicFlag)
 			_vm->_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _queuingAudioStream);
 	}
 }


Commit: a7afc80e185c6a54bc056e0312ae5882a6ebc5ad
    https://github.com/scummvm/scummvm/commit/a7afc80e185c6a54bc056e0312ae5882a6ebc5ad
Author: D G Turner (digitall at scummvm.org)
Date: 2015-12-23T21:34:09+01:00

Commit Message:
LAB: Avoid variable shadowing compiler warning.

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 3702e70..8d26cef 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -227,7 +227,7 @@ int DisplayMan::flowText(
 			x += (width - textLength(msgFont, lineBuffer, strlen(lineBuffer))) / 2;
 
 		if (output)
-			text(msgFont, x, y, penColor, lineBuffer, strlen(lineBuffer));
+			drawText(msgFont, x, y, penColor, lineBuffer, strlen(lineBuffer));
 
 		numLines--;
 		y += fontHeight;
@@ -325,7 +325,7 @@ void DisplayMan::drawMessage(const char *str) {
 
 			_vm->_event->mouseHide();
 			createBox(168);
-			text(_vm->_msgFont, _vm->_utils->vgaScaleX(7), _vm->_utils->vgaScaleY(155) + _vm->_utils->svgaCord(2), 1, str, strlen(str));
+			drawText(_vm->_msgFont, _vm->_utils->vgaScaleX(7), _vm->_utils->vgaScaleY(155) + _vm->_utils->svgaCord(2), 1, str, strlen(str));
 			_vm->_event->mouseShow();
 			_lastMessageLong = false;
 		}
@@ -668,7 +668,7 @@ uint16 DisplayMan::textHeight(TextFont *tf) {
 /**
  * Draws the text to the screen.
  */
-void DisplayMan::text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numChars) {
+void DisplayMan::drawText(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numChars) {
 	byte *vgaTop = getCurrentDrawingBuffer();
 
 	for (uint16 i = 0; i < numChars; i++) {
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index ca686de..8561982 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -133,7 +133,7 @@ public:
 	void closeFont(TextFont *font);
 	uint16 textLength(TextFont *font, const char *text, uint16 numChars);
 	uint16 textHeight(TextFont *tf);
-	void text(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numChars);
+	void drawText(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numChars);
 	void getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer, uint16 lineWidth);
 
 	bool _longWinInFront;


Commit: b3b3c0cfd565b66a77fdfa810845619dea362d95
    https://github.com/scummvm/scummvm/commit/b3b3c0cfd565b66a77fdfa810845619dea362d95
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:09+01:00

Commit Message:
LAB: Remove parameters from processMainButton and performAction

Changed paths:
    engines/lab/engine.cpp
    engines/lab/lab.h



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 70fe2fa..d98f8b6 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -649,7 +649,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 			_graphics->screenUpdate();
 		}
 	} else if ((msgClass == kMessageButtonUp) && !_alternate) {
-		processMainButton(wrkClosePtr, curInv, lastInv, oldDirection, forceDraw, buttonId, actionMode);
+		processMainButton(curInv, lastInv, oldDirection, forceDraw, buttonId, actionMode);
 	} else if ((msgClass == kMessageButtonUp) && _alternate) {
 		processAltButton(curInv, lastInv, buttonId, actionMode);
 	} else if (leftButtonClick && _mainDisplay) {
@@ -667,11 +667,11 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 					_tilePuzzle->mouseTile(curPos);
 				break;
 			default:
-				performAction(wrkClosePtr, actionMode, curPos, curInv);
+				performAction(actionMode, curPos, curInv);
 				break;
 			}
 		} else
-			performAction(wrkClosePtr, actionMode, curPos, curInv);
+			performAction(actionMode, curPos, curInv);
 
 		mayShowCrumbIndicator();
 		_graphics->screenUpdate();
@@ -700,7 +700,7 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 		ViewData *vptr = getViewData(_roomNum, _direction);
 		CloseDataPtr oldClosePtr = vptr->_closeUps;
 
-		if (!wrkClosePtr) {
+		if (!wrkClosePtr) { // CHECKME: Always true?
 			CloseDataPtr tmpClosePtr = _closeDataPtr;
 			setCurrentClose(curPos, &tmpClosePtr, true);
 
@@ -815,7 +815,7 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &quali
 	return true;
 }
 
-void LabEngine::processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint16 &lastInv, uint16 &oldDirection, bool &forceDraw, uint16 buttonId, uint16 &actionMode) {
+void LabEngine::processMainButton(uint16 &curInv, uint16 &lastInv, uint16 &oldDirection, bool &forceDraw, uint16 buttonId, uint16 &actionMode) {
 	uint16 newDir;
 	uint16 oldRoomNum;
 
@@ -829,7 +829,6 @@ void LabEngine::processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint
 			doMainView(&_closeDataPtr);
 
 			_anim->_doBlack = true;
-			wrkClosePtr = nullptr;
 			_closeDataPtr = nullptr;
 			mayShowCrumbIndicator();
 		} else {
@@ -868,7 +867,6 @@ void LabEngine::processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint
 	case kButtonLeft:
 	case kButtonRight:
 		_closeDataPtr = nullptr;
-		wrkClosePtr = nullptr;
 		if (buttonId == kButtonLeft)
 			drawStaticMessage(kTextTurnLeft);
 		else
@@ -887,7 +885,6 @@ void LabEngine::processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint
 
 	case kButtonForward:
 		_closeDataPtr = nullptr;
-		wrkClosePtr = nullptr;
 		oldRoomNum = _roomNum;
 
 		if (doGoForward(&_closeDataPtr)) {
@@ -1080,8 +1077,7 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 	_graphics->screenUpdate();
 }
 
-void LabEngine::performAction(CloseDataPtr wrkClosePtr, uint16 actionMode, Common::Point curPos, uint16 &curInv) {
-	wrkClosePtr = nullptr;
+void LabEngine::performAction(uint16 actionMode, Common::Point curPos, uint16 &curInv) {
 	eatMessages();
 
 	switch (actionMode) {
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 33d8db5..28bd0ac 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -252,9 +252,9 @@ private:
 	bool takeItem(Common::Point pos, CloseDataPtr *closePtrList);
 	void turnPage(bool fromLeft);
 	bool processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &qualifier, Common::Point &curPos, uint16 &curInv, bool &forceDraw, uint16 code);
-	void processMainButton(CloseDataPtr wrkClosePtr, uint16 &curInv, uint16 &lastInv, uint16 &oldDirection, bool &forceDraw, uint16 buttonId, uint16 &actionMode);
+	void processMainButton(uint16 &curInv, uint16 &lastInv, uint16 &oldDirection, bool &forceDraw, uint16 buttonId, uint16 &actionMode);
 	void processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonId, uint16 &actionMode);
-	void performAction(CloseDataPtr wrkClosePtr, uint16 actionMode, Common::Point curPos, uint16 &curInv);
+	void performAction(uint16 actionMode, Common::Point curPos, uint16 &curInv);
 
 private:
 	bool saveGame(int slot, Common::String desc);


Commit: 5c360b40215ce35acbb1a0f5d6bfe5b27d3561f8
    https://github.com/scummvm/scummvm/commit/5c360b40215ce35acbb1a0f5d6bfe5b27d3561f8
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:34:09+01:00

Commit Message:
LAB: Remove dead code

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index d98f8b6..a229b68 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -699,20 +699,16 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 	} else if (msgClass == kMessageDeltaMove) {
 		ViewData *vptr = getViewData(_roomNum, _direction);
 		CloseDataPtr oldClosePtr = vptr->_closeUps;
+		CloseDataPtr tmpClosePtr = _closeDataPtr;
+		setCurrentClose(curPos, &tmpClosePtr, true);
 
-		if (!wrkClosePtr) { // CHECKME: Always true?
-			CloseDataPtr tmpClosePtr = _closeDataPtr;
-			setCurrentClose(curPos, &tmpClosePtr, true);
-
-			if (!tmpClosePtr || (tmpClosePtr == _closeDataPtr)) {
-				if (!_closeDataPtr)
-					wrkClosePtr = oldClosePtr;
-				else
-					wrkClosePtr = _closeDataPtr->_subCloseUps;
-			} else
-				wrkClosePtr = tmpClosePtr->_nextCloseUp;
+		if (!tmpClosePtr || (tmpClosePtr == _closeDataPtr)) {
+			if (!_closeDataPtr)
+				wrkClosePtr = oldClosePtr;
+			else
+				wrkClosePtr = _closeDataPtr->_subCloseUps;
 		} else
-			wrkClosePtr = wrkClosePtr->_nextCloseUp;
+			wrkClosePtr = tmpClosePtr->_nextCloseUp;
 
 
 		if (!wrkClosePtr) {


Commit: 70396e6fbac882780886327dfd673b52270bc7e2
    https://github.com/scummvm/scummvm/commit/70396e6fbac882780886327dfd673b52270bc7e2
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:10+01:00

Commit Message:
LAB: Handle some differences in the intro of the Amiga version

Changed paths:
    engines/lab/intro.cpp



diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 22ad25a..9fbd0b3 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -241,12 +241,12 @@ void Intro::introSequence() {
 
 	_vm->_anim->_doBlack = true;
 
-	if (_vm->getPlatform() != Common::kPlatformWindows) {
+	if (_vm->getPlatform() == Common::kPlatformDOS) {
 		nReadPict("EA0", true);
 		nReadPict("EA1", true);
 		nReadPict("EA2", true);
 		nReadPict("EA3", true);
-	} else {
+	} else if (_vm->getPlatform() == Common::kPlatformWindows) {
 		nReadPict("WYRMKEEP", true);
 		// Wait 4 seconds
 		for (uint16 i = 0; i < 4 * 1000 / 10; i++) {
@@ -258,10 +258,14 @@ void Intro::introSequence() {
 	}
 
 	_vm->_graphics->blackAllScreen();
-	_vm->_music->initMusic("Music:BackGrou");
+	
+	if (_vm->getPlatform() == Common::kPlatformAmiga)
+		_vm->_music->initMusic("Music:BackGround");
+	else
+		_vm->_music->initMusic("Music:BackGrou");
 
 	_vm->_anim->_noPalChange = true;
-	if (_vm->getPlatform() != Common::kPlatformWindows)
+	if (_vm->getPlatform() == Common::kPlatformDOS)
 		nReadPict("TNDcycle.pic", true);
 	else
 		nReadPict("TNDcycle2.pic", true);


Commit: 4d5856a95eb5967f784cd60280496386f2a767e9
    https://github.com/scummvm/scummvm/commit/4d5856a95eb5967f784cd60280496386f2a767e9
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:10+01:00

Commit Message:
LAB: Handle the music encoding of the Amiga version

Changed paths:
    engines/lab/music.cpp



diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 18a5cc3..873f2dc 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -88,8 +88,10 @@ void Music::updateMusic() {
 		byte soundFlags = Audio::FLAG_LITTLE_ENDIAN;
 		if (_vm->getPlatform() == Common::kPlatformWindows)
 			soundFlags |= Audio::FLAG_16BITS;
-		else
+		else if (_vm->getPlatform() == Common::kPlatformDOS)
 			soundFlags |= Audio::FLAG_UNSIGNED;
+		else if (_vm->getPlatform() == Common::kPlatformAmiga)
+			soundFlags = 0;
 
 		_queuingAudioStream->queueBuffer(musicBuffer, MUSICBUFSIZE, DisposeAfterUse::YES, soundFlags);
 


Commit: 5c480485d45f5bdcc783d7962af471638f6b91aa
    https://github.com/scummvm/scummvm/commit/5c480485d45f5bdcc783d7962af471638f6b91aa
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:10+01:00

Commit Message:
LAB: Simplify the Amiga music flags

Changed paths:
    engines/lab/music.cpp



diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 873f2dc..38ecba3 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -90,8 +90,6 @@ void Music::updateMusic() {
 			soundFlags |= Audio::FLAG_16BITS;
 		else if (_vm->getPlatform() == Common::kPlatformDOS)
 			soundFlags |= Audio::FLAG_UNSIGNED;
-		else if (_vm->getPlatform() == Common::kPlatformAmiga)
-			soundFlags = 0;
 
 		_queuingAudioStream->queueBuffer(musicBuffer, MUSICBUFSIZE, DisposeAfterUse::YES, soundFlags);
 


Commit: f1bb844e90cd9722170c1a02dd23a7a4cded1943
    https://github.com/scummvm/scummvm/commit/f1bb844e90cd9722170c1a02dd23a7a4cded1943
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:10+01:00

Commit Message:
LAB: Fix a memory leak in the Image class

Changed paths:
    engines/lab/engine.cpp
    engines/lab/image.cpp
    engines/lab/image.h



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index a229b68..5eed831 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -1229,8 +1229,7 @@ int LabEngine::followCrumbs() {
 
 
 void LabEngine::mayShowCrumbIndicator() {
-	static byte dropCrumbs[] = { 0x00 };
-	static Image dropCrumbsImage(24, 24, dropCrumbs, this);
+	static Image dropCrumbsImage(24, 24, nullptr, this);
 	if (getPlatform() != Common::kPlatformWindows)
 		return;
 
@@ -1242,8 +1241,7 @@ void LabEngine::mayShowCrumbIndicator() {
 }
 
 void LabEngine::mayShowCrumbIndicatorOff() {
-	static byte dropCrumbsOff[] = { 0x00 };
-	static Image dropCrumbsOffImage(24, 24, dropCrumbsOff, this);
+	static Image dropCrumbsOffImage(24, 24, nullptr, this);
 
 	if (getPlatform() != Common::kPlatformWindows)
 		return;
diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp
index 6ace005..2e0ecc1 100644
--- a/engines/lab/image.cpp
+++ b/engines/lab/image.cpp
@@ -49,10 +49,14 @@ Image::Image(Common::File *s, LabEngine *vm) : _vm(vm) {
 	if (size & 1)
 		size++;
 
-	_imageData = new byte[size];	// FIXME: Memory leak!
+	_imageData = new byte[size];
 	s->read(_imageData, size);
 }
 
+Image::~Image() {
+	delete _imageData;
+}
+
 /**
  * Blits a piece of one image to another.
  */
diff --git a/engines/lab/image.h b/engines/lab/image.h
index 90ea1f3..e95125e 100644
--- a/engines/lab/image.h
+++ b/engines/lab/image.h
@@ -47,9 +47,10 @@ public:
 	uint16 _height;
 	byte *_imageData;
 
-	Image(LabEngine *vm) : _width(0), _height(0), _imageData(0), _vm(vm) {}
+	Image(LabEngine *vm) : _width(0), _height(0), _imageData(nullptr), _vm(vm) {}
 	Image(int w, int h, byte *d, LabEngine *vm) : _width(w), _height(h), _imageData(d), _vm(vm) {}
 	Image(Common::File *s, LabEngine *vm);
+	virtual ~Image();
 
 	void drawImage(uint16 x, uint16 y);
 	void drawMaskImage(uint16 x, uint16 y);


Commit: eb70efc900cd224c4ca301ddf49785ab21ab6132
    https://github.com/scummvm/scummvm/commit/eb70efc900cd224c4ca301ddf49785ab21ab6132
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:34:10+01:00

Commit Message:
LAB: Simplify decIncInv()

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 5eed831..a34926f 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -390,30 +390,30 @@ bool LabEngine::doUse(uint16 curInv) {
  */
 void LabEngine::decIncInv(uint16 *curInv, bool decreaseFl) {
 	int8 step = (decreaseFl) ? -1 : 1;
+	uint newInv = *curInv + step;
+
+	// Handle wrapping
+	if (newInv < 1)
+		newInv = _numInv;
+	if (newInv > _numInv)
+		newInv = 1;
+
 	interfaceOff();
 	
-	(*curInv) += step;
-
-	while (*curInv && (*curInv <= _numInv)) {
-		if (_conditions->in(*curInv) && _inventory[*curInv]._bitmapName) {
-			_nextFileName = getInvName(*curInv);
+	while (newInv && (newInv <= _numInv)) {
+		if (_conditions->in(newInv) && _inventory[newInv]._bitmapName) {
+			_nextFileName = getInvName(newInv);
+			*curInv = newInv;
 			break;
 		}
 
-		(*curInv) += step;
-	}
-
-	if ((*curInv == 0) || (*curInv > _numInv)) {
-		(*curInv) += step;
+		newInv += step;
 
-		while (*curInv && (*curInv <= _numInv)) {
-			if (_conditions->in(*curInv) && _inventory[*curInv]._bitmapName) {
-				_nextFileName = getInvName(*curInv);
-				break;
-			}
-
-			(*curInv) += step;
-		}
+		// Handle wrapping
+		if (newInv < 1)
+			newInv = _numInv;
+		if (newInv > _numInv)
+			newInv = 1;
 	}
 }
 


Commit: 3e8eaa2c3552df625c2654b7d76e9b1f35bc9e92
    https://github.com/scummvm/scummvm/commit/3e8eaa2c3552df625c2654b7d76e9b1f35bc9e92
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:35:27+01:00

Commit Message:
LAB: Use Common::String for strings, removing a ton of memory leaks

Also, add a method to properly free room views

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/engine.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/processroom.cpp
    engines/lab/processroom.h
    engines/lab/resource.cpp
    engines/lab/resource.h
    engines/lab/special.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 8d26cef..c928649 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -66,7 +66,7 @@ DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) {
 DisplayMan::~DisplayMan() {
 	freePict();
 	delete _dispBitMap;
-	delete[]_displayBuffer;
+	delete[] _displayBuffer;
 }
 
 // From readPict.c.  Reads in pictures and animations from disk.
@@ -92,10 +92,10 @@ void DisplayMan::loadBackPict(const char *fileName, uint16 *highPal) {
 /**
  * Reads in a picture into the display bitmap.
  */
-void DisplayMan::readPict(const char *filename, bool playOnce, bool onlyDiffData, byte *memoryBuffer, uint16 maxHeight) {
+void DisplayMan::readPict(Common::String filename, bool playOnce, bool onlyDiffData, byte *memoryBuffer, uint16 maxHeight) {
 	_vm->_anim->stopDiff();
 
-	loadPict(filename);
+	loadPict(filename.c_str());
 
 	_vm->_music->updateMusic();
 
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index 8561982..1b90484 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -74,7 +74,7 @@ public:
 
 	void loadPict(const char *filename);
 	void loadBackPict(const char *fileName, uint16 *highPal);
-	void readPict(const char *filename, bool playOnce, bool onlyDiffData = false, byte *memoryBuffer = nullptr, uint16 maxHeight = 0);
+	void readPict(Common::String filename, bool playOnce, bool onlyDiffData = false, byte *memoryBuffer = nullptr, uint16 maxHeight = 0);
 	void freePict();
 	void doScrollBlack();
 	void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem);
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index a34926f..81c401f 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -130,15 +130,15 @@ void LabEngine::drawRoomMessage(uint16 curInv, CloseDataPtr closePtr) {
 	}
 
 	if (_alternate) {
-		if ((curInv <= _numInv) && _conditions->in(curInv) && _inventory[curInv]._bitmapName) {
+		if ((curInv <= _numInv) && _conditions->in(curInv) && _inventory[curInv]._bitmapName != "") {
 			if ((curInv == kItemLamp) && _conditions->in(kCondLampOn))
 				// LAB: Labyrinth specific
 				drawStaticMessage(kTextkLampOn);
 			else if (_inventory[curInv]._many > 1) {
-				Common::String roomMessage = Common::String(_inventory[curInv]._name) + "  (" + Common::String::format("%d", _inventory[curInv]._many) + ")";
+				Common::String roomMessage = _inventory[curInv]._name + "  (" + Common::String::format("%d", _inventory[curInv]._many) + ")";
 				_graphics->drawMessage(roomMessage.c_str());
 			} else
-				_graphics->drawMessage(_inventory[curInv]._name);
+				_graphics->drawMessage(_inventory[curInv]._name.c_str());
 		}
 	} else
 		drawDirection(closePtr);
@@ -219,7 +219,7 @@ bool LabEngine::doCloseUp(CloseDataPtr closePtr) {
 	case kMonitorMuseum:
 	case kMonitorLibrary:
 	case kMonitorWindow:
-		doMonitor(closePtr->_graphicName, closePtr->_message, false, textRect);
+		doMonitor(closePtr->_graphicName.c_str(), closePtr->_message.c_str(), false, textRect);
 		break;
 	case kMonitorGramophone:
 		textRect.right = 171;
@@ -261,7 +261,7 @@ bool LabEngine::doCloseUp(CloseDataPtr closePtr) {
 /**
  * Gets the current inventory name.
  */
-const char *LabEngine::getInvName(uint16 curInv) {
+Common::String LabEngine::getInvName(uint16 curInv) {
 	if (_mainDisplay)
 		return _inventory[curInv]._bitmapName;
 
@@ -401,7 +401,7 @@ void LabEngine::decIncInv(uint16 *curInv, bool decreaseFl) {
 	interfaceOff();
 	
 	while (newInv && (newInv <= _numInv)) {
-		if (_conditions->in(newInv) && _inventory[newInv]._bitmapName) {
+		if (_conditions->in(newInv) && _inventory[newInv]._bitmapName != "") {
 			_nextFileName = getInvName(newInv);
 			*curInv = newInv;
 			break;
@@ -477,11 +477,11 @@ void LabEngine::mainGameLoop() {
 			if (_noUpdateDiff) {
 				// Potentially entered another room
 				_roomsFound->inclElement(_roomNum);
-				forceDraw |= (strcmp(_nextFileName, _curFileName) != 0);
+				forceDraw |= (_nextFileName != _curFileName);
 
 				_noUpdateDiff = false;
 				_curFileName = _nextFileName;
-			} else if (strcmp(_nextFileName, _curFileName) != 0) {
+			} else if (_nextFileName != _curFileName) {
 				interfaceOff();
 				// Potentially entered another room
 				_roomsFound->inclElement(_roomNum);
@@ -491,19 +491,19 @@ void LabEngine::mainGameLoop() {
 					switch (_closeDataPtr->_closeUpType) {
 					case SPECIALLOCK:
 						if (_mainDisplay)
-							_tilePuzzle->showCombination(_curFileName);
+							_tilePuzzle->showCombination(_curFileName.c_str());
 						break;
 					case SPECIALBRICK:
 					case SPECIALBRICKNOMOUSE:
 						if (_mainDisplay)
-							_tilePuzzle->showTile(_curFileName, (_closeDataPtr->_closeUpType == SPECIALBRICKNOMOUSE));
+							_tilePuzzle->showTile(_curFileName.c_str(), (_closeDataPtr->_closeUpType == SPECIALBRICKNOMOUSE));
 						break;
 					default:
-						_graphics->readPict(_curFileName, false);
+						_graphics->readPict(_curFileName.c_str(), false);
 						break;
 					}
 				} else
-					_graphics->readPict(_curFileName, false);
+					_graphics->readPict(_curFileName.c_str(), false);
 
 				drawRoomMessage(curInv, _closeDataPtr);
 				forceDraw = false;
@@ -577,23 +577,8 @@ void LabEngine::mainGameLoop() {
 
 	delete _conditions;
 	delete _roomsFound;
-
-	if (_rooms) {
-		delete[] _rooms;
-		_rooms = nullptr;
-	}
-
-	if (_inventory) {
-		for (int i = 1; i <= _numInv; i++) {
-			if (_inventory[i]._name)
-				delete[] _inventory[i]._name;
-
-			if (_inventory[i]._bitmapName)
-				delete[] _inventory[i]._bitmapName;
-		}
-
-		delete[] _inventory;
-	}
+	delete[] _rooms;
+	delete[] _inventory;
 }
 
 void LabEngine::showLab2Teaser() {
@@ -1014,7 +999,7 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 				curInv++;
 		}
 
-		if ((curInv <= _numInv) && _conditions->in(curInv) && _inventory[curInv]._bitmapName)
+		if ((curInv <= _numInv) && _conditions->in(curInv) && _inventory[curInv]._bitmapName != "")
 			_nextFileName = getInvName(curInv);
 
 		break;
@@ -1112,16 +1097,10 @@ void LabEngine::performAction(uint16 actionMode, Common::Point curPos, uint16 &c
 		if (_closeDataPtr == tmpClosePtr) {
 			if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 				drawStaticMessage(kTextNothing);
-		}
-		else if (tmpClosePtr->_graphicName) {
-			if (*(tmpClosePtr->_graphicName)) {
-				_anim->_doBlack = true;
-				_closeDataPtr = tmpClosePtr;
-			}
-			else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
-				drawStaticMessage(kTextNothing);
-		}
-		else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
+		} else if (tmpClosePtr->_graphicName != "") {
+			_anim->_doBlack = true;
+			_closeDataPtr = tmpClosePtr;
+		} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 			drawStaticMessage(kTextNothing);
 	}
 			break;
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 016dd72..80e3fee 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -96,10 +96,6 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	for (int i = 0; i < 10; i++)
 		_invImages[i] = nullptr;
 
-	_curFileName = nullptr;
-	_nextFileName = nullptr;
-	_newFileName = nullptr;
-
 	_curFileName = " ";
 	_msgFont = nullptr;
 	_inventory = nullptr;
@@ -120,8 +116,6 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 
 	_blankJournal = nullptr;
 	_journalFont = nullptr;
-	_journalText = nullptr;
-	_journalTextTitle = nullptr;
 	_journalPage = 0;
 	_lastPage = false;
 	_monitorPage = 0;
@@ -143,16 +137,21 @@ LabEngine::~LabEngine() {
 	DebugMan.clearAllDebugChannels();
 
 	freeMapData();
+	for (uint16 i = 1; i <= _manyRooms; i++)
+		_resource->freeViews(i);
+	delete[] _rooms;
+
 	delete _event;
 	delete _resource;
 	delete _music;
 	delete _anim;
 	delete _graphics;
-	delete[] _rooms;
 	delete _tilePuzzle;
 	delete _utils;
 	delete _journalBackImage;
 	delete _screenImage;
+
+	_CrtDumpMemoryLeaks();
 }
 
 Common::Error LabEngine::run() {
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 28bd0ac..9609ca8 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -31,7 +31,10 @@
 #ifndef LAB_LAB_H
 #define LAB_LAB_H
 
+#define _CRTDBG_MAP_ALLOC
 #include "common/system.h"
+#include <crtdbg.h>
+
 #include "common/random.h"
 #include "common/rect.h"
 #include "common/savefile.h"
@@ -118,11 +121,11 @@ private:
 
 	uint32 _extraGameFeatures;
 
-	char *_journalText;
-	char *_journalTextTitle;
-	const char *_nextFileName;
-	const char *_newFileName;
-	const char *_monitorTextFilename;
+	Common::String _journalText;
+	Common::String _journalTextTitle;
+	Common::String _nextFileName;
+	Common::String _newFileName;
+	Common::String _monitorTextFilename;
 
 	CloseDataPtr _closeDataPtr;
 	ButtonList _journalButtonList;
@@ -154,7 +157,7 @@ public:
 
 	uint32 _crumbTimestamp;
 
-	const char *_curFileName;
+	Common::String _curFileName;
 
 	Anim *_anim;
 	CrumbData _breadCrumbs[MAX_CRUMBS];
@@ -188,7 +191,7 @@ public:
 
 	void changeVolume(int delta);
 	uint16 getDirection() { return _direction; }
-	char *getPictName(CloseDataPtr *closePtrList);
+	Common::String getPictName(CloseDataPtr *closePtrList);
 	uint16 getQuarters();
 	void setDirection(uint16 direction) { _direction = direction; };
 	void setQuarters(uint16 quarters);
@@ -205,7 +208,7 @@ private:
 	void doJournal();
 	bool doMainView(CloseDataPtr *closePtrList);
 	void doMap(uint16 curRoom);
-	void doMonitor(char *background, char *textfile, bool isinteractive, Common::Rect textRect);
+	void doMonitor(Common::String background, Common::String textfile, bool isinteractive, Common::Rect textRect);
 	void doNotes();
 	bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults);
 	bool doOperateRule(Common::Point pos, int16 ItemNum, CloseDataPtr *closePtrList);
@@ -228,7 +231,7 @@ private:
 	void freeScreens();
 	bool fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Common::Point tmpPos,
 		uint16 &curInv, IntuiMessage *curMsg, bool &forceDraw, uint16 buttonId, uint16 &actionMode);
-	const char *getInvName(uint16 curInv);
+	Common::String getInvName(uint16 curInv);
 	uint16 getLowerFloor(uint16 floorNum);
 	CloseData *getObject(Common::Point pos, CloseDataPtr closePtr);
 	uint16 getUpperFloor(uint16 floorNum);
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 4c2bfe2..f535cdf 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -404,8 +404,8 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad
 		_graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 75, 134, 97), textPrt);
 	}
 
-	if (_rooms[curMsg]._roomMsg)
-		_graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 148, 134, 186), _rooms[curMsg]._roomMsg);
+	if (_rooms[curMsg]._roomMsg != "")
+		_graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 148, 134, 186), _rooms[curMsg]._roomMsg.c_str());
 
 	if (fadeIn)
 		_graphics->fade(true, 0);
@@ -535,11 +535,11 @@ void LabEngine::processMap(uint16 curRoom) {
 					}
 
 					if (oldMsg != curMsg) {
-						if (_rooms[curMsg]._roomMsg == nullptr)
+						if (_rooms[curMsg]._roomMsg != "")
 							_resource->readViews(curMsg);
 
-						char *sptr;
-						if ((sptr = _rooms[curMsg]._roomMsg)) {
+						const char *sptr;
+						if ((sptr = _rooms[curMsg]._roomMsg.c_str())) {
 							_event->mouseHide();
 							_graphics->setPen(3);
 							_graphics->rectFillScaled(13, 148, 135, 186);
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index c21dce7..2cec365 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -69,7 +69,7 @@ bool LabEngine::checkConditions(int16 *condition) {
  * Gets the current ViewDataPointer.
  */
 ViewData *LabEngine::getViewData(uint16 roomNum, uint16 direction) {
-	if (!_rooms[roomNum]._roomMsg)
+	if (_rooms[roomNum]._roomMsg == "")
 		_resource->readViews(roomNum);
 
 	ViewData *view = _rooms[roomNum]._view[direction];
@@ -135,7 +135,7 @@ CloseDataPtr LabEngine::findClosePtrMatch(CloseDataPtr closePtr, CloseDataPtr cl
 /**
  * Returns the current picture name.
  */
-char *LabEngine::getPictName(CloseDataPtr *closePtrList) {
+Common::String LabEngine::getPictName(CloseDataPtr *closePtrList) {
 	ViewData *viewPtr = getViewData(_roomNum, _direction);
 
 	if (*closePtrList) {
@@ -152,15 +152,15 @@ char *LabEngine::getPictName(CloseDataPtr *closePtrList) {
  * Draws the current direction to the screen.
  */
 void LabEngine::drawDirection(CloseDataPtr closePtr) {
-	if (closePtr && closePtr->_message) {
-		_graphics->drawMessage(closePtr->_message);
+	if (closePtr && closePtr->_message != "") {
+		_graphics->drawMessage(closePtr->_message.c_str());
 		return;
 	}
 
 	Common::String message;
 
-	if (_rooms[_roomNum]._roomMsg) {
-		message += _rooms[_roomNum]._roomMsg;
+	if (_rooms[_roomNum]._roomMsg != "") {
+		message = Common::String(_rooms[_roomNum]._roomMsg).c_str();
 		message += ", ";
 	}
 
@@ -228,7 +228,7 @@ void LabEngine::setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, b
 		else
 			target = Common::Rect(_utils->scaleX(closePtr->_x1), _utils->scaleY(closePtr->_y1), _utils->scaleX(closePtr->_x2), _utils->scaleY(closePtr->_y2));
 
-		if (target.contains(pos) && closePtr->_graphicName) {
+		if (target.contains(pos) && closePtr->_graphicName != "") {
 			*closePtrList = closePtr;
 			return;
 		}
@@ -320,11 +320,11 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			break;
 
 		case SHOWCURPICT: {
-			char *test = getPictName(closePtrList);
+			Common::String test = getPictName(closePtrList);
 
-			if (strcmp(test, _curFileName) != 0) {
+			if (test != _curFileName) {
 				_curFileName = test;
-				_graphics->readPict(_curFileName, true);
+				_graphics->readPict(_curFileName.c_str(), true);
 			}
 			}
 			break;
diff --git a/engines/lab/processroom.h b/engines/lab/processroom.h
index 1d3316e..cc08c8a 100644
--- a/engines/lab/processroom.h
+++ b/engines/lab/processroom.h
@@ -95,15 +95,15 @@ struct CloseData {
 	uint16 _x1, _y1, _x2, _y2;
 	int16 _closeUpType;          // if > 0, an object.  If < 0, an item
 	uint16 _depth;               // Level of the closeup.
-	char *_graphicName;
-	char *_message;
+	Common::String _graphicName;
+	Common::String _message;
 	CloseData *_nextCloseUp;
 	CloseData *_subCloseUps;
 };
 
 struct ViewData {
 	int16 *_condition;
-	char *_graphicName;
+	Common::String _graphicName;
 	ViewData *_nextCondition;
 	CloseDataPtr _closeUps;
 };
@@ -131,13 +131,13 @@ struct RoomData {
 	byte _transitionType;
 	ViewData *_view[4];
 	RuleList *_rules;
-	char *_roomMsg;
+	Common::String _roomMsg;
 };
 
 struct InventoryData {
 	uint16 _many;
-	char *_name;
-	char *_bitmapName;
+	Common::String _name;
+	Common::String _bitmapName;
 };
 
 // Map Flags
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 7629d0c..39b3023 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -73,7 +73,7 @@ TextFont *Resource::getFont(const char *fileName) {
 	return textfont;
 }
 
-char *Resource::getText(const char *fileName) {
+Common::String Resource::getText(const char *fileName) {
 	Common::File *dataFile = openDataFile(fileName);
 
 	_vm->_music->updateMusic();
@@ -87,7 +87,11 @@ char *Resource::getText(const char *fileName) {
 		*text++ -= (byte)95;
 
 	delete dataFile;
-	return (char *)buffer;
+
+	Common::String str = (char *)buffer;
+	delete[] buffer;
+
+	return str;
 }
 
 bool Resource::readRoomData(const char *fileName) {
@@ -110,7 +114,7 @@ bool Resource::readRoomData(const char *fileName) {
 		_vm->_rooms[i]._view[EAST] = nullptr;
 		_vm->_rooms[i]._view[WEST] = nullptr;
 		_vm->_rooms[i]._rules = nullptr;
-		_vm->_rooms[i]._roomMsg = nullptr;
+		_vm->_rooms[i]._roomMsg = "";
 	}
 
 	delete dataFile;
@@ -138,6 +142,8 @@ bool Resource::readViews(uint16 roomNum) {
 	Common::String fileName = "LAB:Rooms/" + Common::String::format("%d", roomNum);
 	Common::File *dataFile = openDataFile(fileName.c_str(), MKTAG('R', 'O', 'M', '4'));
 
+	freeViews(roomNum);
+
 	_vm->_rooms[roomNum]._roomMsg = readString(dataFile);
 	_vm->_rooms[roomNum]._view[NORTH] = readView(dataFile);
 	_vm->_rooms[roomNum]._view[SOUTH] = readView(dataFile);
@@ -151,6 +157,25 @@ bool Resource::readViews(uint16 roomNum) {
 	return true;
 }
 
+void Resource::freeViews(uint16 roomNum) {
+	for (uint16 i = 0; i < 4; i++) {
+		delete _vm->_rooms[roomNum]._view[i];
+		_vm->_rooms[roomNum]._view[i] = nullptr;
+	}
+
+	if (_vm->_rooms[roomNum]._rules) {
+		for (RuleList::iterator rule = _vm->_rooms[roomNum]._rules->begin(); rule != _vm->_rooms[roomNum]._rules->end(); ++rule) {
+			delete (*rule)->_actionList;
+			delete[](*rule)->_condition;
+			delete *rule;
+			*rule = nullptr;
+		}
+
+		delete _vm->_rooms[roomNum]._rules;
+		_vm->_rooms[roomNum]._rules = nullptr;
+	}
+}
+
 Common::String Resource::translateFileName(Common::String filename) {
 	filename.toUppercase();
 	Common::String fileNameStrFinal;
@@ -209,17 +234,18 @@ Common::File *Resource::openDataFile(const char *fileName, uint32 fileHeader) {
 	return dataFile;
 }
 
-char *Resource::readString(Common::File *file) {
+Common::String Resource::readString(Common::File *file) {
 	byte size = file->readByte();
 	if (!size)
-		return NULL;
-	char *str = new char[size];
-	char *c = str;
+		return nullptr;
+
+	Common::String str;
+	char c;
 	for (int i = 0; i < size; i++) {
-		*c = file->readByte();
+		c = file->readByte();
 		// Decrypt char
-		*c = (i < size - 1) ? *c - 95 : '\0';
-		c++;
+		c = (i < size - 1) ? c - 95 : '\0';
+		str += c;
 	}
 
 	return str;
@@ -247,7 +273,7 @@ RuleList *Resource::readRule(Common::File *file) {
 		c = file->readByte();
 
 		if (c == 1) {
-			Rule *rule = new Rule();;
+			Rule *rule = new Rule();
 			rule->_ruleType = file->readSint16LE();
 			rule->_param1 = file->readSint16LE();
 			rule->_param2 = file->readSint16LE();
@@ -282,13 +308,20 @@ Action *Resource::readAction(Common::File *file) {
 
 			if (action->_actionType == SHOWMESSAGES) {
 				char **messages = (char **)malloc(action->_param1 * 4);
+				Common::String tmp;
 
-				for (int i = 0; i < action->_param1; i++)
-					messages[i] = readString(file);
+				for (int i = 0; i < action->_param1; i++) {
+					tmp = readString(file);
+					messages[i] = (char *)malloc(tmp.size());	// FIXME: memory leak!
+					memcpy(messages[i], tmp.c_str(), tmp.size());
+				}
 
 				action->_data = (byte *)messages;
 			} else {
-				action->_data = (byte *)readString(file);
+				Common::String tmp;
+				tmp = readString(file);
+				action->_data =  (byte *)malloc(tmp.size());	// FIXME: memory leak!
+				memcpy(action->_data, tmp.c_str(), tmp.size());
 			}
 
 			action->_nextAction = nullptr;
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index 4826558..37f8b4d 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -101,13 +101,14 @@ public:
 	bool readRoomData(const char *fileName);
 	InventoryData *readInventory(const char *fileName);
 	bool readViews(uint16 roomNum);
+	void freeViews(uint16 roomNum);
 	TextFont *getFont(const char *fileName);
-	char *getText(const char *fileName);
+	Common::String getText(const char *fileName);
 	Common::String getStaticText(byte index) const { return _staticText[index]; }
 
 private:
 	LabEngine *_vm;
-	char *readString(Common::File *file);
+	Common::String readString(Common::File *file);
 	int16 *readConditions(Common::File *file);
 	RuleList *readRule(Common::File *file);
 	Action *readAction(Common::File *file);
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 6e69578..4ea6843 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -52,13 +52,12 @@ namespace Lab {
  */
 void LabEngine::doNotes() {
 	TextFont *noteFont = _resource->getFont("F:Note.fon");
-	char *noteText = _resource->getText("Lab:Rooms/Notes");
+	Common::String noteText = _resource->getText("Lab:Rooms/Notes");
 
 	Common::Rect textRect = Common::Rect(_utils->vgaScaleX(25) + _utils->svgaCord(15), _utils->vgaScaleY(50), _utils->vgaScaleX(295) - _utils->svgaCord(15), _utils->vgaScaleY(148));
-	_graphics->flowText(noteFont, -2 + _utils->svgaCord(1), 0, 0, false, false, true, true, textRect, noteText);
+	_graphics->flowText(noteFont, -2 + _utils->svgaCord(1), 0, 0, false, false, true, true, textRect, noteText.c_str());
 	_graphics->setPalette(_anim->_diffPalette, 256);
 	_graphics->closeFont(noteFont);
-	delete[] noteText;
 }
 
 /**
@@ -67,39 +66,35 @@ void LabEngine::doNotes() {
  */
 void LabEngine::doWestPaper() {
 	TextFont *paperFont = _resource->getFont("F:News22.fon");
-	char *paperText = _resource->getText("Lab:Rooms/Date");
+	Common::String paperText = _resource->getText("Lab:Rooms/Date");
 
 	Common::Rect textRect = Common::Rect(_utils->vgaScaleX(57), _utils->vgaScaleY(77) + _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(91));
-	_graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, textRect, paperText);
+	_graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, textRect, paperText.c_str());
 	_graphics->closeFont(paperFont);
-	delete[] paperText;
 
 	paperFont = _resource->getFont("F:News32.fon");
 	paperText = _resource->getText("Lab:Rooms/Headline");
 
-	int fileLen = strlen(paperText) - 1;
+	int fileLen = paperText.size() - 1;
 	textRect = Common::Rect(_utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(118));
-	int charsPrinted = _graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, textRect, paperText);
+	int charsPrinted = _graphics->flowText(paperFont, -8, 0, 0, false, true, false, true, textRect, paperText.c_str());
 
 	uint16 y;
 
 	if (charsPrinted < fileLen) {
 		y = 130 - _utils->svgaCord(5);
 		textRect = Common::Rect(_utils->vgaScaleX(57), _utils->vgaScaleY(86) - _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(132));
-		_graphics->flowText(paperFont, -8 - _utils->svgaCord(1), 0, 0, false, true, false, true, textRect, paperText);
+		_graphics->flowText(paperFont, -8 - _utils->svgaCord(1), 0, 0, false, true, false, true, textRect, paperText.c_str());
 	} else
 		y = 115 - _utils->svgaCord(5);
 
 	_graphics->closeFont(paperFont);
-	delete[] paperText;
 
 	paperFont = _resource->getFont("F:Note.fon");
 	paperText = _resource->getText("Lab:Rooms/Col1");
-	charsPrinted = _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(45, y, 158, 148), paperText);
-	delete[] paperText;
+	charsPrinted = _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(45, y, 158, 148), paperText.c_str());
 	paperText = _resource->getText("Lab:Rooms/Col2");
-	charsPrinted = _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(162, y, 275, 148), paperText);
-	delete[] paperText;
+	charsPrinted = _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(162, y, 275, 148), paperText.c_str());
 	_graphics->closeFont(paperFont);
 
 	_graphics->setPalette(_anim->_diffPalette, 256);
@@ -167,11 +162,11 @@ void LabEngine::loadJournalData() {
 void LabEngine::drawJournalText() {
 	uint16 drawingToPage = 1;
 	int charsDrawn = 0;
-	char *curText = _journalText;
+	const char *curText = _journalText.c_str();
 
 	while (drawingToPage < _journalPage) {
 		_music->updateMusic();
-		curText = (char *)(_journalText + charsDrawn);
+		curText = (char *)(_journalText.c_str() + charsDrawn);
 		charsDrawn += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, false, _utils->vgaRectScale(52, 32, 152, 148), curText);
 
 		_lastPage = (*curText == 0);
@@ -183,20 +178,20 @@ void LabEngine::drawJournalText() {
 	}
 
 	if (_journalPage <= 1) {
-		curText = _journalTextTitle;
+		curText = _journalTextTitle.c_str();
 		_graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaRectScale(52, 32, 152, 148), curText);
 	} else {
-		curText = (char *)(_journalText + charsDrawn);
+		curText = (char *)(_journalText.c_str() + charsDrawn);
 		charsDrawn += _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(52, 32, 152, 148), curText);
 	}
 
 	_music->updateMusic();
-	curText = (char *)(_journalText + charsDrawn);
+	curText = (char *)(_journalText.c_str() + charsDrawn);
 	_lastPage = (*curText == 0);
 	_graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(171, 32, 271, 148), curText);
 
-	curText = (char *)(_journalText + charsDrawn);
-	_lastPage |= (*curText == 0);
+	curText = (char *)(_journalText.c_str() + charsDrawn);
+	_lastPage = (*curText == 0);
 }
 
 /**
@@ -386,7 +381,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, Common::Rect text
  * Processes user input.
  */
 void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isInteractive, Common::Rect textRect) {
-	const char *startFileName = _monitorTextFilename;
+	Common::String startFileName = _monitorTextFilename;
 	CloseDataPtr startClosePtr = _closeDataPtr, lastClosePtr[10];
 	uint16 depth = 0;
 
@@ -397,21 +392,20 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 			if (!_closeDataPtr)
 				_closeDataPtr = startClosePtr;
 
-			const char *test;
+			Common::String test;
 			if (_closeDataPtr == startClosePtr)
 				test = startFileName;
 			else
 				test = _closeDataPtr->_graphicName;
 
-			if (strcmp(test, _monitorTextFilename)) {
+			if (test != _monitorTextFilename) {
 				_monitorPage = 0;
 				_monitorTextFilename = test;
 
-				ntext = _resource->getText(_monitorTextFilename);
+				Common::String text = _resource->getText(_monitorTextFilename.c_str());
 				_graphics->fade(false, 0);
-				drawMonText(ntext, monitorFont, textRect, isInteractive);
+				drawMonText((char *)text.c_str(), monitorFont, textRect, isInteractive);
 				_graphics->fade(true, 0);
-				delete[] ntext;
 			}
 		}
 
@@ -481,7 +475,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 /**
  * Does what's necessary for the monitor.
  */
-void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive, Common::Rect textRect) {
+void LabEngine::doMonitor(Common::String background, Common::String textfile, bool isinteractive, Common::Rect textRect) {
 	Common::Rect scaledRect = _utils->vgaRectScale(textRect.left, textRect.top, textRect.right, textRect.bottom);
 	_monitorTextFilename = textfile;
 
@@ -501,15 +495,14 @@ void LabEngine::doMonitor(char *background, char *textfile, bool isinteractive,
 	_monitorButton = new Image(buttonFile, this);
 	delete buttonFile;
 
-	char *ntext = _resource->getText(textfile);
-	_graphics->loadBackPict(background, _highPalette);
-	drawMonText(ntext, monitorFont, scaledRect, isinteractive);
+	Common::String ntext = _resource->getText(textfile.c_str());
+	_graphics->loadBackPict(background.c_str(), _highPalette);
+	drawMonText((char *)ntext.c_str(), monitorFont, scaledRect, isinteractive);
 	_event->mouseShow();
 	_graphics->fade(true, 0);
-	processMonitor(ntext, monitorFont, isinteractive, scaledRect);
+	processMonitor((char *)ntext.c_str(), monitorFont, isinteractive, scaledRect);
 	_graphics->fade(false, 0);
 	_event->mouseHide();
-	delete[] ntext;
 	_graphics->closeFont(monitorFont);
 
 	_graphics->setPen(0);


Commit: 11d16bb34fe9f76e51efa2bdb96306ab340f4ca1
    https://github.com/scummvm/scummvm/commit/11d16bb34fe9f76e51efa2bdb96306ab340f4ca1
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:35:29+01:00

Commit Message:
LAB: Remove some leftover MSVC memory leak tester code

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



diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 80e3fee..696c7ee 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -150,8 +150,6 @@ LabEngine::~LabEngine() {
 	delete _utils;
 	delete _journalBackImage;
 	delete _screenImage;
-
-	_CrtDumpMemoryLeaks();
 }
 
 Common::Error LabEngine::run() {
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 9609ca8..1396c0a 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -31,10 +31,7 @@
 #ifndef LAB_LAB_H
 #define LAB_LAB_H
 
-#define _CRTDBG_MAP_ALLOC
 #include "common/system.h"
-#include <crtdbg.h>
-
 #include "common/random.h"
 #include "common/rect.h"
 #include "common/savefile.h"


Commit: 406710bac6ecd0586ab450aea45e3e97e9012b85
    https://github.com/scummvm/scummvm/commit/406710bac6ecd0586ab450aea45e3e97e9012b85
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:35:29+01:00

Commit Message:
LAB: Plug a memory leak in the sound effects code

Changed paths:
    engines/lab/music.cpp



diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 38ecba3..4176188 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -120,7 +120,7 @@ void Music::playSoundEffect(uint16 sampleSpeed, uint32 length, Common::File *dat
 	byte *soundData = (byte *)malloc(length);
 	dataFile->read(soundData, length);
 
-	Audio::SeekableAudioStream *audioStream = Audio::makeRawStream((const byte *)soundData, length, sampleSpeed, soundFlags, DisposeAfterUse::NO);
+	Audio::SeekableAudioStream *audioStream = Audio::makeRawStream((const byte *)soundData, length, sampleSpeed, soundFlags);
 	uint loops = (_loopSoundEffect) ? 0 : 1;
 	Audio::LoopingAudioStream *loopingAudioStream = new Audio::LoopingAudioStream(audioStream, loops);
 	_vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, loopingAudioStream);


Commit: 2a80c8066c613ea0eb75e9309e2981f3770102f1
    https://github.com/scummvm/scummvm/commit/2a80c8066c613ea0eb75e9309e2981f3770102f1
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:35:29+01:00

Commit Message:
LAB: Plug all the remaining resource-related memory leaks

Changed paths:
    engines/lab/resource.cpp
    engines/lab/resource.h



diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 39b3023..b673072 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -158,22 +158,10 @@ bool Resource::readViews(uint16 roomNum) {
 }
 
 void Resource::freeViews(uint16 roomNum) {
-	for (uint16 i = 0; i < 4; i++) {
-		delete _vm->_rooms[roomNum]._view[i];
-		_vm->_rooms[roomNum]._view[i] = nullptr;
-	}
-
-	if (_vm->_rooms[roomNum]._rules) {
-		for (RuleList::iterator rule = _vm->_rooms[roomNum]._rules->begin(); rule != _vm->_rooms[roomNum]._rules->end(); ++rule) {
-			delete (*rule)->_actionList;
-			delete[](*rule)->_condition;
-			delete *rule;
-			*rule = nullptr;
-		}
+	for (uint16 i = 0; i < 4; i++)
+		freeView(_vm->_rooms[roomNum]._view[i]);
 
-		delete _vm->_rooms[roomNum]._rules;
-		_vm->_rooms[roomNum]._rules = nullptr;
-	}
+	freeRule(_vm->_rooms[roomNum]._rules);
 }
 
 Common::String Resource::translateFileName(Common::String filename) {
@@ -286,6 +274,21 @@ RuleList *Resource::readRule(Common::File *file) {
 	return rules;
 }
 
+void Resource::freeRule(RuleList *ruleList) {
+	if (!ruleList)
+		return;
+
+	for (RuleList::iterator rule = ruleList->begin(); rule != ruleList->end(); ++rule) {
+		freeAction((*rule)->_actionList);
+		delete[](*rule)->_condition;
+		delete *rule;
+		*rule = nullptr;
+	}
+
+	delete ruleList;
+	ruleList = nullptr;
+}
+
 Action *Resource::readAction(Common::File *file) {
 	char c;
 	Action *action = nullptr;
@@ -312,7 +315,7 @@ Action *Resource::readAction(Common::File *file) {
 
 				for (int i = 0; i < action->_param1; i++) {
 					tmp = readString(file);
-					messages[i] = (char *)malloc(tmp.size());	// FIXME: memory leak!
+					messages[i] = (char *)malloc(tmp.size());
 					memcpy(messages[i], tmp.c_str(), tmp.size());
 				}
 
@@ -320,7 +323,7 @@ Action *Resource::readAction(Common::File *file) {
 			} else {
 				Common::String tmp;
 				tmp = readString(file);
-				action->_data =  (byte *)malloc(tmp.size());	// FIXME: memory leak!
+				action->_data =  (byte *)malloc(tmp.size());
 				memcpy(action->_data, tmp.c_str(), tmp.size());
 			}
 
@@ -332,6 +335,21 @@ Action *Resource::readAction(Common::File *file) {
 	return head;
 }
 
+void Resource::freeAction(Action *action) {
+	while (action) {
+		Action *nextAction = action->_nextAction;
+		if (action->_actionType == SHOWMESSAGES) {
+			char **messages = (char **)action->_data;
+			for (int i = 0; i < action->_param1; i++)
+				free(messages[i]);
+			free(messages);
+		} else
+			free(action->_data);
+		delete action;
+		action = nextAction;
+	}
+}
+
 CloseData *Resource::readCloseUps(uint16 depth, Common::File *file) {
 	char c;
 	CloseData *closeup = nullptr;
@@ -364,6 +382,15 @@ CloseData *Resource::readCloseUps(uint16 depth, Common::File *file) {
 	return head;
 }
 
+void Resource::freeCloseUps(CloseData *closeUps) {
+	while (closeUps) {
+		CloseData *nextCloseUp = closeUps->_nextCloseUp;
+		freeCloseUps(closeUps->_subCloseUps);
+		delete closeUps;
+		closeUps = nextCloseUp;
+	}
+}
+
 ViewData *Resource::readView(Common::File *file) {
 	char c;
 	ViewData *view = nullptr;
@@ -390,4 +417,14 @@ ViewData *Resource::readView(Common::File *file) {
 	return head;
 }
 
+void Resource::freeView(ViewData *view) {
+	while (view) {
+		ViewData *nextView = view->_nextCondition;
+		delete[] view->_condition;
+		freeCloseUps(view->_closeUps);
+		delete view;
+		view = nextView;
+	}
+}
+
 } // End of namespace Lab
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index 37f8b4d..26607f2 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -111,9 +111,13 @@ private:
 	Common::String readString(Common::File *file);
 	int16 *readConditions(Common::File *file);
 	RuleList *readRule(Common::File *file);
+	void freeRule(RuleList *ruleList);
 	Action *readAction(Common::File *file);
+	void freeAction(Action *action);
 	CloseData *readCloseUps(uint16 depth, Common::File *file);
+	void freeCloseUps(CloseData *closeUps);
 	ViewData *readView(Common::File *file);
+	void freeView(ViewData *view);
 	void readStaticText();
 	Common::String translateFileName(Common::String filename);
 


Commit: 567ed6a57a2b7c5a05361ac476de7f8a88fa0181
    https://github.com/scummvm/scummvm/commit/567ed6a57a2b7c5a05361ac476de7f8a88fa0181
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:35:29+01:00

Commit Message:
LAB: Formatting

Changed paths:
    engines/lab/eventman.cpp
    engines/lab/lab.cpp



diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index f346fd5..0aa801f 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -298,4 +298,5 @@ Common::Point EventManager::updateAndGetMousePos() {
 
 	return _mousePos;
 }
+
 } // End of namespace Lab
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 696c7ee..5f3f40c 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -232,4 +232,5 @@ void LabEngine::waitTOF() {
 
 	_lastWaitTOFTicks = now;
 }
+
 } // End of namespace Lab


Commit: df1376983d9181a5b08011bf3b5b4d8684d06b38
    https://github.com/scummvm/scummvm/commit/df1376983d9181a5b08011bf3b5b4d8684d06b38
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:29+01:00

Commit Message:
LAB: Simplify code related to _keyBuf handling

Changed paths:
    engines/lab/eventman.cpp
    engines/lab/eventman.h



diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 0aa801f..7f0ddb8 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -116,12 +116,13 @@ EventManager::EventManager(LabEngine *vm) : _vm(vm) {
 	_lastButtonHit = nullptr;
 	_screenButtonList = nullptr;
 	_hitButton = nullptr;
+	_mousePos = Common::Point(0, 0);
+
 	_nextKeyIn = 0;
 	_nextKeyOut = 0;
-	_mousePos = Common::Point(0, 0);
 
 	for (int i = 0; i < 64; i++)
-		_keyBuf[i] = 0;
+		_keyBuf[i] = Common::KEYCODE_INVALID;
 
 }
 
@@ -260,8 +261,7 @@ void EventManager::processInput() {
 				break;
 
 			default: {
-				int n = ((((unsigned int)((_nextKeyIn + 1) >> 31) >> 26) + (byte)_nextKeyIn + 1) & 0x3F)
-					- ((unsigned int)((_nextKeyIn + 1) >> 31) >> 26);
+				int n = (_nextKeyIn + 1) % 64;
 				if (n != _nextKeyOut) {
 					_keyBuf[_nextKeyIn] = event.kbd.keycode;
 					_nextKeyIn = n;
@@ -286,8 +286,7 @@ uint16 EventManager::getNextChar() {
 	processInput();
 	if (_nextKeyIn != _nextKeyOut) {
 		chr = _keyBuf[_nextKeyOut];
-		_nextKeyOut = ((((unsigned int)((_nextKeyOut + 1) >> 31) >> 26) + (byte)_nextKeyOut + 1) & 0x3F)
-			- ((unsigned int)((_nextKeyOut + 1) >> 31) >> 26);
+		_nextKeyOut = (_nextKeyOut + 1) % 64;
 	}
 
 	return chr;
diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h
index 342f859..6563467 100644
--- a/engines/lab/eventman.h
+++ b/engines/lab/eventman.h
@@ -77,7 +77,7 @@ private:
 
 	uint16 _nextKeyIn;
 	uint16 _nextKeyOut;
-	uint16 _keyBuf[64];
+	Common::KeyCode _keyBuf[64];
 
 	Button *_hitButton;
 	Button *_lastButtonHit;


Commit: 164b9d5a6674e3d8285a4277d2868030c4bb2cf1
    https://github.com/scummvm/scummvm/commit/164b9d5a6674e3d8285a4277d2868030c4bb2cf1
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:30+01:00

Commit Message:
LAB: Use Common:KeyCode in keyPress() and getNextChar()

Changed paths:
    engines/lab/eventman.cpp
    engines/lab/eventman.h
    engines/lab/interface.cpp



diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 7f0ddb8..000aaa7 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -211,7 +211,7 @@ void EventManager::setMousePos(Common::Point pos) {
 /**
  * Checks whether or not a key has been pressed.
  */
-bool EventManager::keyPress(uint16 *keyCode) {
+bool EventManager::keyPress(Common::KeyCode *keyCode) {
 	if (haveNextChar()) {
 		*keyCode = getNextChar();
 		return true;
@@ -280,8 +280,8 @@ void EventManager::processInput() {
 	}
 }
 
-uint16 EventManager::getNextChar() {
-	uint16 chr = 0;
+Common::KeyCode EventManager::getNextChar() {
+	Common::KeyCode chr = Common::KEYCODE_INVALID;
 
 	processInput();
 	if (_nextKeyIn != _nextKeyOut) {
diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h
index 6563467..eab5f31 100644
--- a/engines/lab/eventman.h
+++ b/engines/lab/eventman.h
@@ -53,7 +53,8 @@ enum MessageClasses {
 
 struct IntuiMessage {
 	uint32 _msgClass;
-	uint16 _code, _qualifier;
+	uint16 _code; // KeyCode or Button Id
+	uint16 _qualifier;
 	Common::Point _mouse;
 };
 
@@ -87,9 +88,9 @@ private:
 
 private:
 	Button *checkButtonHit(ButtonList *buttonList, Common::Point pos);
-	bool keyPress(uint16 *keyCode);
+	bool keyPress(Common::KeyCode *keyCode);
 	bool haveNextChar();
-	uint16 getNextChar();
+	Common::KeyCode getNextChar();
 	Button *checkNumButtonHit(ButtonList *buttonList, uint16 key);
 	uint16 makeButtonKeyEquiv(uint16 key);
 
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index c47339c..41749f1 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -128,6 +128,8 @@ IntuiMessage *EventManager::getMsg() {
 
 	updateMouse();
 
+	Common::KeyCode curKey;
+
 	if (_lastButtonHit) {
 		updateMouse();
 		message._msgClass = kMessageButtonUp;
@@ -143,7 +145,8 @@ IntuiMessage *EventManager::getMsg() {
 			message._mouse.x /= 2;
 		_leftClick = _rightClick = false;
 		return &message;
-	} else if (keyPress(&message._code)) {
+	} else if (keyPress(&curKey)) {
+		message._code = curKey;
 		Button *curButton = checkNumButtonHit(_screenButtonList, message._code);
 
 		if (curButton) {


Commit: 7f5826cfcb72d1375d6c24b153a446fd9c92f623
    https://github.com/scummvm/scummvm/commit/7f5826cfcb72d1375d6c24b153a446fd9c92f623
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:30+01:00

Commit Message:
LAB: Fix check of ending animation, some renaming

Changed paths:
    engines/lab/engine.cpp
    engines/lab/processroom.cpp
    engines/lab/processroom.h
    engines/lab/resource.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 81c401f..52f8525 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -113,11 +113,11 @@ static char initcolors[] = { '\x00', '\x00', '\x00', '\x30',
 							 '\x2c', '\x08', '\x08', '\x08' };
 
 uint16 LabEngine::getQuarters() {
-	return _inventory[kItemQuarter]._many;
+	return _inventory[kItemQuarter]._quantity;
 }
 
 void LabEngine::setQuarters(uint16 quarters) {
-	_inventory[kItemQuarter]._many = quarters;
+	_inventory[kItemQuarter]._quantity = quarters;
 }
 
 /**
@@ -134,8 +134,8 @@ void LabEngine::drawRoomMessage(uint16 curInv, CloseDataPtr closePtr) {
 			if ((curInv == kItemLamp) && _conditions->in(kCondLampOn))
 				// LAB: Labyrinth specific
 				drawStaticMessage(kTextkLampOn);
-			else if (_inventory[curInv]._many > 1) {
-				Common::String roomMessage = _inventory[curInv]._name + "  (" + Common::String::format("%d", _inventory[curInv]._many) + ")";
+			else if (_inventory[curInv]._quantity > 1) {
+				Common::String roomMessage = _inventory[curInv]._name + "  (" + Common::String::format("%d", _inventory[curInv]._quantity) + ")";
 				_graphics->drawMessage(roomMessage.c_str());
 			} else
 				_graphics->drawMessage(_inventory[curInv]._name.c_str());
@@ -593,8 +593,7 @@ void LabEngine::showLab2Teaser() {
 	_graphics->readPict("P:End/L2In.9", true);
 	_graphics->readPict("P:End/Lost", true);
 
-	warning("STUB: waitForPress");
-	while (!1) { // 1 means ignore SDL_ProcessInput calls
+	while (!_event->getMsg() && !shouldQuit()) {
 		_music->updateMusic();
 		_anim->diffNextFrame();
 		waitTOF();
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 2cec365..c7c3092 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -396,16 +396,16 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			break;
 
 		case SUBINV:
-			if (_inventory[actionList->_param1]._many)
-				(_inventory[actionList->_param1]._many)--;
+			if (_inventory[actionList->_param1]._quantity)
+				(_inventory[actionList->_param1]._quantity)--;
 
-			if (_inventory[actionList->_param1]._many == 0)
+			if (_inventory[actionList->_param1]._quantity == 0)
 				_conditions->exclElement(actionList->_param1);
 
 			break;
 
 		case ADDINV:
-			(_inventory[actionList->_param1]._many) += actionList->_param2;
+			(_inventory[actionList->_param1]._quantity) += actionList->_param2;
 			_conditions->inclElement(actionList->_param1);
 			break;
 
diff --git a/engines/lab/processroom.h b/engines/lab/processroom.h
index cc08c8a..49e328b 100644
--- a/engines/lab/processroom.h
+++ b/engines/lab/processroom.h
@@ -135,7 +135,7 @@ struct RoomData {
 };
 
 struct InventoryData {
-	uint16 _many;
+	uint16 _quantity;
 	Common::String _name;
 	Common::String _bitmapName;
 };
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index b673072..1b4bfd7 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -128,7 +128,7 @@ InventoryData *Resource::readInventory(const char *fileName) {
 	InventoryData *inventory = new InventoryData[_vm->_numInv + 1];
 
 	for (uint16 i = 1; i <= _vm->_numInv; i++) {
-		inventory[i]._many = dataFile->readUint16LE();
+		inventory[i]._quantity = dataFile->readUint16LE();
 		inventory[i]._name = readString(dataFile);
 		inventory[i]._bitmapName = readString(dataFile);
 	}


Commit: 3fcd3c15262adb1b4ac9f69475df2a4145c450d3
    https://github.com/scummvm/scummvm/commit/3fcd3c15262adb1b4ac9f69475df2a4145c450d3
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:30+01:00

Commit Message:
LAB: Avoid memory leaks with fonts

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/engine.cpp
    engines/lab/intro.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index c928649..ecf867b 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -633,12 +633,13 @@ void DisplayMan::overlayRect(uint16 penColor, uint16 x1, uint16 y1, uint16 x2, u
 /**
  * Closes a font and frees all memory associated with it.
  */
-void DisplayMan::closeFont(TextFont *font) {
-	if (font) {
-		if (font->_data && font->_dataLength)
-			delete[] font->_data;
+void DisplayMan::closeFont(TextFont **font) {
+	if (*font) {
+		if ((*font)->_data)
+			delete[] (*font)->_data;
 
-		delete font;
+		delete *font;
+		*font = nullptr;
 	}
 }
 
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index 1b90484..e89bcab 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -130,7 +130,7 @@ public:
 	void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer);
 	void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer);
 	void fade(bool fadein, uint16 res);
-	void closeFont(TextFont *font);
+	void closeFont(TextFont **font);
 	uint16 textLength(TextFont *font, const char *text, uint16 numChars);
 	uint16 textHeight(TextFont *tf);
 	void drawText(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numChars);
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 52f8525..053e961 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -1124,6 +1124,9 @@ void LabEngine::go() {
 	_graphics->setUpScreens();
 
 	_event->initMouse();
+	if (_msgFont)
+		_graphics->closeFont(&_msgFont);
+
 	if (getPlatform() != Common::kPlatformAmiga)
 		_msgFont = _resource->getFont("F:AvanteG.12");
 	else
@@ -1137,7 +1140,7 @@ void LabEngine::go() {
 	_event->mouseShow();
 	mainGameLoop();
 
-	_graphics->closeFont(_msgFont);
+	_graphics->closeFont(&_msgFont);
 	_graphics->freePict();
 
 	freeScreens();
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 9fbd0b3..2d2c55d 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -449,7 +449,7 @@ void Intro::introSequence() {
 		_vm->_anim->_doBlack = true;
 	}
 
-	_vm->_graphics->closeFont(msgFont);
+	_vm->_graphics->closeFont(&msgFont);
 }
 
 } // End of namespace Lab
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 4ea6843..7bb09e6 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -57,7 +57,7 @@ void LabEngine::doNotes() {
 	Common::Rect textRect = Common::Rect(_utils->vgaScaleX(25) + _utils->svgaCord(15), _utils->vgaScaleY(50), _utils->vgaScaleX(295) - _utils->svgaCord(15), _utils->vgaScaleY(148));
 	_graphics->flowText(noteFont, -2 + _utils->svgaCord(1), 0, 0, false, false, true, true, textRect, noteText.c_str());
 	_graphics->setPalette(_anim->_diffPalette, 256);
-	_graphics->closeFont(noteFont);
+	_graphics->closeFont(&noteFont);
 }
 
 /**
@@ -70,7 +70,7 @@ void LabEngine::doWestPaper() {
 
 	Common::Rect textRect = Common::Rect(_utils->vgaScaleX(57), _utils->vgaScaleY(77) + _utils->svgaCord(2), _utils->vgaScaleX(262), _utils->vgaScaleY(91));
 	_graphics->flowText(paperFont, 0, 0, 0, false, true, false, true, textRect, paperText.c_str());
-	_graphics->closeFont(paperFont);
+	_graphics->closeFont(&paperFont);
 
 	paperFont = _resource->getFont("F:News32.fon");
 	paperText = _resource->getText("Lab:Rooms/Headline");
@@ -88,14 +88,14 @@ void LabEngine::doWestPaper() {
 	} else
 		y = 115 - _utils->svgaCord(5);
 
-	_graphics->closeFont(paperFont);
+	_graphics->closeFont(&paperFont);
 
 	paperFont = _resource->getFont("F:Note.fon");
 	paperText = _resource->getText("Lab:Rooms/Col1");
 	charsPrinted = _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(45, y, 158, 148), paperText.c_str());
 	paperText = _resource->getText("Lab:Rooms/Col2");
 	charsPrinted = _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(162, y, 275, 148), paperText.c_str());
-	_graphics->closeFont(paperFont);
+	_graphics->closeFont(&paperFont);
 
 	_graphics->setPalette(_anim->_diffPalette, 256);
 }
@@ -104,6 +104,9 @@ void LabEngine::doWestPaper() {
  * Loads in the data for the journal.
  */
 void LabEngine::loadJournalData() {
+	if (_journalFont)
+		_graphics->closeFont(&_journalFont);
+
 	_journalFont = _resource->getFont("F:Journal.fon");
 	_music->updateMusic();
 
@@ -308,7 +311,7 @@ void LabEngine::doJournal() {
 	delete[] _blankJournal;
 	delete[] _journalBackImage->_imageData;
 	_event->freeButtonList(&_journalButtonList);
-	_graphics->closeFont(_journalFont);
+	_graphics->closeFont(&_journalFont);
 
 	_screenImage->_imageData = _graphics->getCurrentDrawingBuffer();
 
@@ -503,7 +506,7 @@ void LabEngine::doMonitor(Common::String background, Common::String textfile, bo
 	processMonitor((char *)ntext.c_str(), monitorFont, isinteractive, scaledRect);
 	_graphics->fade(false, 0);
 	_event->mouseHide();
-	_graphics->closeFont(monitorFont);
+	_graphics->closeFont(&monitorFont);
 
 	_graphics->setPen(0);
 	_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, _graphics->_screenHeight - 1);


Commit: 1d9e3cd561272ca318c522b8045af4f1dca2a6d9
    https://github.com/scummvm/scummvm/commit/1d9e3cd561272ca318c522b8045af4f1dca2a6d9
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:30+01:00

Commit Message:
LAB: Remove useless variable

Changed paths:
    engines/lab/dispman.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index ecf867b..0e7074d 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -288,9 +288,6 @@ int DisplayMan::longDrawMessage(const char *str) {
 	_vm->_event->attachButtonList(nullptr);
 	_vm->_event->mouseHide();
 
-	char newText[512];
-	strcpy(newText, str);
-
 	if (!_longWinInFront) {
 		_longWinInFront = true;
 		// Clear Area


Commit: 2981ccc24384aef44ff34a00ab547462735d6632
    https://github.com/scummvm/scummvm/commit/2981ccc24384aef44ff34a00ab547462735d6632
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:30+01:00

Commit Message:
LAB: get rid of the last strcpy

Changed paths:
    engines/lab/special.cpp



diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 7bb09e6..fa08fdc 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -110,8 +110,7 @@ void LabEngine::loadJournalData() {
 	_journalFont = _resource->getFont("F:Journal.fon");
 	_music->updateMusic();
 
-	char filename[20];
-	strcpy(filename, "Lab:Rooms/j0");
+	Common::String filename = "Lab:Rooms/j0";
 
 	bool bridge = _conditions->in(BRIDGE0) || _conditions->in(BRIDGE1);
 	bool dirty  = _conditions->in(DIRTY);
@@ -119,25 +118,25 @@ void LabEngine::loadJournalData() {
 	bool clean  = !_conditions->in(NOCLEAN);
 
 	if (bridge && clean && news)
-		filename[11] = '8';
+		filename += '8';
 	else if (clean && news)
-		filename[11] = '9';
+		filename += '9';
 	else if (bridge && clean)
-		filename[11] = '6';
+		filename += '6';
 	else if (clean)
-		filename[11] = '7';
+		filename += '7';
 	else if (bridge && dirty && news)
-		filename[11] = '4';
+		filename += '4';
 	else if (dirty && news)
-		filename[11] = '5';
+		filename += '5';
 	else if (bridge && dirty)
-		filename[11] = '2';
+		filename += '2';
 	else if (dirty)
-		filename[11] = '3';
+		filename += '3';
 	else if (bridge)
-		filename[11] = '1';
+		filename += '1';
 
-	_journalText = _resource->getText(filename);
+	_journalText = _resource->getText(filename.c_str());
 	_journalTextTitle = _resource->getText("Lab:Rooms/jt");
 
 	Common::File *journalFile = _resource->openDataFile("P:JImage");


Commit: d827faf1561123a87fec12c18ac584bac5f6afa4
    https://github.com/scummvm/scummvm/commit/d827faf1561123a87fec12c18ac584bac5f6afa4
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:30+01:00

Commit Message:
LAB: Rename a parameter for consistency with other function definitions

Changed paths:
    engines/lab/music.cpp
    engines/lab/music.h



diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 4176188..8edd2a8 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -258,7 +258,7 @@ void Music::checkRoomMusic() {
 /**
  * Changes the background music to something else.
  */
-void Music::changeMusic(const char *newmusic) {
+void Music::changeMusic(const char *filename) {
 	if (!_tFile) {
 		_tFile = _file;
 		_oldMusicOn = _musicOn;
@@ -268,7 +268,7 @@ void Music::changeMusic(const char *newmusic) {
 			_tLeftInFile = _leftInFile;
 	}
 
-	_file = _vm->_resource->openDataFile(newmusic);
+	_file = _vm->_resource->openDataFile(filename);
 	// turn music off
 	_musicOn = true;
 	setMusic(false);
diff --git a/engines/lab/music.h b/engines/lab/music.h
index 4ea075e..ba249e1 100644
--- a/engines/lab/music.h
+++ b/engines/lab/music.h
@@ -80,7 +80,7 @@ public:
 public:
 	Music(LabEngine *vm);
 
-	void changeMusic(const char *newmusic);
+	void changeMusic(const char *filename);
 	void checkRoomMusic();
 	void freeMusic();
 	bool initMusic(const char *filename);


Commit: a2097d2a2eb9d7abfcb4f73b1c45c3778f39f3ca
    https://github.com/scummvm/scummvm/commit/a2097d2a2eb9d7abfcb4f73b1c45c3778f39f3ca
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:30+01:00

Commit Message:
LAB: Get rid of strcat by using Common::String

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/intro.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 0e7074d..49ea40a 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -122,38 +122,37 @@ void DisplayMan::freePict() {
 /**
  * Extracts the first word from a string.
  */
-void DisplayMan::getWord(char *wordBuffer, const char *mainBuffer, uint16 *wordWidth) {
+Common::String DisplayMan::getWord(const char *mainBuffer, uint16 *wordWidth) {
 	uint16 width = 0;
+	Common::String result;
 
 	while ((mainBuffer[width] != ' ') && mainBuffer[width] && (mainBuffer[width] != '\n')) {
-		wordBuffer[width] = mainBuffer[width];
+		result += mainBuffer[width];
 		width++;
 	}
 
-	wordBuffer[width] = 0;
-
 	*wordWidth = width;
+	return result;
 }
 
 /**
  * Gets a line of text for flowText; makes sure that its length is less than
  * or equal to the maximum width.
  */
-void DisplayMan::getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer, uint16 lineWidth) {
+Common::String DisplayMan::getLine(TextFont *tf, const char **mainBuffer, uint16 lineWidth) {
 	uint16 curWidth = 0, wordWidth;
 	char wordBuffer[100];
+	Common::String result;
 	bool doit = true;
 
 	lineWidth += textLength(tf, " ", 1);
 
-	lineBuffer[0] = 0;
-
 	while ((*mainBuffer)[0] && doit) {
-		getWord(wordBuffer, *mainBuffer, &wordWidth);
-		strcat(wordBuffer, " ");
+		Common::String wordBuffer = getWord(*mainBuffer, &wordWidth);
+		wordBuffer += " ";
 
-		if ((curWidth + textLength(tf, wordBuffer, wordWidth + 1)) <= lineWidth) {
-			strcat(lineBuffer, wordBuffer);
+		if ((curWidth + textLength(tf, wordBuffer.c_str(), wordWidth + 1)) <= lineWidth) {
+			result += wordBuffer;
 			(*mainBuffer) += wordWidth;
 
 			if ((*mainBuffer)[0] == '\n')
@@ -162,10 +161,12 @@ void DisplayMan::getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer
 			if ((*mainBuffer)[0])
 				(*mainBuffer)++;
 
-			curWidth = textLength(tf, lineBuffer, strlen(lineBuffer));
+			curWidth = textLength(tf, result.c_str(), result.size());
 		} else
 			doit = false;
 	}
+
+	return result;
 }
 
 /**
@@ -201,14 +202,14 @@ int DisplayMan::flowText(
 	uint16 numLines   = (textRect.height() + 1) / fontHeight;
 	uint16 width      = textRect.width() + 1;
 	uint16 y          = textRect.top;
-	char lineBuffer[256];
+	Common::String lineBuffer;
 
 	if (centerv && output) {
 		const char *temp = str;
 		uint16 actlines = 0;
 
 		while (temp[0]) {
-			getLine(msgFont, lineBuffer, &temp, width);
+			lineBuffer = getLine(msgFont, &temp, width);
 			actlines++;
 		}
 
@@ -218,16 +219,16 @@ int DisplayMan::flowText(
 
 	int len = 0;
 	while (numLines && str[0]) {
-		getLine(msgFont, lineBuffer, &str, width);
+		lineBuffer = getLine(msgFont, &str, width);
 
 		uint16 x = textRect.left;
-		len += strlen(lineBuffer);
+		len += lineBuffer.size();
 
 		if (centerh)
-			x += (width - textLength(msgFont, lineBuffer, strlen(lineBuffer))) / 2;
+			x += (width - textLength(msgFont, lineBuffer.c_str(), lineBuffer.size())) / 2;
 
 		if (output)
-			drawText(msgFont, x, y, penColor, lineBuffer, strlen(lineBuffer));
+			drawText(msgFont, x, y, penColor, lineBuffer.c_str(), lineBuffer.size());
 
 		numLines--;
 		y += fontHeight;
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index e89bcab..518a4f7 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -62,7 +62,7 @@ private:
 
 	uint16 fadeNumIn(uint16 num, uint16 res, uint16 counter);
 	uint16 fadeNumOut(uint16 num, uint16 res, uint16 counter);
-	void getWord(char *wordBuffer, const char *mainBuffer, uint16 *wordWidth);
+	Common::String getWord(const char *mainBuffer, uint16 *wordWidth);
 
 	byte _curPen;
 	Common::File *_curBitmap;
@@ -134,7 +134,7 @@ public:
 	uint16 textLength(TextFont *font, const char *text, uint16 numChars);
 	uint16 textHeight(TextFont *tf);
 	void drawText(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numChars);
-	void getLine(TextFont *tf, char *lineBuffer, const char **mainBuffer, uint16 lineWidth);
+	Common::String getLine(TextFont *tf, const char **mainBuffer, uint16 lineWidth);
 
 	bool _longWinInFront;
 	bool _lastMessageLong;
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 2d2c55d..be52e29 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -71,8 +71,7 @@ void Intro::introEatMessages() {
  * Reads in a picture.
  */
 void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
-	char path[50] = "Lab:rooms/Intro/";
-	strcat(path, filename);
+	Common::String path = Common::String("Lab:rooms/Intro/") + filename;
 
 	uint timeDelay = (isScreen) ? 35 : 7;
 	_vm->_music->updateMusic();
@@ -85,7 +84,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 	bool doneFl = false;
 	bool begin = true;
 
-	Common::File *textFile = _vm->_resource->openDataFile(path);
+	Common::File *textFile = _vm->_resource->openDataFile(path.c_str());
 	byte *textBuffer = new byte[textFile->size()];
 	textFile->read(textBuffer, textFile->size());
 	delete textFile;


Commit: b9326e3850c96539243763d7b5b67f9d94a4a397
    https://github.com/scummvm/scummvm/commit/b9326e3850c96539243763d7b5b67f9d94a4a397
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:30+01:00

Commit Message:
LAB: Refactor some DispMan functions to use Common::String

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/intro.cpp
    engines/lab/processroom.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 49ea40a..42021e3 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -122,16 +122,12 @@ void DisplayMan::freePict() {
 /**
  * Extracts the first word from a string.
  */
-Common::String DisplayMan::getWord(const char *mainBuffer, uint16 *wordWidth) {
-	uint16 width = 0;
+Common::String DisplayMan::getWord(const char *mainBuffer) {
 	Common::String result;
 
-	while ((mainBuffer[width] != ' ') && mainBuffer[width] && (mainBuffer[width] != '\n')) {
-		result += mainBuffer[width];
-		width++;
-	}
+	for (int i = 0; mainBuffer[i] && (mainBuffer[i] != ' ') && (mainBuffer[i] != '\n'); i++)
+		result += mainBuffer[i];
 
-	*wordWidth = width;
 	return result;
 }
 
@@ -140,20 +136,18 @@ Common::String DisplayMan::getWord(const char *mainBuffer, uint16 *wordWidth) {
  * or equal to the maximum width.
  */
 Common::String DisplayMan::getLine(TextFont *tf, const char **mainBuffer, uint16 lineWidth) {
-	uint16 curWidth = 0, wordWidth;
-	char wordBuffer[100];
+	uint16 curWidth = 0;
 	Common::String result;
 	bool doit = true;
 
-	lineWidth += textLength(tf, " ", 1);
+	lineWidth += textLength(tf, " ");
 
 	while ((*mainBuffer)[0] && doit) {
-		Common::String wordBuffer = getWord(*mainBuffer, &wordWidth);
-		wordBuffer += " ";
+		Common::String wordBuffer = getWord(*mainBuffer) + " ";
 
-		if ((curWidth + textLength(tf, wordBuffer.c_str(), wordWidth + 1)) <= lineWidth) {
+		if ((curWidth + textLength(tf, wordBuffer)) <= lineWidth) {
 			result += wordBuffer;
-			(*mainBuffer) += wordWidth;
+			(*mainBuffer) += wordBuffer.size() - 1;
 
 			if ((*mainBuffer)[0] == '\n')
 				doit = false;
@@ -161,7 +155,7 @@ Common::String DisplayMan::getLine(TextFont *tf, const char **mainBuffer, uint16
 			if ((*mainBuffer)[0])
 				(*mainBuffer)++;
 
-			curWidth = textLength(tf, result.c_str(), result.size());
+			curWidth = textLength(tf, result);
 		} else
 			doit = false;
 	}
@@ -225,10 +219,10 @@ int DisplayMan::flowText(
 		len += lineBuffer.size();
 
 		if (centerh)
-			x += (width - textLength(msgFont, lineBuffer.c_str(), lineBuffer.size())) / 2;
+			x += (width - textLength(msgFont, lineBuffer)) / 2;
 
 		if (output)
-			drawText(msgFont, x, y, penColor, lineBuffer.c_str(), lineBuffer.size());
+			drawText(msgFont, x, y, penColor, lineBuffer);
 
 		numLines--;
 		y += fontHeight;
@@ -282,8 +276,8 @@ void DisplayMan::createBox(uint16 y2) {
 	drawVLine(_vm->_utils->vgaScaleX(2), _vm->_utils->vgaScaleY(152), _vm->_utils->vgaScaleY(y2));
 }
 
-int DisplayMan::longDrawMessage(const char *str) {
-	if (!str)
+int DisplayMan::longDrawMessage(Common::String str) {
+	if (!str.size())
 		return 0;
 
 	_vm->_event->attachButtonList(nullptr);
@@ -299,20 +293,20 @@ int DisplayMan::longDrawMessage(const char *str) {
 	createBox(198);
 	_vm->_event->mouseShow();
 
-	return flowText(_vm->_msgFont, 0, 1, 7, false, true, true, true, _vm->_utils->vgaRectScale(6, 155, 313, 195), str);
+	return flowText(_vm->_msgFont, 0, 1, 7, false, true, true, true, _vm->_utils->vgaRectScale(6, 155, 313, 195), str.c_str());
 }
 
 /**
  * Draws a message to the message box.
  */
-void DisplayMan::drawMessage(const char *str) {
+void DisplayMan::drawMessage(Common::String str) {
 	if (_doNotDrawMessage) {
 		_doNotDrawMessage = false;
 		return;
 	}
 
-	if (str) {
-		if ((textLength(_vm->_msgFont, str, strlen(str)) > _vm->_utils->vgaScaleX(306))) {
+	if (str.size()) {
+		if ((textLength(_vm->_msgFont, str) > _vm->_utils->vgaScaleX(306))) {
 			longDrawMessage(str);
 			_lastMessageLong = true;
 		} else {
@@ -323,7 +317,7 @@ void DisplayMan::drawMessage(const char *str) {
 
 			_vm->_event->mouseHide();
 			createBox(168);
-			drawText(_vm->_msgFont, _vm->_utils->vgaScaleX(7), _vm->_utils->vgaScaleY(155) + _vm->_utils->svgaCord(2), 1, str, strlen(str));
+			drawText(_vm->_msgFont, _vm->_utils->vgaScaleX(7), _vm->_utils->vgaScaleY(155) + _vm->_utils->svgaCord(2), 1, str);
 			_vm->_event->mouseShow();
 			_lastMessageLong = false;
 		}
@@ -644,13 +638,13 @@ void DisplayMan::closeFont(TextFont **font) {
 /**
  * Returns the length of a text in the specified font.
  */
-uint16 DisplayMan::textLength(TextFont *font, const char *text, uint16 numChars) {
+uint16 DisplayMan::textLength(TextFont *font, Common::String text) {
 	uint16 length = 0;
 
 	if (font) {
+		int numChars = text.size();
 		for (uint16 i = 0; i < numChars; i++) {
-			length += font->_widths[(uint)*text];
-			text++;
+			length += font->_widths[text[i]];
 		}
 	}
 
@@ -667,8 +661,9 @@ uint16 DisplayMan::textHeight(TextFont *tf) {
 /**
  * Draws the text to the screen.
  */
-void DisplayMan::drawText(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numChars) {
+void DisplayMan::drawText(TextFont *tf, uint16 x, uint16 y, uint16 color, Common::String text) {
 	byte *vgaTop = getCurrentDrawingBuffer();
+	int numChars = text.size();
 
 	for (uint16 i = 0; i < numChars; i++) {
 		uint32 realOffset = (_screenWidth * y) + x;
@@ -677,8 +672,8 @@ void DisplayMan::drawText(TextFont *tf, uint16 x, uint16 y, uint16 color, const
 		int32 leftInSegment = _screenBytesPerPage - segmentOffset;
 		byte *vgaCur = vgaTop + segmentOffset;
 
-		if (tf->_widths[(uint)*text]) {
-			byte *cdata = tf->_data + tf->_offsets[(uint)*text];
+		if (tf->_widths[text[i]]) {
+			byte *cdata = tf->_data + tf->_offsets[text[i]];
 			uint16 bwidth = *cdata++;
 			byte *vgaTemp = vgaCur;
 			byte *vgaTempLine = vgaCur;
@@ -739,8 +734,7 @@ void DisplayMan::drawText(TextFont *tf, uint16 x, uint16 y, uint16 color, const
 			}
 		}
 
-		x += tf->_widths[(int)*text];
-		text++;
+		x += tf->_widths[text[i]];
 	}
 }
 
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index 518a4f7..e2b9359 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -62,7 +62,7 @@ private:
 
 	uint16 fadeNumIn(uint16 num, uint16 res, uint16 counter);
 	uint16 fadeNumOut(uint16 num, uint16 res, uint16 counter);
-	Common::String getWord(const char *mainBuffer, uint16 *wordWidth);
+	Common::String getWord(const char *mainBuffer);
 
 	byte _curPen;
 	Common::File *_curBitmap;
@@ -88,8 +88,8 @@ public:
 	void createBox(uint16 y2);
 	void drawPanel();
 	void setUpScreens();
-	int32 longDrawMessage(const char *str);
-	void drawMessage(const char *str);
+	int32 longDrawMessage(Common::String str);
+	void drawMessage(Common::String str);
 	void setPen(byte pennum);
 	void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void rectFill(Common::Rect fillRect);
@@ -131,9 +131,9 @@ public:
 	void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer);
 	void fade(bool fadein, uint16 res);
 	void closeFont(TextFont **font);
-	uint16 textLength(TextFont *font, const char *text, uint16 numChars);
+	uint16 textLength(TextFont *font, Common::String text);
 	uint16 textHeight(TextFont *tf);
-	void drawText(TextFont *tf, uint16 x, uint16 y, uint16 color, const char *text, uint16 numChars);
+	void drawText(TextFont *tf, uint16 x, uint16 y, uint16 color, Common::String text);
 	Common::String getLine(TextFont *tf, const char **mainBuffer, uint16 lineWidth);
 
 	bool _longWinInFront;
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index be52e29..db88161 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -105,7 +105,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 				charDrawn = _vm->_graphics->flowText(msgFont, (!_vm->_isHiRes) * -1, 5, 7, false, false, true, true, _vm->_utils->vgaRectScale(14, 11, 306, 189), (char *)curText);
 				_vm->_graphics->fade(true, 0);
 			} else
-				charDrawn = _vm->_graphics->longDrawMessage((char *)curText);
+				charDrawn = _vm->_graphics->longDrawMessage(Common::String((char *)curText));
 
 			curText += charDrawn;
 			doneFl = (*curText == 0);
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index c7c3092..edb3a3b 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -337,21 +337,24 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			_conditions->exclElement(actionList->_param1);
 			break;
 
-		case SHOWMESSAGE:
+		case SHOWMESSAGE: {
 			_graphics->_doNotDrawMessage = false;
 
+			Common::String text = Common::String((char *)actionList->_data);
 			if (_graphics->_longWinInFront)
-				_graphics->longDrawMessage((char *)actionList->_data);
+				_graphics->longDrawMessage(text);
 			else
-				_graphics->drawMessage((char *)actionList->_data);
+				_graphics->drawMessage(text);
 
 			_graphics->_doNotDrawMessage = true;
+			}
 			break;
 
 		case CSHOWMESSAGE:
 			if (!*closePtrList) {
+				Common::String text = Common::String((char *)actionList->_data);
 				_graphics->_doNotDrawMessage = false;
-				_graphics->drawMessage((char *)actionList->_data);
+				_graphics->drawMessage(text);
 				_graphics->_doNotDrawMessage = true;
 			}
 
@@ -360,7 +363,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 		case SHOWMESSAGES: {
 				char **str = (char **)actionList->_data;
 				_graphics->_doNotDrawMessage = false;
-				_graphics->drawMessage(str[_utils->getRandom(actionList->_param1)]);
+				_graphics->drawMessage(Common::String(str[_utils->getRandom(actionList->_param1)]));
 				_graphics->_doNotDrawMessage = true;
 			}
 			break;


Commit: ee4e67a731058907758b4fd34ffc1745c19e51c4
    https://github.com/scummvm/scummvm/commit/ee4e67a731058907758b4fd34ffc1745c19e51c4
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:30+01:00

Commit Message:
LAB: Move and improve function comments to header in DispMan

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 42021e3..fd71e8e 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -89,9 +89,6 @@ void DisplayMan::loadBackPict(const char *fileName, uint16 *highPal) {
 	_vm->_anim->_noPalChange = false;
 }
 
-/**
- * Reads in a picture into the display bitmap.
- */
 void DisplayMan::readPict(Common::String filename, bool playOnce, bool onlyDiffData, byte *memoryBuffer, uint16 maxHeight) {
 	_vm->_anim->stopDiff();
 
@@ -115,13 +112,6 @@ void DisplayMan::freePict() {
 	_curBitmap = nullptr;
 }
 
-//---------------------------------------------------------------------------
-//------------ Does all the text rendering to the message boxes. ------------
-//---------------------------------------------------------------------------
-
-/**
- * Extracts the first word from a string.
- */
 Common::String DisplayMan::getWord(const char *mainBuffer) {
 	Common::String result;
 
@@ -131,10 +121,6 @@ Common::String DisplayMan::getWord(const char *mainBuffer) {
 	return result;
 }
 
-/**
- * Gets a line of text for flowText; makes sure that its length is less than
- * or equal to the maximum width.
- */
 Common::String DisplayMan::getLine(TextFont *tf, const char **mainBuffer, uint16 lineWidth) {
 	uint16 curWidth = 0;
 	Common::String result;
@@ -163,24 +149,8 @@ Common::String DisplayMan::getLine(TextFont *tf, const char **mainBuffer, uint16
 	return result;
 }
 
-/**
- * Dumps a chunk of text to an arbitrary box; flows it within that box and
- * optionally centers it. Returns the number of characters that were
- * processed.
- * Note: Every individual word MUST be int16 enough to fit on a line, and
- * each line less than 255 characters.
- */
-int DisplayMan::flowText(
-			TextFont *font,        // the TextAttr pointer
-			int16 spacing,         // How much vertical spacing between the lines
-			byte penColor,         // pen number to use for text
-			byte backPen,          // the background color
-			bool fillBack,         // Whether to fill the background
-			bool centerh,          // Whether to center the text horizontally
-			bool centerv,          // Whether to center the text vertically
-			bool output,           // Whether to output any text
-			Common::Rect textRect,	// Cords
-			const char *str) {     // The text itself
+int DisplayMan::flowText(TextFont *font, int16 spacing, byte penColor, byte backPen,
+			bool fillBack, bool centerh, bool centerv, bool output, Common::Rect textRect, const char *str) {
 	if (fillBack) {
 		setPen(backPen);
 		rectFill(textRect);
@@ -233,20 +203,9 @@ int DisplayMan::flowText(
 	return len;
 }
 
-/**
- * Calls flowText, but flows it to memory.  Same restrictions as flowText.
- */
-int DisplayMan::flowTextToMem(Image *destIm,
-			TextFont *font,        // the TextAttr pointer
-			int16 spacing,         // How much vertical spacing between the lines
-			byte penColor,         // pen number to use for text
-			byte backPen,          // the background color
-			bool fillBack,         // Whether to fill the background
-			bool centerh,          // Whether to center the text horizontally
-			bool centerv,          // Whether to center the text vertically
-			bool output,           // Whether to output any text
-			Common::Rect textRect,  // Cords
-			const char *str) {     // The text itself
+int DisplayMan::flowTextToMem(Image *destIm, TextFont *font, int16 spacing, byte penColor,
+			byte backPen, bool fillBack, bool centerh, bool centerv, bool output, Common::Rect textRect,
+			const char *str) {
 	byte *saveDisplayBuffer = _currentDisplayBuffer;
 	uint32 bytesPerPage = _screenBytesPerPage;
 
@@ -261,8 +220,6 @@ int DisplayMan::flowTextToMem(Image *destIm,
 	return res;
 }
 
-//----- The control panel stuff -----
-
 void DisplayMan::createBox(uint16 y2) {
 	// Message box area
 	setPen(7);
@@ -296,9 +253,6 @@ int DisplayMan::longDrawMessage(Common::String str) {
 	return flowText(_vm->_msgFont, 0, 1, 7, false, true, true, true, _vm->_utils->vgaRectScale(6, 155, 313, 195), str.c_str());
 }
 
-/**
- * Draws a message to the message box.
- */
 void DisplayMan::drawMessage(Common::String str) {
 	if (_doNotDrawMessage) {
 		_doNotDrawMessage = false;
@@ -324,9 +278,6 @@ void DisplayMan::drawMessage(Common::String str) {
 	}
 }
 
-/**
- * Draws the control panel display.
- */
 void DisplayMan::drawPanel() {
 	_vm->_event->mouseHide();
 
@@ -385,9 +336,6 @@ void DisplayMan::drawPanel() {
 	_vm->_event->mouseShow();
 }
 
-/**
- * Sets up the Labyrinth screens, and opens up the initial windows.
- */
 void DisplayMan::setUpScreens() {
 	EventManager *e = _vm->_event;
 	ButtonList *moveButtonList = &_vm->_moveButtonList;
@@ -445,16 +393,10 @@ void DisplayMan::setUpScreens() {
 	delete invFile;
 }
 
-/**
- * Sets the pen number to use on all the drawing operations.
- */
 void DisplayMan::setPen(byte penNum) {
 	_curPen = penNum;
 }
 
-/**
- * Fills in a rectangle.
- */
 void DisplayMan::rectFill(Common::Rect fillRect) {
 	int width = fillRect.width() + 1;
 	int height = fillRect.height() + 1;
@@ -489,16 +431,10 @@ void DisplayMan::rectFillScaled(uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	rectFill(_vm->_utils->vgaRectScale(x1, y1, x2, y2));
 }
 
-/**
- * Draws a horizontal line.
- */
 void DisplayMan::drawVLine(uint16 x, uint16 y1, uint16 y2) {
 	rectFill(x, y1, x, y2);
 }
 
-/**
- * Draws a vertical line.
- */
 void DisplayMan::drawHLine(uint16 x1, uint16 y, uint16 x2) {
 	rectFill(x1, y, x2, y);
 }
@@ -510,9 +446,6 @@ void DisplayMan::screenUpdate() {
 	_vm->_event->processInput();
 }
 
-/**
- * Sets up either a low-res or a high-res 256 color screen.
- */
 void DisplayMan::createScreen(bool hiRes) {
 	if (hiRes) {
 		_screenWidth  = 640;
@@ -528,10 +461,6 @@ void DisplayMan::createScreen(bool hiRes) {
 	_displayBuffer = new byte[_screenBytesPerPage];
 }
 
-/**
- * Converts an Amiga palette (up to 16 colors) to a VGA palette, then sets
- * the VGA palette.
- */
 void DisplayMan::setAmigaPal(uint16 *pal, uint16 numColors) {
 	byte vgaPal[16 * 3];
 	uint16 vgaIdx = 0;
@@ -549,17 +478,6 @@ void DisplayMan::setAmigaPal(uint16 *pal, uint16 numColors) {
 	_vm->waitTOF();
 }
 
-/**
- * Writes any number of the 256 color registers.
- * first:    the number of the first color register to write.
- * numReg:   the number of registers to write
- * buf:      a char pointer which contains the selected color registers.
- *           Each value representing a color register occupies 3 bytes in
- *           the array.  The order is red, green then blue.  The first byte
- *           in the array is the red component of the first element selected.
- *           The length of the buffer is 3 times the number of registers
- *           selected.
- */
 void DisplayMan::writeColorRegs(byte *buf, uint16 first, uint16 numReg) {
 	byte tmp[256 * 3];
 
@@ -575,9 +493,6 @@ void DisplayMan::setPalette(void *newPal, uint16 numColors) {
 		writeColorRegs((byte *)newPal, 0, numColors);
 }
 
-/**
- * Returns the base address of the current VGA display.
- */
 byte *DisplayMan::getCurrentDrawingBuffer() {
 	if (_currentDisplayBuffer)
 		return _currentDisplayBuffer;
@@ -585,9 +500,6 @@ byte *DisplayMan::getCurrentDrawingBuffer() {
 	return _displayBuffer;
 }
 
-/**
- * Overlays a region on the screen using the desired pen color.
- */
 void DisplayMan::overlayRect(uint16 penColor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	int w = x2 - x1 + 1;
 	int h = y2 - y1 + 1;
@@ -622,9 +534,6 @@ void DisplayMan::overlayRect(uint16 penColor, uint16 x1, uint16 y1, uint16 x2, u
 	}
 }
 
-/**
- * Closes a font and frees all memory associated with it.
- */
 void DisplayMan::closeFont(TextFont **font) {
 	if (*font) {
 		if ((*font)->_data)
@@ -635,9 +544,6 @@ void DisplayMan::closeFont(TextFont **font) {
 	}
 }
 
-/**
- * Returns the length of a text in the specified font.
- */
 uint16 DisplayMan::textLength(TextFont *font, Common::String text) {
 	uint16 length = 0;
 
@@ -651,16 +557,10 @@ uint16 DisplayMan::textLength(TextFont *font, Common::String text) {
 	return length;
 }
 
-/**
- * Returns the height of a specified font.
- */
 uint16 DisplayMan::textHeight(TextFont *tf) {
 	return (tf) ? tf->_height : 0;
 }
 
-/**
- * Draws the text to the screen.
- */
 void DisplayMan::drawText(TextFont *tf, uint16 x, uint16 y, uint16 color, Common::String text) {
 	byte *vgaTop = getCurrentDrawingBuffer();
 	int numChars = text.size();
@@ -738,9 +638,6 @@ void DisplayMan::drawText(TextFont *tf, uint16 x, uint16 y, uint16 color, Common
 	}
 }
 
-/**
- * Scrolls the display to black.
- */
 void DisplayMan::doScrollBlack() {
 	uint16 width = _vm->_utils->vgaScaleX(320);
 	uint16 height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
@@ -833,9 +730,6 @@ void DisplayMan::copyPage(uint16 width, uint16 height, uint16 nheight, uint16 st
 	}
 }
 
-/**
- * Scrolls the display to a new picture from a black screen.
- */
 void DisplayMan::doScrollWipe(char *filename) {
 	_vm->_event->mouseHide();
 	uint16 width = _vm->_utils->vgaScaleX(320);
@@ -887,9 +781,6 @@ void DisplayMan::doScrollWipe(char *filename) {
 	_vm->_event->mouseShow();
 }
 
-/**
- * Does the scroll bounce.  Assumes bitmap already in memory.
- */
 void DisplayMan::doScrollBounce() {
 	const uint16 *newby, *newby1;
 
@@ -933,9 +824,6 @@ void DisplayMan::doScrollBounce() {
 	_vm->_event->mouseShow();
 }
 
-/**
- * Does the transporter wipe.
- */
 void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, char *filename) {
 	uint16 lastY, linesLast;
 
@@ -1023,9 +911,6 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, char *filename) {
 	delete[] bitMapBuffer;
 }
 
-/**
- * Does a certain number of pre-programmed wipes.
- */
 void DisplayMan::doTransition(TransitionType transitionType, CloseDataPtr *closePtrList, char *filename) {
 	switch (transitionType) {
 	case kTransitionWipe:
@@ -1053,9 +938,6 @@ void DisplayMan::doTransition(TransitionType transitionType, CloseDataPtr *close
 	}
 }
 
-/**
- * Changes the front screen to black.
- */
 void DisplayMan::blackScreen() {
 	byte pal[256 * 3];
 	memset(pal, 0, 248 * 3);
@@ -1064,18 +946,12 @@ void DisplayMan::blackScreen() {
 	g_system->delayMillis(32);
 }
 
-/**
- * Changes the front screen to white.
- */
 void DisplayMan::whiteScreen() {
 	byte pal[256 * 3];
 	memset(pal, 255, 248 * 3);
 	writeColorRegs(pal, 8, 248);
 }
 
-/**
- * Changes the entire screen to black.
-*/
 void DisplayMan::blackAllScreen() {
 	byte pal[256 * 3];
 	memset(pal, 0, 256 * 3);
@@ -1084,11 +960,6 @@ void DisplayMan::blackAllScreen() {
 	g_system->delayMillis(32);
 }
 
-/**
- * Scrolls the display in the x direction by blitting.
- * The _tempScrollData variable must be initialized to some memory, or this
- * function will fail.
- */
 void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer) {
 	Image im(_vm);
 	im._imageData = buffer;
@@ -1120,9 +991,6 @@ void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint1
 	}
 }
 
-/**
- * Scrolls the display in the y direction by blitting.
- */
 void DisplayMan::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer) {
 	Image im(_vm);
 	im._imageData = buffer;
@@ -1154,9 +1022,6 @@ void DisplayMan::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint1
 	}
 }
 
-/**
- * Does the fading of the Palette on the screen.
- */
 uint16 DisplayMan::fadeNumIn(uint16 num, uint16 res, uint16 counter) {
 	return (num - ((((int32)(15 - counter)) * ((int32)(num - res))) / 15));
 }
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index e2b9359..e9bba74 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -60,8 +60,15 @@ class DisplayMan {
 private:
 	LabEngine *_vm;
 
+	/**
+	 * Does the fading of the Palette on the screen.
+	 */
 	uint16 fadeNumIn(uint16 num, uint16 res, uint16 counter);
 	uint16 fadeNumOut(uint16 num, uint16 res, uint16 counter);
+
+	/**
+	 * Extracts the first word from a string.
+	 */
 	Common::String getWord(const char *mainBuffer);
 
 	byte _curPen;
@@ -74,66 +81,200 @@ public:
 
 	void loadPict(const char *filename);
 	void loadBackPict(const char *fileName, uint16 *highPal);
+
+	/**
+	 * Reads in a picture into the display bitmap.
+	 */
 	void readPict(Common::String filename, bool playOnce, bool onlyDiffData = false, byte *memoryBuffer = nullptr, uint16 maxHeight = 0);
 	void freePict();
+
+	/**
+	 * Scrolls the display to black.
+	 */
 	void doScrollBlack();
 	void copyPage(uint16 width, uint16 height, uint16 nheight, uint16 startline, byte *mem);
+
+	/**
+	 * Scrolls the display to a new picture from a black screen.
+	 */
 	void doScrollWipe(char *filename);
+
+	/**
+	 * Does the scroll bounce.  Assumes bitmap already in memory.
+	 */
 	void doScrollBounce();
+
+	/**
+	 * Does the transporter wipe.
+	 */
 	void doTransWipe(CloseDataPtr *closePtrList, char *filename);
+
+	/**
+	 * Does a certain number of pre-programmed wipes.
+	 */
 	void doTransition(TransitionType transitionType, CloseDataPtr *closePtrList, char *filename);
+
+	/**
+	 * Changes the front screen to black.
+	 */
 	void blackScreen();
+
+	/**
+	 * Changes the front screen to white.
+	 */
 	void whiteScreen();
+
+	/**
+	 * Changes the entire screen to black.
+	*/
 	void blackAllScreen();
 	void createBox(uint16 y2);
+
+	/**
+	 * Draws the control panel display.
+	 */
 	void drawPanel();
+
+	/**
+	 * Sets up the Labyrinth screens, and opens up the initial windows.
+	 */
 	void setUpScreens();
 	int32 longDrawMessage(Common::String str);
+
+	/**
+	 * Draws a message to the message box.
+	 */
 	void drawMessage(Common::String str);
+
+	/**
+	 * Sets the pen number to use on all the drawing operations.
+	 */
 	void setPen(byte pennum);
+
+	/**
+	 * Fills in a rectangle.
+	 */
 	void rectFill(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 	void rectFill(Common::Rect fillRect);
 	void rectFillScaled(uint16 x1, uint16 y1, uint16 x2, uint16 y2);
-	// Window text stuff
-	int flowText(TextFont *font,		// the TextAttr pointer
-				int16 spacing,			// How much vertical spacing between the lines
-				byte penColor,			// pen number to use for text
-				byte backPen,			// the background color
-				bool fillBack,			// Whether to fill the background
-				bool centerh,			// Whether to center the text horizontally
-				bool centerv,			// Whether to center the text vertically
-				bool output,			// Whether to output any text
-				Common::Rect textRect,	// Cords
-				const char *text);		// The text itself
-
-	int flowTextToMem(Image *destIm,
-				TextFont *font,			// the TextAttr pointer
-				int16 spacing,			// How much vertical spacing between the lines
-				byte penColor,			// pen number to use for text
-				byte backPen,			// the background color
-				bool fillBack,			// Whether to fill the background
-				bool centerh,			// Whether to center the text horizontally
-				bool centerv,			// Whether to center the text vertically
-				bool output,			// Whether to output any text
-				Common::Rect textRect,	// Cords
-				const char *str);		// The text itself
+	/**
+	 * Dumps a chunk of text to an arbitrary box; flows it within that box and
+	 * optionally centers it. Returns the number of characters that were processed.
+	 * @note Every individual word MUST be int16 enough to fit on a line, and
+	 * each line less than 255 characters.
+	 * @param font Pointer on the font used
+	 * @param spacing How much vertical spacing between the lines
+	 * @param penColor Pen number to use for text
+	 * @param backPen Background color
+	 * @param fillBack Whether to fill the background
+	 * @param centerh Whether to center the text horizontally
+	 * @param centerv Whether to center the text vertically
+	 * @param output Whether to output any text
+	 * @param textRect Coords
+	 * @param text The text itself
+	 */
+	int flowText(TextFont *font, int16 spacing, byte penColor, byte backPen, bool fillBack,
+				bool centerh, bool centerv, bool output, Common::Rect textRect, const char *text);
 
+	/**
+	 * Calls flowText, but flows it to memory.  Same restrictions as flowText.
+	 * @param destIm Destination buffer
+	 * @param font Pointer on the font used
+	 * @param penColor Pen number to use for text
+	 * @param backPen Background color
+	 * @param fillBack Whether to fill the background
+	 * @param centerh Whether to center the text horizontally
+	 * @param centerv Whether to center the text vertically
+	 * @param output Whether to output any text
+	 * @param textRect Coords
+	 * @param text The text itself
+	 */
+	int flowTextToMem(Image *destIm, TextFont *font, int16 spacing, byte penColor, byte backPen,
+				bool fillBack, bool centerh, bool centerv, bool output, Common::Rect textRect,
+				const char *text);
+
+	/**
+	 * Draws a vertical line.
+	 */
 	void drawHLine(uint16 x, uint16 y1, uint16 y2);
+
+	/**
+	 * Draws a horizontal line.
+	 */
 	void drawVLine(uint16 x1, uint16 y, uint16 x2);
 	void screenUpdate();
+
+	/**
+	 * Sets up either a low-res or a high-res 256 color screen.
+	 */
 	void createScreen(bool hiRes);
+
+	/**
+	 * Converts an Amiga palette (up to 16 colors) to a VGA palette, then sets
+	 * the VGA palette.
+	 */
 	void setAmigaPal(uint16 *pal, uint16 numColors);
+
+	/**
+	 * Writes any number of the 256 color registers.
+	 * @param buf A char pointer which contains the selected color registers.
+	 * Each value representing a color register occupies 3 bytes in the array.  The
+	 * order is red, green then blue. The first byte in the array is the red component
+	 * of the first element selected. The length of the buffer is 3 times the number
+	 * of registers selected.
+	 * @param first The number of the first color register to write.
+	 * @param numReg The number of registers to write.
+	 */
 	void writeColorRegs(byte *buf, uint16 first, uint16 numReg);
 	void setPalette(void *newPal, uint16 numColors);
+
+	/**
+	 * Overlays a region on the screen using the desired pen color.
+	 */
 	void overlayRect(uint16 penColor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+
+	/**
+	 * Returns the base address of the current VGA display.
+	 */
 	byte *getCurrentDrawingBuffer();
+
+	/**
+	 * Scrolls the display in the x direction by blitting.
+	 * The _tempScrollData variable must be initialized to some memory, or this
+	 * function will fail.
+	 */
 	void scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer);
+
+	/**
+	 * Scrolls the display in the y direction by blitting.
+	 */
 	void scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer);
 	void fade(bool fadein, uint16 res);
+
+	/**
+	 * Closes a font and frees all memory associated with it.
+	 */
 	void closeFont(TextFont **font);
+
+	/**
+	 * Returns the length of a text in the specified font.
+	 */
 	uint16 textLength(TextFont *font, Common::String text);
+
+	/**
+	 * Returns the height of a specified font.
+	 */
 	uint16 textHeight(TextFont *tf);
+
+	/**
+	 * Draws the text to the screen.
+	 */
 	void drawText(TextFont *tf, uint16 x, uint16 y, uint16 color, Common::String text);
+
+	/**
+	 * Gets a line of text for flowText; makes sure that its length is less than
+	 * or equal to the maximum width.
+	 */
 	Common::String getLine(TextFont *tf, const char **mainBuffer, uint16 lineWidth);
 
 	bool _longWinInFront;


Commit: 28c74aed05e6b7ea127bb521ea8c456075608b07
    https://github.com/scummvm/scummvm/commit/28c74aed05e6b7ea127bb521ea8c456075608b07
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:30+01:00

Commit Message:
LAB: More work on the comments

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h
    engines/lab/engine.cpp
    engines/lab/intro.cpp
    engines/lab/intro.h
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/processroom.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 4b06096..49dbe28 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -240,17 +240,11 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 	}
 }
 
-/**
- * Stops an animation from running.
- */
 void Anim::stopDiff() {
 	if (_isPlaying && _isAnim)
 		_vm->_graphics->blackScreen();
 }
 
-/**
- * Stops an animation from running.
- */
 void Anim::stopDiffEnd() {
 	if (!_isPlaying)
 		return;
@@ -262,9 +256,6 @@ void Anim::stopDiffEnd() {
 	}
 }
 
-/**
- * Reads in a DIFF file.
- */
 void Anim::readDiff(Common::File *diffFile, bool playOnce, bool onlyDiffData) {
 	_playOnce = playOnce;
 	_delayMicros = 0;
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 7e21567..3c236f3 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -83,9 +83,20 @@ public:
 	bool _noPalChange;   // Don't change the palette.
 	BitMap _rawDiffBM;
 
+	/**
+	 * Reads in a DIFF file.
+	 */
 	void readDiff(Common::File *diffFile, bool playOnce, bool onlyDiffData = false);
 	void diffNextFrame(bool onlyDiffData = false);
+
+	/**
+	 * Stops an animation from running.
+	 */
 	void stopDiff();
+
+	/**
+	 * Stops an animation from running.
+	 */
 	void stopDiffEnd();
 };
 
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 053e961..2d7725a 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -120,9 +120,6 @@ void LabEngine::setQuarters(uint16 quarters) {
 	_inventory[kItemQuarter]._quantity = quarters;
 }
 
-/**
- * Draws the message for the room.
- */
 void LabEngine::drawRoomMessage(uint16 curInv, CloseDataPtr closePtr) {
 	if (_lastTooLong) {
 		_lastTooLong = false;
@@ -158,9 +155,6 @@ void LabEngine::freeScreens() {
 	}
 }
 
-/**
- * Permanently flips the imagery of a button.
- */
 void LabEngine::perFlipButton(uint16 buttonId) {
 	for (ButtonList::iterator button = _moveButtonList.begin(); button != _moveButtonList.end(); ++button) {
 		Button *topButton = *button;
@@ -180,9 +174,6 @@ void LabEngine::perFlipButton(uint16 buttonId) {
 	}
 }
 
-/**
- * Eats all the available messages.
- */
 void LabEngine::eatMessages() {
 	IntuiMessage *msg;
 
@@ -191,9 +182,6 @@ void LabEngine::eatMessages() {
 	} while (msg && !g_engine->shouldQuit());
 }
 
-/**
- * Checks whether the close up is one of the special case closeups.
- */
 bool LabEngine::doCloseUp(CloseDataPtr closePtr) {
 	if (!closePtr)
 		return false;
@@ -258,9 +246,6 @@ bool LabEngine::doCloseUp(CloseDataPtr closePtr) {
 	return true;
 }
 
-/**
- * Gets the current inventory name.
- */
 Common::String LabEngine::getInvName(uint16 curInv) {
 	if (_mainDisplay)
 		return _inventory[curInv]._bitmapName;
@@ -288,9 +273,6 @@ Common::String LabEngine::getInvName(uint16 curInv) {
 	return _inventory[curInv]._bitmapName;
 }
 
-/**
- * Turns the interface off.
- */
 void LabEngine::interfaceOff() {
 	if (!_interfaceOff) {
 		_event->attachButtonList(nullptr);
@@ -299,9 +281,6 @@ void LabEngine::interfaceOff() {
 	}
 }
 
-/**
- * Turns the interface on.
- */
 void LabEngine::interfaceOn() {
 	if (_interfaceOff) {
 		_interfaceOff = false;
@@ -316,9 +295,6 @@ void LabEngine::interfaceOn() {
 		_event->attachButtonList(&_moveButtonList);
 }
 
-/**
- * If the user hits the "Use" button; things that can get used on themselves.
- */
 bool LabEngine::doUse(uint16 curInv) {
 	switch (curInv) {
 	case kItemMap:
@@ -385,9 +361,6 @@ bool LabEngine::doUse(uint16 curInv) {
 	}
 }
 
-/**
- * Decrements the current inventory number.
- */
 void LabEngine::decIncInv(uint16 *curInv, bool decreaseFl) {
 	int8 step = (decreaseFl) ? -1 : 1;
 	uint newInv = *curInv + step;
@@ -417,9 +390,6 @@ void LabEngine::decIncInv(uint16 *curInv, bool decreaseFl) {
 	}
 }
 
-/**
- * The main game loop.
- */
 void LabEngine::mainGameLoop() {
 	uint16 actionMode = 4;
 	uint16 curInv = kItemMap;
@@ -1148,9 +1118,6 @@ void LabEngine::go() {
 	_music->freeMusic();
 }
 
-/**
- * New code to allow quick(er) return navigation in game.
- */
 int LabEngine::followCrumbs() {
 	// NORTH, SOUTH, EAST, WEST
 	int movement[4][4] = {
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index db88161..5e1a8ce 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -45,10 +45,6 @@ Intro::Intro(LabEngine *vm) : _vm(vm) {
 	_introDoBlack = false;
 }
 
-/**
- * Goes through, and responds to all the intuition messages currently in the
- * message queue.
- */
 void Intro::introEatMessages() {
 	while (1) {
 		IntuiMessage *msg = _vm->_event->getMsg();
@@ -67,9 +63,6 @@ void Intro::introEatMessages() {
 	}
 }
 
-/**
- * Reads in a picture.
- */
 void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 	Common::String path = Common::String("Lab:rooms/Intro/") + filename;
 
@@ -196,9 +189,6 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 	}	// while(1)
 }
 
-/**
- * Does a one second delay, but checks the music while doing it.
- */
 void Intro::musicDelay() {
 	_vm->_music->updateMusic();
 
@@ -227,9 +217,6 @@ void Intro::nReadPict(const char *filename, bool playOnce) {
 	_vm->_graphics->readPict(finalFileName.c_str(), playOnce);
 }
 
-/**
- * Does the introduction sequence for Labyrinth.
- */
 void Intro::introSequence() {
 	uint16 palette[16] = {
 		0x0000, 0x0855, 0x0FF9, 0x0EE7,
diff --git a/engines/lab/intro.h b/engines/lab/intro.h
index 323859c..ac292d0 100644
--- a/engines/lab/intro.h
+++ b/engines/lab/intro.h
@@ -36,11 +36,27 @@ namespace Lab {
 class Intro {
 public:
 	Intro(LabEngine *vm);
+
+	/**
+	 * Does the introduction sequence for Labyrinth.
+	 */
 	void introSequence();
 
 private:
+	/**
+	 * Goes through, and responds to all the intuition messages currently in the
+	 * message queue.
+	 */
 	void introEatMessages();
+
+	/**
+	 * Reads in a picture.
+	 */
 	void doPictText(const char *Filename, TextFont *msgFont, bool isscreen);
+
+	/**
+	 * Does a one second delay, but checks the music while doing it.
+	 */
 	void musicDelay();
 	void nReadPict(const char *Filename, bool PlayOnce);
 
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 1396c0a..295d913 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -188,6 +188,10 @@ public:
 
 	void changeVolume(int delta);
 	uint16 getDirection() { return _direction; }
+
+	/**
+	 * Returns the current picture name.
+	 */
 	Common::String getPictName(CloseDataPtr *closePtrList);
 	uint16 getQuarters();
 	void setDirection(uint16 direction) { _direction = direction; };
@@ -195,61 +199,254 @@ public:
 	void waitTOF();
 
 private:
+	/**
+	 * Checks whether all the conditions in a condition list are met.
+	 */
 	bool checkConditions(int16 *condition);
+
+	/**
+	 * Decrements the current inventory number.
+	 */
 	void decIncInv(uint16 *CurInv, bool dec);
+
+	/**
+	 * Processes the action list.
+	 */
 	void doActions(Action *actionList, CloseDataPtr *closePtrList);
+
+	/**
+	 * Goes through the rules if an action is taken.
+	 */
 	bool doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *closePtrList);
+
+	/**
+	 * Does the work for doActionRule.
+	 */
 	bool doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults);
+
+	/**
+	 * Checks whether the close up is one of the special case closeups.
+	 */
 	bool doCloseUp(CloseDataPtr closePtr);
+
+	/**
+	 * Goes through the rules if the user tries to go forward.
+	 */
 	bool doGoForward(CloseDataPtr *closePtrList);
+
+	/**
+	 * Does the journal processing.
+	 */
 	void doJournal();
+
+	/**
+	 * Goes through the rules if the user tries to go to the main view
+	 */
 	bool doMainView(CloseDataPtr *closePtrList);
+
+	/**
+	 * Does the map processing.
+	 */
 	void doMap(uint16 curRoom);
+
+	/**
+	 * Does what's necessary for the monitor.
+	 */
 	void doMonitor(Common::String background, Common::String textfile, bool isinteractive, Common::Rect textRect);
+
+	/**
+	 * Does the things to properly set up the detective notes.
+	 */
 	void doNotes();
+
+	/**
+	 * Does the work for doActionRule.
+	 */
 	bool doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults);
+
+	/**
+	 * Goes through the rules if the user tries to operate an item on an object.
+	 */
 	bool doOperateRule(Common::Point pos, int16 ItemNum, CloseDataPtr *closePtrList);
+
+	/**
+	 * Goes through the rules if the user tries to turn.
+	 */
 	bool doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList);
+
+	/**
+	 * If the user hits the "Use" button; things that can get used on themselves.
+	 */
 	bool doUse(uint16 curInv);
+
+	/**
+	 * Does the things to properly set up the old west newspaper.  Assumes that
+	 * OpenHiRes already called.
+	 */
 	void doWestPaper();
+
+	/**
+	 * Draws the current direction to the screen.
+	 */
 	void drawDirection(CloseDataPtr closePtr);
+
+	/**
+	 * Draws the journal from page x.
+	 */
 	void drawJournal(uint16 wipenum, bool needFade);
+
+	/**
+	 * Draws the text to the back journal screen to the appropriate Page number
+	 */
 	void drawJournalText();
+
+	/**
+	 * Draws the map
+	 */
 	void drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fadeOut, bool fadeIn);
+
+	/**
+	 * Draws the text for the monitor.
+	 */
 	void drawMonText(char *text, TextFont *monitorFont, Common::Rect textRect, bool isinteractive);
+
+	/**
+	 * Draws a room map.
+	 */
 	void drawRoomMap(uint16 curRoom, bool drawMarkFl);
+
+	/**
+	 * Draws the message for the room.
+	 */
 	void drawRoomMessage(uint16 curInv, CloseDataPtr closePtr);
 	void drawStaticMessage(byte index);
+
+	/**
+	 * Eats all the available messages.
+	 */
 	void eatMessages();
+
+	/**
+	 * Goes through the list of closeups to find a match.
+	 * @note Known bug here.  If there are two objects that have closeups, and
+	 * some of the closeups have the same hit boxes, then this returns the first
+	 * occurrence of the object with the same hit box.
+	 */
 	CloseDataPtr findClosePtrMatch(CloseDataPtr closePtr, CloseDataPtr closePtrList);
+
+	/**
+	 * Checks if a floor has been visited.
+	 */
 	bool floorVisited(uint16 floorNum);
+
+	/**
+	 * New code to allow quick(er) return navigation in game.
+	 */
 	int followCrumbs();
 	void freeMapData();
 	void freeScreens();
 	bool fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Common::Point tmpPos,
 		uint16 &curInv, IntuiMessage *curMsg, bool &forceDraw, uint16 buttonId, uint16 &actionMode);
+
+	/**
+	 * Gets the current inventory name.
+	 */
 	Common::String getInvName(uint16 curInv);
+
+	/**
+	 * Returns the floor to show when the down arrow is pressed
+	 * @note The original did not show all the visited floors, but we do
+	 */
 	uint16 getLowerFloor(uint16 floorNum);
+
+	/**
+	 * Gets an object, if any, from the user's click on the screen.
+	 */
 	CloseData *getObject(Common::Point pos, CloseDataPtr closePtr);
+
+	/**
+	 * Returns the floor to show when the up arrow is pressed
+	 * @note The original did not show all the visited floors, but we do
+	 */
 	uint16 getUpperFloor(uint16 floorNum);
+
+	/**
+	 * Gets the current ViewDataPointer.
+	 */
 	ViewData *getViewData(uint16 roomNum, uint16 direction);
+
+	/**
+	 * Turns the interface off.
+	 */
 	void interfaceOff();
+
+	/**
+	 * Turns the interface on.
+	 */
 	void interfaceOn();
+
+	/**
+	 * Loads in the data for the journal.
+	 */
 	void loadJournalData();
+
+	/**
+	 * Loads in the map data.
+	 */
 	void loadMapData();
+
+	/**
+	 * The main game loop.
+	 */
 	void mainGameLoop();
 	void showLab2Teaser();
 	void mayShowCrumbIndicator();
 	void mayShowCrumbIndicatorOff();
+
+	/**
+	 * Permanently flips the imagery of a button.
+	 */
 	void perFlipButton(uint16 buttonId);
+
+	/**
+	 * process a arrow button movement.
+	 */
 	uint16 processArrow(uint16 curDirection, uint16 arrow);
+
+	/**
+	 * Processes user input.
+	 */
 	void processJournal();
+
+	/**
+	 * Processes the map.
+	 */
 	void processMap(uint16 curRoom);
+
+	/**
+	 * Processes user input.
+	 */
 	void processMonitor(char *ntext, TextFont *monitorFont, bool isInteractive, Common::Rect textRect);
+
+	/**
+	 * Figures out what a room's coordinates should be.
+	 */
 	Common::Rect roomCoords(uint16 curRoom);
 	bool saveRestoreGame();
+
+	/**
+	 * Sets the current close up data.
+	 */
 	void setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, bool useAbsoluteCoords);
+
+	/**
+	 * Takes the currently selected item.
+	 */
 	bool takeItem(Common::Point pos, CloseDataPtr *closePtrList);
+
+	/**
+	 * Does the turn page wipe.
+	 */
 	void turnPage(bool fromLeft);
 	bool processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &qualifier, Common::Point &curPos, uint16 &curInv, bool &forceDraw, uint16 code);
 	void processMainButton(uint16 &curInv, uint16 &lastInv, uint16 &oldDirection, bool &forceDraw, uint16 buttonId, uint16 &actionMode);
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index f535cdf..05c36fc 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -56,9 +56,6 @@ enum MapFloor {
 	kFloorCarnival
 };
 
-/**
- * Loads in the map data.
- */
 void LabEngine::loadMapData() {
 	Common::File *mapImages = _resource->openDataFile("P:MapImage");
 
@@ -134,9 +131,6 @@ void LabEngine::freeMapData() {
 	_maps = nullptr;
 }
 
-/**
- * Figures out what a room's coordinates should be.
- */
 Common::Rect LabEngine::roomCoords(uint16 curRoom) {
 	Image *curRoomImg = nullptr;
 
@@ -173,9 +167,6 @@ Common::Rect LabEngine::roomCoords(uint16 curRoom) {
 	return Common::Rect(x1, y1, x2, y2);
 }
 
-/**
- * Draws a room map.
- */
 void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) {
 	uint16 drawX, drawY, offset;
 
@@ -307,9 +298,6 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) {
 		_imgMapX[_direction]->drawImage(drawX, drawY);
 }
 
-/**
- * Checks if a floor has been visited.
- */
 bool LabEngine::floorVisited(uint16 floorNum) {
 	for (uint16 i = 1; i <= _maxRooms; i++) {
 		if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x)
@@ -319,10 +307,6 @@ bool LabEngine::floorVisited(uint16 floorNum) {
 	return false;
 }
 
-/**
- * Returns the floor to show when the up arrow is pressed
- * Note: The original did not show all the visited floors, but we do
- */
 uint16 LabEngine::getUpperFloor(uint16 floorNum) {
 	if ((floorNum == kFloorCarnival) || (floorNum == kFloorNone))
 		return kFloorNone;
@@ -334,10 +318,6 @@ uint16 LabEngine::getUpperFloor(uint16 floorNum) {
 	return kFloorNone;
 }
 
-/**
- * Returns the floor to show when the down arrow is pressed
- * Note: The original did not show all the visited floors, but we do
- */
 uint16 LabEngine::getLowerFloor(uint16 floorNum) {
 	if ((floorNum == kFloorLower) || (floorNum == kFloorNone))
 		return kFloorNone;
@@ -349,9 +329,6 @@ uint16 LabEngine::getLowerFloor(uint16 floorNum) {
 	return kFloorNone;
 }
 
-/**
- * Draws the map
- */
 void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fadeOut, bool fadeIn) {
 	_event->mouseHide();
 
@@ -413,9 +390,6 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad
 	_event->mouseShow();
 }
 
-/**
- * Processes the map.
- */
 void LabEngine::processMap(uint16 curRoom) {
 	byte place = 1;
 	uint16 curMsg = curRoom;
@@ -570,9 +544,6 @@ void LabEngine::processMap(uint16 curRoom) {
 	}
 }
 
-/**
- * Does the map processing.
- */
 void LabEngine::doMap(uint16 curRoom) {
 	static uint16 amigaMapPalette[] = {
 		0x0BA8, 0x0C11, 0x0A74, 0x0076,
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index edb3a3b..2a4d508 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -44,9 +44,6 @@ namespace Lab {
 
 #define NOFILE         "no file"
 
-/**
- * Checks whether all the conditions in a condition list are met.
- */
 bool LabEngine::checkConditions(int16 *condition) {
 	if (!condition)
 		return true;
@@ -65,9 +62,6 @@ bool LabEngine::checkConditions(int16 *condition) {
 	return res;
 }
 
-/**
- * Gets the current ViewDataPointer.
- */
 ViewData *LabEngine::getViewData(uint16 roomNum, uint16 direction) {
 	if (_rooms[roomNum]._roomMsg == "")
 		_resource->readViews(roomNum);
@@ -84,9 +78,6 @@ ViewData *LabEngine::getViewData(uint16 roomNum, uint16 direction) {
 	return view;
 }
 
-/**
- * Gets an object, if any, from the user's click on the screen.
- */
 CloseData *LabEngine::getObject(Common::Point pos, CloseDataPtr closePtr) {
 	CloseDataPtr wrkClosePtr;
 	if (!closePtr)
@@ -106,12 +97,6 @@ CloseData *LabEngine::getObject(Common::Point pos, CloseDataPtr closePtr) {
 	return nullptr;
 }
 
-/**
- * Goes through the list of closeups to find a match.
- * NYI: Known bug here.  If there are two objects that have closeups, and
- *      some of the closeups have the same hit boxes, then this returns the
- *      first occurrence of the object with the same hit box.
- */
 CloseDataPtr LabEngine::findClosePtrMatch(CloseDataPtr closePtr, CloseDataPtr closePtrList) {
 	CloseDataPtr resClosePtr;
 
@@ -132,9 +117,6 @@ CloseDataPtr LabEngine::findClosePtrMatch(CloseDataPtr closePtr, CloseDataPtr cl
 	return nullptr;
 }
 
-/**
- * Returns the current picture name.
- */
 Common::String LabEngine::getPictName(CloseDataPtr *closePtrList) {
 	ViewData *viewPtr = getViewData(_roomNum, _direction);
 
@@ -148,9 +130,6 @@ Common::String LabEngine::getPictName(CloseDataPtr *closePtrList) {
 	return viewPtr->_graphicName;
 }
 
-/**
- * Draws the current direction to the screen.
- */
 void LabEngine::drawDirection(CloseDataPtr closePtr) {
 	if (closePtr && closePtr->_message != "") {
 		_graphics->drawMessage(closePtr->_message.c_str());
@@ -176,9 +155,6 @@ void LabEngine::drawDirection(CloseDataPtr closePtr) {
 	_graphics->drawMessage(message.c_str());
 }
 
-/**
- * process a arrow button movement.
- */
 uint16 LabEngine::processArrow(uint16 curDirection, uint16 arrow) {
 	if (arrow == 1) { // Forward
 		uint16 room = _rooms[_roomNum]._doors[curDirection];
@@ -210,9 +186,6 @@ uint16 LabEngine::processArrow(uint16 curDirection, uint16 arrow) {
 	return curDirection;
 }
 
-/**
- * Sets the current close up data.
- */
 void LabEngine::setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, bool useAbsoluteCoords) {
 	CloseDataPtr closePtr;
 
@@ -237,9 +210,6 @@ void LabEngine::setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, b
 	}
 }
 
-/**
- * Takes the currently selected item.
- */
 bool LabEngine::takeItem(Common::Point pos, CloseDataPtr *closePtrList) {
 	CloseDataPtr closePtr;
 
@@ -265,9 +235,6 @@ bool LabEngine::takeItem(Common::Point pos, CloseDataPtr *closePtrList) {
 	return false;
 }
 
-/**
- * Processes the action list.
- */
 void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 	while (actionList) {
 		_music->updateMusic();
@@ -539,9 +506,6 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 	}
 }
 
-/**
- * Does the work for doActionRule.
- */
 bool LabEngine::doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults) {
 	action++;
 
@@ -571,9 +535,6 @@ bool LabEngine::doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr closeP
 	return false;
 }
 
-/**
- * Goes through the rules if an action is taken.
- */
 bool LabEngine::doActionRule(Common::Point pos, int16 action, int16 roomNum, CloseDataPtr *closePtrList) {
 	if (roomNum)
 		_newFileName = NOFILE;
@@ -594,9 +555,6 @@ bool LabEngine::doActionRule(Common::Point pos, int16 action, int16 roomNum, Clo
 	return false;
 }
 
-/**
- * Does the work for doActionRule.
- */
 bool LabEngine::doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr closePtr, CloseDataPtr *setCloseList, bool allowDefaults) {
 	if (closePtr)
 		if (closePtr->_closeUpType > 0) {
@@ -622,9 +580,6 @@ bool LabEngine::doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr clos
 	return false;
 }
 
-/**
- * Goes through the rules if the user tries to operate an item on an object.
- */
 bool LabEngine::doOperateRule(Common::Point pos, int16 ItemNum, CloseDataPtr *closePtrList) {
 	_newFileName = NOFILE;
 	CloseDataPtr closePtr = getObject(pos, *closePtrList);
@@ -653,9 +608,6 @@ bool LabEngine::doOperateRule(Common::Point pos, int16 ItemNum, CloseDataPtr *cl
 	return false;
 }
 
-/**
- * Goes through the rules if the user tries to go forward.
- */
 bool LabEngine::doGoForward(CloseDataPtr *closePtrList) {
 	RuleList *rules = _rooms[_roomNum]._rules;
 
@@ -672,9 +624,6 @@ bool LabEngine::doGoForward(CloseDataPtr *closePtrList) {
 	return false;
 }
 
-/**
- * Goes through the rules if the user tries to turn.
- */
 bool LabEngine::doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList) {
 	from++;
 	to++;
@@ -695,9 +644,6 @@ bool LabEngine::doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList) {
 	return false;
 }
 
-/**
- * Goes through the rules if the user tries to go to the main view
- */
 bool LabEngine::doMainView(CloseDataPtr *closePtrList) {
 	RuleList *rules = _rooms[_roomNum]._rules;
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index fa08fdc..9f33d96 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -47,9 +47,6 @@ namespace Lab {
 #define NONEWS      135
 #define NOCLEAN     152
 
-/**
- * Does the things to properly set up the detective notes.
- */
 void LabEngine::doNotes() {
 	TextFont *noteFont = _resource->getFont("F:Note.fon");
 	Common::String noteText = _resource->getText("Lab:Rooms/Notes");
@@ -60,10 +57,6 @@ void LabEngine::doNotes() {
 	_graphics->closeFont(&noteFont);
 }
 
-/**
- * Does the things to properly set up the old west newspaper.  Assumes that
- * OpenHiRes already called.
- */
 void LabEngine::doWestPaper() {
 	TextFont *paperFont = _resource->getFont("F:News22.fon");
 	Common::String paperText = _resource->getText("Lab:Rooms/Date");
@@ -100,9 +93,6 @@ void LabEngine::doWestPaper() {
 	_graphics->setPalette(_anim->_diffPalette, 256);
 }
 
-/**
- * Loads in the data for the journal.
- */
 void LabEngine::loadJournalData() {
 	if (_journalFont)
 		_graphics->closeFont(&_journalFont);
@@ -158,9 +148,6 @@ void LabEngine::loadJournalData() {
 	_screenImage->_imageData = _graphics->getCurrentDrawingBuffer();
 }
 
-/**
- * Draws the text to the back journal screen to the appropriate Page number
- */
 void LabEngine::drawJournalText() {
 	uint16 drawingToPage = 1;
 	int charsDrawn = 0;
@@ -196,9 +183,6 @@ void LabEngine::drawJournalText() {
 	_lastPage = (*curText == 0);
 }
 
-/**
- * Does the turn page wipe.
- */
 void LabEngine::turnPage(bool fromLeft) {
 	if (fromLeft) {
 		for (int i = 0; i < _graphics->_screenWidth; i += 8) {
@@ -217,9 +201,6 @@ void LabEngine::turnPage(bool fromLeft) {
 	}
 }
 
-/**
- * Draws the journal from page x.
- */
 void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 	_event->mouseHide();
 	_music->updateMusic();
@@ -244,9 +225,6 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 	_event->mouseShow();
 }
 
-/**
- * Processes user input.
- */
 void LabEngine::processJournal() {
 	while (1) {
 		// Make sure we check the music at least after every message
@@ -285,9 +263,6 @@ void LabEngine::processJournal() {
 	}
 }
 
-/**
- * Does the journal processing.
- */
 void LabEngine::doJournal() {
 	_graphics->blackAllScreen();
 	_lastPage = false;
@@ -319,9 +294,6 @@ void LabEngine::doJournal() {
 	_graphics->blackScreen();
 }
 
-/**
- * Draws the text for the monitor.
- */
 void LabEngine::drawMonText(char *text, TextFont *monitorFont, Common::Rect textRect, bool isinteractive) {
 	uint16 drawingToPage = 0, yspacing = 0;
 	int charsDrawn = 0;
@@ -379,9 +351,6 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, Common::Rect text
 	_event->mouseShow();
 }
 
-/**
- * Processes user input.
- */
 void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isInteractive, Common::Rect textRect) {
 	Common::String startFileName = _monitorTextFilename;
 	CloseDataPtr startClosePtr = _closeDataPtr, lastClosePtr[10];
@@ -474,9 +443,6 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 	}
 }
 
-/**
- * Does what's necessary for the monitor.
- */
 void LabEngine::doMonitor(Common::String background, Common::String textfile, bool isinteractive, Common::Rect textRect) {
 	Common::Rect scaledRect = _utils->vgaRectScale(textRect.left, textRect.top, textRect.right, textRect.bottom);
 	_monitorTextFilename = textfile;


Commit: eaa6f3bd0126c4a3fc51daa7a9be10c0c159e028
    https://github.com/scummvm/scummvm/commit/eaa6f3bd0126c4a3fc51daa7a9be10c0c159e028
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:30+01:00

Commit Message:
LAB: Fix some GCC warnings

Changed paths:
    engines/lab/dispman.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index fd71e8e..f570493 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -550,7 +550,7 @@ uint16 DisplayMan::textLength(TextFont *font, Common::String text) {
 	if (font) {
 		int numChars = text.size();
 		for (uint16 i = 0; i < numChars; i++) {
-			length += font->_widths[text[i]];
+			length += font->_widths[(byte)text[i]];
 		}
 	}
 
@@ -572,8 +572,8 @@ void DisplayMan::drawText(TextFont *tf, uint16 x, uint16 y, uint16 color, Common
 		int32 leftInSegment = _screenBytesPerPage - segmentOffset;
 		byte *vgaCur = vgaTop + segmentOffset;
 
-		if (tf->_widths[text[i]]) {
-			byte *cdata = tf->_data + tf->_offsets[text[i]];
+		if (tf->_widths[(byte)text[i]]) {
+			byte *cdata = tf->_data + tf->_offsets[(byte)text[i]];
 			uint16 bwidth = *cdata++;
 			byte *vgaTemp = vgaCur;
 			byte *vgaTempLine = vgaCur;
@@ -634,7 +634,7 @@ void DisplayMan::drawText(TextFont *tf, uint16 x, uint16 y, uint16 color, Common
 			}
 		}
 
-		x += tf->_widths[text[i]];
+		x += tf->_widths[(byte)text[i]];
 	}
 }
 


Commit: c6e5232fa30ae48416c07c13e8abf183e6f0ef7e
    https://github.com/scummvm/scummvm/commit/c6e5232fa30ae48416c07c13e8abf183e6f0ef7e
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:31+01:00

Commit Message:
LAB: Fix bug identified by eriktorbjorn

Changed paths:
    engines/lab/image.cpp



diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp
index 2e0ecc1..9b2b99d 100644
--- a/engines/lab/image.cpp
+++ b/engines/lab/image.cpp
@@ -54,7 +54,7 @@ Image::Image(Common::File *s, LabEngine *vm) : _vm(vm) {
 }
 
 Image::~Image() {
-	delete _imageData;
+	delete[] _imageData;
 }
 
 /**


Commit: 08a035f0e5d9fcab4c7f28817f8e344918b0250c
    https://github.com/scummvm/scummvm/commit/08a035f0e5d9fcab4c7f28817f8e344918b0250c
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:31+01:00

Commit Message:
LAB: Fix loop in flooVisited

Changed paths:
    engines/lab/map.cpp



diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 05c36fc..84da359 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -299,7 +299,7 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) {
 }
 
 bool LabEngine::floorVisited(uint16 floorNum) {
-	for (uint16 i = 1; i <= _maxRooms; i++) {
+	for (uint16 i = 0; i < _maxRooms; i++) {
 		if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x)
 			return true;
 	}


Commit: a4266d2109d2c7e121d3a69b06bfa29436edcb39
    https://github.com/scummvm/scummvm/commit/a4266d2109d2c7e121d3a69b06bfa29436edcb39
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:31+01:00

Commit Message:
LAB: Better handling of the Trial check in the puzzle

Changed paths:
    engines/lab/tilepuzzle.cpp



diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index df46a57..c9214fd 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -150,14 +150,13 @@ void TilePuzzle::changeTile(uint16 col, uint16 row) {
 	}
 
 	if (scrolltype != -1) {
-		doTileScroll(col, row, scrolltype);
-
 		if (_vm->getFeatures() & GF_WINDOWS_TRIAL) {
 			GUI::MessageDialog trialMessage("This puzzle is not available in the trial version of the game");
 			trialMessage.runModal();
 			return;
 		}
 
+		doTileScroll(col, row, scrolltype);
 		bool check = true;
 		row = 0;
 		col = 0;


Commit: a41f9076c597714075b0ecd5f41cd6f6cfd2add2
    https://github.com/scummvm/scummvm/commit/a41f9076c597714075b0ecd5f41cd6f6cfd2add2
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:31+01:00

Commit Message:
LAB: Fix malloc pointed by eriktorbjorn

Changed paths:
    engines/lab/resource.cpp



diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 1b4bfd7..a0f6350 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -310,7 +310,7 @@ Action *Resource::readAction(Common::File *file) {
 			action->_param3 = file->readSint16LE();
 
 			if (action->_actionType == SHOWMESSAGES) {
-				char **messages = (char **)malloc(action->_param1 * 4);
+				char **messages = (char **)malloc(action->_param1 * sizeof(char *));
 				Common::String tmp;
 
 				for (int i = 0; i < action->_param1; i++) {


Commit: a4d3bda5c179fd1019f0812f04e6913fba863c28
    https://github.com/scummvm/scummvm/commit/a4d3bda5c179fd1019f0812f04e6913fba863c28
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:31+01:00

Commit Message:
LAB: Use an array of Common::Strings instead of bytes in Action

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/music.cpp
    engines/lab/music.h
    engines/lab/processroom.cpp
    engines/lab/processroom.h



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index f570493..bb07ba3 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -730,7 +730,7 @@ void DisplayMan::copyPage(uint16 width, uint16 height, uint16 nheight, uint16 st
 	}
 }
 
-void DisplayMan::doScrollWipe(char *filename) {
+void DisplayMan::doScrollWipe(Common::String filename) {
 	_vm->_event->mouseHide();
 	uint16 width = _vm->_utils->vgaScaleX(320);
 	uint16 height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
@@ -740,7 +740,7 @@ void DisplayMan::doScrollWipe(char *filename) {
 		_vm->waitTOF();
 	}
 
-	readPict(filename, true, true);
+	readPict(filename.c_str(), true, true);
 	setPalette(_vm->_anim->_diffPalette, 256);
 	byte *mem = _vm->_anim->_rawDiffBM._planes[0];
 
@@ -824,7 +824,7 @@ void DisplayMan::doScrollBounce() {
 	_vm->_event->mouseShow();
 }
 
-void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, char *filename) {
+void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, Common::String filename) {
 	uint16 lastY, linesLast;
 
 	if (_vm->_isHiRes) {
@@ -860,7 +860,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, char *filename) {
 		setPen(0);
 	}	// for j
 
-	if (!filename)
+	if (!filename.size())
 		_vm->_curFileName = _vm->getPictName(closePtrList);
 	else if (filename[0] > ' ')
 		_vm->_curFileName = filename;
@@ -911,7 +911,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, char *filename) {
 	delete[] bitMapBuffer;
 }
 
-void DisplayMan::doTransition(TransitionType transitionType, CloseDataPtr *closePtrList, char *filename) {
+void DisplayMan::doTransition(TransitionType transitionType, CloseDataPtr *closePtrList, Common::String filename) {
 	switch (transitionType) {
 	case kTransitionWipe:
 	case kTransitionTransporter:
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index e9bba74..6be377d 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -97,7 +97,7 @@ public:
 	/**
 	 * Scrolls the display to a new picture from a black screen.
 	 */
-	void doScrollWipe(char *filename);
+	void doScrollWipe(Common::String filename);
 
 	/**
 	 * Does the scroll bounce.  Assumes bitmap already in memory.
@@ -107,12 +107,12 @@ public:
 	/**
 	 * Does the transporter wipe.
 	 */
-	void doTransWipe(CloseDataPtr *closePtrList, char *filename);
+	void doTransWipe(CloseDataPtr *closePtrList, Common::String filename);
 
 	/**
 	 * Does a certain number of pre-programmed wipes.
 	 */
-	void doTransition(TransitionType transitionType, CloseDataPtr *closePtrList, char *filename);
+	void doTransition(TransitionType transitionType, CloseDataPtr *closePtrList, Common::String filename);
 
 	/**
 	 * Changes the front screen to black.
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 8edd2a8..a6f50b7 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -258,7 +258,7 @@ void Music::checkRoomMusic() {
 /**
  * Changes the background music to something else.
  */
-void Music::changeMusic(const char *filename) {
+void Music::changeMusic(const Common::String filename) {
 	if (!_tFile) {
 		_tFile = _file;
 		_oldMusicOn = _musicOn;
@@ -268,7 +268,7 @@ void Music::changeMusic(const char *filename) {
 			_tLeftInFile = _leftInFile;
 	}
 
-	_file = _vm->_resource->openDataFile(filename);
+	_file = _vm->_resource->openDataFile(filename.c_str());
 	// turn music off
 	_musicOn = true;
 	setMusic(false);
diff --git a/engines/lab/music.h b/engines/lab/music.h
index ba249e1..820d403 100644
--- a/engines/lab/music.h
+++ b/engines/lab/music.h
@@ -80,7 +80,7 @@ public:
 public:
 	Music(LabEngine *vm);
 
-	void changeMusic(const char *filename);
+	void changeMusic(const Common::String filename);
 	void checkRoomMusic();
 	void freeMusic();
 	bool initMusic(const char *filename);
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 2a4d508..07e9633 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -243,38 +243,38 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 		case PLAYSOUND:
 			_music->_loopSoundEffect = false;
 			_music->_waitTillFinished = true;
-			_music->readMusic((char *)actionList->_data, true);
+			_music->readMusic(actionList->_messages[0].c_str(), true);
 			_music->_waitTillFinished = false;
 			break;
 
 		case PLAYSOUNDB:
 			_music->_loopSoundEffect = false;
 			_music->_waitTillFinished = false;
-			_music->readMusic((char *)actionList->_data, false);
+			_music->readMusic(actionList->_messages[0].c_str(), false);
 			break;
 
 		case PLAYSOUNDCONT:
 			_music->_loopSoundEffect = true;
-			_music->readMusic((char *)actionList->_data, _music->_waitTillFinished);
+			_music->readMusic(actionList->_messages[0].c_str(), _music->_waitTillFinished);
 			break;
 
 		case SHOWDIFF:
-			_graphics->readPict((char *)actionList->_data, true);
+			_graphics->readPict(actionList->_messages[0].c_str(), true);
 			break;
 
 		case SHOWDIFFCONT:
-			_graphics->readPict((char *)actionList->_data, false);
+			_graphics->readPict(actionList->_messages[0].c_str(), false);
 			break;
 
 		case LOADDIFF:
-			if (actionList->_data)
+			if (actionList->_messages[0].size())
 				// Puts a file into memory
-				_graphics->loadPict((char *)actionList->_data);
+				_graphics->loadPict(actionList->_messages[0].c_str());
 
 			break;
 
 		case TRANSITION:
-			_graphics->doTransition((TransitionType)actionList->_param1, closePtrList, (char *)actionList->_data);
+			_graphics->doTransition((TransitionType)actionList->_param1, closePtrList, actionList->_messages[0].c_str());
 			break;
 
 		case NOUPDATE:
@@ -307,7 +307,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 		case SHOWMESSAGE: {
 			_graphics->_doNotDrawMessage = false;
 
-			Common::String text = Common::String((char *)actionList->_data);
+			Common::String text = actionList->_messages[0];
 			if (_graphics->_longWinInFront)
 				_graphics->longDrawMessage(text);
 			else
@@ -319,7 +319,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 
 		case CSHOWMESSAGE:
 			if (!*closePtrList) {
-				Common::String text = Common::String((char *)actionList->_data);
+				Common::String text = actionList->_messages[0];
 				_graphics->_doNotDrawMessage = false;
 				_graphics->drawMessage(text);
 				_graphics->_doNotDrawMessage = true;
@@ -328,10 +328,10 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			break;
 
 		case SHOWMESSAGES: {
-				char **str = (char **)actionList->_data;
-				_graphics->_doNotDrawMessage = false;
-				_graphics->drawMessage(Common::String(str[_utils->getRandom(actionList->_param1)]));
-				_graphics->_doNotDrawMessage = true;
+			Common::String *str = actionList->_messages;
+			_graphics->_doNotDrawMessage = false;
+			_graphics->drawMessage(str[_utils->getRandom(actionList->_param1)]);
+			_graphics->_doNotDrawMessage = true;
 			}
 			break;
 
@@ -404,7 +404,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			break;
 
 		case CHANGEMUSIC:
-			_music->changeMusic((const char *)actionList->_data);
+			_music->changeMusic(actionList->_messages[0]);
 			_music->setMusicReset(false);
 			break;
 
diff --git a/engines/lab/processroom.h b/engines/lab/processroom.h
index 49e328b..60f696b 100644
--- a/engines/lab/processroom.h
+++ b/engines/lab/processroom.h
@@ -113,7 +113,7 @@ struct Action {
 	int16 _param1;
 	int16 _param2;
 	int16 _param3;
-	byte *_data;            // Message, or a pointer to array of messages.
+	Common::String *_messages;
 	Action *_nextAction;
 };
 


Commit: ae9c2fea51adb1e5b713683e1fadfbb11558c267
    https://github.com/scummvm/scummvm/commit/ae9c2fea51adb1e5b713683e1fadfbb11558c267
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:31+01:00

Commit Message:
LAB: Replace char* by Common::String in several functions

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/intro.cpp
    engines/lab/intro.h
    engines/lab/labsets.cpp
    engines/lab/labsets.h
    engines/lab/music.cpp
    engines/lab/music.h
    engines/lab/processroom.cpp
    engines/lab/resource.cpp
    engines/lab/resource.h
    engines/lab/special.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index bb07ba3..32c3388 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -70,15 +70,15 @@ DisplayMan::~DisplayMan() {
 }
 
 // From readPict.c.  Reads in pictures and animations from disk.
-void DisplayMan::loadPict(const char *filename) {
+void DisplayMan::loadPict(const Common::String filename) {
 	freePict();
 	_curBitmap = _vm->_resource->openDataFile(filename);
 }
 
-void DisplayMan::loadBackPict(const char *fileName, uint16 *highPal) {
+void DisplayMan::loadBackPict(const Common::String fileName, uint16 *highPal) {
 	_fadePalette = highPal;
 	_vm->_anim->_noPalChange = true;
-	readPict(fileName, true);
+	readPict(fileName.c_str(), true);
 
 	for (uint16 i = 0; i < 16; i++) {
 		highPal[i] = ((_vm->_anim->_diffPalette[i * 3] >> 2) << 8) +
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index 6be377d..3ada808 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -79,8 +79,8 @@ public:
 	DisplayMan(LabEngine *lab);
 	virtual ~DisplayMan();
 
-	void loadPict(const char *filename);
-	void loadBackPict(const char *fileName, uint16 *highPal);
+	void loadPict(const Common::String filename);
+	void loadBackPict(const Common::String fileName, uint16 *highPal);
 
 	/**
 	 * Reads in a picture into the display bitmap.
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 5e1a8ce..4f9ba59 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -63,7 +63,7 @@ void Intro::introEatMessages() {
 	}
 }
 
-void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
+void Intro::doPictText(const Common::String filename, TextFont *msgFont, bool isScreen) {
 	Common::String path = Common::String("Lab:rooms/Intro/") + filename;
 
 	uint timeDelay = (isScreen) ? 35 : 7;
@@ -77,7 +77,7 @@ void Intro::doPictText(const char *filename, TextFont *msgFont, bool isScreen) {
 	bool doneFl = false;
 	bool begin = true;
 
-	Common::File *textFile = _vm->_resource->openDataFile(path.c_str());
+	Common::File *textFile = _vm->_resource->openDataFile(path);
 	byte *textBuffer = new byte[textFile->size()];
 	textFile->read(textBuffer, textFile->size());
 	delete textFile;
@@ -203,7 +203,7 @@ void Intro::musicDelay() {
 	}
 }
 
-void Intro::nReadPict(const char *filename, bool playOnce) {
+void Intro::nReadPict(const Common::String filename, bool playOnce) {
 	Common::String finalFileName = Common::String("P:Intro/") + filename;
 
 	_vm->_music->updateMusic();
diff --git a/engines/lab/intro.h b/engines/lab/intro.h
index ac292d0..6f7bc97 100644
--- a/engines/lab/intro.h
+++ b/engines/lab/intro.h
@@ -52,13 +52,13 @@ private:
 	/**
 	 * Reads in a picture.
 	 */
-	void doPictText(const char *Filename, TextFont *msgFont, bool isscreen);
+	void doPictText(const Common::String Filename, TextFont *msgFont, bool isScreen);
 
 	/**
 	 * Does a one second delay, but checks the music while doing it.
 	 */
 	void musicDelay();
-	void nReadPict(const char *Filename, bool PlayOnce);
+	void nReadPict(const Common::String Filename, bool PlayOnce);
 
 	LabEngine *_vm;
 	bool _quitIntro, _introDoBlack;
diff --git a/engines/lab/labsets.cpp b/engines/lab/labsets.cpp
index b19755e..3e84275 100644
--- a/engines/lab/labsets.cpp
+++ b/engines/lab/labsets.cpp
@@ -61,7 +61,7 @@ void LargeSet::exclElement(uint16 element) {
 	_array[(element - 1) >> 4] &= ~(1 << ((element - 1) % 16));
 }
 
-bool LargeSet::readInitialConditions(const char *fileName) {
+bool LargeSet::readInitialConditions(const Common::String fileName) {
 	Common::File *file = _vm->_resource->openDataFile(fileName, MKTAG('C', 'O', 'N', '0'));
 
 	uint16 conditions = file->readUint16LE();
diff --git a/engines/lab/labsets.h b/engines/lab/labsets.h
index 0c1af77..afd997e 100644
--- a/engines/lab/labsets.h
+++ b/engines/lab/labsets.h
@@ -46,7 +46,7 @@ public:
 	bool in(uint16 element);
 	void inclElement(uint16 element);
 	void exclElement(uint16 element);
-	bool readInitialConditions(const char *fileName);
+	bool readInitialConditions(const Common::String fileName);
 
 private:
 	LabEngine *_vm;
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index a6f50b7..5ff23ea 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -170,7 +170,7 @@ void Music::startMusic(bool restartFl) {
 /**
  * Initializes the music buffers.
  */
-bool Music::initMusic(const char *filename) {
+bool Music::initMusic(const Common::String filename) {
 	_musicOn = true;
 	_musicPaused = false;
 	_file = _vm->_resource->openDataFile(filename);
@@ -268,7 +268,7 @@ void Music::changeMusic(const Common::String filename) {
 			_tLeftInFile = _leftInFile;
 	}
 
-	_file = _vm->_resource->openDataFile(filename.c_str());
+	_file = _vm->_resource->openDataFile(filename);
 	// turn music off
 	_musicOn = true;
 	setMusic(false);
@@ -311,7 +311,7 @@ void Music::resetMusic() {
 /**
  * Reads in a music file.  Ignores any graphics.
  */
-bool Music::readMusic(const char *filename, bool waitTillFinished) {
+bool Music::readMusic(const Common::String filename, bool waitTillFinished) {
 	Common::File *file = _vm->_resource->openDataFile(filename, MKTAG('D', 'I', 'F', 'F'));
 	updateMusic();
 	if (!_loopSoundEffect)
diff --git a/engines/lab/music.h b/engines/lab/music.h
index 820d403..a6f8369 100644
--- a/engines/lab/music.h
+++ b/engines/lab/music.h
@@ -83,10 +83,10 @@ public:
 	void changeMusic(const Common::String filename);
 	void checkRoomMusic();
 	void freeMusic();
-	bool initMusic(const char *filename);
+	bool initMusic(const Common::String filename);
 	bool isSoundEffectActive() const;
 	void playSoundEffect(uint16 sampleSpeed, uint32 length, Common::File *dataFile);
-	bool readMusic(const char *filename, bool waitTillFinished);
+	bool readMusic(const Common::String filename, bool waitTillFinished);
 	void resetMusic();
 	void resumeBackMusic();
 	void setMusic(bool on);
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 07e9633..b597963 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -243,19 +243,19 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 		case PLAYSOUND:
 			_music->_loopSoundEffect = false;
 			_music->_waitTillFinished = true;
-			_music->readMusic(actionList->_messages[0].c_str(), true);
+			_music->readMusic(actionList->_messages[0], true);
 			_music->_waitTillFinished = false;
 			break;
 
 		case PLAYSOUNDB:
 			_music->_loopSoundEffect = false;
 			_music->_waitTillFinished = false;
-			_music->readMusic(actionList->_messages[0].c_str(), false);
+			_music->readMusic(actionList->_messages[0], false);
 			break;
 
 		case PLAYSOUNDCONT:
 			_music->_loopSoundEffect = true;
-			_music->readMusic(actionList->_messages[0].c_str(), _music->_waitTillFinished);
+			_music->readMusic(actionList->_messages[0], _music->_waitTillFinished);
 			break;
 
 		case SHOWDIFF:
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index a0f6350..4c0de7b 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -50,7 +50,7 @@ void Resource::readStaticText() {
 	delete labTextFile;
 }
 
-TextFont *Resource::getFont(const char *fileName) {
+TextFont *Resource::getFont(const Common::String fileName) {
 	// TODO: Add support for the font format of the Amiga version
 	Common::File *dataFile = openDataFile(fileName, MKTAG('V', 'G', 'A', 'F'));
 
@@ -73,7 +73,7 @@ TextFont *Resource::getFont(const char *fileName) {
 	return textfont;
 }
 
-Common::String Resource::getText(const char *fileName) {
+Common::String Resource::getText(const Common::String fileName) {
 	Common::File *dataFile = openDataFile(fileName);
 
 	_vm->_music->updateMusic();
@@ -94,7 +94,7 @@ Common::String Resource::getText(const char *fileName) {
 	return str;
 }
 
-bool Resource::readRoomData(const char *fileName) {
+bool Resource::readRoomData(const Common::String fileName) {
 	Common::File *dataFile = openDataFile(fileName, MKTAG('D', 'O', 'R', '1'));
 
 	_vm->_manyRooms = dataFile->readUint16LE();
@@ -121,7 +121,7 @@ bool Resource::readRoomData(const char *fileName) {
 	return true;
 }
 
-InventoryData *Resource::readInventory(const char *fileName) {
+InventoryData *Resource::readInventory(const Common::String fileName) {
 	Common::File *dataFile = openDataFile(fileName, MKTAG('I', 'N', 'V', '1'));
 
 	_vm->_numInv = dataFile->readUint16LE();
@@ -140,7 +140,7 @@ InventoryData *Resource::readInventory(const char *fileName) {
 
 bool Resource::readViews(uint16 roomNum) {
 	Common::String fileName = "LAB:Rooms/" + Common::String::format("%d", roomNum);
-	Common::File *dataFile = openDataFile(fileName.c_str(), MKTAG('R', 'O', 'M', '4'));
+	Common::File *dataFile = openDataFile(fileName, MKTAG('R', 'O', 'M', '4'));
 
 	freeViews(roomNum);
 
@@ -205,7 +205,7 @@ Common::String Resource::translateFileName(Common::String filename) {
 	return fileNameStrFinal;
 }
 
-Common::File *Resource::openDataFile(const char *fileName, uint32 fileHeader) {
+Common::File *Resource::openDataFile(const Common::String fileName, uint32 fileHeader) {
 	Common::File *dataFile = new Common::File();
 	dataFile->open(translateFileName(fileName));
 	if (!dataFile->isOpen())
@@ -310,21 +310,13 @@ Action *Resource::readAction(Common::File *file) {
 			action->_param3 = file->readSint16LE();
 
 			if (action->_actionType == SHOWMESSAGES) {
-				char **messages = (char **)malloc(action->_param1 * sizeof(char *));
-				Common::String tmp;
+				action->_messages = new Common::String[action->_param1];
 
-				for (int i = 0; i < action->_param1; i++) {
-					tmp = readString(file);
-					messages[i] = (char *)malloc(tmp.size());
-					memcpy(messages[i], tmp.c_str(), tmp.size());
-				}
-
-				action->_data = (byte *)messages;
+				for (int i = 0; i < action->_param1; i++)
+					action->_messages[i] = readString(file);
 			} else {
-				Common::String tmp;
-				tmp = readString(file);
-				action->_data =  (byte *)malloc(tmp.size());
-				memcpy(action->_data, tmp.c_str(), tmp.size());
+				action->_messages = new Common::String[1];
+				action->_messages[0] = readString(file);
 			}
 
 			action->_nextAction = nullptr;
@@ -338,13 +330,7 @@ Action *Resource::readAction(Common::File *file) {
 void Resource::freeAction(Action *action) {
 	while (action) {
 		Action *nextAction = action->_nextAction;
-		if (action->_actionType == SHOWMESSAGES) {
-			char **messages = (char **)action->_data;
-			for (int i = 0; i < action->_param1; i++)
-				free(messages[i]);
-			free(messages);
-		} else
-			free(action->_data);
+		delete[] action->_messages;
 		delete action;
 		action = nextAction;
 	}
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index 26607f2..f4aa357 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -97,13 +97,13 @@ public:
 	Resource(LabEngine *vm);
 	~Resource() {}
 
-	Common::File *openDataFile(const char * fileName, uint32 fileHeader = 0);
-	bool readRoomData(const char *fileName);
-	InventoryData *readInventory(const char *fileName);
+	Common::File *openDataFile(const Common::String fileName, uint32 fileHeader = 0);
+	bool readRoomData(const Common::String fileName);
+	InventoryData *readInventory(const Common::String fileName);
 	bool readViews(uint16 roomNum);
 	void freeViews(uint16 roomNum);
-	TextFont *getFont(const char *fileName);
-	Common::String getText(const char *fileName);
+	TextFont *getFont(const Common::String fileName);
+	Common::String getText(const Common::String fileName);
 	Common::String getStaticText(byte index) const { return _staticText[index]; }
 
 private:
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 9f33d96..a45a8fa 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -126,7 +126,7 @@ void LabEngine::loadJournalData() {
 	else if (bridge)
 		filename += '1';
 
-	_journalText = _resource->getText(filename.c_str());
+	_journalText = _resource->getText(filename);
 	_journalTextTitle = _resource->getText("Lab:Rooms/jt");
 
 	Common::File *journalFile = _resource->openDataFile("P:JImage");
@@ -463,8 +463,8 @@ void LabEngine::doMonitor(Common::String background, Common::String textfile, bo
 	_monitorButton = new Image(buttonFile, this);
 	delete buttonFile;
 
-	Common::String ntext = _resource->getText(textfile.c_str());
-	_graphics->loadBackPict(background.c_str(), _highPalette);
+	Common::String ntext = _resource->getText(textfile);
+	_graphics->loadBackPict(background, _highPalette);
 	drawMonText((char *)ntext.c_str(), monitorFont, scaledRect, isinteractive);
 	_event->mouseShow();
 	_graphics->fade(true, 0);


Commit: baa638fe2ecb8a6dbde0a8fd6d5af20f80aa0676
    https://github.com/scummvm/scummvm/commit/baa638fe2ecb8a6dbde0a8fd6d5af20f80aa0676
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:31+01:00

Commit Message:
LAB: Remove useless call to c_str

Changed paths:
    engines/lab/special.cpp



diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index a45a8fa..3f5a3d0 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -373,7 +373,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 				_monitorPage = 0;
 				_monitorTextFilename = test;
 
-				Common::String text = _resource->getText(_monitorTextFilename.c_str());
+				Common::String text = _resource->getText(_monitorTextFilename);
 				_graphics->fade(false, 0);
 				drawMonText((char *)text.c_str(), monitorFont, textRect, isInteractive);
 				_graphics->fade(true, 0);


Commit: af8f87d55d9d16bc3ce94fb6276cb79a10de3008
    https://github.com/scummvm/scummvm/commit/af8f87d55d9d16bc3ce94fb6276cb79a10de3008
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:31+01:00

Commit Message:
LAB: Fix compilation for non-MSVC compilers

Changed paths:
    engines/lab/resource.cpp



diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 4c0de7b..a9d8441 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -209,13 +209,13 @@ Common::File *Resource::openDataFile(const Common::String fileName, uint32 fileH
 	Common::File *dataFile = new Common::File();
 	dataFile->open(translateFileName(fileName));
 	if (!dataFile->isOpen())
-		error("openDataFile: Couldn't open %s (%s)", translateFileName(fileName).c_str(), fileName);
+		error("openDataFile: Couldn't open %s (%s)", translateFileName(fileName).c_str(), fileName.c_str());
 
 	if (fileHeader > 0) {
 		uint32 headerTag = dataFile->readUint32BE();
 		if (headerTag != fileHeader) {
 			dataFile->close();
-			error("openDataFile: Unexpected header in %s (%s) - expected: %d, got: %d", translateFileName(fileName).c_str(), fileName, fileHeader, headerTag);
+			error("openDataFile: Unexpected header in %s (%s) - expected: %d, got: %d", translateFileName(fileName).c_str(), fileName.c_str(), fileHeader, headerTag);
 		}
 	}
 


Commit: 7e047b45b782a31c2d902136ef57218f344ebc3f
    https://github.com/scummvm/scummvm/commit/7e047b45b782a31c2d902136ef57218f344ebc3f
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:31+01:00

Commit Message:
LAB: Fix a delete[] pointed out by eriktorbjorn

Changed paths:
    engines/lab/dispman.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 32c3388..6ed3dcd 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -108,7 +108,7 @@ void DisplayMan::readPict(Common::String filename, bool playOnce, bool onlyDiffD
 }
 
 void DisplayMan::freePict() {
-	delete _curBitmap;
+	delete[] _curBitmap;
 	_curBitmap = nullptr;
 }
 


Commit: 6981d750eac1d16eac66d9c91645f620fd7e9a95
    https://github.com/scummvm/scummvm/commit/6981d750eac1d16eac66d9c91645f620fd7e9a95
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:31+01:00

Commit Message:
LAB: Fix a bug pointed out by wjp in getObject

Changed paths:
    engines/lab/processroom.cpp
    engines/lab/utils.cpp
    engines/lab/utils.h



diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index b597963..243c086 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -87,7 +87,7 @@ CloseData *LabEngine::getObject(Common::Point pos, CloseDataPtr closePtr) {
 
 	Common::Rect objRect;
 	while (wrkClosePtr) {
-		objRect = Common::Rect(_utils->scaleX(wrkClosePtr->_x1), _utils->scaleX(wrkClosePtr->_y1), _utils->scaleX(wrkClosePtr->_x2), _utils->scaleX(wrkClosePtr->_y2));
+		objRect = _utils->rectScale(wrkClosePtr->_x1, wrkClosePtr->_y1, wrkClosePtr->_x2, wrkClosePtr->_y2);
 		if (objRect.contains(pos))
 			return wrkClosePtr;
 
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index 3bd3057..3de1540 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -60,6 +60,10 @@ uint16 Utils::scaleY(uint16 y) {
 		return ((y * 10) / 24);
 }
 
+Common::Rect Utils::rectScale(int16 x1, int16 y1, int16 x2, int16 y2) {
+	return Common::Rect(scaleX(x1), scaleY(y1), scaleX(x2), scaleY(y2));
+}
+
 uint16 Utils::mapScaleX(uint16 x) {
 	if (_vm->_isHiRes)
 		return (x - 45);
diff --git a/engines/lab/utils.h b/engines/lab/utils.h
index f9a36ba..333d532 100644
--- a/engines/lab/utils.h
+++ b/engines/lab/utils.h
@@ -51,6 +51,7 @@ public:
 
 	uint16 scaleX(uint16 x);
 	uint16 scaleY(uint16 y);
+	Common::Rect rectScale(int16 x1, int16 y1, int16 x2, int16 y2);
 	int16 vgaScaleX(int16 x);
 	int16 vgaScaleY(int16 y);
 	Common::Rect vgaRectScale(int16 x1, int16 y1, int16 x2, int16 y2);


Commit: feeaf094868b12622b7da90f424fb3b1918ce64b
    https://github.com/scummvm/scummvm/commit/feeaf094868b12622b7da90f424fb3b1918ce64b
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:32+01:00

Commit Message:
LAB: Use rectScale in two other places

Changed paths:
    engines/lab/processroom.cpp



diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 243c086..496920b 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -199,7 +199,7 @@ void LabEngine::setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, b
 		if (!useAbsoluteCoords)
 			target = Common::Rect(closePtr->_x1, closePtr->_y1, closePtr->_x2, closePtr->_y2);
 		else
-			target = Common::Rect(_utils->scaleX(closePtr->_x1), _utils->scaleY(closePtr->_y1), _utils->scaleX(closePtr->_x2), _utils->scaleY(closePtr->_y2));
+			target = _utils->rectScale(closePtr->_x1, closePtr->_y1, closePtr->_x2, closePtr->_y2);
 
 		if (target.contains(pos) && closePtr->_graphicName != "") {
 			*closePtrList = closePtr;
@@ -223,7 +223,7 @@ bool LabEngine::takeItem(Common::Point pos, CloseDataPtr *closePtrList) {
 
 	Common::Rect objRect;
 	while (closePtr) {
-		objRect = Common::Rect(_utils->scaleX(closePtr->_x1), _utils->scaleX(closePtr->_y1), _utils->scaleX(closePtr->_x2), _utils->scaleX(closePtr->_y2));
+		objRect = _utils->rectScale(closePtr->_x1, closePtr->_y1, closePtr->_x2, closePtr->_y2);
 		if (objRect.contains(pos) && (closePtr->_closeUpType < 0)) {
 			_conditions->inclElement(abs(closePtr->_closeUpType));
 			return true;


Commit: cc039ef1135dc6f751ef23e22c344b7b9456653c
    https://github.com/scummvm/scummvm/commit/cc039ef1135dc6f751ef23e22c344b7b9456653c
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:32+01:00

Commit Message:
LAB: Fix crash in intro

Changed paths:
    engines/lab/dispman.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 6ed3dcd..32c3388 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -108,7 +108,7 @@ void DisplayMan::readPict(Common::String filename, bool playOnce, bool onlyDiffD
 }
 
 void DisplayMan::freePict() {
-	delete[] _curBitmap;
+	delete _curBitmap;
 	_curBitmap = nullptr;
 }
 


Commit: 4dfc428bac7e80a89e9177786b806d8ad0436078
    https://github.com/scummvm/scummvm/commit/4dfc428bac7e80a89e9177786b806d8ad0436078
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:32+01:00

Commit Message:
LAB: Some cleanup and refactoring

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/engine.cpp
    engines/lab/intro.cpp
    engines/lab/intro.h
    engines/lab/processroom.cpp
    engines/lab/tilepuzzle.cpp
    engines/lab/tilepuzzle.h



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 32c3388..d66d1a9 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -78,7 +78,7 @@ void DisplayMan::loadPict(const Common::String filename) {
 void DisplayMan::loadBackPict(const Common::String fileName, uint16 *highPal) {
 	_fadePalette = highPal;
 	_vm->_anim->_noPalChange = true;
-	readPict(fileName.c_str(), true);
+	readPict(fileName, true);
 
 	for (uint16 i = 0; i < 16; i++) {
 		highPal[i] = ((_vm->_anim->_diffPalette[i * 3] >> 2) << 8) +
@@ -92,7 +92,7 @@ void DisplayMan::loadBackPict(const Common::String fileName, uint16 *highPal) {
 void DisplayMan::readPict(Common::String filename, bool playOnce, bool onlyDiffData, byte *memoryBuffer, uint16 maxHeight) {
 	_vm->_anim->stopDiff();
 
-	loadPict(filename.c_str());
+	loadPict(filename);
 
 	_vm->_music->updateMusic();
 
@@ -740,7 +740,7 @@ void DisplayMan::doScrollWipe(Common::String filename) {
 		_vm->waitTOF();
 	}
 
-	readPict(filename.c_str(), true, true);
+	readPict(filename, true, true);
 	setPalette(_vm->_anim->_diffPalette, 256);
 	byte *mem = _vm->_anim->_rawDiffBM._planes[0];
 
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 2d7725a..cefc357 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -466,7 +466,7 @@ void LabEngine::mainGameLoop() {
 					case SPECIALBRICK:
 					case SPECIALBRICKNOMOUSE:
 						if (_mainDisplay)
-							_tilePuzzle->showTile(_curFileName.c_str(), (_closeDataPtr->_closeUpType == SPECIALBRICKNOMOUSE));
+							_tilePuzzle->showTile(_curFileName, (_closeDataPtr->_closeUpType == SPECIALBRICKNOMOUSE));
 						break;
 					default:
 						_graphics->readPict(_curFileName.c_str(), false);
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 4f9ba59..6b28db9 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -214,7 +214,7 @@ void Intro::nReadPict(const Common::String filename, bool playOnce) {
 
 	_vm->_anim->_doBlack = _introDoBlack;
 	_vm->_anim->stopDiffEnd();
-	_vm->_graphics->readPict(finalFileName.c_str(), playOnce);
+	_vm->_graphics->readPict(finalFileName, playOnce);
 }
 
 void Intro::introSequence() {
@@ -228,12 +228,12 @@ void Intro::introSequence() {
 	_vm->_anim->_doBlack = true;
 
 	if (_vm->getPlatform() == Common::kPlatformDOS) {
-		nReadPict("EA0", true);
-		nReadPict("EA1", true);
-		nReadPict("EA2", true);
-		nReadPict("EA3", true);
+		nReadPict("EA0");
+		nReadPict("EA1");
+		nReadPict("EA2");
+		nReadPict("EA3");
 	} else if (_vm->getPlatform() == Common::kPlatformWindows) {
-		nReadPict("WYRMKEEP", true);
+		nReadPict("WYRMKEEP");
 		// Wait 4 seconds
 		for (uint16 i = 0; i < 4 * 1000 / 10; i++) {
 			introEatMessages();
@@ -252,9 +252,9 @@ void Intro::introSequence() {
 
 	_vm->_anim->_noPalChange = true;
 	if (_vm->getPlatform() == Common::kPlatformDOS)
-		nReadPict("TNDcycle.pic", true);
+		nReadPict("TNDcycle.pic");
 	else
-		nReadPict("TNDcycle2.pic", true);
+		nReadPict("TNDcycle2.pic");
 	_vm->_anim->_noPalChange = false;
 
 	_vm->_graphics->_fadePalette = palette;
@@ -291,24 +291,24 @@ void Intro::introSequence() {
 	_vm->_graphics->blackAllScreen();
 	_vm->_music->updateMusic();
 
-	nReadPict("Title.A", true);
-	nReadPict("AB", true);
+	nReadPict("Title.A");
+	nReadPict("AB");
 	musicDelay();
-	nReadPict("BA", true);
-	nReadPict("AC", true);
+	nReadPict("BA");
+	nReadPict("AC");
 	musicDelay();
 
 	if (_vm->getPlatform() == Common::kPlatformWindows)
 		musicDelay(); // more credits on this page now
 
-	nReadPict("CA", true);
-	nReadPict("AD", true);
+	nReadPict("CA");
+	nReadPict("AD");
 	musicDelay();
 
 	if (_vm->getPlatform() == Common::kPlatformWindows)
 		musicDelay(); // more credits on this page now
 
-	nReadPict("DA", true);
+	nReadPict("DA");
 	musicDelay();
 
 	_vm->_music->updateMusic();
@@ -318,7 +318,7 @@ void Intro::introSequence() {
 	TextFont *msgFont = _vm->_resource->getFont("F:Map.fon");
 
 	_vm->_anim->_noPalChange = true;
-	nReadPict("Intro.1", true);
+	nReadPict("Intro.1");
 	_vm->_anim->_noPalChange = false;
 
 	for (uint16 i = 0; i < 16; i++) {
@@ -337,28 +337,28 @@ void Intro::introSequence() {
 	_vm->_music->updateMusic();
 
 	_introDoBlack = true;
-	nReadPict("Station1", true);
+	nReadPict("Station1");
 	doPictText("i.3", msgFont, false);
 
-	nReadPict("Station2", true);
+	nReadPict("Station2");
 	doPictText("i.4", msgFont, false);
 
-	nReadPict("Stiles4", true);
+	nReadPict("Stiles4");
 	doPictText("i.5", msgFont, false);
 
-	nReadPict("Stiles3", true);
+	nReadPict("Stiles3");
 	doPictText("i.6", msgFont, false);
 
 	if (_vm->getPlatform() == Common::kPlatformWindows)
-		nReadPict("Platform2", true);
+		nReadPict("Platform2");
 	else
-		nReadPict("Platform", true);
+		nReadPict("Platform");
 	doPictText("i.7", msgFont, false);
 
-	nReadPict("Subway.1", true);
+	nReadPict("Subway.1");
 	doPictText("i.8", msgFont, false);
 
-	nReadPict("Subway.2", true);
+	nReadPict("Subway.2");
 
 	doPictText("i.9", msgFont, false);
 	doPictText("i.10", msgFont, false);
@@ -380,30 +380,30 @@ void Intro::introSequence() {
 	doPictText("i.13", msgFont, false);
 
 	_introDoBlack = false;
-	nReadPict("Daed0", true);
+	nReadPict("Daed0");
 	doPictText("i.14", msgFont, false);
 
-	nReadPict("Daed1", true);
+	nReadPict("Daed1");
 	doPictText("i.15", msgFont, false);
 
-	nReadPict("Daed2", true);
+	nReadPict("Daed2");
 	doPictText("i.16", msgFont, false);
 	doPictText("i.17", msgFont, false);
 	doPictText("i.18", msgFont, false);
 
-	nReadPict("Daed3", true);
+	nReadPict("Daed3");
 	doPictText("i.19", msgFont, false);
 	doPictText("i.20", msgFont, false);
 
-	nReadPict("Daed4", true);
+	nReadPict("Daed4");
 	doPictText("i.21", msgFont, false);
 
-	nReadPict("Daed5", true);
+	nReadPict("Daed5");
 	doPictText("i.22", msgFont, false);
 	doPictText("i.23", msgFont, false);
 	doPictText("i.24", msgFont, false);
 
-	nReadPict("Daed6", true);
+	nReadPict("Daed6");
 	doPictText("i.25", msgFont, false);
 	doPictText("i.26", msgFont, false);
 
@@ -412,22 +412,22 @@ void Intro::introSequence() {
 	doPictText("i.28", msgFont, false);
 	_vm->_anim->stopDiffEnd();
 
-	nReadPict("Daed8", true);
+	nReadPict("Daed8");
 	doPictText("i.29", msgFont, false);
 	doPictText("i.30", msgFont, false);
 
-	nReadPict("Daed9", true);
+	nReadPict("Daed9");
 	doPictText("i.31", msgFont, false);
 	doPictText("i.32", msgFont, false);
 	doPictText("i.33", msgFont, false);
 
-	nReadPict("Daed9a", true);
-	nReadPict("Daed10", true);
+	nReadPict("Daed9a");
+	nReadPict("Daed10");
 	doPictText("i.34", msgFont, false);
 	doPictText("i.35", msgFont, false);
 	doPictText("i.36", msgFont, false);
 
-	nReadPict("SubX", true);
+	nReadPict("SubX");
 
 	if (_quitIntro) {
 		_vm->_graphics->setPen(0);
diff --git a/engines/lab/intro.h b/engines/lab/intro.h
index 6f7bc97..7eb4c6d 100644
--- a/engines/lab/intro.h
+++ b/engines/lab/intro.h
@@ -58,7 +58,7 @@ private:
 	 * Does a one second delay, but checks the music while doing it.
 	 */
 	void musicDelay();
-	void nReadPict(const Common::String Filename, bool PlayOnce);
+	void nReadPict(const Common::String Filename, bool PlayOnce = true);
 
 	LabEngine *_vm;
 	bool _quitIntro, _introDoBlack;
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 496920b..d3d37be 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -259,17 +259,17 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			break;
 
 		case SHOWDIFF:
-			_graphics->readPict(actionList->_messages[0].c_str(), true);
+			_graphics->readPict(actionList->_messages[0], true);
 			break;
 
 		case SHOWDIFFCONT:
-			_graphics->readPict(actionList->_messages[0].c_str(), false);
+			_graphics->readPict(actionList->_messages[0], false);
 			break;
 
 		case LOADDIFF:
 			if (actionList->_messages[0].size())
 				// Puts a file into memory
-				_graphics->loadPict(actionList->_messages[0].c_str());
+				_graphics->loadPict(actionList->_messages[0]);
 
 			break;
 
@@ -291,7 +291,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 
 			if (test != _curFileName) {
 				_curFileName = test;
-				_graphics->readPict(_curFileName.c_str(), true);
+				_graphics->readPict(_curFileName, true);
 			}
 			}
 			break;
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index c9214fd..cb93f25 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -251,7 +251,7 @@ void TilePuzzle::doTile(bool showsolution) {
 /**
  * Reads in a backdrop picture.
  */
-void TilePuzzle::showTile(const char *filename, bool showSolution) {
+void TilePuzzle::showTile(const Common::String filename, bool showSolution) {
 	_vm->_anim->_doBlack = true;
 	_vm->_anim->_noPalChange = true;
 	_vm->_graphics->readPict(filename, true);
diff --git a/engines/lab/tilepuzzle.h b/engines/lab/tilepuzzle.h
index a20f4ce..da159be 100644
--- a/engines/lab/tilepuzzle.h
+++ b/engines/lab/tilepuzzle.h
@@ -50,7 +50,7 @@ public:
 	virtual ~TilePuzzle();
 
 	void mouseTile(Common::Point pos);
-	void showTile(const char *filename, bool showSolution);
+	void showTile(const Common::String filename, bool showSolution);
 	void mouseCombination(Common::Point pos);
 	void showCombination(const char *filename);
 	void save(Common::OutSaveFile *file);


Commit: cff1f99b26e64b03a8c7d6f456b48b333e8bf882
    https://github.com/scummvm/scummvm/commit/cff1f99b26e64b03a8c7d6f456b48b333e8bf882
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:32+01:00

Commit Message:
LAB: Set a default to the second parameter of readPict

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/engine.cpp
    engines/lab/processroom.cpp
    engines/lab/savegame.cpp
    engines/lab/special.cpp
    engines/lab/tilepuzzle.cpp
    engines/lab/tilepuzzle.h



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index d66d1a9..9dbaf8d3 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -78,7 +78,7 @@ void DisplayMan::loadPict(const Common::String filename) {
 void DisplayMan::loadBackPict(const Common::String fileName, uint16 *highPal) {
 	_fadePalette = highPal;
 	_vm->_anim->_noPalChange = true;
-	readPict(fileName, true);
+	readPict(fileName);
 
 	for (uint16 i = 0; i < 16; i++) {
 		highPal[i] = ((_vm->_anim->_diffPalette[i * 3] >> 2) << 8) +
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index 3ada808..1ca5887 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -85,7 +85,7 @@ public:
 	/**
 	 * Reads in a picture into the display bitmap.
 	 */
-	void readPict(Common::String filename, bool playOnce, bool onlyDiffData = false, byte *memoryBuffer = nullptr, uint16 maxHeight = 0);
+	void readPict(Common::String filename, bool playOnce = true, bool onlyDiffData = false, byte *memoryBuffer = nullptr, uint16 maxHeight = 0);
 	void freePict();
 
 	/**
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index cefc357..9ded7e2 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -331,7 +331,7 @@ bool LabEngine::doUse(uint16 curInv) {
 
 		_anim->_doBlack = false;
 		_anim->_waitForEffect = true;
-		_graphics->readPict("Music:Click", true);
+		_graphics->readPict("Music:Click");
 		_anim->_waitForEffect = false;
 
 		_anim->_doBlack = false;
@@ -461,7 +461,7 @@ void LabEngine::mainGameLoop() {
 					switch (_closeDataPtr->_closeUpType) {
 					case SPECIALLOCK:
 						if (_mainDisplay)
-							_tilePuzzle->showCombination(_curFileName.c_str());
+							_tilePuzzle->showCombination(_curFileName);
 						break;
 					case SPECIALBRICK:
 					case SPECIALBRICKNOMOUSE:
@@ -469,11 +469,11 @@ void LabEngine::mainGameLoop() {
 							_tilePuzzle->showTile(_curFileName, (_closeDataPtr->_closeUpType == SPECIALBRICKNOMOUSE));
 						break;
 					default:
-						_graphics->readPict(_curFileName.c_str(), false);
+						_graphics->readPict(_curFileName, false);
 						break;
 					}
 				} else
-					_graphics->readPict(_curFileName.c_str(), false);
+					_graphics->readPict(_curFileName, false);
 
 				drawRoomMessage(curInv, _closeDataPtr);
 				forceDraw = false;
@@ -553,15 +553,15 @@ void LabEngine::mainGameLoop() {
 
 void LabEngine::showLab2Teaser() {
 	_graphics->blackAllScreen();
-	_graphics->readPict("P:End/L2In.1", true);
+	_graphics->readPict("P:End/L2In.1");
 
 	for (uint16 i = 0; i < 120; i++) {
 		_music->updateMusic();
 		waitTOF();
 	}
 
-	_graphics->readPict("P:End/L2In.9", true);
-	_graphics->readPict("P:End/Lost", true);
+	_graphics->readPict("P:End/L2In.9");
+	_graphics->readPict("P:End/Lost");
 
 	while (!_event->getMsg() && !shouldQuit()) {
 		_music->updateMusic();
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index d3d37be..d467be9 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -291,7 +291,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 
 			if (test != _curFileName) {
 				_curFileName = test;
-				_graphics->readPict(_curFileName, true);
+				_graphics->readPict(_curFileName);
 			}
 			}
 			break;
@@ -339,7 +339,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			if (actionList->_param1 & 0x8000) {
 				// This is a Wyrmkeep Windows trial version, thus stop at this
 				// point, since we can't check for game payment status
-				_graphics->readPict(getPictName(closePtrList), true);
+				_graphics->readPict(getPictName(closePtrList));
 				actionList = nullptr;
 				GUI::MessageDialog trialMessage("This is the end of the trial version. You can play the full game using the original interpreter from Wyrmkeep");
 				trialMessage.runModal();
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 26ced8d..2ea481d 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -132,7 +132,7 @@ bool LabEngine::saveGame(int slot, Common::String desc) {
 
 	// Load scene pic
 	CloseDataPtr closePtr = nullptr;
-	_graphics->readPict(getPictName(&closePtr), true);
+	_graphics->readPict(getPictName(&closePtr));
 
 	writeSaveGameHeader(file, desc);
 	file->writeUint16LE(_roomNum);
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 3f5a3d0..ddc7ea4 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -448,10 +448,10 @@ void LabEngine::doMonitor(Common::String background, Common::String textfile, bo
 	_monitorTextFilename = textfile;
 
 	_graphics->blackAllScreen();
-	_graphics->readPict("P:Mon/Monitor.1", true);
-	_graphics->readPict("P:Mon/NWD1", true);
-	_graphics->readPict("P:Mon/NWD2", true);
-	_graphics->readPict("P:Mon/NWD3", true);
+	_graphics->readPict("P:Mon/Monitor.1");
+	_graphics->readPict("P:Mon/NWD1");
+	_graphics->readPict("P:Mon/NWD2");
+	_graphics->readPict("P:Mon/NWD3");
 	_graphics->blackAllScreen();
 
 	_monitorPage = 0;
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index cb93f25..a22f51f 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -175,7 +175,7 @@ void TilePuzzle::changeTile(uint16 col, uint16 row) {
 			// unlocked combination
 			_vm->_conditions->inclElement(BRICKOPEN);
 			_vm->_anim->_doBlack = true;
-			_vm->_graphics->readPict("p:Up/BDOpen", true);
+			_vm->_graphics->readPict("p:Up/BDOpen");
 		}
 	}
 }
@@ -254,7 +254,7 @@ void TilePuzzle::doTile(bool showsolution) {
 void TilePuzzle::showTile(const Common::String filename, bool showSolution) {
 	_vm->_anim->_doBlack = true;
 	_vm->_anim->_noPalChange = true;
-	_vm->_graphics->readPict(filename, true);
+	_vm->_graphics->readPict(filename);
 	_vm->_anim->_noPalChange = false;
 	_vm->_graphics->blackScreen();
 
@@ -379,10 +379,10 @@ void TilePuzzle::doCombination() {
 /**
  * Reads in a backdrop picture.
  */
-void TilePuzzle::showCombination(const char *filename) {
+void TilePuzzle::showCombination(const Common::String filename) {
 	_vm->_anim->_doBlack = true;
 	_vm->_anim->_noPalChange = true;
-	_vm->_graphics->readPict(filename, true);
+	_vm->_graphics->readPict(filename);
 	_vm->_anim->_noPalChange = false;
 
 	_vm->_graphics->blackScreen();
diff --git a/engines/lab/tilepuzzle.h b/engines/lab/tilepuzzle.h
index da159be..65870b0 100644
--- a/engines/lab/tilepuzzle.h
+++ b/engines/lab/tilepuzzle.h
@@ -52,7 +52,7 @@ public:
 	void mouseTile(Common::Point pos);
 	void showTile(const Common::String filename, bool showSolution);
 	void mouseCombination(Common::Point pos);
-	void showCombination(const char *filename);
+	void showCombination(const Common::String filename);
 	void save(Common::OutSaveFile *file);
 	void load(Common::InSaveFile *file);
 


Commit: 2edd0c51425db5e4407d38dbbeea788173f383b5
    https://github.com/scummvm/scummvm/commit/2edd0c51425db5e4407d38dbbeea788173f383b5
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:32+01:00

Commit Message:
LAB: Remove a couple of useless calls to c_Str()

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 9ded7e2..ee9ca42 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -207,7 +207,7 @@ bool LabEngine::doCloseUp(CloseDataPtr closePtr) {
 	case kMonitorMuseum:
 	case kMonitorLibrary:
 	case kMonitorWindow:
-		doMonitor(closePtr->_graphicName.c_str(), closePtr->_message.c_str(), false, textRect);
+		doMonitor(closePtr->_graphicName, closePtr->_message, false, textRect);
 		break;
 	case kMonitorGramophone:
 		textRect.right = 171;


Commit: b53735ba064012b3c981d5ef497d5f8c2e974291
    https://github.com/scummvm/scummvm/commit/b53735ba064012b3c981d5ef497d5f8c2e974291
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:32+01:00

Commit Message:
LAB: Constify some parameters

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/lab.h
    engines/lab/resource.cpp
    engines/lab/resource.h
    engines/lab/savegame.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 9dbaf8d3..d493e93 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -69,7 +69,6 @@ DisplayMan::~DisplayMan() {
 	delete[] _displayBuffer;
 }
 
-// From readPict.c.  Reads in pictures and animations from disk.
 void DisplayMan::loadPict(const Common::String filename) {
 	freePict();
 	_curBitmap = _vm->_resource->openDataFile(filename);
@@ -89,11 +88,9 @@ void DisplayMan::loadBackPict(const Common::String fileName, uint16 *highPal) {
 	_vm->_anim->_noPalChange = false;
 }
 
-void DisplayMan::readPict(Common::String filename, bool playOnce, bool onlyDiffData, byte *memoryBuffer, uint16 maxHeight) {
+void DisplayMan::readPict(const Common::String filename, bool playOnce, bool onlyDiffData, byte *memoryBuffer, uint16 maxHeight) {
 	_vm->_anim->stopDiff();
-
 	loadPict(filename);
-
 	_vm->_music->updateMusic();
 
 	if (!_vm->_music->_loopSoundEffect)
@@ -544,7 +541,7 @@ void DisplayMan::closeFont(TextFont **font) {
 	}
 }
 
-uint16 DisplayMan::textLength(TextFont *font, Common::String text) {
+uint16 DisplayMan::textLength(TextFont *font, const Common::String text) {
 	uint16 length = 0;
 
 	if (font) {
@@ -561,7 +558,7 @@ uint16 DisplayMan::textHeight(TextFont *tf) {
 	return (tf) ? tf->_height : 0;
 }
 
-void DisplayMan::drawText(TextFont *tf, uint16 x, uint16 y, uint16 color, Common::String text) {
+void DisplayMan::drawText(TextFont *tf, uint16 x, uint16 y, uint16 color, const Common::String text) {
 	byte *vgaTop = getCurrentDrawingBuffer();
 	int numChars = text.size();
 
@@ -730,7 +727,7 @@ void DisplayMan::copyPage(uint16 width, uint16 height, uint16 nheight, uint16 st
 	}
 }
 
-void DisplayMan::doScrollWipe(Common::String filename) {
+void DisplayMan::doScrollWipe(const Common::String filename) {
 	_vm->_event->mouseHide();
 	uint16 width = _vm->_utils->vgaScaleX(320);
 	uint16 height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
@@ -824,7 +821,7 @@ void DisplayMan::doScrollBounce() {
 	_vm->_event->mouseShow();
 }
 
-void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, Common::String filename) {
+void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, const Common::String filename) {
 	uint16 lastY, linesLast;
 
 	if (_vm->_isHiRes) {
@@ -911,7 +908,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, Common::String filename
 	delete[] bitMapBuffer;
 }
 
-void DisplayMan::doTransition(TransitionType transitionType, CloseDataPtr *closePtrList, Common::String filename) {
+void DisplayMan::doTransition(TransitionType transitionType, CloseDataPtr *closePtrList, const Common::String filename) {
 	switch (transitionType) {
 	case kTransitionWipe:
 	case kTransitionTransporter:
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index 1ca5887..a88923e 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -85,7 +85,7 @@ public:
 	/**
 	 * Reads in a picture into the display bitmap.
 	 */
-	void readPict(Common::String filename, bool playOnce = true, bool onlyDiffData = false, byte *memoryBuffer = nullptr, uint16 maxHeight = 0);
+	void readPict(const Common::String filename, bool playOnce = true, bool onlyDiffData = false, byte *memoryBuffer = nullptr, uint16 maxHeight = 0);
 	void freePict();
 
 	/**
@@ -97,7 +97,7 @@ public:
 	/**
 	 * Scrolls the display to a new picture from a black screen.
 	 */
-	void doScrollWipe(Common::String filename);
+	void doScrollWipe(const Common::String filename);
 
 	/**
 	 * Does the scroll bounce.  Assumes bitmap already in memory.
@@ -107,12 +107,12 @@ public:
 	/**
 	 * Does the transporter wipe.
 	 */
-	void doTransWipe(CloseDataPtr *closePtrList, Common::String filename);
+	void doTransWipe(CloseDataPtr *closePtrList, const Common::String filename);
 
 	/**
 	 * Does a certain number of pre-programmed wipes.
 	 */
-	void doTransition(TransitionType transitionType, CloseDataPtr *closePtrList, Common::String filename);
+	void doTransition(TransitionType transitionType, CloseDataPtr *closePtrList, const Common::String filename);
 
 	/**
 	 * Changes the front screen to black.
@@ -259,7 +259,7 @@ public:
 	/**
 	 * Returns the length of a text in the specified font.
 	 */
-	uint16 textLength(TextFont *font, Common::String text);
+	uint16 textLength(TextFont *font, const Common::String text);
 
 	/**
 	 * Returns the height of a specified font.
@@ -269,7 +269,7 @@ public:
 	/**
 	 * Draws the text to the screen.
 	 */
-	void drawText(TextFont *tf, uint16 x, uint16 y, uint16 color, Common::String text);
+	void drawText(TextFont *tf, uint16 x, uint16 y, uint16 color, const Common::String text);
 
 	/**
 	 * Gets a line of text for flowText; makes sure that its length is less than
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 295d913..74fbd2a 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -252,7 +252,7 @@ private:
 	/**
 	 * Does what's necessary for the monitor.
 	 */
-	void doMonitor(Common::String background, Common::String textfile, bool isinteractive, Common::Rect textRect);
+	void doMonitor(const Common::String background, const Common::String textfile, bool isinteractive, Common::Rect textRect);
 
 	/**
 	 * Does the things to properly set up the detective notes.
@@ -454,7 +454,7 @@ private:
 	void performAction(uint16 actionMode, Common::Point curPos, uint16 &curInv);
 
 private:
-	bool saveGame(int slot, Common::String desc);
+	bool saveGame(int slot, const Common::String desc);
 	bool loadGame(int slot);
 	void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName);
 };
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index a9d8441..b5ecb0b 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -164,43 +164,44 @@ void Resource::freeViews(uint16 roomNum) {
 	freeRule(_vm->_rooms[roomNum]._rules);
 }
 
-Common::String Resource::translateFileName(Common::String filename) {
-	filename.toUppercase();
+Common::String Resource::translateFileName(const Common::String filename) {
+	Common::String upperFilename = filename;
+	upperFilename.toUppercase();
 	Common::String fileNameStrFinal;
 
-	if (filename.hasPrefix("P:") || filename.hasPrefix("F:")) {
+	if (upperFilename.hasPrefix("P:") || upperFilename.hasPrefix("F:")) {
 		if (_vm->_isHiRes)
 			fileNameStrFinal = "GAME/SPICT/";
 		else
 			fileNameStrFinal = "GAME/PICT/";
 
 		if (_vm->getPlatform() == Common::kPlatformAmiga) {
-			if (filename.hasPrefix("P:")) {
+			if (upperFilename.hasPrefix("P:")) {
 				fileNameStrFinal = "PICT/";
 			} else {
 				fileNameStrFinal = "LABFONTS/";
-				filename += "T";	// all the Amiga fonts have a ".FONT" suffix
+				upperFilename += "T";	// all the Amiga fonts have a ".FONT" suffix
 			}
 		}
-	} else if (filename.hasPrefix("LAB:")) {
+	} else if (upperFilename.hasPrefix("LAB:")) {
 		if (_vm->getPlatform() != Common::kPlatformAmiga)
 			fileNameStrFinal = "GAME/";
-	} else if (filename.hasPrefix("MUSIC:")) {
+	} else if (upperFilename.hasPrefix("MUSIC:")) {
 		if (_vm->getPlatform() != Common::kPlatformAmiga)
 			fileNameStrFinal = "GAME/MUSIC/";
 		else
 			fileNameStrFinal = "MUSIC/";
 	}
 
-	if (filename.contains(':')) {
-		while (filename[0] != ':') {
-			filename.deleteChar(0);
+	if (upperFilename.contains(':')) {
+		while (upperFilename[0] != ':') {
+			upperFilename.deleteChar(0);
 		}
 
-		filename.deleteChar(0);
+		upperFilename.deleteChar(0);
 	}
 
-	fileNameStrFinal += filename;
+	fileNameStrFinal += upperFilename;
 
 	return fileNameStrFinal;
 }
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index f4aa357..73757e8 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -119,7 +119,7 @@ private:
 	ViewData *readView(Common::File *file);
 	void freeView(ViewData *view);
 	void readStaticText();
-	Common::String translateFileName(Common::String filename);
+	Common::String translateFileName(const Common::String filename);
 
 	Common::String _staticText[48];
 };
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 2ea481d..a0d7fe9 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -122,7 +122,7 @@ bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
 /**
  * Writes the game out to disk.
  */
-bool LabEngine::saveGame(int slot, Common::String desc) {
+bool LabEngine::saveGame(int slot, const Common::String desc) {
 	Common::String fileName = generateSaveFileName(slot);
 	Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
 	Common::OutSaveFile *file = saveFileManager->openForSaving(fileName);
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index ddc7ea4..946277b 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -443,7 +443,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 	}
 }
 
-void LabEngine::doMonitor(Common::String background, Common::String textfile, bool isinteractive, Common::Rect textRect) {
+void LabEngine::doMonitor(const Common::String background, const Common::String textfile, bool isinteractive, Common::Rect textRect) {
 	Common::Rect scaledRect = _utils->vgaRectScale(textRect.left, textRect.top, textRect.right, textRect.bottom);
 	_monitorTextFilename = textfile;
 


Commit: eba44d30949a9c4e9dc996a35b41c891fba8edf9
    https://github.com/scummvm/scummvm/commit/eba44d30949a9c4e9dc996a35b41c891fba8edf9
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:32+01:00

Commit Message:
LAB: Close _curBitmap before deleting it

Changed paths:
    engines/lab/dispman.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index d493e93..1123f94 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -105,8 +105,11 @@ void DisplayMan::readPict(const Common::String filename, bool playOnce, bool onl
 }
 
 void DisplayMan::freePict() {
-	delete _curBitmap;
-	_curBitmap = nullptr;
+	if (_curBitmap) {
+		_curBitmap->close();
+		delete _curBitmap;
+		_curBitmap = nullptr;
+	}
 }
 
 Common::String DisplayMan::getWord(const char *mainBuffer) {


Commit: 2eeb027604a470b8e5410751962734b677d605f1
    https://github.com/scummvm/scummvm/commit/2eeb027604a470b8e5410751962734b677d605f1
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:32+01:00

Commit Message:
LAB: Revert previous commit as suggested by wjp

Changed paths:
    engines/lab/dispman.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 1123f94..d493e93 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -105,11 +105,8 @@ void DisplayMan::readPict(const Common::String filename, bool playOnce, bool onl
 }
 
 void DisplayMan::freePict() {
-	if (_curBitmap) {
-		_curBitmap->close();
-		delete _curBitmap;
-		_curBitmap = nullptr;
-	}
+	delete _curBitmap;
+	_curBitmap = nullptr;
 }
 
 Common::String DisplayMan::getWord(const char *mainBuffer) {


Commit: fa222f0ca878b3bf55b439ccf0e1e0849cecfe63
    https://github.com/scummvm/scummvm/commit/fa222f0ca878b3bf55b439ccf0e1e0849cecfe63
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:32+01:00

Commit Message:
LAB: Make string check more readable, remove a useless c_str()

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/engine.cpp
    engines/lab/lab.cpp
    engines/lab/map.cpp
    engines/lab/processroom.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index d493e93..59d725b 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -231,7 +231,7 @@ void DisplayMan::createBox(uint16 y2) {
 }
 
 int DisplayMan::longDrawMessage(Common::String str) {
-	if (!str.size())
+	if (str.empty())
 		return 0;
 
 	_vm->_event->attachButtonList(nullptr);
@@ -256,22 +256,23 @@ void DisplayMan::drawMessage(Common::String str) {
 		return;
 	}
 
-	if (str.size()) {
-		if ((textLength(_vm->_msgFont, str) > _vm->_utils->vgaScaleX(306))) {
-			longDrawMessage(str);
-			_lastMessageLong = true;
-		} else {
-			if (_longWinInFront) {
-				_longWinInFront = false;
-				drawPanel();
-			}
+	if (str.empty())
+		return;
 
-			_vm->_event->mouseHide();
-			createBox(168);
-			drawText(_vm->_msgFont, _vm->_utils->vgaScaleX(7), _vm->_utils->vgaScaleY(155) + _vm->_utils->svgaCord(2), 1, str);
-			_vm->_event->mouseShow();
-			_lastMessageLong = false;
+	if ((textLength(_vm->_msgFont, str) > _vm->_utils->vgaScaleX(306))) {
+		longDrawMessage(str);
+		_lastMessageLong = true;
+	} else {
+		if (_longWinInFront) {
+			_longWinInFront = false;
+			drawPanel();
 		}
+
+		_vm->_event->mouseHide();
+		createBox(168);
+		drawText(_vm->_msgFont, _vm->_utils->vgaScaleX(7), _vm->_utils->vgaScaleY(155) + _vm->_utils->svgaCord(2), 1, str);
+		_vm->_event->mouseShow();
+		_lastMessageLong = false;
 	}
 }
 
@@ -857,7 +858,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, const Common::String fi
 		setPen(0);
 	}	// for j
 
-	if (!filename.size())
+	if (filename.empty())
 		_vm->_curFileName = _vm->getPictName(closePtrList);
 	else if (filename[0] > ' ')
 		_vm->_curFileName = filename;
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index ee9ca42..6cf86c2 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -127,7 +127,7 @@ void LabEngine::drawRoomMessage(uint16 curInv, CloseDataPtr closePtr) {
 	}
 
 	if (_alternate) {
-		if ((curInv <= _numInv) && _conditions->in(curInv) && _inventory[curInv]._bitmapName != "") {
+		if ((curInv <= _numInv) && _conditions->in(curInv) && !_inventory[curInv]._bitmapName.empty()) {
 			if ((curInv == kItemLamp) && _conditions->in(kCondLampOn))
 				// LAB: Labyrinth specific
 				drawStaticMessage(kTextkLampOn);
@@ -374,7 +374,7 @@ void LabEngine::decIncInv(uint16 *curInv, bool decreaseFl) {
 	interfaceOff();
 	
 	while (newInv && (newInv <= _numInv)) {
-		if (_conditions->in(newInv) && _inventory[newInv]._bitmapName != "") {
+		if (_conditions->in(newInv) && !_inventory[newInv]._bitmapName.empty()) {
 			_nextFileName = getInvName(newInv);
 			*curInv = newInv;
 			break;
@@ -968,7 +968,7 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 				curInv++;
 		}
 
-		if ((curInv <= _numInv) && _conditions->in(curInv) && _inventory[curInv]._bitmapName != "")
+		if ((curInv <= _numInv) && _conditions->in(curInv) && !_inventory[curInv]._bitmapName.empty())
 			_nextFileName = getInvName(curInv);
 
 		break;
@@ -1066,7 +1066,7 @@ void LabEngine::performAction(uint16 actionMode, Common::Point curPos, uint16 &c
 		if (_closeDataPtr == tmpClosePtr) {
 			if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 				drawStaticMessage(kTextNothing);
-		} else if (tmpClosePtr->_graphicName != "") {
+		} else if (!tmpClosePtr->_graphicName.empty()) {
 			_anim->_doBlack = true;
 			_closeDataPtr = tmpClosePtr;
 		} else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 5f3f40c..3336870 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -212,7 +212,7 @@ Common::String LabEngine::generateSaveFileName(uint slot) {
 }
 
 void LabEngine::drawStaticMessage(byte index) {
-	_graphics->drawMessage(_resource->getStaticText((StaticText)index).c_str());
+	_graphics->drawMessage(_resource->getStaticText((StaticText)index));
 }
 
 void LabEngine::changeVolume(int delta) {
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 84da359..63e3571 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -381,7 +381,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad
 		_graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 75, 134, 97), textPrt);
 	}
 
-	if (_rooms[curMsg]._roomMsg != "")
+	if (!_rooms[curMsg]._roomMsg.empty())
 		_graphics->flowText(_msgFont, 0, 5, 3, true, true, true, true, _utils->vgaRectScale(14, 148, 134, 186), _rooms[curMsg]._roomMsg.c_str());
 
 	if (fadeIn)
@@ -509,7 +509,7 @@ void LabEngine::processMap(uint16 curRoom) {
 					}
 
 					if (oldMsg != curMsg) {
-						if (_rooms[curMsg]._roomMsg != "")
+						if (!_rooms[curMsg]._roomMsg.empty())
 							_resource->readViews(curMsg);
 
 						const char *sptr;
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index d467be9..efabb8d 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -63,7 +63,7 @@ bool LabEngine::checkConditions(int16 *condition) {
 }
 
 ViewData *LabEngine::getViewData(uint16 roomNum, uint16 direction) {
-	if (_rooms[roomNum]._roomMsg == "")
+	if (!_rooms[roomNum]._roomMsg.empty())
 		_resource->readViews(roomNum);
 
 	ViewData *view = _rooms[roomNum]._view[direction];
@@ -131,17 +131,15 @@ Common::String LabEngine::getPictName(CloseDataPtr *closePtrList) {
 }
 
 void LabEngine::drawDirection(CloseDataPtr closePtr) {
-	if (closePtr && closePtr->_message != "") {
-		_graphics->drawMessage(closePtr->_message.c_str());
+	if (closePtr && !closePtr->_message.empty()) {
+		_graphics->drawMessage(closePtr->_message);
 		return;
 	}
 
 	Common::String message;
 
-	if (_rooms[_roomNum]._roomMsg != "") {
-		message = Common::String(_rooms[_roomNum]._roomMsg).c_str();
-		message += ", ";
-	}
+	if (!_rooms[_roomNum]._roomMsg.empty())
+		message = _rooms[_roomNum]._roomMsg + ", ";
 
 	if (_direction == NORTH)
 		message += _resource->getStaticText(kTextFacingNorth);
@@ -152,7 +150,7 @@ void LabEngine::drawDirection(CloseDataPtr closePtr) {
 	else if (_direction == WEST)
 		message += _resource->getStaticText(kTextFacingWest);
 
-	_graphics->drawMessage(message.c_str());
+	_graphics->drawMessage(message);
 }
 
 uint16 LabEngine::processArrow(uint16 curDirection, uint16 arrow) {
@@ -201,7 +199,7 @@ void LabEngine::setCurrentClose(Common::Point pos, CloseDataPtr *closePtrList, b
 		else
 			target = _utils->rectScale(closePtr->_x1, closePtr->_y1, closePtr->_x2, closePtr->_y2);
 
-		if (target.contains(pos) && closePtr->_graphicName != "") {
+		if (target.contains(pos) && !closePtr->_graphicName.empty()) {
 			*closePtrList = closePtr;
 			return;
 		}
@@ -267,7 +265,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			break;
 
 		case LOADDIFF:
-			if (actionList->_messages[0].size())
+			if (!actionList->_messages[0].empty())
 				// Puts a file into memory
 				_graphics->loadPict(actionList->_messages[0]);
 


Commit: 9b6851c1a73b57c262148a2d96ca7c07e32f96a5
    https://github.com/scummvm/scummvm/commit/9b6851c1a73b57c262148a2d96ca7c07e32f96a5
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:33+01:00

Commit Message:
LAB: Safeguard: Set some variables to null pointer after deleting them

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 6cf86c2..ad9cd9b 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -549,6 +549,11 @@ void LabEngine::mainGameLoop() {
 	delete _roomsFound;
 	delete[] _rooms;
 	delete[] _inventory;
+
+	_conditions = nullptr;
+	_roomsFound = nullptr;
+	_rooms = nullptr;
+	_inventory = nullptr;
 }
 
 void LabEngine::showLab2Teaser() {


Commit: be1fd471be362eff1d6e05bef8b8469655174b16
    https://github.com/scummvm/scummvm/commit/be1fd471be362eff1d6e05bef8b8469655174b16
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:33+01:00

Commit Message:
LAB: better fix of loadMapData, taking into account the other loops on _maps

Changed paths:
    engines/lab/map.cpp



diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index 63e3571..db0ba20 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -87,8 +87,8 @@ void LabEngine::loadMapData() {
 		_music->stopSoundEffect();
 
 	_maxRooms = mapFile->readUint16LE();
-	_maps = new MapData[_maxRooms];	// will be freed when the user exits the map
-	for (int i = 0; i < _maxRooms; i++) {
+	_maps = new MapData[_maxRooms + 1];	// will be freed when the user exits the map
+	for (int i = 1; i <= _maxRooms; i++) {
 		_maps[i]._x = mapFile->readUint16LE();
 		_maps[i]._y = mapFile->readUint16LE();
 		_maps[i]._pageNumber = mapFile->readUint16LE();


Commit: 6aad3aebd947867f967ef1292538bede13a6653b
    https://github.com/scummvm/scummvm/commit/6aad3aebd947867f967ef1292538bede13a6653b
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:33+01:00

Commit Message:
LAB: Move some more comments to header files

Changed paths:
    engines/lab/lab.h
    engines/lab/savegame.cpp
    engines/lab/tilepuzzle.cpp
    engines/lab/tilepuzzle.h
    engines/lab/utils.cpp
    engines/lab/utils.h



diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 74fbd2a..42b1305 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -454,7 +454,14 @@ private:
 	void performAction(uint16 actionMode, Common::Point curPos, uint16 &curInv);
 
 private:
+	/**
+	 * Writes the game out to disk.
+	 */
 	bool saveGame(int slot, const Common::String desc);
+
+	/**
+	 * Reads the game from disk.
+	 */
 	bool loadGame(int slot);
 	void writeSaveGameHeader(Common::OutSaveFile *out, const Common::String &saveName);
 };
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index a0d7fe9..70330a0 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -119,9 +119,6 @@ bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
 	return true;
 }
 
-/**
- * Writes the game out to disk.
- */
 bool LabEngine::saveGame(int slot, const Common::String desc) {
 	Common::String fileName = generateSaveFileName(slot);
 	Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
@@ -162,9 +159,6 @@ bool LabEngine::saveGame(int slot, const Common::String desc) {
 	return true;
 }
 
-/**
- * Reads the game from disk.
- */
 bool LabEngine::loadGame(int slot) {
 	Common::String fileName = generateSaveFileName(slot);
 	Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index a22f51f..54507fd 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -95,9 +95,6 @@ TilePuzzle::~TilePuzzle() {
 	}
 }
 
-/**
- * Processes mouse clicks and changes the combination.
- */
 void TilePuzzle::mouseTile(Common::Point pos) {
 	Common::Point realPos = _vm->_utils->vgaUnscale(pos);
 
@@ -111,9 +108,6 @@ void TilePuzzle::mouseTile(Common::Point pos) {
 		changeTile(tileX, tileY);
 }
 
-/**
- * Changes the combination number of one of the slots
- */
 void TilePuzzle::changeTile(uint16 col, uint16 row) {
 	int16 scrolltype = -1;
 
@@ -180,9 +174,6 @@ void TilePuzzle::changeTile(uint16 col, uint16 row) {
 	}
 }
 
-/**
- * Processes mouse clicks and changes the combination.
- */
 void TilePuzzle::mouseCombination(Common::Point pos) {
 	Common::Point realPos = _vm->_utils->vgaUnscale(pos);
 
@@ -206,9 +197,6 @@ void TilePuzzle::mouseCombination(Common::Point pos) {
 	changeCombination(number);
 }
 
-/**
- * Draws the images of the combination lock to the display bitmap.
- */
 void TilePuzzle::doTile(bool showsolution) {
 	uint16 row = 0, col = 0, rowm, colm, num;
 	int16 rows, cols;
@@ -248,9 +236,6 @@ void TilePuzzle::doTile(bool showsolution) {
 	}
 }
 
-/**
- * Reads in a backdrop picture.
- */
 void TilePuzzle::showTile(const Common::String filename, bool showSolution) {
 	_vm->_anim->_doBlack = true;
 	_vm->_anim->_noPalChange = true;
@@ -271,9 +256,6 @@ void TilePuzzle::showTile(const Common::String filename, bool showSolution) {
 	_vm->_graphics->setPalette(_vm->_anim->_diffPalette, 256);
 }
 
-/**
- * Does the scrolling for the tiles on the tile puzzle.
- */
 void TilePuzzle::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 	int16 dX = 0, dY = 0, dx = 0, dy = 0, sx = 0, sy = 0;
 	int last = 0;
@@ -315,9 +297,6 @@ void TilePuzzle::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 	delete[] buffer;
 }
 
-/**
- * Changes the combination number of one of the slots
- */
 void TilePuzzle::changeCombination(uint16 number) {
 	const int solution[6] = { 0, 4, 0, 8, 7, 2 };
 
@@ -368,17 +347,11 @@ void TilePuzzle::scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x
 		_vm->_graphics->scrollDisplayY(dy, x1, y1, x2, y2, buffer);
 }
 
-/**
- * Draws the images of the combination lock to the display bitmap.
- */
 void TilePuzzle::doCombination() {
 	for (int i = 0; i <= 5; i++)
 		_numberImages[_combination[i]]->drawImage(_vm->_utils->vgaScaleX(COMBINATION_X[i]), _vm->_utils->vgaScaleY(65));
 }
 
-/**
- * Reads in a backdrop picture.
- */
 void TilePuzzle::showCombination(const Common::String filename) {
 	_vm->_anim->_doBlack = true;
 	_vm->_anim->_noPalChange = true;
diff --git a/engines/lab/tilepuzzle.h b/engines/lab/tilepuzzle.h
index 65870b0..dd4abba 100644
--- a/engines/lab/tilepuzzle.h
+++ b/engines/lab/tilepuzzle.h
@@ -49,20 +49,54 @@ public:
 	TilePuzzle(LabEngine *vm);
 	virtual ~TilePuzzle();
 
+	/**
+	 * Processes mouse clicks and changes the combination.
+	 */
 	void mouseTile(Common::Point pos);
-	void showTile(const Common::String filename, bool showSolution);
+
+	/**
+	 * Processes mouse clicks and changes the combination.
+	 */
 	void mouseCombination(Common::Point pos);
+
+	/**
+	 * Reads in a backdrop picture.
+	 */
 	void showCombination(const Common::String filename);
+
+	/**
+	 * Reads in a backdrop picture.
+	 */
+	void showTile(const Common::String filename, bool showSolution);
 	void save(Common::OutSaveFile *file);
 	void load(Common::InSaveFile *file);
 
 private:
+	/**
+	 * Changes the combination number of one of the slots
+	 */
+	void changeCombination(uint16 number);
+
+	/**
+	 * Changes the combination number of one of the slots
+	 */
+	void changeTile(uint16 col, uint16 row);
+
+	/**
+	 * Draws the images of the combination lock to the display bitmap.
+	 */
+	void doCombination();
+
+	/**
+	 * Draws the images of the combination lock to the display bitmap.
+	 */
 	void doTile(bool showsolution);
+
+	/**
+	 * Does the scrolling for the tiles on the tile puzzle.
+	 */
 	void doTileScroll(uint16 col, uint16 row, uint16 scrolltype);
-	void changeCombination(uint16 number);
 	void scrollRaster(int16 dx, int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer);
-	void doCombination();
-	void changeTile(uint16 col, uint16 row);
 };
 
 } // End of namespace Lab
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index 3de1540..aeb76e6 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -38,10 +38,6 @@ Utils::Utils(LabEngine *vm) : _vm(vm), _rnd("lab") {
 	_dataBytesPerRow = 0;
 }
 
-/**
- * Scales the x co-ordinates to that of the new display.  In the room parser
- * file, co-ordinates are set up on a 360x336 display.
- */
 uint16 Utils::scaleX(uint16 x) {
 	if (_vm->_isHiRes)
 		return (uint16)((x * 16) / 9);
@@ -49,10 +45,6 @@ uint16 Utils::scaleX(uint16 x) {
 		return (uint16)((x * 8) / 9);
 }
 
-/**
- * Scales the y co-ordinates to that of the new display.  In the room parser
- * file, co-ordinates are set up on a 368x336 display.
- */
 uint16 Utils::scaleY(uint16 y) {
 	if (_vm->_isHiRes)
 		return (y + (y / 14));
@@ -82,9 +74,6 @@ Common::Rect Utils::mapRectScale(int16 x1, int16 y1, int16 x2, int16 y2) {
 	return Common::Rect(mapScaleX(x1), mapScaleY(y1), mapScaleX(x2), mapScaleY(y2));
 }
 
-/**
- * Scales the VGA coords to SVGA if necessary; otherwise, returns VGA coords.
- */
 int16 Utils::vgaScaleX(int16 x) {
 	if (_vm->_isHiRes)
 		return (x * 2);
@@ -92,9 +81,6 @@ int16 Utils::vgaScaleX(int16 x) {
 		return x;
 }
 
-/**
- * Scales the VGA coords to SVGA if necessary; otherwise, returns VGA coords.
- */
 int16 Utils::vgaScaleY(int16 y) {
 	if (_vm->_isHiRes)
 		return ((y * 12) / 5);
@@ -113,9 +99,6 @@ uint16 Utils::svgaCord(uint16 cord) {
 		return 0;
 }
 
-/**
- * Converts SVGA coords to VGA if necessary, otherwise returns VGA coords.
- */
 Common::Point Utils::vgaUnscale(Common::Point pos) {
 	Common::Point result;
 	if (_vm->_isHiRes) {
@@ -127,10 +110,6 @@ Common::Point Utils::vgaUnscale(Common::Point pos) {
 	return result;
 }
 
-/**
- * Undiffs a piece of memory when header size is a byte, and copy/skip size
- * is also a byte or a word.
- */
 template<typename T>
 void Utils::unDiff(T *dest, Common::File *sourceFile) {
 	byte bytesPerWord = sizeof(T);
@@ -162,12 +141,6 @@ void Utils::unDiff(T *dest, Common::File *sourceFile) {
 	}
 }
 
-/*------------------------- unDiff Vertical Memory --------------------------*/
-
-/**
- * Undiffs a piece of memory when header size is a byte, and copy/skip size
- * is a byte or a word or a double word.
- */
 template<typename T>
 void Utils::verticalUnDiff(T *dest, Common::File *sourceFile, uint16 bytesPerRow) {
 	uint16 counter = 0;
@@ -262,9 +235,6 @@ void Utils::verticalRunLengthDecode(byte *dest, Common::File *sourceFile, uint16
 	}
 }
 
-/**
- * Does the undiffing between the bitmaps.
- */
 void Utils::unDiff(byte *newBuf, byte *oldBuf, Common::File *sourceFile, uint16 bytesPerRow, bool isVertical) {
 	sourceFile->skip(1);
 	byte bufType = sourceFile->readByte();
diff --git a/engines/lab/utils.h b/engines/lab/utils.h
index 333d532..a7bb420 100644
--- a/engines/lab/utils.h
+++ b/engines/lab/utils.h
@@ -38,9 +38,16 @@ private:
 	LabEngine *_vm;
 	uint16 _dataBytesPerRow;
 
+	/**
+	 * Undiffs a piece of memory based on the header size.
+	 */
 	template<typename T>
 	void unDiff(T *dest, Common::File *sourceFile);
 
+	/**
+	 * Undiffs a piece of memory when header size is a byte, and copy/skip size
+	 * is a byte or a word or a double word.
+	 */
 	template<typename T>
 	void verticalUnDiff(T *dest, Common::File *sourceFile, uint16 bytesPerRow);
 
@@ -49,17 +56,42 @@ public:
 
 	Common::RandomSource _rnd;
 
+	/**
+	 * Scales the x co-ordinates to that of the new display.  In the room parser
+	 * file, co-ordinates are set up on a 360x336 display.
+	 */
 	uint16 scaleX(uint16 x);
+
+	/**
+	 * Scales the y co-ordinates to that of the new display.  In the room parser
+	 * file, co-ordinates are set up on a 368x336 display.
+	 */
 	uint16 scaleY(uint16 y);
 	Common::Rect rectScale(int16 x1, int16 y1, int16 x2, int16 y2);
+
+	/**
+	 * Scales the VGA x coords to SVGA if necessary; otherwise, returns VGA coords.
+	 */
 	int16 vgaScaleX(int16 x);
+
+	/**
+	 * Scales the VGA y coords to SVGA if necessary; otherwise, returns VGA coords.
+	 */
 	int16 vgaScaleY(int16 y);
 	Common::Rect vgaRectScale(int16 x1, int16 y1, int16 x2, int16 y2);
 	uint16 svgaCord(uint16 cord);
 	uint16 mapScaleX(uint16 x);
 	uint16 mapScaleY(uint16 y);
 	Common::Rect mapRectScale(int16 x1, int16 y1, int16 x2, int16 y2);
+
+	/**
+	 * Converts SVGA coords to VGA if necessary, otherwise returns VGA coords.
+	 */
 	Common::Point vgaUnscale(Common::Point pos);
+
+	/**
+	 * Does the undiffing between the bitmaps.
+	 */
 	void unDiff(byte *newBuf, byte *oldBuf, Common::File *sourceFile, uint16 bytesPerRow, bool isVertical);
 	void runLengthDecode(byte *dest, Common::File *sourceFile);
 	void verticalRunLengthDecode(byte *dest, Common::File *sourceFile, uint16 bytesPerRow);


Commit: 46f792d82d580b489e5251388e55644358563534
    https://github.com/scummvm/scummvm/commit/46f792d82d580b489e5251388e55644358563534
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:33+01:00

Commit Message:
LAB: Delete some more variables in LabEngine destructor

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



diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 3336870..1b92850 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -140,7 +140,10 @@ LabEngine::~LabEngine() {
 	for (uint16 i = 1; i <= _manyRooms; i++)
 		_resource->freeViews(i);
 	delete[] _rooms;
+	delete[] _inventory;
 
+	delete _conditions;
+	delete _roomsFound;
 	delete _event;
 	delete _resource;
 	delete _music;
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index 42b1305..db3ae2a 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -39,6 +39,7 @@
 #include "engines/savestate.h"
 
 #include "lab/image.h"
+#include "lab/labsets.h"
 
 struct ADGameDescription;
 
@@ -59,7 +60,6 @@ class Anim;
 class DisplayMan;
 class EventManager;
 class Image;
-class LargeSet;
 class Music;
 class Resource;
 class TilePuzzle;


Commit: 10baf6b9a2903c9d9ac0e8756ca161efdb233b07
    https://github.com/scummvm/scummvm/commit/10baf6b9a2903c9d9ac0e8756ca161efdb233b07
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:33+01:00

Commit Message:
LAB: Finish moving function comments to header

Changed paths:
    engines/lab/eventman.cpp
    engines/lab/eventman.h
    engines/lab/image.cpp
    engines/lab/image.h
    engines/lab/interface.cpp
    engines/lab/music.cpp
    engines/lab/music.h



diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 000aaa7..d2cf508 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -59,10 +59,6 @@ static const byte mouseData[] = {
 #define MOUSE_WIDTH 10
 #define MOUSE_HEIGHT 15
 
-/**
- * Checks whether or not the cords fall within one of the buttons in a list
- * of buttons.
- */
 Button *EventManager::checkButtonHit(ButtonList *buttonList, Common::Point pos) {
 	for (ButtonList::iterator buttonItr = buttonList->begin(); buttonItr != buttonList->end(); ++buttonItr) {
 		Button *button = *buttonItr;
@@ -151,9 +147,6 @@ void EventManager::updateMouse() {
 		_vm->_graphics->screenUpdate();
 }
 
-/**
- * Initializes the mouse.
- */
 void EventManager::initMouse() {
 	g_system->setMouseCursor(mouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0);
 	g_system->showMouse(false);
@@ -161,9 +154,6 @@ void EventManager::initMouse() {
 	setMousePos(Common::Point(0, 0));
 }
 
-/**
- * Shows the mouse.
- */
 void EventManager::mouseShow() {
 	if (_mouseHidden) {
 		processInput();
@@ -173,9 +163,6 @@ void EventManager::mouseShow() {
 	g_system->showMouse(true);
 }
 
-/**
- * Hides the mouse.
- */
 void EventManager::mouseHide() {
 	if (!_mouseHidden) {
 		_mouseHidden = true;
@@ -184,10 +171,6 @@ void EventManager::mouseHide() {
 	}
 }
 
-/**
- * Gets the current mouse co-ordinates.  NOTE: On IBM version, will scale
- * from virtual to screen co-ordinates automatically.
- */
 Common::Point EventManager::getMousePos() {
 	if (_vm->_isHiRes)
 		return _mousePos;
@@ -195,9 +178,6 @@ Common::Point EventManager::getMousePos() {
 		return Common::Point(_mousePos.x / 2, _mousePos.y);
 }
 
-/**
- * Moves the mouse to new co-ordinates.
- */
 void EventManager::setMousePos(Common::Point pos) {
 	if (_vm->_isHiRes)
 		g_system->warpMouse(pos.x, pos.y);
@@ -208,9 +188,6 @@ void EventManager::setMousePos(Common::Point pos) {
 		processInput();
 }
 
-/**
- * Checks whether or not a key has been pressed.
- */
 bool EventManager::keyPress(Common::KeyCode *keyCode) {
 	if (haveNextChar()) {
 		*keyCode = getNextChar();
diff --git a/engines/lab/eventman.h b/engines/lab/eventman.h
index eab5f31..9639721 100644
--- a/engines/lab/eventman.h
+++ b/engines/lab/eventman.h
@@ -87,11 +87,28 @@ private:
 	Common::KeyState _keyPressed;
 
 private:
+	/**
+	 * Checks whether or not the cords fall within one of the buttons in a list
+	 * of buttons.
+	 */
 	Button *checkButtonHit(ButtonList *buttonList, Common::Point pos);
+
+	/**
+	 * Checks whether or not a key has been pressed.
+	 */
 	bool keyPress(Common::KeyCode *keyCode);
 	bool haveNextChar();
 	Common::KeyCode getNextChar();
+
+	/**
+	 * Checks whether or not the coords fall within one of the buttons in a list
+	 * of buttons.
+	 */
 	Button *checkNumButtonHit(ButtonList *buttonList, uint16 key);
+
+	/**
+	 * Make a key press have the right case for a button KeyEquiv value.
+	 */
 	uint16 makeButtonKeyEquiv(uint16 key);
 
 public:
@@ -100,15 +117,40 @@ public:
 	void attachButtonList(ButtonList *buttonList);
 	Button *createButton(uint16 x, uint16 y, uint16 id, uint16 key, Image *image, Image *altImage);
 	void toggleButton(Button *button, uint16 penColor, bool enable);
+
+	/**
+	 * Draws a button list to the screen.
+	 */
 	void drawButtonList(ButtonList *buttonList);
 	void freeButtonList(ButtonList *buttonList);
 	Button *getButton(uint16 id);
+
+	/**
+	 * Gets the current mouse co-ordinates.  NOTE: On IBM version, will scale
+	 * from virtual to screen co-ordinates automatically.
+	 */
 	Common::Point getMousePos();
 	IntuiMessage *getMsg();
+
+	/**
+	 * Initializes the mouse.
+	 */
 	void initMouse();
+
+	/**
+	 * Shows the mouse.
+	 */
 	void mouseShow();
+
+	/**
+	 * Hides the mouse.
+	 */
 	void mouseHide();
 	void processInput();
+
+	/**
+	 * Moves the mouse to new co-ordinates.
+	 */
 	void setMousePos(Common::Point pos);
 	void updateMouse();
 	Common::Point updateAndGetMousePos();
diff --git a/engines/lab/image.cpp b/engines/lab/image.cpp
index 9b2b99d..ce0d543 100644
--- a/engines/lab/image.cpp
+++ b/engines/lab/image.cpp
@@ -37,9 +37,6 @@
 
 namespace Lab {
 
-/**
- * Reads in an image from disk.
- */
 Image::Image(Common::File *s, LabEngine *vm) : _vm(vm) {
 	_width = s->readUint16LE();
 	_height = s->readUint16LE();
@@ -57,9 +54,6 @@ Image::~Image() {
 	delete[] _imageData;
 }
 
-/**
- * Blits a piece of one image to another.
- */
 void Image::blitBitmap(uint16 xs, uint16 ys, Image *imDest,
 	uint16 xd, uint16 yd, uint16 width, uint16 height, byte masked) {
 	int w = width;
@@ -106,23 +100,14 @@ void Image::blitBitmap(uint16 xs, uint16 ys, Image *imDest,
 	}
 }
 
-/**
- * Draws an image to the screen.
- */
 void Image::drawImage(uint16 x, uint16 y) {
 	blitBitmap(0, 0, nullptr, x, y, _width, _height, false);
 }
 
-/**
- * Draws an image to the screen with transparency.
- */
 void Image::drawMaskImage(uint16 x, uint16 y) {
 	blitBitmap(0, 0, nullptr, x, y, _width, _height, true);
 }
 
-/**
- * Reads an image from the screen.
- */
 void Image::readScreenImage(uint16 x, uint16 y) {
 	int w = _width;
 	int h = _height;
diff --git a/engines/lab/image.h b/engines/lab/image.h
index e95125e..bac32cd 100644
--- a/engines/lab/image.h
+++ b/engines/lab/image.h
@@ -52,9 +52,24 @@ public:
 	Image(Common::File *s, LabEngine *vm);
 	virtual ~Image();
 
+	/**
+	 * Draws an image to the screen.
+	 */
 	void drawImage(uint16 x, uint16 y);
+
+	/**
+	 * Draws an image to the screen with transparency.
+	 */
 	void drawMaskImage(uint16 x, uint16 y);
+
+	/**
+	 * Reads an image from the screen.
+	 */
 	void readScreenImage(uint16 x, uint16 y);
+
+	/**
+	 * Blits a piece of one image to another.
+	 */
 	void blitBitmap(uint16 xs, uint16 ys, Image *ImDest, uint16 xd, uint16 yd, uint16 width, uint16 height, byte masked);
 };
 
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 41749f1..7fb3ba2 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -67,9 +67,6 @@ void EventManager::freeButtonList(ButtonList *buttonList) {
 	buttonList->clear();
 }
 
-/**
- * Draws a button list to the screen.
- */
 void EventManager::drawButtonList(ButtonList *buttonList) {
 	for (ButtonList::iterator button = buttonList->begin(); button != buttonList->end(); ++button) {
 		toggleButton((*button), 1, true);
@@ -88,9 +85,6 @@ void EventManager::toggleButton(Button *button, uint16 disabledPenColor, bool en
 	button->_isEnabled = enable;
 }
 
-/**
- * Make a key press have the right case for a button KeyEquiv value.
- */
 uint16 EventManager::makeButtonKeyEquiv(uint16 key) {
 	if (Common::isAlnum(key))
 		key = tolower(key);
@@ -98,10 +92,6 @@ uint16 EventManager::makeButtonKeyEquiv(uint16 key) {
 	return key;
 }
 
-/**
- * Checks whether or not the coords fall within one of the buttons in a list
- * of buttons.
- */
 Button *EventManager::checkNumButtonHit(ButtonList *buttonList, uint16 key) {
 	uint16 gkey = key - '0';
 
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 5ff23ea..78887f1 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -63,10 +63,6 @@ Music::Music(LabEngine *vm) : _vm(vm) {
 	_waitTillFinished = false;
 }
 
-/**
- * Figures out which buffer is currently playing based on messages sent to
- * it from the Audio device.
- */
 void Music::updateMusic() {
 	_vm->_event->processInput();
 	_vm->_event->updateMouse();
@@ -149,9 +145,6 @@ void Music::fillbuffer(byte *musicBuffer) {
 	}
 }
 
-/**
- * Starts up the music initially.
- */
 void Music::startMusic(bool restartFl) {
 	if (!_musicOn)
 		return;
@@ -167,9 +160,6 @@ void Music::startMusic(bool restartFl) {
 	updateMusic();
 }
 
-/**
- * Initializes the music buffers.
- */
 bool Music::initMusic(const Common::String filename) {
 	_musicOn = true;
 	_musicPaused = false;
@@ -178,9 +168,6 @@ bool Music::initMusic(const Common::String filename) {
 	return true;
 }
 
-/**
- * Frees up the music buffers and closes the file.
- */
 void Music::freeMusic() {
 	_musicOn = false;
 
@@ -192,9 +179,6 @@ void Music::freeMusic() {
 	_file = nullptr;
 }
 
-/**
- * Pauses the background music.
- */
 void Music::pauseBackMusic() {
 	if (!_musicPaused && _musicOn) {
 		updateMusic();
@@ -207,9 +191,6 @@ void Music::pauseBackMusic() {
 	}
 }
 
-/**
- * Resumes the paused background music.
- */
 void Music::resumeBackMusic() {
 	if (_musicPaused) {
 		stopSoundEffect();
@@ -222,9 +203,6 @@ void Music::resumeBackMusic() {
 	}
 }
 
-/**
- * Turns the music on and off.
- */
 void Music::setMusic(bool on) {
 	stopSoundEffect();
 
@@ -238,9 +216,6 @@ void Music::setMusic(bool on) {
 		_musicOn = on;
 }
 
-/**
- * Checks the music that should be playing in a particular room.
- */
 void Music::checkRoomMusic() {
 	if ((_lastMusicRoom == _vm->_roomNum) || !_musicOn)
 		return;
@@ -255,9 +230,6 @@ void Music::checkRoomMusic() {
 	_lastMusicRoom = _vm->_roomNum;
 }
 
-/**
- * Changes the background music to something else.
- */
 void Music::changeMusic(const Common::String filename) {
 	if (!_tFile) {
 		_tFile = _file;
@@ -278,9 +250,6 @@ void Music::changeMusic(const Common::String filename) {
 	setMusic(true);
 }
 
-/**
- * Changes the background music to the original piece playing.
- */
 void Music::resetMusic() {
 	if (!_tFile)
 		return;
@@ -308,9 +277,6 @@ void Music::resetMusic() {
 	_tFile = 0;
 }
 
-/**
- * Reads in a music file.  Ignores any graphics.
- */
 bool Music::readMusic(const Common::String filename, bool waitTillFinished) {
 	Common::File *file = _vm->_resource->openDataFile(filename, MKTAG('D', 'I', 'F', 'F'));
 	updateMusic();
diff --git a/engines/lab/music.h b/engines/lab/music.h
index a6f8369..857ea81 100644
--- a/engines/lab/music.h
+++ b/engines/lab/music.h
@@ -69,8 +69,16 @@ private:
 private:
 	void fillbuffer(byte *musicBuffer);
 	uint16 getPlayingBufferCount();
+
+	/**
+	 * Pauses the background music.
+	 */
 	void pauseBackMusic();
 	void readSound(bool waitTillFinished, Common::File *file);
+
+	/**
+	 * Starts up the music initially.
+	 */
 	void startMusic(bool restartFl);
 
 public:
@@ -80,18 +88,54 @@ public:
 public:
 	Music(LabEngine *vm);
 
+	/**
+	 * Changes the background music to something else.
+	 */
 	void changeMusic(const Common::String filename);
+
+	/**
+	 * Checks the music that should be playing in a particular room.
+	 */
 	void checkRoomMusic();
+
+	/**
+	 * Frees up the music buffers and closes the file.
+	 */
 	void freeMusic();
+
+	/**
+	 * Initializes the music buffers.
+	 */
 	bool initMusic(const Common::String filename);
 	bool isSoundEffectActive() const;
 	void playSoundEffect(uint16 sampleSpeed, uint32 length, Common::File *dataFile);
+
+	/**
+	 * Reads in a music file.  Ignores any graphics.
+	 */
 	bool readMusic(const Common::String filename, bool waitTillFinished);
+
+	/**
+	 * Changes the background music to the original piece playing.
+	 */
 	void resetMusic();
+
+	/**
+	 * Resumes the paused background music.
+	 */
 	void resumeBackMusic();
+
+	/**
+	 * Turns the music on and off.
+	 */
 	void setMusic(bool on);
 	void setMusicReset(bool reset) { _doReset = reset; }
 	void stopSoundEffect();
+
+	/**
+	 * Figures out which buffer is currently playing based on messages sent to
+	 * it from the Audio device.
+	 */
 	void updateMusic();
 };
 


Commit: 137e12bf95b26dbffa4bc3a29891dd6cfd46935a
    https://github.com/scummvm/scummvm/commit/137e12bf95b26dbffa4bc3a29891dd6cfd46935a
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:33+01:00

Commit Message:
LAB: Fix regression in intro

Changed paths:
    engines/lab/processroom.cpp



diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index efabb8d..2cc002b 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -63,7 +63,7 @@ bool LabEngine::checkConditions(int16 *condition) {
 }
 
 ViewData *LabEngine::getViewData(uint16 roomNum, uint16 direction) {
-	if (!_rooms[roomNum]._roomMsg.empty())
+	if (_rooms[roomNum]._roomMsg.empty())
 		_resource->readViews(roomNum);
 
 	ViewData *view = _rooms[roomNum]._view[direction];


Commit: df05be466e0e1e11e922dac643ebe8196d05f691
    https://github.com/scummvm/scummvm/commit/df05be466e0e1e11e922dac643ebe8196d05f691
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:33+01:00

Commit Message:
LAB: Fix readString when encrypted strings are stored with a wrong size and multiple \0

Changed paths:
    engines/lab/resource.cpp



diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index b5ecb0b..6142878 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -226,18 +226,19 @@ Common::File *Resource::openDataFile(const Common::String fileName, uint32 fileH
 Common::String Resource::readString(Common::File *file) {
 	byte size = file->readByte();
 	if (!size)
-		return nullptr;
+		return Common::String("");
 
-	Common::String str;
-	char c;
+	char *str = new char[size];
 	for (int i = 0; i < size; i++) {
-		c = file->readByte();
+		char c = file->readByte();
 		// Decrypt char
 		c = (i < size - 1) ? c - 95 : '\0';
-		str += c;
+		str[i] = c;
 	}
 
-	return str;
+	Common::String result = str;
+	delete str;
+	return result;
 }
 
 int16 *Resource::readConditions(Common::File *file) {


Commit: e88d09d2ecff4cdfae2cb07b96afd46efbbf98c5
    https://github.com/scummvm/scummvm/commit/e88d09d2ecff4cdfae2cb07b96afd46efbbf98c5
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:33+01:00

Commit Message:
LAB: Fix delete in previous commit

Changed paths:
    engines/lab/resource.cpp



diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 6142878..278222f 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -237,7 +237,7 @@ Common::String Resource::readString(Common::File *file) {
 	}
 
 	Common::String result = str;
-	delete str;
+	delete[] str;
 	return result;
 }
 


Commit: 26c48305b58b054bc81c1de37b7af9e79eb231bf
    https://github.com/scummvm/scummvm/commit/26c48305b58b054bc81c1de37b7af9e79eb231bf
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:34+01:00

Commit Message:
LAB: Add a couple of safeguards

Changed paths:
    engines/lab/resource.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 278222f..0e8c118 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -158,6 +158,9 @@ bool Resource::readViews(uint16 roomNum) {
 }
 
 void Resource::freeViews(uint16 roomNum) {
+	if (!_vm->_rooms)
+		return;
+
 	for (uint16 i = 0; i < 4; i++)
 		freeView(_vm->_rooms[roomNum]._view[i]);
 
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 946277b..32abde2 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -284,6 +284,8 @@ void LabEngine::doJournal() {
 
 	delete[] _blankJournal;
 	delete[] _journalBackImage->_imageData;
+	_blankJournal = _journalBackImage->_imageData = nullptr;
+
 	_event->freeButtonList(&_journalButtonList);
 	_graphics->closeFont(&_journalFont);
 


Commit: 02b606e3750490ce30bfc30a39118bc761c2d1bd
    https://github.com/scummvm/scummvm/commit/02b606e3750490ce30bfc30a39118bc761c2d1bd
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:34+01:00

Commit Message:
LAB: Avoid to delete _screenImage->_imageData, which causes a crash

Changed paths:
    engines/lab/lab.cpp



diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 1b92850..ecc9a42 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -152,6 +152,9 @@ LabEngine::~LabEngine() {
 	delete _tilePuzzle;
 	delete _utils;
 	delete _journalBackImage;
+	// _screenImage->_imageData is always pointing to the current drawing buffer.
+	// It shouldn't be deleted there.
+	_screenImage->_imageData = nullptr;
 	delete _screenImage;
 }
 


Commit: 108cbce3b5b8d4c5613e92c53e041972afcdc869
    https://github.com/scummvm/scummvm/commit/108cbce3b5b8d4c5613e92c53e041972afcdc869
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:34+01:00

Commit Message:
LAB: Remove useless assignments

Changed paths:
    engines/lab/special.cpp



diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 32abde2..900c2b3 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -85,9 +85,9 @@ void LabEngine::doWestPaper() {
 
 	paperFont = _resource->getFont("F:Note.fon");
 	paperText = _resource->getText("Lab:Rooms/Col1");
-	charsPrinted = _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(45, y, 158, 148), paperText.c_str());
+	_graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(45, y, 158, 148), paperText.c_str());
 	paperText = _resource->getText("Lab:Rooms/Col2");
-	charsPrinted = _graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(162, y, 275, 148), paperText.c_str());
+	_graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(162, y, 275, 148), paperText.c_str());
 	_graphics->closeFont(&paperFont);
 
 	_graphics->setPalette(_anim->_diffPalette, 256);


Commit: 503b63386628257ab79374afe4f7cca2b72b2527
    https://github.com/scummvm/scummvm/commit/503b63386628257ab79374afe4f7cca2b72b2527
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:34+01:00

Commit Message:
LAB: Remove useless casts and dead code

Changed paths:
    engines/lab/special.cpp



diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 900c2b3..9a21ee7 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -86,10 +86,11 @@ void LabEngine::doWestPaper() {
 	paperFont = _resource->getFont("F:Note.fon");
 	paperText = _resource->getText("Lab:Rooms/Col1");
 	_graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(45, y, 158, 148), paperText.c_str());
+
 	paperText = _resource->getText("Lab:Rooms/Col2");
 	_graphics->flowText(paperFont, -4, 0, 0, false, false, false, true, _utils->vgaRectScale(162, y, 275, 148), paperText.c_str());
-	_graphics->closeFont(&paperFont);
 
+	_graphics->closeFont(&paperFont);
 	_graphics->setPalette(_anim->_diffPalette, 256);
 }
 
@@ -130,10 +131,9 @@ void LabEngine::loadJournalData() {
 	_journalTextTitle = _resource->getText("Lab:Rooms/jt");
 
 	Common::File *journalFile = _resource->openDataFile("P:JImage");
-	Utils *utils = _utils;
-	_journalButtonList.push_back(_event->createButton( 80, utils->vgaScaleY(162) + utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile, this), new Image(journalFile, this)));	// back
-	_journalButtonList.push_back(_event->createButton(194, utils->vgaScaleY(162) + utils->svgaCord(1), 2,            0, new Image(journalFile, this), new Image(journalFile, this)));	// cancel
-	_journalButtonList.push_back(_event->createButton(144, utils->vgaScaleY(164) - utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile, this), new Image(journalFile, this)));	// forward
+	_journalButtonList.push_back(_event->createButton( 80, _utils->vgaScaleY(162) + _utils->svgaCord(1), 0, VKEY_LTARROW, new Image(journalFile, this), new Image(journalFile, this)));	// back
+	_journalButtonList.push_back(_event->createButton(194, _utils->vgaScaleY(162) + _utils->svgaCord(1), 2,            0, new Image(journalFile, this), new Image(journalFile, this)));	// cancel
+	_journalButtonList.push_back(_event->createButton(144, _utils->vgaScaleY(164) - _utils->svgaCord(1), 1, VKEY_RTARROW, new Image(journalFile, this), new Image(journalFile, this)));	// forward
 	delete journalFile;
 
 	_anim->_noPalChange = true;
@@ -155,7 +155,7 @@ void LabEngine::drawJournalText() {
 
 	while (drawingToPage < _journalPage) {
 		_music->updateMusic();
-		curText = (char *)(_journalText.c_str() + charsDrawn);
+		curText = _journalText.c_str() + charsDrawn;
 		charsDrawn += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, false, _utils->vgaRectScale(52, 32, 152, 148), curText);
 
 		_lastPage = (*curText == 0);
@@ -170,17 +170,14 @@ void LabEngine::drawJournalText() {
 		curText = _journalTextTitle.c_str();
 		_graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, true, true, true, _utils->vgaRectScale(52, 32, 152, 148), curText);
 	} else {
-		curText = (char *)(_journalText.c_str() + charsDrawn);
+		curText = _journalText.c_str() + charsDrawn;
 		charsDrawn += _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(52, 32, 152, 148), curText);
 	}
 
 	_music->updateMusic();
-	curText = (char *)(_journalText.c_str() + charsDrawn);
+	curText = _journalText.c_str() + charsDrawn;
 	_lastPage = (*curText == 0);
 	_graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(171, 32, 271, 148), curText);
-
-	curText = (char *)(_journalText.c_str() + charsDrawn);
-	_lastPage = (*curText == 0);
 }
 
 void LabEngine::turnPage(bool fromLeft) {
@@ -334,7 +331,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, Common::Rect text
 
 	while (drawingToPage < _monitorPage) {
 		_music->updateMusic();
-		curText = (char *)(text + charsDrawn);
+		curText = text + charsDrawn;
 		charsDrawn += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, textRect, curText);
 		_lastPage = (*curText == 0);
 
@@ -344,12 +341,9 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, Common::Rect text
 			drawingToPage++;
 	}
 
-	curText = (char *)(text + charsDrawn);
+	curText = text + charsDrawn;
 	_lastPage = (*curText == 0);
 	charsDrawn = _graphics->flowText(monitorFont, yspacing, 2, 0, false, false, false, true, textRect, curText);
-	curText += charsDrawn;
-	_lastPage |= (*curText == 0);
-
 	_event->mouseShow();
 }
 


Commit: 0823ebb36f7a464ea5986768c95d4e8d0adff3f9
    https://github.com/scummvm/scummvm/commit/0823ebb36f7a464ea5986768c95d4e8d0adff3f9
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:34+01:00

Commit Message:
LAB: Reduce the use of redirections in Resource

Changed paths:
    engines/lab/resource.cpp
    engines/lab/resource.h



diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 0e8c118..43820cf 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -94,7 +94,7 @@ Common::String Resource::getText(const Common::String fileName) {
 	return str;
 }
 
-bool Resource::readRoomData(const Common::String fileName) {
+void Resource::readRoomData(const Common::String fileName) {
 	Common::File *dataFile = openDataFile(fileName, MKTAG('D', 'O', 'R', '1'));
 
 	_vm->_manyRooms = dataFile->readUint16LE();
@@ -103,22 +103,22 @@ bool Resource::readRoomData(const Common::String fileName) {
 	memset(_vm->_rooms, 0, (_vm->_manyRooms + 1) * sizeof(RoomData));
 
 	for (uint16 i = 1; i <= _vm->_manyRooms; i++) {
-		_vm->_rooms[i]._doors[NORTH] = dataFile->readUint16LE();
-		_vm->_rooms[i]._doors[SOUTH] = dataFile->readUint16LE();
-		_vm->_rooms[i]._doors[EAST] = dataFile->readUint16LE();
-		_vm->_rooms[i]._doors[WEST] = dataFile->readUint16LE();
-		_vm->_rooms[i]._transitionType = dataFile->readByte();
-
-		_vm->_rooms[i]._view[NORTH] = nullptr;
-		_vm->_rooms[i]._view[SOUTH] = nullptr;
-		_vm->_rooms[i]._view[EAST] = nullptr;
-		_vm->_rooms[i]._view[WEST] = nullptr;
-		_vm->_rooms[i]._rules = nullptr;
-		_vm->_rooms[i]._roomMsg = "";
+		RoomData curRoom = _vm->_rooms[i];
+		curRoom._doors[NORTH] = dataFile->readUint16LE();
+		curRoom._doors[SOUTH] = dataFile->readUint16LE();
+		curRoom._doors[EAST] = dataFile->readUint16LE();
+		curRoom._doors[WEST] = dataFile->readUint16LE();
+		curRoom._transitionType = dataFile->readByte();
+
+		curRoom._view[NORTH] = nullptr;
+		curRoom._view[SOUTH] = nullptr;
+		curRoom._view[EAST] = nullptr;
+		curRoom._view[WEST] = nullptr;
+		curRoom._rules = nullptr;
+		curRoom._roomMsg = "";
 	}
 
 	delete dataFile;
-	return true;
 }
 
 InventoryData *Resource::readInventory(const Common::String fileName) {
@@ -134,27 +134,25 @@ InventoryData *Resource::readInventory(const Common::String fileName) {
 	}
 
 	delete dataFile;
-
 	return inventory;
 }
 
-bool Resource::readViews(uint16 roomNum) {
+void Resource::readViews(uint16 roomNum) {
 	Common::String fileName = "LAB:Rooms/" + Common::String::format("%d", roomNum);
 	Common::File *dataFile = openDataFile(fileName, MKTAG('R', 'O', 'M', '4'));
 
 	freeViews(roomNum);
+	RoomData curRoom = _vm->_rooms[roomNum];
 
-	_vm->_rooms[roomNum]._roomMsg = readString(dataFile);
-	_vm->_rooms[roomNum]._view[NORTH] = readView(dataFile);
-	_vm->_rooms[roomNum]._view[SOUTH] = readView(dataFile);
-	_vm->_rooms[roomNum]._view[EAST] = readView(dataFile);
-	_vm->_rooms[roomNum]._view[WEST] = readView(dataFile);
-	_vm->_rooms[roomNum]._rules = readRule(dataFile);
+	curRoom._roomMsg = readString(dataFile);
+	curRoom._view[NORTH] = readView(dataFile);
+	curRoom._view[SOUTH] = readView(dataFile);
+	curRoom._view[EAST] = readView(dataFile);
+	curRoom._view[WEST] = readView(dataFile);
+	curRoom._rules = readRule(dataFile);
 
 	_vm->_music->updateMusic();
-
 	delete dataFile;
-	return true;
 }
 
 void Resource::freeViews(uint16 roomNum) {
@@ -247,7 +245,7 @@ Common::String Resource::readString(Common::File *file) {
 int16 *Resource::readConditions(Common::File *file) {
 	int16 i = 0, cond;
 	int16 *list = new int16[25];
-	memset(list, 0, 25 * 2);
+	memset(list, 0, 25 * sizeof(int16));
 
 	do {
 		cond = file->readUint16LE();
@@ -287,7 +285,6 @@ void Resource::freeRule(RuleList *ruleList) {
 		freeAction((*rule)->_actionList);
 		delete[](*rule)->_condition;
 		delete *rule;
-		*rule = nullptr;
 	}
 
 	delete ruleList;
diff --git a/engines/lab/resource.h b/engines/lab/resource.h
index 73757e8..dcb7491 100644
--- a/engines/lab/resource.h
+++ b/engines/lab/resource.h
@@ -98,9 +98,9 @@ public:
 	~Resource() {}
 
 	Common::File *openDataFile(const Common::String fileName, uint32 fileHeader = 0);
-	bool readRoomData(const Common::String fileName);
+	void readRoomData(const Common::String fileName);
 	InventoryData *readInventory(const Common::String fileName);
-	bool readViews(uint16 roomNum);
+	void readViews(uint16 roomNum);
 	void freeViews(uint16 roomNum);
 	TextFont *getFont(const Common::String fileName);
 	Common::String getText(const Common::String fileName);


Commit: db99a31accd584d31be6e140bb52e592de0165bb
    https://github.com/scummvm/scummvm/commit/db99a31accd584d31be6e140bb52e592de0165bb
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:34+01:00

Commit Message:
LAB: Fix stupid regression

Changed paths:
    engines/lab/resource.cpp



diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 43820cf..a679899 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -103,19 +103,19 @@ void Resource::readRoomData(const Common::String fileName) {
 	memset(_vm->_rooms, 0, (_vm->_manyRooms + 1) * sizeof(RoomData));
 
 	for (uint16 i = 1; i <= _vm->_manyRooms; i++) {
-		RoomData curRoom = _vm->_rooms[i];
-		curRoom._doors[NORTH] = dataFile->readUint16LE();
-		curRoom._doors[SOUTH] = dataFile->readUint16LE();
-		curRoom._doors[EAST] = dataFile->readUint16LE();
-		curRoom._doors[WEST] = dataFile->readUint16LE();
-		curRoom._transitionType = dataFile->readByte();
-
-		curRoom._view[NORTH] = nullptr;
-		curRoom._view[SOUTH] = nullptr;
-		curRoom._view[EAST] = nullptr;
-		curRoom._view[WEST] = nullptr;
-		curRoom._rules = nullptr;
-		curRoom._roomMsg = "";
+		RoomData *curRoom = &_vm->_rooms[i];
+		curRoom->_doors[NORTH] = dataFile->readUint16LE();
+		curRoom->_doors[SOUTH] = dataFile->readUint16LE();
+		curRoom->_doors[EAST] = dataFile->readUint16LE();
+		curRoom->_doors[WEST] = dataFile->readUint16LE();
+		curRoom->_transitionType = dataFile->readByte();
+
+		curRoom->_view[NORTH] = nullptr;
+		curRoom->_view[SOUTH] = nullptr;
+		curRoom->_view[EAST] = nullptr;
+		curRoom->_view[WEST] = nullptr;
+		curRoom->_rules = nullptr;
+		curRoom->_roomMsg = "";
 	}
 
 	delete dataFile;
@@ -142,14 +142,14 @@ void Resource::readViews(uint16 roomNum) {
 	Common::File *dataFile = openDataFile(fileName, MKTAG('R', 'O', 'M', '4'));
 
 	freeViews(roomNum);
-	RoomData curRoom = _vm->_rooms[roomNum];
-
-	curRoom._roomMsg = readString(dataFile);
-	curRoom._view[NORTH] = readView(dataFile);
-	curRoom._view[SOUTH] = readView(dataFile);
-	curRoom._view[EAST] = readView(dataFile);
-	curRoom._view[WEST] = readView(dataFile);
-	curRoom._rules = readRule(dataFile);
+	RoomData *curRoom = &_vm->_rooms[roomNum];
+
+	curRoom->_roomMsg = readString(dataFile);
+	curRoom->_view[NORTH] = readView(dataFile);
+	curRoom->_view[SOUTH] = readView(dataFile);
+	curRoom->_view[EAST] = readView(dataFile);
+	curRoom->_view[WEST] = readView(dataFile);
+	curRoom->_rules = readRule(dataFile);
 
 	_vm->_music->updateMusic();
 	delete dataFile;


Commit: f3db3ba30559dffd16964fdddaa0d680fc31304a
    https://github.com/scummvm/scummvm/commit/f3db3ba30559dffd16964fdddaa0d680fc31304a
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:34+01:00

Commit Message:
LAB: Remove deletes from mainGameLoop

Those are already handled properly in the engine destructor, as pointed by eriktorbjorn

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index ad9cd9b..f16cdab 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -544,16 +544,6 @@ void LabEngine::mainGameLoop() {
 				break;
 		}
 	}
-
-	delete _conditions;
-	delete _roomsFound;
-	delete[] _rooms;
-	delete[] _inventory;
-
-	_conditions = nullptr;
-	_roomsFound = nullptr;
-	_rooms = nullptr;
-	_inventory = nullptr;
 }
 
 void LabEngine::showLab2Teaser() {


Commit: 7380ddf40035fa3a3c6d5e7974e8f9928d6e148a
    https://github.com/scummvm/scummvm/commit/7380ddf40035fa3a3c6d5e7974e8f9928d6e148a
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:34+01:00

Commit Message:
LAB:  Change RuleList to a Common::List<Rule> as suggested by wjp

Changed paths:
    engines/lab/lab.h
    engines/lab/processroom.cpp
    engines/lab/resource.cpp



diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index db3ae2a..ce8bae4 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -87,7 +87,7 @@ struct CrumbData {
 #define MAX_CRUMBS          128
 
 typedef CloseData *CloseDataPtr;
-typedef Common::List<Rule *> RuleList;
+typedef Common::List<Rule> RuleList;
 
 // Direction defines
 #define NORTH   0
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 2cc002b..7659287 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -516,13 +516,13 @@ bool LabEngine::doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr closeP
 		}
 
 		for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
-			if (((*rule)->_ruleType == ACTION) &&
-				(((*rule)->_param1 == action) || (((*rule)->_param1 == 0) && allowDefaults))) {
-				if ((((*rule)->_param2 == closePtr->_closeUpType) ||
-					  (((*rule)->_param2 == 0) && allowDefaults)) ||
-					  ((action == 1) && ((*rule)->_param2 == (-closePtr->_closeUpType)))) {
-					if (checkConditions((*rule)->_condition)) {
-						doActions((*rule)->_actionList, setCloseList);
+			if ((rule->_ruleType == ACTION) &&
+				((rule->_param1 == action) || ((rule->_param1 == 0) && allowDefaults))) {
+				if (((rule->_param2 == closePtr->_closeUpType) ||
+					  ((rule->_param2 == 0) && allowDefaults)) ||
+					  ((action == 1) && (rule->_param2 == -closePtr->_closeUpType))) {
+					if (checkConditions(rule->_condition)) {
+						doActions(rule->_actionList, setCloseList);
 						return true;
 					}
 				}
@@ -564,11 +564,11 @@ bool LabEngine::doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr clos
 			}
 
 			for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
-				if (((*rule)->_ruleType == OPERATE) &&
-					  (((*rule)->_param1 == itemNum) || (((*rule)->_param1 == 0) && allowDefaults)) &&
-						(((*rule)->_param2 == closePtr->_closeUpType) || (((*rule)->_param2 == 0) && allowDefaults))) {
-					if (checkConditions((*rule)->_condition)) {
-						doActions((*rule)->_actionList, setCloseList);
+				if ((rule->_ruleType == OPERATE) &&
+					  ((rule->_param1 == itemNum) || ((rule->_param1 == 0) && allowDefaults)) &&
+						((rule->_param2 == closePtr->_closeUpType) || ((rule->_param2 == 0) && allowDefaults))) {
+					if (checkConditions(rule->_condition)) {
+						doActions(rule->_actionList, setCloseList);
 						return true;
 					}
 				}
@@ -609,8 +609,7 @@ bool LabEngine::doOperateRule(Common::Point pos, int16 ItemNum, CloseDataPtr *cl
 bool LabEngine::doGoForward(CloseDataPtr *closePtrList) {
 	RuleList *rules = _rooms[_roomNum]._rules;
 
-	for (RuleList::iterator ruleIter = rules->begin(); ruleIter != rules->end(); ++ruleIter) {
-		Rule *rule = *ruleIter;
+	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
 		if ((rule->_ruleType == GOFORWARD) && (rule->_param1 == (_direction + 1))) {
 			if (checkConditions(rule->_condition)) {
 				doActions(rule->_actionList, closePtrList);
@@ -629,11 +628,11 @@ bool LabEngine::doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList) {
 	RuleList *rules = _rooms[_roomNum]._rules;
 
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
-		if (((*rule)->_ruleType == TURN) ||
-			  (((*rule)->_ruleType == TURNFROMTO) &&
-			  ((*rule)->_param1 == from) && ((*rule)->_param2 == to))) {
-			if (checkConditions((*rule)->_condition)) {
-				doActions((*rule)->_actionList, closePtrList);
+		if ((rule->_ruleType == TURN) ||
+			  ((rule->_ruleType == TURNFROMTO) &&
+			  (rule->_param1 == from) && (rule->_param2 == to))) {
+			if (checkConditions(rule->_condition)) {
+				doActions(rule->_actionList, closePtrList);
 				return true;
 			}
 		}
@@ -645,9 +644,9 @@ bool LabEngine::doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList) {
 bool LabEngine::doMainView(CloseDataPtr *closePtrList) {
 	RuleList *rules = _rooms[_roomNum]._rules;
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
-		if ((*rule)->_ruleType == GOMAINVIEW) {
-			if (checkConditions((*rule)->_condition)) {
-				doActions((*rule)->_actionList, closePtrList);
+		if (rule->_ruleType == GOMAINVIEW) {
+			if (checkConditions(rule->_condition)) {
+				doActions(rule->_actionList, closePtrList);
 				return true;
 			}
 		}
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index a679899..311f046 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -264,12 +264,12 @@ RuleList *Resource::readRule(Common::File *file) {
 		c = file->readByte();
 
 		if (c == 1) {
-			Rule *rule = new Rule();
-			rule->_ruleType = file->readSint16LE();
-			rule->_param1 = file->readSint16LE();
-			rule->_param2 = file->readSint16LE();
-			rule->_condition = readConditions(file);
-			rule->_actionList = readAction(file);
+			Rule rule;
+			rule._ruleType = file->readSint16LE();
+			rule._param1 = file->readSint16LE();
+			rule._param2 = file->readSint16LE();
+			rule._condition = readConditions(file);
+			rule._actionList = readAction(file);
 			rules->push_back(rule);
 		}
 	} while (c == 1);
@@ -282,9 +282,8 @@ void Resource::freeRule(RuleList *ruleList) {
 		return;
 
 	for (RuleList::iterator rule = ruleList->begin(); rule != ruleList->end(); ++rule) {
-		freeAction((*rule)->_actionList);
-		delete[](*rule)->_condition;
-		delete *rule;
+		freeAction(rule->_actionList);
+		delete[] rule->_condition;
 	}
 
 	delete ruleList;


Commit: be4c436dcaa960bceedd6d526041df06919bc225
    https://github.com/scummvm/scummvm/commit/be4c436dcaa960bceedd6d526041df06919bc225
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:34+01:00

Commit Message:
LAB: Move event update functions out of updateMusic

Changed paths:
    engines/lab/anim.cpp
    engines/lab/dispman.cpp
    engines/lab/engine.cpp
    engines/lab/intro.cpp
    engines/lab/lab.cpp
    engines/lab/lab.h
    engines/lab/map.cpp
    engines/lab/music.cpp
    engines/lab/processroom.cpp
    engines/lab/resource.cpp
    engines/lab/special.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 49dbe28..d59a571 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -130,7 +130,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 			return;
 		}
 
-		_vm->_music->updateMusic();
+		_vm->updateMusicAndEvents();
 		_header = _diffFile->readUint32LE();
 		_size = _diffFile->readUint32LE();
 
@@ -191,7 +191,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 		case 31:
 			if (_waitForEffect) {
 				while (_vm->_music->isSoundEffectActive()) {
-					_vm->_music->updateMusic();
+					_vm->updateMusicAndEvents();
 					_vm->waitTOF();
 				}
 			}
@@ -211,7 +211,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 
 				if (_waitForEffect) {
 					while (_vm->_music->isSoundEffectActive()) {
-						_vm->_music->updateMusic();
+						_vm->updateMusicAndEvents();
 						_vm->waitTOF();
 
 						if (_vm->_graphics->_dispBitMap->_drawOnScreen)
@@ -251,7 +251,7 @@ void Anim::stopDiffEnd() {
 
 	_stopPlayingEnd = true;
 	while (_isPlaying) {
-		_vm->_music->updateMusic();
+		_vm->updateMusicAndEvents();
 		diffNextFrame();
 	}
 }
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 59d725b..307a7f7 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -91,7 +91,7 @@ void DisplayMan::loadBackPict(const Common::String fileName, uint16 *highPal) {
 void DisplayMan::readPict(const Common::String filename, bool playOnce, bool onlyDiffData, byte *memoryBuffer, uint16 maxHeight) {
 	_vm->_anim->stopDiff();
 	loadPict(filename);
-	_vm->_music->updateMusic();
+	_vm->updateMusicAndEvents();
 
 	if (!_vm->_music->_loopSoundEffect)
 		_vm->_music->stopSoundEffect();
@@ -647,16 +647,16 @@ void DisplayMan::doScrollBlack() {
 	img._width = width;
 	img._height = height;
 	img._imageData = mem;
-	_vm->_music->updateMusic();
+	_vm->updateMusicAndEvents();
 	img.readScreenImage(0, 0);
-	_vm->_music->updateMusic();
+	_vm->updateMusicAndEvents();
 
 	byte *baseAddr = getCurrentDrawingBuffer();
 	uint16 by = _vm->_utils->vgaScaleX(4);
 	uint16 nheight = height;
 
 	while (nheight) {
-		_vm->_music->updateMusic();
+		_vm->updateMusicAndEvents();
 
 		if (!_vm->_isHiRes)
 			_vm->waitTOF();
@@ -734,7 +734,7 @@ void DisplayMan::doScrollWipe(const Common::String filename) {
 	uint16 height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
 
 	while (_vm->_music->isSoundEffectActive()) {
-		_vm->_music->updateMusic();
+		_vm->updateMusicAndEvents();
 		_vm->waitTOF();
 	}
 
@@ -742,13 +742,13 @@ void DisplayMan::doScrollWipe(const Common::String filename) {
 	setPalette(_vm->_anim->_diffPalette, 256);
 	byte *mem = _vm->_anim->_rawDiffBM._planes[0];
 
-	_vm->_music->updateMusic();
+	_vm->updateMusicAndEvents();
 	uint16 by = _vm->_utils->vgaScaleX(3);
 	uint16 nheight = height;
 	uint16 startLine = 0, onRow = 0;
 
 	while (onRow < _vm->_anim->_headerdata._height) {
-		_vm->_music->updateMusic();
+		_vm->updateMusicAndEvents();
 
 		if ((by > nheight) && nheight)
 			by = nheight;
@@ -798,11 +798,11 @@ void DisplayMan::doScrollBounce() {
 	int height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
 	byte *mem = _vm->_anim->_rawDiffBM._planes[0];
 
-	_vm->_music->updateMusic();
+	_vm->updateMusicAndEvents();
 	int startLine = _vm->_anim->_headerdata._height - height - 1;
 
 	for (int i = 0; i < 5; i++) {
-		_vm->_music->updateMusic();
+		_vm->updateMusicAndEvents();
 		startLine -= newby[i];
 		copyPage(width, height, 0, startLine, mem);
 
@@ -811,7 +811,7 @@ void DisplayMan::doScrollBounce() {
 	}
 
 	for (int i = 8; i > 0; i--) {
-		_vm->_music->updateMusic();
+		_vm->updateMusicAndEvents();
 		startLine += newby1[i - 1];
 		copyPage(width, height, 0, startLine, mem);
 
@@ -841,7 +841,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, const Common::String fi
 
 			while (curY < lastY) {
 				if (linesDone >= linesLast) {
-					_vm->_music->updateMusic();
+					_vm->updateMusicAndEvents();
 					_vm->waitTOF();
 					linesDone = 0;
 				}
@@ -886,7 +886,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, const Common::String fi
 
 			while (curY < lastY) {
 				if (linesDone >= linesLast) {
-					_vm->_music->updateMusic();
+					_vm->updateMusicAndEvents();
 					_vm->waitTOF();
 					linesDone = 0;
 				}
@@ -1045,7 +1045,7 @@ void DisplayMan::fade(bool fadeIn, uint16 res) {
 
 		setAmigaPal(newPal, 16);
 		_vm->waitTOF();
-		_vm->_music->updateMusic();
+		_vm->updateMusicAndEvents();
 	}
 }
 
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index f16cdab..b4c20b5 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -493,7 +493,7 @@ void LabEngine::mainGameLoop() {
 		}
 
 		// Make sure we check the music at least after every message
-		_music->updateMusic();
+		updateMusicAndEvents();
 		interfaceOn();
 		IntuiMessage *curMsg = _event->getMsg();
 		if (g_engine->shouldQuit()) {
@@ -505,7 +505,7 @@ void LabEngine::mainGameLoop() {
 			// Does music load and next animation frame when you've run out of messages
 			gotMessage = false;
 			_music->checkRoomMusic();
-			_music->updateMusic();
+			updateMusicAndEvents();
 			_anim->diffNextFrame();
 
 			if (_followingCrumbs) {
@@ -551,7 +551,7 @@ void LabEngine::showLab2Teaser() {
 	_graphics->readPict("P:End/L2In.1");
 
 	for (uint16 i = 0; i < 120; i++) {
-		_music->updateMusic();
+		updateMusicAndEvents();
 		waitTOF();
 	}
 
@@ -559,7 +559,7 @@ void LabEngine::showLab2Teaser() {
 	_graphics->readPict("P:End/Lost");
 
 	while (!_event->getMsg() && !shouldQuit()) {
-		_music->updateMusic();
+		updateMusicAndEvents();
 		_anim->diffNextFrame();
 		waitTOF();
 	}
@@ -728,7 +728,7 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &quali
 
 		while (1) {
 			// Make sure we check the music at least after every message
-			_music->updateMusic();
+			updateMusicAndEvents();
 			curMsg = _event->getMsg();
 
 			if (g_engine->shouldQuit())
@@ -736,7 +736,7 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &quali
 
 			if (!curMsg) {
 				// Does music load and next animation frame when you've run out of messages
-				_music->updateMusic();
+				updateMusicAndEvents();
 				_anim->diffNextFrame();
 			} else if (curMsg->_msgClass == kMessageRawKey) {
 				if ((curMsg->_code == Common::KEYCODE_y) || (curMsg->_code == Common::KEYCODE_q)) {
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 6b28db9..a60bd24 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -67,7 +67,7 @@ void Intro::doPictText(const Common::String filename, TextFont *msgFont, bool is
 	Common::String path = Common::String("Lab:rooms/Intro/") + filename;
 
 	uint timeDelay = (isScreen) ? 35 : 7;
-	_vm->_music->updateMusic();
+	_vm->updateMusicAndEvents();
 
 	if (_quitIntro)
 		return;
@@ -124,7 +124,7 @@ void Intro::doPictText(const Common::String filename, TextFont *msgFont, bool is
 		}
 
 		if (!msg) {
-			_vm->_music->updateMusic();
+			_vm->updateMusicAndEvents();
 			_vm->_anim->diffNextFrame();
 
 			uint32 elapsedSeconds = (g_system->getMillis() - lastMillis) / 1000;
@@ -190,13 +190,13 @@ void Intro::doPictText(const Common::String filename, TextFont *msgFont, bool is
 }
 
 void Intro::musicDelay() {
-	_vm->_music->updateMusic();
+	_vm->updateMusicAndEvents();
 
 	if (_quitIntro)
 		return;
 
 	for (uint16 i = 0; i < 20; i++) {
-		_vm->_music->updateMusic();
+		_vm->updateMusicAndEvents();
 		_vm->waitTOF();
 		_vm->waitTOF();
 		_vm->waitTOF();
@@ -206,7 +206,7 @@ void Intro::musicDelay() {
 void Intro::nReadPict(const Common::String filename, bool playOnce) {
 	Common::String finalFileName = Common::String("P:Intro/") + filename;
 
-	_vm->_music->updateMusic();
+	_vm->updateMusicAndEvents();
 	introEatMessages();
 
 	if (_quitIntro)
@@ -268,14 +268,14 @@ void Intro::introSequence() {
 					(_vm->_anim->_diffPalette[i * 3 + 2] >> 2);
 	}
 
-	_vm->_music->updateMusic();
+	_vm->updateMusicAndEvents();
 	_vm->_graphics->fade(true, 0);
 
 	for (int times = 0; times < 150; times++) {
 		if (_quitIntro)
 			break;
 
-		_vm->_music->updateMusic();
+		_vm->updateMusicAndEvents();
 		uint16 temp = palette[2];
 
 		for (uint16 i = 2; i < 15; i++)
@@ -289,7 +289,7 @@ void Intro::introSequence() {
 
 	_vm->_graphics->fade(false, 0);
 	_vm->_graphics->blackAllScreen();
-	_vm->_music->updateMusic();
+	_vm->updateMusicAndEvents();
 
 	nReadPict("Title.A");
 	nReadPict("AB");
@@ -311,9 +311,9 @@ void Intro::introSequence() {
 	nReadPict("DA");
 	musicDelay();
 
-	_vm->_music->updateMusic();
+	_vm->updateMusicAndEvents();
 	_vm->_graphics->blackAllScreen();
-	_vm->_music->updateMusic();
+	_vm->updateMusicAndEvents();
 
 	TextFont *msgFont = _vm->_resource->getFont("F:Map.fon");
 
@@ -334,7 +334,7 @@ void Intro::introSequence() {
 	}
 
 	_vm->_graphics->blackAllScreen();
-	_vm->_music->updateMusic();
+	_vm->updateMusicAndEvents();
 
 	_introDoBlack = true;
 	nReadPict("Station1");
@@ -369,7 +369,7 @@ void Intro::introSequence() {
 			for (uint16 idx = (8 * 3); idx < (255 * 3); idx++)
 				_vm->_anim->_diffPalette[idx] = 255 - _vm->_anim->_diffPalette[idx];
 
-			_vm->_music->updateMusic();
+			_vm->updateMusicAndEvents();
 			_vm->waitTOF();
 			_vm->_graphics->setPalette(_vm->_anim->_diffPalette, 256);
 			_vm->waitTOF();
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index ecc9a42..52a96eb 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -239,4 +239,10 @@ void LabEngine::waitTOF() {
 	_lastWaitTOFTicks = now;
 }
 
+void LabEngine::updateMusicAndEvents() {
+	_event->processInput();
+	_event->updateMouse();
+	_music->updateMusic();
+}
+
 } // End of namespace Lab
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index ce8bae4..fa7f850 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -196,6 +196,7 @@ public:
 	uint16 getQuarters();
 	void setDirection(uint16 direction) { _direction = direction; };
 	void setQuarters(uint16 quarters);
+	void updateMusicAndEvents();
 	void waitTOF();
 
 private:
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index db0ba20..b9f5703 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -82,7 +82,7 @@ void LabEngine::loadMapData() {
 	delete mapImages;
 
 	Common::File *mapFile = _resource->openDataFile("Lab:Maps", MKTAG('M', 'A', 'P', '0'));
-	_music->updateMusic();
+	updateMusicAndEvents();
 	if (!_music->_loopSoundEffect)
 		_music->stopSoundEffect();
 
@@ -344,7 +344,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad
 	for (uint16 i = 1; i <= _maxRooms; i++) {
 		if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x) {
 			drawRoomMap(i, (bool)(i == curRoom));
-			_music->updateMusic();
+			updateMusicAndEvents();
 		}
 	}
 
@@ -397,7 +397,7 @@ void LabEngine::processMap(uint16 curRoom) {
 
 	while (1) {
 		// Make sure we check the music at least after every message
-		_music->updateMusic();
+		updateMusicAndEvents();
 		IntuiMessage *msg = _event->getMsg();
 		if (g_engine->shouldQuit()) {
 			_quitLab = true;
@@ -405,7 +405,7 @@ void LabEngine::processMap(uint16 curRoom) {
 		}
 
 		if (!msg) {
-			_music->updateMusic();
+			updateMusicAndEvents();
 
 			byte newcolor[3];
 
@@ -554,7 +554,7 @@ void LabEngine::doMap(uint16 curRoom) {
 
 	_graphics->_fadePalette = amigaMapPalette;
 
-	_music->updateMusic();
+	updateMusicAndEvents();
 	loadMapData();
 	_graphics->blackAllScreen();
 	_event->attachButtonList(&_mapButtonList);
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 78887f1..a8dd281 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -64,34 +64,32 @@ Music::Music(LabEngine *vm) : _vm(vm) {
 }
 
 void Music::updateMusic() {
-	_vm->_event->processInput();
-	_vm->_event->updateMouse();
+	if (!_musicOn || (getPlayingBufferCount() >= MAXBUFFERS))
+		return;
 
-	if (_musicOn && (getPlayingBufferCount() < MAXBUFFERS)) {
-		// NOTE: We need to use malloc(), cause this will be freed with free()
-		// by the music code
-		byte *musicBuffer = (byte *)malloc(MUSICBUFSIZE);
-		fillbuffer(musicBuffer);
+	// NOTE: We need to use malloc(), cause this will be freed with free()
+	// by the music code
+	byte *musicBuffer = (byte *)malloc(MUSICBUFSIZE);
+	fillbuffer(musicBuffer);
 
-		// Queue a music block, and start the music, if needed
-		bool startMusicFlag = false;
+	// Queue a music block, and start the music, if needed
+	bool startMusicFlag = false;
 
-		if (!_queuingAudioStream) {
-			_queuingAudioStream = Audio::makeQueuingAudioStream(SAMPLESPEED, false);
-			startMusicFlag = true;
-		}
+	if (!_queuingAudioStream) {
+		_queuingAudioStream = Audio::makeQueuingAudioStream(SAMPLESPEED, false);
+		startMusicFlag = true;
+	}
 
-		byte soundFlags = Audio::FLAG_LITTLE_ENDIAN;
-		if (_vm->getPlatform() == Common::kPlatformWindows)
-			soundFlags |= Audio::FLAG_16BITS;
-		else if (_vm->getPlatform() == Common::kPlatformDOS)
-			soundFlags |= Audio::FLAG_UNSIGNED;
+	byte soundFlags = Audio::FLAG_LITTLE_ENDIAN;
+	if (_vm->getPlatform() == Common::kPlatformWindows)
+		soundFlags |= Audio::FLAG_16BITS;
+	else if (_vm->getPlatform() == Common::kPlatformDOS)
+		soundFlags |= Audio::FLAG_UNSIGNED;
 
-		_queuingAudioStream->queueBuffer(musicBuffer, MUSICBUFSIZE, DisposeAfterUse::YES, soundFlags);
+	_queuingAudioStream->queueBuffer(musicBuffer, MUSICBUFSIZE, DisposeAfterUse::YES, soundFlags);
 
-		if (startMusicFlag)
-			_vm->_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _queuingAudioStream);
-	}
+	if (startMusicFlag)
+		_vm->_mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, _queuingAudioStream);
 }
 
 uint16 Music::getPlayingBufferCount() {
@@ -157,7 +155,7 @@ void Music::startMusic(bool restartFl) {
 	}
 
 	_musicOn = true;
-	updateMusic();
+	_vm->updateMusicAndEvents();
 }
 
 bool Music::initMusic(const Common::String filename) {
@@ -181,7 +179,7 @@ void Music::freeMusic() {
 
 void Music::pauseBackMusic() {
 	if (!_musicPaused && _musicOn) {
-		updateMusic();
+		_vm->updateMusicAndEvents();
 		_musicOn = false;
 		stopSoundEffect();
 
@@ -198,7 +196,7 @@ void Music::resumeBackMusic() {
 
 		_vm->_mixer->pauseHandle(_musicHandle, false);
 
-		updateMusic();
+		_vm->updateMusicAndEvents();
 		_musicPaused = false;
 	}
 }
@@ -211,7 +209,7 @@ void Music::setMusic(bool on) {
 		startMusic(true);
 	} else if (!on && _musicOn) {
 		_musicOn = false;
-		updateMusic();
+		_vm->updateMusicAndEvents();
 	} else
 		_musicOn = on;
 }
@@ -264,7 +262,7 @@ void Music::resetMusic() {
 
 	_musicOn = true;
 	setMusic(false);
-	updateMusic();
+	_vm->updateMusicAndEvents();
 
 	if (!_oldMusicOn) {
 		_tFile = 0;
@@ -279,7 +277,7 @@ void Music::resetMusic() {
 
 bool Music::readMusic(const Common::String filename, bool waitTillFinished) {
 	Common::File *file = _vm->_resource->openDataFile(filename, MKTAG('D', 'I', 'F', 'F'));
-	updateMusic();
+	_vm->updateMusicAndEvents();
 	if (!_loopSoundEffect)
 		stopSoundEffect();
 
@@ -307,14 +305,14 @@ void Music::readSound(bool waitTillFinished, Common::File *file) {
 		return;
 
 	while (soundTag != 65535) {
-		updateMusic();
+		_vm->updateMusicAndEvents();
 		soundTag = file->readUint32LE();
 		soundSize = file->readUint32LE() - 8;
 
 		if ((soundTag == 30) || (soundTag == 31)) {
 			if (waitTillFinished) {
 				while (isSoundEffectActive()) {
-					updateMusic();
+					_vm->updateMusicAndEvents();
 					_vm->waitTOF();
 				}
 			}
@@ -327,7 +325,7 @@ void Music::readSound(bool waitTillFinished, Common::File *file) {
 		} else if (soundTag == 65535L) {
 			if (waitTillFinished) {
 				while (isSoundEffectActive()) {
-					updateMusic();
+					_vm->updateMusicAndEvents();
 					_vm->waitTOF();
 				}
 			}
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 7659287..0d09c37 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -235,7 +235,7 @@ bool LabEngine::takeItem(Common::Point pos, CloseDataPtr *closePtrList) {
 
 void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 	while (actionList) {
-		_music->updateMusic();
+		updateMusicAndEvents();
 
 		switch (actionList->_actionType) {
 		case PLAYSOUND:
@@ -387,7 +387,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 				_graphics->screenUpdate();
 
 				while (g_system->getMillis() < targetMillis) {
-					_music->updateMusic();
+					updateMusicAndEvents();
 					_anim->diffNextFrame();
 				}
 			}
@@ -412,12 +412,12 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			break;
 
 		case FILLMUSIC:
-			_music->updateMusic();
+			updateMusicAndEvents();
 			break;
 
 		case WAITSOUND:
 			while (_music->isSoundEffectActive()) {
-				_music->updateMusic();
+				updateMusicAndEvents();
 				_anim->diffNextFrame();
 				waitTOF();
 			}
@@ -497,7 +497,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 		_music->stopSoundEffect();
 	} else {
 		while (_music->isSoundEffectActive()) {
-			_music->updateMusic();
+			updateMusicAndEvents();
 			_anim->diffNextFrame();
 			waitTOF();
 		}
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 311f046..1063fd5 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -59,7 +59,7 @@ TextFont *Resource::getFont(const Common::String fileName) {
 	if (fileSize <= headerSize)
 		return nullptr;
 
-	_vm->_music->updateMusic();
+	_vm->updateMusicAndEvents();
 
 	TextFont *textfont = new TextFont();
 	textfont->_dataLength = fileSize - headerSize;
@@ -76,7 +76,7 @@ TextFont *Resource::getFont(const Common::String fileName) {
 Common::String Resource::getText(const Common::String fileName) {
 	Common::File *dataFile = openDataFile(fileName);
 
-	_vm->_music->updateMusic();
+	_vm->updateMusicAndEvents();
 
 	uint32 count = dataFile->size();
 	byte *buffer = new byte[count];
@@ -151,7 +151,7 @@ void Resource::readViews(uint16 roomNum) {
 	curRoom->_view[WEST] = readView(dataFile);
 	curRoom->_rules = readRule(dataFile);
 
-	_vm->_music->updateMusic();
+	_vm->updateMusicAndEvents();
 	delete dataFile;
 }
 
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 9a21ee7..7615c2d 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -99,7 +99,7 @@ void LabEngine::loadJournalData() {
 		_graphics->closeFont(&_journalFont);
 
 	_journalFont = _resource->getFont("F:Journal.fon");
-	_music->updateMusic();
+	updateMusicAndEvents();
 
 	Common::String filename = "Lab:Rooms/j0";
 
@@ -154,7 +154,7 @@ void LabEngine::drawJournalText() {
 	const char *curText = _journalText.c_str();
 
 	while (drawingToPage < _journalPage) {
-		_music->updateMusic();
+		updateMusicAndEvents();
 		curText = _journalText.c_str() + charsDrawn;
 		charsDrawn += _graphics->flowText(_journalFont, -2, 2, 0, false, false, false, false, _utils->vgaRectScale(52, 32, 152, 148), curText);
 
@@ -174,7 +174,7 @@ void LabEngine::drawJournalText() {
 		charsDrawn += _graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(52, 32, 152, 148), curText);
 	}
 
-	_music->updateMusic();
+	updateMusicAndEvents();
 	curText = _journalText.c_str() + charsDrawn;
 	_lastPage = (*curText == 0);
 	_graphics->flowTextToMem(_journalBackImage, _journalFont, -2, 2, 0, false, false, false, true, _utils->vgaRectScale(171, 32, 271, 148), curText);
@@ -183,14 +183,14 @@ void LabEngine::drawJournalText() {
 void LabEngine::turnPage(bool fromLeft) {
 	if (fromLeft) {
 		for (int i = 0; i < _graphics->_screenWidth; i += 8) {
-			_music->updateMusic();
+			updateMusicAndEvents();
 			waitTOF();
 			_screenImage->_imageData = _graphics->getCurrentDrawingBuffer();
 			_journalBackImage->blitBitmap(i, 0, _screenImage, i, 0, 8, _graphics->_screenHeight, false);
 		}
 	} else {
 		for (int i = (_graphics->_screenWidth - 8); i > 0; i -= 8) {
-			_music->updateMusic();
+			updateMusicAndEvents();
 			waitTOF();
 			_screenImage->_imageData = _graphics->getCurrentDrawingBuffer();
 			_journalBackImage->blitBitmap(i, 0, _screenImage, i, 0, 8, _graphics->_screenHeight, false);
@@ -200,7 +200,7 @@ void LabEngine::turnPage(bool fromLeft) {
 
 void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 	_event->mouseHide();
-	_music->updateMusic();
+	updateMusicAndEvents();
 	drawJournalText();
 	_graphics->loadBackPict("P:Journal.pic", _highPalette);
 
@@ -225,7 +225,7 @@ void LabEngine::drawJournal(uint16 wipenum, bool needFade) {
 void LabEngine::processJournal() {
 	while (1) {
 		// Make sure we check the music at least after every message
-		_music->updateMusic();
+		updateMusicAndEvents();
 		IntuiMessage *msg = _event->getMsg();
 		if (g_engine->shouldQuit()) {
 			_quitLab = true;
@@ -233,7 +233,7 @@ void LabEngine::processJournal() {
 		}
 
 		if (!msg)
-			_music->updateMusic();
+			updateMusicAndEvents();
 		else {
 			uint32 msgClass  = msg->_msgClass;
 			uint16 buttonId  = msg->_code;
@@ -269,7 +269,7 @@ void LabEngine::doJournal() {
 	_journalBackImage->_imageData = nullptr;
 	_screenImage->_imageData = _graphics->getCurrentDrawingBuffer();
 
-	_music->updateMusic();
+	updateMusicAndEvents();
 	loadJournalData();
 	_event->attachButtonList(&_journalButtonList);
 	drawJournal(0, true);
@@ -330,7 +330,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, Common::Rect text
 	}
 
 	while (drawingToPage < _monitorPage) {
-		_music->updateMusic();
+		updateMusicAndEvents();
 		curText = text + charsDrawn;
 		charsDrawn += _graphics->flowText(monitorFont, yspacing, 0, 0, false, false, false, false, textRect, curText);
 		_lastPage = (*curText == 0);
@@ -377,7 +377,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 		}
 
 		// Make sure we check the music at least after every message
-		_music->updateMusic();
+		updateMusicAndEvents();
 		IntuiMessage *msg = _event->getMsg();
 		if (g_engine->shouldQuit()) {
 			_quitLab = true;
@@ -385,7 +385,7 @@ void LabEngine::processMonitor(char *ntext, TextFont *monitorFont, bool isIntera
 		}
 
 		if (!msg) {
-			_music->updateMusic();
+			updateMusicAndEvents();
 		} else {
 			uint32 msgClass  = msg->_msgClass;
 			uint16 mouseX    = msg->_mouse.x;


Commit: 8c9d65b8cbfad71c9751d982ee15ea4be856f6d9
    https://github.com/scummvm/scummvm/commit/8c9d65b8cbfad71c9751d982ee15ea4be856f6d9
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:34+01:00

Commit Message:
LAB: Rename a member of Anim

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index d59a571..ee9fd64 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -68,7 +68,7 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 	_doBlack = false;
 	_diffWidth = 0;
 	_diffHeight = 0;
-	DrawBitMap = _vm->_graphics->_dispBitMap;
+	_drawBitMap = _vm->_graphics->_dispBitMap;
 
 	for (int i = 0; i < 3 * 256; i++)
 		_diffPalette[i] = 0;
@@ -145,14 +145,14 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 		case 10:
 			if (onlyDiffData)
 				warning("Boom");
-			_diffFile->read(DrawBitMap->_planes[_curBit], _size);
+			_diffFile->read(_drawBitMap->_planes[_curBit], _size);
 			_curBit++;
 			break;
 
 		case 11:
 			curPos = _diffFile->pos();
 			_diffFile->skip(4);
-			_vm->_utils->runLengthDecode(DrawBitMap->_planes[_curBit], _diffFile);
+			_vm->_utils->runLengthDecode(_drawBitMap->_planes[_curBit], _diffFile);
 			_curBit++;
 			_diffFile->seek(curPos + _size, SEEK_SET);
 			break;
@@ -160,21 +160,21 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 		case 12:
 			curPos = _diffFile->pos();
 			_diffFile->skip(4);
-			_vm->_utils->verticalRunLengthDecode(DrawBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow);
+			_vm->_utils->verticalRunLengthDecode(_drawBitMap->_planes[_curBit], _diffFile, _drawBitMap->_bytesPerRow);
 			_curBit++;
 			_diffFile->seek(curPos + _size, SEEK_SET);
 			break;
 
 		case 20:
 			curPos = _diffFile->pos();
-			_vm->_utils->unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, false);
+			_vm->_utils->unDiff(_drawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap->_planes[_curBit], _diffFile, _drawBitMap->_bytesPerRow, false);
 			_curBit++;
 			_diffFile->seek(curPos + _size, SEEK_SET);
 			break;
 
 		case 21:
 			curPos = _diffFile->pos();
-			_vm->_utils->unDiff(DrawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap->_planes[_curBit], _diffFile, DrawBitMap->_bytesPerRow, true);
+			_vm->_utils->unDiff(_drawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap->_planes[_curBit], _diffFile, _drawBitMap->_bytesPerRow, true);
 			_curBit++;
 			_diffFile->seek(curPos + _size, SEEK_SET);
 			break;
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 3c236f3..2a87cc5 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -71,7 +71,7 @@ private:
 	uint16 _sampleSpeed;
 	uint32 _diffWidth;
 	uint32 _diffHeight;
-	BitMap *DrawBitMap;
+	BitMap *_drawBitMap;
 
 public:
 	Anim(LabEngine *vm);


Commit: 8a3ff50d5c5f7a82c32f2b31ffc95a197acbf8d5
    https://github.com/scummvm/scummvm/commit/8a3ff50d5c5f7a82c32f2b31ffc95a197acbf8d5
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:34+01:00

Commit Message:
LAB: Remove _drawBitMap, make diffNextFrame a bit more readable

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index ee9fd64..dcf5718 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -68,7 +68,6 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 	_doBlack = false;
 	_diffWidth = 0;
 	_diffHeight = 0;
-	_drawBitMap = _vm->_graphics->_dispBitMap;
 
 	for (int i = 0; i < 3 * 256; i++)
 		_diffPalette[i] = 0;
@@ -79,13 +78,14 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 		// Already done.
 		return;
 
-	if (_vm->_graphics->_dispBitMap->_drawOnScreen)
-		_vm->_graphics->_dispBitMap->_planes[0] = _vm->_graphics->getCurrentDrawingBuffer();
+	BitMap *disp = _vm->_graphics->_dispBitMap;
+	if (disp->_drawOnScreen)
+		disp->_planes[0] = _vm->_graphics->getCurrentDrawingBuffer();
 
-	_vm->_graphics->_dispBitMap->_planes[1] = _vm->_graphics->_dispBitMap->_planes[0] + 0x10000;
-	_vm->_graphics->_dispBitMap->_planes[2] = _vm->_graphics->_dispBitMap->_planes[1] + 0x10000;
-	_vm->_graphics->_dispBitMap->_planes[3] = _vm->_graphics->_dispBitMap->_planes[2] + 0x10000;
-	_vm->_graphics->_dispBitMap->_planes[4] = _vm->_graphics->_dispBitMap->_planes[3] + 0x10000;
+	disp->_planes[1] = disp->_planes[0] + 0x10000;
+	disp->_planes[2] = disp->_planes[1] + 0x10000;
+	disp->_planes[3] = disp->_planes[2] + 0x10000;
+	disp->_planes[4] = disp->_planes[3] + 0x10000;
 
 	_vm->_event->mouseHide();
 
@@ -123,7 +123,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 			_isAnim = (_frameNum >= 3) && (!_playOnce);
 			_curBit = 0;
 
-			if (_vm->_graphics->_dispBitMap->_drawOnScreen)
+			if (disp->_drawOnScreen)
 				_vm->_graphics->screenUpdate();
 
 			// done with the next frame.
@@ -145,14 +145,14 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 		case 10:
 			if (onlyDiffData)
 				warning("Boom");
-			_diffFile->read(_drawBitMap->_planes[_curBit], _size);
+			_diffFile->read(disp->_planes[_curBit], _size);
 			_curBit++;
 			break;
 
 		case 11:
 			curPos = _diffFile->pos();
 			_diffFile->skip(4);
-			_vm->_utils->runLengthDecode(_drawBitMap->_planes[_curBit], _diffFile);
+			_vm->_utils->runLengthDecode(disp->_planes[_curBit], _diffFile);
 			_curBit++;
 			_diffFile->seek(curPos + _size, SEEK_SET);
 			break;
@@ -160,21 +160,21 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 		case 12:
 			curPos = _diffFile->pos();
 			_diffFile->skip(4);
-			_vm->_utils->verticalRunLengthDecode(_drawBitMap->_planes[_curBit], _diffFile, _drawBitMap->_bytesPerRow);
+			_vm->_utils->verticalRunLengthDecode(disp->_planes[_curBit], _diffFile, disp->_bytesPerRow);
 			_curBit++;
 			_diffFile->seek(curPos + _size, SEEK_SET);
 			break;
 
 		case 20:
 			curPos = _diffFile->pos();
-			_vm->_utils->unDiff(_drawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap->_planes[_curBit], _diffFile, _drawBitMap->_bytesPerRow, false);
+			_vm->_utils->unDiff(disp->_planes[_curBit], disp->_planes[_curBit], _diffFile, disp->_bytesPerRow, false);
 			_curBit++;
 			_diffFile->seek(curPos + _size, SEEK_SET);
 			break;
 
 		case 21:
 			curPos = _diffFile->pos();
-			_vm->_utils->unDiff(_drawBitMap->_planes[_curBit], _vm->_graphics->_dispBitMap->_planes[_curBit], _diffFile, _drawBitMap->_bytesPerRow, true);
+			_vm->_utils->unDiff(disp->_planes[_curBit], disp->_planes[_curBit], _diffFile, disp->_bytesPerRow, true);
 			_curBit++;
 			_diffFile->seek(curPos + _size, SEEK_SET);
 			break;
@@ -214,7 +214,7 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 						_vm->updateMusicAndEvents();
 						_vm->waitTOF();
 
-						if (_vm->_graphics->_dispBitMap->_drawOnScreen)
+						if (disp->_drawOnScreen)
 							didTOF = true;
 					}
 				}
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 2a87cc5..f958732 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -71,7 +71,6 @@ private:
 	uint16 _sampleSpeed;
 	uint32 _diffWidth;
 	uint32 _diffHeight;
-	BitMap *_drawBitMap;
 
 public:
 	Anim(LabEngine *vm);


Commit: 040fa45cf10bbd7196e0219dea4a302ed7064ed7
    https://github.com/scummvm/scummvm/commit/040fa45cf10bbd7196e0219dea4a302ed7064ed7
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:34+01:00

Commit Message:
LAB: Fix header define for Anim

Changed paths:
    engines/lab/anim.h



diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index f958732..9ffaaf7 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -28,8 +28,8 @@
  *
  */
 
-#ifndef LAB_DIFF_H
-#define LAB_DIFF_H
+#ifndef LAB_ANIM_H
+#define LAB_ANIM_H
 
 namespace Lab {
 
@@ -101,4 +101,4 @@ public:
 
 } // End of namespace Lab
 
-#endif // LAB_DIFF_H
+#endif // LAB_ANIM_H


Commit: 50a6cf12ef88503e2f5efd9e91dbc2768abb0f95
    https://github.com/scummvm/scummvm/commit/50a6cf12ef88503e2f5efd9e91dbc2768abb0f95
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:35+01:00

Commit Message:
LAB: Add a safeguard on numChunks

Changed paths:
    engines/lab/anim.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index dcf5718..d893c9c 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -321,6 +321,8 @@ void Anim::readDiff(Common::File *diffFile, bool playOnce, bool onlyDiffData) {
 
 		if ((uint32)(_numChunks * 0x10000) < (uint32)(((int32)_diffWidth) * _diffHeight))
 			_numChunks++;
+
+		assert (_numChunks < 16);
 	} else
 		return;
 


Commit: 966f82d82e523f9807655c7a06ccb98454c416d4
    https://github.com/scummvm/scummvm/commit/966f82d82e523f9807655c7a06ccb98454c416d4
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:35:35+01:00

Commit Message:
LAB: Clarify a bit the use of header in Anim

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index d893c9c..b3a5a8f 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -39,7 +39,7 @@
 namespace Lab {
 
 Anim::Anim(LabEngine *vm) : _vm(vm) {
-	_header = 0;
+	_lastBlockHeader = 0;
 	_curBit = 0;
 	_numChunks = 1;
 	_headerdata._width = 0;
@@ -74,7 +74,7 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 }
 
 void Anim::diffNextFrame(bool onlyDiffData) {
-	if (_header == 65535)
+	if (_lastBlockHeader == 65535)
 		// Already done.
 		return;
 
@@ -131,12 +131,12 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 		}
 
 		_vm->updateMusicAndEvents();
-		_header = _diffFile->readUint32LE();
+		_lastBlockHeader = _diffFile->readUint32LE();
 		_size = _diffFile->readUint32LE();
 
 		uint32 curPos = 0;
 
-		switch (_header) {
+		switch (_lastBlockHeader) {
 		case 8:
 			_diffFile->read(_diffPalette, _size);
 			_isPal = true;
@@ -259,7 +259,6 @@ void Anim::stopDiffEnd() {
 void Anim::readDiff(Common::File *diffFile, bool playOnce, bool onlyDiffData) {
 	_playOnce = playOnce;
 	_delayMicros = 0;
-	_header = 0;
 	_curBit = 0;
 	_frameNum = 0;
 	_numChunks = 1;
@@ -275,65 +274,66 @@ void Anim::readDiff(Common::File *diffFile, bool playOnce, bool onlyDiffData) {
 	_diffFile = diffFile;
 
 	_continuous = false;
-	uint32 signature = _diffFile->readUint32BE();
-	_header = _diffFile->readUint32LE();
+	uint32 signature1 = _diffFile->readUint32BE();
+	uint32 signature2 = _diffFile->readUint32LE();
 
-	if ((signature != MKTAG('D', 'I', 'F', 'F')) || (_header != 1219009121L)) {
+	if ((signature1 != MKTAG('D', 'I', 'F', 'F')) || (signature2 != 1219009121L)) {
 		_isPlaying = false;
 		return;
 	}
 
-	_header = _diffFile->readUint32LE();
+	uint32 signature3 = _diffFile->readUint32LE();
 	_size = _diffFile->readUint32LE();
 
-	if (_header == 0) {
-		// sizeof(headerdata) != 18, but the padding might be at the end
-		// 2 bytes, version, unused.
-		_diffFile->skip(2);
-		_headerdata._width = _diffFile->readUint16LE();
-		_headerdata._height = _diffFile->readUint16LE();
-		// 1 byte, depth, unused
-		_diffFile->skip(1);
-		_headerdata._fps = _diffFile->readByte();
+	if (signature3 != 0)
+		return;
 
-		// HACK: The original game defines a 1 second delay when changing screens, which is
-		// very annoying. We first removed the delay, but it looked wrong when changing screens
-		// as it was possible to see that something was displayed, without being able to tell
-		// what it was. A shorter delay (150ms) makes it acceptable during gameplay and
-		// readable. The big question is: do we need that message?
-		g_system->delayMillis(150);
+	// sizeof(headerdata) != 18, but the padding might be at the end
+	// 2 bytes, version, unused.
+	_diffFile->skip(2);
+	_headerdata._width = _diffFile->readUint16LE();
+	_headerdata._height = _diffFile->readUint16LE();
+	// 1 byte, depth, unused
+	_diffFile->skip(1);
+	_headerdata._fps = _diffFile->readByte();
 
-		if (_headerdata._fps == 1)
-			_headerdata._fps = 0;
+	// HACK: The original game defines a 1 second delay when changing screens, which is
+	// very annoying. We first removed the delay, but it looked wrong when changing screens
+	// as it was possible to see that something was displayed, without being able to tell
+	// what it was. A shorter delay (150ms) makes it acceptable during gameplay and
+	// readable. The big question is: do we need that message?
+	g_system->delayMillis(150);
 
-		// 4 + 2 bytes, buffer size and machine, unused
-		_diffFile->skip(6);
-		_headerdata._flags = _diffFile->readUint32LE();
+	if (_headerdata._fps == 1)
+		_headerdata._fps = 0;
 
-		_diffFile->skip(_size - 18);
+	// 4 + 2 bytes, buffer size and machine, unused
+	_diffFile->skip(6);
+	_headerdata._flags = _diffFile->readUint32LE();
 
-		_continuous = CONTINUOUS & _headerdata._flags;
-		_diffWidth = _headerdata._width;
-		_diffHeight = _headerdata._height;
-		_vm->_utils->setBytesPerRow(_diffWidth);
+	_diffFile->skip(_size - 18);
 
-		_numChunks = (((int32)_diffWidth) * _diffHeight) / 0x10000;
+	_continuous = CONTINUOUS & _headerdata._flags;
+	_diffWidth = _headerdata._width;
+	_diffHeight = _headerdata._height;
+	_vm->_utils->setBytesPerRow(_diffWidth);
 
-		if ((uint32)(_numChunks * 0x10000) < (uint32)(((int32)_diffWidth) * _diffHeight))
-			_numChunks++;
+	_numChunks = (((int32)_diffWidth) * _diffHeight) / 0x10000;
 
-		assert (_numChunks < 16);
-	} else
-		return;
+	if ((uint32)(_numChunks * 0x10000) < (uint32)(((int32)_diffWidth) * _diffHeight))
+		_numChunks++;
 
-	for (_header = 0; _header < 8; _header++)
-		_rawDiffBM._planes[_header] = nullptr;
+	assert(_numChunks < 16);
+
+	for (int i = 0; i < 8; i++)
+		_rawDiffBM._planes[i] = nullptr;
 
 	if (_headerdata._fps)
 		_delayMicros = 1000 / _headerdata._fps;
 
+	_lastBlockHeader = signature3;
 	if (_playOnce) {
-		while (_header != 65535)
+		while (_lastBlockHeader != 65535)
 			diffNextFrame(onlyDiffData);
 	} else
 		diffNextFrame(onlyDiffData);
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 9ffaaf7..563f281 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -53,7 +53,7 @@ class Anim {
 private:
 	LabEngine *_vm;
 
-	uint32 _header;
+	uint32 _lastBlockHeader;
 	uint16 _curBit;
 	uint16 _numChunks;
 	uint32 _delayMicros;


Commit: f59ccf534cc357d4cde1889fc9ff3ad852d73360
    https://github.com/scummvm/scummvm/commit/f59ccf534cc357d4cde1889fc9ff3ad852d73360
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:35:35+01:00

Commit Message:
LAB: Get rid of the _doNotDrawMessage hack (from the original)

This is actually a nasty hack in the original to avoid duplicate
messages, but it ended up hiding some game messages. This hack isn't
really necessary at all for game functionality, so it has been
removed, without any notable side-effects

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/engine.cpp
    engines/lab/processroom.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 307a7f7..55c66cd 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -45,7 +45,6 @@ namespace Lab {
 DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) {
 	_longWinInFront = false;
 	_lastMessageLong = false;
-	_doNotDrawMessage = false;
 
 	_screenBytesPerPage = 65536;
 	_curPen = 0;
@@ -251,11 +250,6 @@ int DisplayMan::longDrawMessage(Common::String str) {
 }
 
 void DisplayMan::drawMessage(Common::String str) {
-	if (_doNotDrawMessage) {
-		_doNotDrawMessage = false;
-		return;
-	}
-
 	if (str.empty())
 		return;
 
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index a88923e..b5e1248 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -284,7 +284,6 @@ public:
 	int _screenHeight;
 	byte *_displayBuffer;
 	byte *_currentDisplayBuffer;
-	bool _doNotDrawMessage;
 	uint16 *_fadePalette;
 	BitMap *_dispBitMap;
 };
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index b4c20b5..4a977d8 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -592,7 +592,6 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 	if (_graphics->_longWinInFront) {
 		if ((msgClass == kMessageRawKey) || (leftButtonClick || rightButtonClick)) {
 			_graphics->_longWinInFront = false;
-			_graphics->_doNotDrawMessage = false;
 			_graphics->drawPanel();
 			drawRoomMessage(curInv, _closeDataPtr);
 			_graphics->screenUpdate();
@@ -628,7 +627,6 @@ bool LabEngine::fromCrumbs(uint32 tmpClass, uint16 code, uint16 qualifier, Commo
 		eatMessages();
 		_alternate = !_alternate;
 		_anim->_doBlack = true;
-		_graphics->_doNotDrawMessage = false;
 		_mainDisplay = true;
 		// Sets the correct button list
 		interfaceOn();
@@ -701,7 +699,6 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &quali
 					eatMessages();
 					_alternate = false;
 					_anim->_doBlack = true;
-					_graphics->_doNotDrawMessage = false;
 
 					_mainDisplay = true;
 					// Sets the correct button list
@@ -721,7 +718,6 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &quali
 		}
 	} else if ((code == Common::KEYCODE_x) || (code == Common::KEYCODE_q)) {
 		// Quit?
-		_graphics->_doNotDrawMessage = false;
 		_graphics->drawMessage("Do you want to quit? (Y/N)");
 		eatMessages();
 		interfaceOff();
@@ -792,7 +788,6 @@ void LabEngine::processMainButton(uint16 &curInv, uint16 &lastInv, uint16 &oldDi
 
 		_alternate = true;
 		_anim->_doBlack = true;
-		_graphics->_doNotDrawMessage = false;
 		// Sets the correct button list
 		interfaceOn();
 		_mainDisplay = false;
@@ -909,7 +904,6 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 		eatMessages();
 		_alternate = false;
 		_anim->_doBlack = true;
-		_graphics->_doNotDrawMessage = false;
 
 		_mainDisplay = true;
 		// Sets the correct button list
@@ -971,14 +965,12 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 	case kButtonPrevItem:
 		decIncInv(&curInv, true);
 		lastInv = curInv;
-		_graphics->_doNotDrawMessage = false;
 		drawRoomMessage(curInv, _closeDataPtr);
 		break;
 
 	case kButtonNextItem:
 		decIncInv(&curInv, false);
 		lastInv = curInv;
-		_graphics->_doNotDrawMessage = false;
 		drawRoomMessage(curInv, _closeDataPtr);
 		break;
 
@@ -1001,7 +993,6 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 				eatMessages();
 				_alternate = false;
 				_anim->_doBlack = true;
-				_graphics->_doNotDrawMessage = false;
 
 				_mainDisplay = true;
 				// Sets the correct button list
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 0d09c37..71f53e1 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -302,35 +302,20 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			_conditions->exclElement(actionList->_param1);
 			break;
 
-		case SHOWMESSAGE: {
-			_graphics->_doNotDrawMessage = false;
-
-			Common::String text = actionList->_messages[0];
+		case SHOWMESSAGE:
 			if (_graphics->_longWinInFront)
-				_graphics->longDrawMessage(text);
+				_graphics->longDrawMessage(actionList->_messages[0]);
 			else
-				_graphics->drawMessage(text);
-
-			_graphics->_doNotDrawMessage = true;
-			}
+				_graphics->drawMessage(actionList->_messages[0]);
 			break;
 
 		case CSHOWMESSAGE:
-			if (!*closePtrList) {
-				Common::String text = actionList->_messages[0];
-				_graphics->_doNotDrawMessage = false;
-				_graphics->drawMessage(text);
-				_graphics->_doNotDrawMessage = true;
-			}
-
+			if (!*closePtrList)
+				_graphics->drawMessage(actionList->_messages[0]);
 			break;
 
-		case SHOWMESSAGES: {
-			Common::String *str = actionList->_messages;
-			_graphics->_doNotDrawMessage = false;
-			_graphics->drawMessage(str[_utils->getRandom(actionList->_param1)]);
-			_graphics->_doNotDrawMessage = true;
-			}
+		case SHOWMESSAGES:
+			_graphics->drawMessage(actionList->_messages[_utils->getRandom(actionList->_param1)]);
 			break;
 
 		case SETPOSITION:
@@ -378,7 +363,11 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			break;
 
 		case SHOWDIR:
-			_graphics->_doNotDrawMessage = false;
+			// Originally, this set _doNotDrawMessage to false, so that the
+			// message would be shown by drawMessage(). However, _doNotDrawMEssage
+			// ended up hiding subsequent game messages, so this call is actually
+			// a nasty hack, and has been removed in ScummVM without any notable
+			// side-effects.
 			break;
 
 		case WAITSECS: {


Commit: ced5b677f63dcb53fc0606bf9578b1fff6981075
    https://github.com/scummvm/scummvm/commit/ced5b677f63dcb53fc0606bf9578b1fff6981075
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:35:35+01:00

Commit Message:
LAB: Add enums for action types, rule types ad rule actions

Changed paths:
    engines/lab/engine.cpp
    engines/lab/processroom.cpp
    engines/lab/processroom.h
    engines/lab/resource.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 4a977d8..3350dd7 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -1023,9 +1023,9 @@ void LabEngine::performAction(uint16 actionMode, Common::Point curPos, uint16 &c
 			_curFileName = _newFileName;
 		else if (takeItem(curPos, &_closeDataPtr))
 			drawStaticMessage(kTextTakeItem);
-		else if (doActionRule(curPos, TAKEDEF - 1, _roomNum, &_closeDataPtr))
+		else if (doActionRule(curPos, kRuleActionTakeDef, _roomNum, &_closeDataPtr))
 			_curFileName = _newFileName;
-		else if (doActionRule(curPos, TAKE - 1, 0, &_closeDataPtr))
+		else if (doActionRule(curPos, kRuleActionTake, 0, &_closeDataPtr))
 			_curFileName = _newFileName;
 		else if (curPos.y < (_utils->vgaScaleY(149) + _utils->svgaCord(2)))
 			drawStaticMessage(kTextNothing);
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 71f53e1..2e37847 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -238,53 +238,53 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 		updateMusicAndEvents();
 
 		switch (actionList->_actionType) {
-		case PLAYSOUND:
+		case kActionPlaySound:
 			_music->_loopSoundEffect = false;
 			_music->_waitTillFinished = true;
 			_music->readMusic(actionList->_messages[0], true);
 			_music->_waitTillFinished = false;
 			break;
 
-		case PLAYSOUNDB:
+		case kActionPlaySoundNoWait:
 			_music->_loopSoundEffect = false;
 			_music->_waitTillFinished = false;
 			_music->readMusic(actionList->_messages[0], false);
 			break;
 
-		case PLAYSOUNDCONT:
+		case kActionPlaySoundLooping:
 			_music->_loopSoundEffect = true;
 			_music->readMusic(actionList->_messages[0], _music->_waitTillFinished);
 			break;
 
-		case SHOWDIFF:
+		case kActionShowDiff:
 			_graphics->readPict(actionList->_messages[0], true);
 			break;
 
-		case SHOWDIFFCONT:
+		case kActionShowDiffLooping:
 			_graphics->readPict(actionList->_messages[0], false);
 			break;
 
-		case LOADDIFF:
+		case kActionLoadDiff:
 			if (!actionList->_messages[0].empty())
 				// Puts a file into memory
 				_graphics->loadPict(actionList->_messages[0]);
 
 			break;
 
-		case TRANSITION:
+		case kActionTransition:
 			_graphics->doTransition((TransitionType)actionList->_param1, closePtrList, actionList->_messages[0].c_str());
 			break;
 
-		case NOUPDATE:
+		case kActionNoUpdate:
 			_noUpdateDiff = true;
 			_anim->_doBlack = false;
 			break;
 
-		case FORCEUPDATE:
+		case kActionForceUpdate:
 			_curFileName = " ";
 			break;
 
-		case SHOWCURPICT: {
+		case kActionShowCurPict: {
 			Common::String test = getPictName(closePtrList);
 
 			if (test != _curFileName) {
@@ -294,31 +294,31 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			}
 			break;
 
-		case SETELEMENT:
+		case kActionSetElement:
 			_conditions->inclElement(actionList->_param1);
 			break;
 
-		case UNSETELEMENT:
+		case kActionUnsetElement:
 			_conditions->exclElement(actionList->_param1);
 			break;
 
-		case SHOWMESSAGE:
+		case kActionShowMessage:
 			if (_graphics->_longWinInFront)
 				_graphics->longDrawMessage(actionList->_messages[0]);
 			else
 				_graphics->drawMessage(actionList->_messages[0]);
 			break;
 
-		case CSHOWMESSAGE:
+		case kActionCShowMessage:
 			if (!*closePtrList)
 				_graphics->drawMessage(actionList->_messages[0]);
 			break;
 
-		case SHOWMESSAGES:
+		case kActionShowMessages:
 			_graphics->drawMessage(actionList->_messages[_utils->getRandom(actionList->_param1)]);
 			break;
 
-		case SETPOSITION:
+		case kActionChangeRoom:
 			if (actionList->_param1 & 0x8000) {
 				// This is a Wyrmkeep Windows trial version, thus stop at this
 				// point, since we can't check for game payment status
@@ -335,7 +335,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			_anim->_doBlack = true;
 			break;
 
-		case SETCLOSEUP: {
+		case kActionSetCloseup: {
 			Common::Point curPos = Common::Point(_utils->scaleX(actionList->_param1), _utils->scaleY(actionList->_param2));
 				CloseDataPtr tmpClosePtr = getObject(curPos, *closePtrList);
 
@@ -344,11 +344,11 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			}
 			break;
 
-		case MAINVIEW:
+		case kActionMainView:
 			*closePtrList = nullptr;
 			break;
 
-		case SUBINV:
+		case kActionSubInv:
 			if (_inventory[actionList->_param1]._quantity)
 				(_inventory[actionList->_param1]._quantity)--;
 
@@ -357,12 +357,12 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 
 			break;
 
-		case ADDINV:
+		case kActionAddInv:
 			(_inventory[actionList->_param1]._quantity) += actionList->_param2;
 			_conditions->inclElement(actionList->_param1);
 			break;
 
-		case SHOWDIR:
+		case kActionShowDir:
 			// Originally, this set _doNotDrawMessage to false, so that the
 			// message would be shown by drawMessage(). However, _doNotDrawMEssage
 			// ended up hiding subsequent game messages, so this call is actually
@@ -370,7 +370,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			// side-effects.
 			break;
 
-		case WAITSECS: {
+		case kActionWaitSecs: {
 				uint32 targetMillis = g_system->getMillis() + actionList->_param1 * 1000;
 
 				_graphics->screenUpdate();
@@ -382,29 +382,29 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			}
 			break;
 
-		case STOPMUSIC:
+		case kActionStopMusic:
 			_music->setMusic(false);
 			break;
 
-		case STARTMUSIC:
+		case kActionStartMusic:
 			_music->setMusic(true);
 			break;
 
-		case CHANGEMUSIC:
+		case kActionChangeMusic:
 			_music->changeMusic(actionList->_messages[0]);
 			_music->setMusicReset(false);
 			break;
 
-		case RESETMUSIC:
+		case kActionResetMusic:
 			_music->resetMusic();
 			_music->setMusicReset(true);
 			break;
 
-		case FILLMUSIC:
+		case kActionFillMusic:
 			updateMusicAndEvents();
 			break;
 
-		case WAITSOUND:
+		case kActionWaitSound:
 			while (_music->isSoundEffectActive()) {
 				updateMusicAndEvents();
 				_anim->diffNextFrame();
@@ -413,7 +413,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 
 			break;
 
-		case CLEARSOUND:
+		case kActionClearSound:
 			if (_music->_loopSoundEffect) {
 				_music->_loopSoundEffect = false;
 				_music->stopSoundEffect();
@@ -422,26 +422,26 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 
 			break;
 
-		case WINMUSIC:
+		case kActionWinMusic:
 			_music->freeMusic();
 			_music->initMusic("Music:WinGame");
 			break;
 
-		case WINGAME:
+		case kActionWinGame:
 			_quitLab = true;
 			showLab2Teaser();
 			break;
 
-		case LOSTGAME:
+		case kActionLostGame:
 			// This seems to be unused?
 			error("Unused opcode LOSTGAME has been called");
 			break;
 
-		case RESETBUFFER:
+		case kActionResetBuffer:
 			_graphics->freePict();
 			break;
 
-		case SPECIALCMD:
+		case kActionSpecialCmd:
 			if (actionList->_param1 == 0)
 				_anim->_doBlack = true;
 			else if (actionList->_param1 == 1)
@@ -505,7 +505,7 @@ bool LabEngine::doActionRuleSub(int16 action, int16 roomNum, CloseDataPtr closeP
 		}
 
 		for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
-			if ((rule->_ruleType == ACTION) &&
+			if ((rule->_ruleType == kRuleTypeAction) &&
 				((rule->_param1 == action) || ((rule->_param1 == 0) && allowDefaults))) {
 				if (((rule->_param2 == closePtr->_closeUpType) ||
 					  ((rule->_param2 == 0) && allowDefaults)) ||
@@ -553,7 +553,7 @@ bool LabEngine::doOperateRuleSub(int16 itemNum, int16 roomNum, CloseDataPtr clos
 			}
 
 			for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
-				if ((rule->_ruleType == OPERATE) &&
+				if ((rule->_ruleType == kRuleTypeOperate) &&
 					  ((rule->_param1 == itemNum) || ((rule->_param1 == 0) && allowDefaults)) &&
 						((rule->_param2 == closePtr->_closeUpType) || ((rule->_param2 == 0) && allowDefaults))) {
 					if (checkConditions(rule->_condition)) {
@@ -599,7 +599,7 @@ bool LabEngine::doGoForward(CloseDataPtr *closePtrList) {
 	RuleList *rules = _rooms[_roomNum]._rules;
 
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
-		if ((rule->_ruleType == GOFORWARD) && (rule->_param1 == (_direction + 1))) {
+		if ((rule->_ruleType == kRuleTypeGoForward) && (rule->_param1 == (_direction + 1))) {
 			if (checkConditions(rule->_condition)) {
 				doActions(rule->_actionList, closePtrList);
 				return true;
@@ -617,8 +617,8 @@ bool LabEngine::doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList) {
 	RuleList *rules = _rooms[_roomNum]._rules;
 
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
-		if ((rule->_ruleType == TURN) ||
-			  ((rule->_ruleType == TURNFROMTO) &&
+		if ((rule->_ruleType == kRuleTypeTurn) ||
+			  ((rule->_ruleType == kRuleTypeTurnFromTo) &&
 			  (rule->_param1 == from) && (rule->_param2 == to))) {
 			if (checkConditions(rule->_condition)) {
 				doActions(rule->_actionList, closePtrList);
@@ -633,7 +633,7 @@ bool LabEngine::doTurn(uint16 from, uint16 to, CloseDataPtr *closePtrList) {
 bool LabEngine::doMainView(CloseDataPtr *closePtrList) {
 	RuleList *rules = _rooms[_roomNum]._rules;
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
-		if (rule->_ruleType == GOMAINVIEW) {
+		if (rule->_ruleType == kRuleTypeGoMainView) {
 			if (checkConditions(rule->_condition)) {
 				doActions(rule->_actionList, closePtrList);
 				return true;
diff --git a/engines/lab/processroom.h b/engines/lab/processroom.h
index 60f696b..9cdada2 100644
--- a/engines/lab/processroom.h
+++ b/engines/lab/processroom.h
@@ -33,59 +33,63 @@
 
 namespace Lab {
 
-//------------------------------- Action types ------------------------------
-#define PLAYSOUND     1
-#define PLAYSOUNDCONT 2
-#define SHOWDIFF      3
-#define SHOWDIFFCONT  4
-#define LOADDIFF      5
-#define LOADBM        6
-#define SHOWBM        7
-#define TRANSITION    8
-#define NOUPDATE      9
-#define FORCEUPDATE  10
-#define SHOWCURPICT  11
-#define SETELEMENT   12
-#define UNSETELEMENT 13
-#define SHOWMESSAGE  14
-#define SHOWMESSAGES 15
-#define SETPOSITION  16
-#define SETCLOSEUP   17
-#define MAINVIEW     18
-#define SUBINV       19
-#define ADDINV       20
-#define SHOWDIR      21
-#define WAITSECS     22
-#define STOPMUSIC    23
-#define STARTMUSIC   24
-#define CHANGEMUSIC  25
-#define RESETMUSIC   26
-#define FILLMUSIC    27
-#define WAITSOUND    28
-#define CLEARSOUND   29
-#define WINMUSIC     30
-#define WINGAME      31
-#define LOSTGAME     32
-#define RESETBUFFER  33
-#define SPECIALCMD   34
-#define CSHOWMESSAGE 35
-#define PLAYSOUNDB   36
-
-// Rule Types
-#define ACTION      1
-#define OPERATE     2
-#define GOFORWARD   3
-#define CONDITIONS  4
-#define TURN        5
-#define GOMAINVIEW  6
-#define TURNFROMTO  7
-
-//----------------------------- Rule Type Action ----------------------------
-#define TAKE        1
-#define MOVE        2
-#define OPENDOOR    3
-#define CLOSEDOOR   4
-#define TAKEDEF     5
+enum ActionType {
+	kActionPlaySound = 1,
+	kActionPlaySoundLooping = 2,
+	kActionShowDiff = 3,
+	kActionShowDiffLooping = 4,
+	kActionLoadDiff = 5,
+	kActionLoadBitmap = 6,	// unused?
+	kActionShowBitmap = 7,	// unused?
+	kActionTransition = 8,
+	kActionNoUpdate = 9,
+	kActionForceUpdate = 10,
+	kActionShowCurPict = 11,
+	kActionSetElement = 12,
+	kActionUnsetElement = 13,
+	kActionShowMessage = 14,
+	kActionShowMessages = 15,
+	kActionChangeRoom = 16,
+	kActionSetCloseup = 17,
+	kActionMainView = 18,
+	kActionSubInv = 19,
+	kActionAddInv = 20,
+	kActionShowDir = 21,
+	kActionWaitSecs = 22,
+	kActionStopMusic = 23,
+	kActionStartMusic = 24,
+	kActionChangeMusic = 25,
+	kActionResetMusic = 26,
+	kActionFillMusic = 27,
+	kActionWaitSound = 28,
+	kActionClearSound = 29,
+	kActionWinMusic = 30,
+	kActionWinGame = 31,
+	kActionLostGame = 32,
+	kActionResetBuffer = 33,
+	kActionSpecialCmd = 34,
+	kActionCShowMessage = 35,
+	kActionPlaySoundNoWait = 36
+};
+
+enum RuleType {
+	kRuleTypeNone = 0,
+	kRuleTypeAction = 1,
+	kRuleTypeOperate = 2,
+	kRuleTypeGoForward = 3,
+	kRuleTypeConditions = 4,	// unused?
+	kRuleTypeTurn = 5,
+	kRuleTypeGoMainView = 6,
+	kRuleTypeTurnFromTo = 7
+};
+
+enum RuleAction {
+	kRuleActionTake = 0,
+	kRuleActionMove = 1,	// unused?
+	kRuleActionOpenDoor = 2,	// unused?
+	kRuleActionCloseDoor = 3,	// unused?
+	kRuleActionTakeDef = 4
+};
 
 #if defined(WIN32)
 #pragma pack(push, 1)
@@ -109,7 +113,7 @@ struct ViewData {
 };
 
 struct Action {
-	int16 _actionType;
+	ActionType _actionType;
 	int16 _param1;
 	int16 _param2;
 	int16 _param3;
@@ -118,12 +122,11 @@ struct Action {
 };
 
 struct Rule {
-	int16 _ruleType;
+	RuleType _ruleType;
 	int16 _param1;
 	int16 _param2;
 	int16 *_condition;
 	Action *_actionList;
-	Rule *_nextRule;
 };
 
 struct RoomData {
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 1063fd5..6e2559d 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -265,7 +265,7 @@ RuleList *Resource::readRule(Common::File *file) {
 
 		if (c == 1) {
 			Rule rule;
-			rule._ruleType = file->readSint16LE();
+			rule._ruleType = (RuleType)file->readSint16LE();
 			rule._param1 = file->readSint16LE();
 			rule._param2 = file->readSint16LE();
 			rule._condition = readConditions(file);
@@ -305,12 +305,12 @@ Action *Resource::readAction(Common::File *file) {
 				head = action;
 			if (prev)
 				prev->_nextAction = action;
-			action->_actionType = file->readSint16LE();
+			action->_actionType = (ActionType)file->readSint16LE();
 			action->_param1 = file->readSint16LE();
 			action->_param2 = file->readSint16LE();
 			action->_param3 = file->readSint16LE();
 
-			if (action->_actionType == SHOWMESSAGES) {
+			if (action->_actionType == kActionShowMessages) {
 				action->_messages = new Common::String[action->_param1];
 
 				for (int i = 0; i < action->_param1; i++)


Commit: 333d55371668f25e8879300b738f75f722e110df
    https://github.com/scummvm/scummvm/commit/333d55371668f25e8879300b738f75f722e110df
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:43:16+01:00

Commit Message:
LAB: Add a console, with two new commands (scene and scene_resources)

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



diff --git a/engines/lab/console.cpp b/engines/lab/console.cpp
new file mode 100644
index 0000000..b819e1d
--- /dev/null
+++ b/engines/lab/console.cpp
@@ -0,0 +1,78 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public 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 "gui/debugger.h"
+
+#include "lab/lab.h"
+#include "lab/console.h"
+#include "lab/processroom.h"
+#include "lab/resource.h"
+
+namespace Lab {
+
+Console::Console(LabEngine *vm) : GUI::Debugger(), _vm(vm) {
+	registerCmd("scene",			WRAP_METHOD(Console, Cmd_Scene));
+	registerCmd("scene_resources",  WRAP_METHOD(Console, Cmd_DumpSceneResources));
+}
+
+Console::~Console() {
+}
+
+bool Console::Cmd_Scene(int argc, const char **argv) {
+	if (argc != 2) {
+		const char *directions[] = { "North", "South", "East", "West" };
+		debugPrintf("Current scene is %d, direction: %s\n", _vm->_roomNum, directions[_vm->getDirection()]);
+		debugPrintf("Use %s <scene number> to change the current scene\n", argv[0]);
+		return true;
+	}
+
+	_vm->_roomNum = atoi(argv[1]);
+
+	return false;
+}
+
+bool Console::Cmd_DumpSceneResources(int argc, const char **argv) {
+	if (argc != 2) {
+		debugPrintf("Usage: %s <scene number> to dump the resources for a scene\n", argv[0]);
+		return true;
+	}
+
+	int scene = atoi(argv[1]);
+	_vm->_resource->readViews(scene);
+	RoomData *roomData = &_vm->_rooms[scene];
+	RuleList *rules = roomData->_rules;
+	const char *transitions[] = { "None", "Wipe", "ScrollWipe", "ScrollBlack", "ScrollBounce", "Transporter", "ReadFirstFrame", "ReadNextFrame" };
+	const char *ruleTypes[] = { "None", "Action", "Operate", "Go forward", "Conditions", "Turn", "Go main view", "Turn from to" };
+
+	debugPrintf("Room mesage: %s\n", roomData->_roomMsg.c_str());
+	debugPrintf("Transition: %s (%d)\n", transitions[roomData->_transitionType], roomData->_transitionType);
+
+	debugPrintf("Script:\n");
+	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
+		debugPrintf("Rule type: %s\n", ruleTypes[rule->_ruleType]);
+
+	}
+
+	return true;
+}
+
+} // End of namespace Neverhood
diff --git a/engines/lab/console.h b/engines/lab/console.h
new file mode 100644
index 0000000..a863e11
--- /dev/null
+++ b/engines/lab/console.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 LAB_CONSOLE_H
+#define LAB_CONSOLE_H
+
+#include "gui/debugger.h"
+
+namespace Lab {
+
+class LabEngine;
+
+class Console : public GUI::Debugger {
+public:
+	Console(LabEngine *vm);
+	virtual ~Console(void);
+
+private:
+	LabEngine *_vm;
+
+	bool Cmd_Scene(int argc, const char **argv);
+	bool Cmd_DumpSceneResources(int argc, const char **argv);
+};
+
+} // End of namespace Lab
+#endif
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index d2cf508..2e6561c 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -228,15 +228,19 @@ void EventManager::processInput() {
 			case Common::KEYCODE_LEFTBRACKET:
 				_vm->changeVolume(-1);
 				break;
-
 			case Common::KEYCODE_RIGHTBRACKET:
 				_vm->changeVolume(1);
 				break;
-
 			case Common::KEYCODE_z:
 				//saveSettings();
 				break;
-
+			case Common::KEYCODE_d:
+				if (event.kbd.hasFlags(Common::KBD_CTRL)) {
+					// Open debugger console
+					_vm->_console->attach();
+					continue;
+				}
+				// Intentional fall through
 			default: {
 				int n = (_nextKeyIn + 1) % 64;
 				if (n != _nextKeyOut) {
@@ -251,10 +255,11 @@ void EventManager::processInput() {
 		default:
 			break;
 		}
-
-		g_system->copyRectToScreen(_vm->_graphics->_displayBuffer, _vm->_graphics->_screenWidth, 0, 0, _vm->_graphics->_screenWidth, _vm->_graphics->_screenHeight);
-		g_system->updateScreen();
 	}
+
+	g_system->copyRectToScreen(_vm->_graphics->_displayBuffer, _vm->_graphics->_screenWidth, 0, 0, _vm->_graphics->_screenWidth, _vm->_graphics->_screenHeight);
+	_vm->_console->onFrame();
+	g_system->updateScreen();
 }
 
 Common::KeyCode EventManager::getNextChar() {
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 52a96eb..52dd416 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -37,6 +37,7 @@
 #include "lab/lab.h"
 
 #include "lab/anim.h"
+#include "lab/console.h"
 #include "lab/dispman.h"
 #include "lab/eventman.h"
 #include "lab/image.h"
@@ -83,6 +84,7 @@ LabEngine::LabEngine(OSystem *syst, const ADGameDescription *gameDesc)
 	_rooms = nullptr;
 	_tilePuzzle = nullptr;
 	_utils = nullptr;
+	_console = nullptr;
 	_journalBackImage = nullptr;
 	_screenImage = nullptr;
 
@@ -151,6 +153,7 @@ LabEngine::~LabEngine() {
 	delete _graphics;
 	delete _tilePuzzle;
 	delete _utils;
+	delete _console;
 	delete _journalBackImage;
 	// _screenImage->_imageData is always pointing to the current drawing buffer.
 	// It shouldn't be deleted there.
@@ -171,6 +174,7 @@ Common::Error LabEngine::run() {
 	_anim = new Anim(this);
 	_tilePuzzle = new TilePuzzle(this);
 	_utils = new Utils(this);
+	_console = new Console(this);
 	_journalBackImage = new Image(this);
 	_screenImage = new Image(this);
 
diff --git a/engines/lab/lab.h b/engines/lab/lab.h
index fa7f850..ba642f5 100644
--- a/engines/lab/lab.h
+++ b/engines/lab/lab.h
@@ -38,6 +38,7 @@
 #include "engines/engine.h"
 #include "engines/savestate.h"
 
+#include "lab/console.h"
 #include "lab/image.h"
 #include "lab/labsets.h"
 
@@ -171,6 +172,8 @@ public:
 	TextFont *_msgFont;
 	TilePuzzle *_tilePuzzle;
 	Utils *_utils;
+	Console *_console;
+	GUI::Debugger *getDebugger() { return _console; }
 
 public:
 	LabEngine(OSystem *syst, const ADGameDescription *gameDesc);
diff --git a/engines/lab/module.mk b/engines/lab/module.mk
index 6b7932a..a619cba 100644
--- a/engines/lab/module.mk
+++ b/engines/lab/module.mk
@@ -2,6 +2,7 @@ MODULE := engines/lab
 
 MODULE_OBJS := \
 	anim.o \
+	console.o \
 	detection.o \
 	dispman.o \
 	engine.o \


Commit: f7395ba0ab0847961fda31479f0483f3686a5a4e
    https://github.com/scummvm/scummvm/commit/f7395ba0ab0847961fda31479f0483f3686a5a4e
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:43:16+01:00

Commit Message:
LAB: Rewrite the action message functionality (_doNotShowMessage)

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/engine.cpp
    engines/lab/intro.cpp
    engines/lab/lab.cpp
    engines/lab/processroom.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 55c66cd..2ae99a5 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -45,6 +45,7 @@ namespace Lab {
 DisplayMan::DisplayMan(LabEngine *vm) : _vm(vm) {
 	_longWinInFront = false;
 	_lastMessageLong = false;
+	_actionMessageShown = false;
 
 	_screenBytesPerPage = 65536;
 	_curPen = 0;
@@ -229,7 +230,14 @@ void DisplayMan::createBox(uint16 y2) {
 	drawVLine(_vm->_utils->vgaScaleX(2), _vm->_utils->vgaScaleY(152), _vm->_utils->vgaScaleY(y2));
 }
 
-int DisplayMan::longDrawMessage(Common::String str) {
+int DisplayMan::longDrawMessage(Common::String str, bool isActionMessage) {
+	if (isActionMessage) {
+		_actionMessageShown = true;
+	} else if (_actionMessageShown) {
+		_actionMessageShown = false;
+		return 0;
+	}
+
 	if (str.empty())
 		return 0;
 
@@ -249,12 +257,19 @@ int DisplayMan::longDrawMessage(Common::String str) {
 	return flowText(_vm->_msgFont, 0, 1, 7, false, true, true, true, _vm->_utils->vgaRectScale(6, 155, 313, 195), str.c_str());
 }
 
-void DisplayMan::drawMessage(Common::String str) {
+void DisplayMan::drawMessage(Common::String str, bool isActionMessage) {
+	if (isActionMessage) {
+		_actionMessageShown = true;
+	} else if (_actionMessageShown) {
+		_actionMessageShown = false;
+		return;
+	}
+
 	if (str.empty())
 		return;
 
 	if ((textLength(_vm->_msgFont, str) > _vm->_utils->vgaScaleX(306))) {
-		longDrawMessage(str);
+		longDrawMessage(str, isActionMessage);
 		_lastMessageLong = true;
 	} else {
 		if (_longWinInFront) {
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index b5e1248..99a4f45b 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -139,12 +139,15 @@ public:
 	 * Sets up the Labyrinth screens, and opens up the initial windows.
 	 */
 	void setUpScreens();
-	int32 longDrawMessage(Common::String str);
+
+	int32 longDrawMessage(Common::String str, bool isActionMessage);
 
 	/**
 	 * Draws a message to the message box.
 	 */
-	void drawMessage(Common::String str);
+	void drawMessage(Common::String str, bool isActionMessage);
+
+	void setActionMessage(bool val) { _actionMessageShown = val; }
 
 	/**
 	 * Sets the pen number to use on all the drawing operations.
@@ -279,6 +282,7 @@ public:
 
 	bool _longWinInFront;
 	bool _lastMessageLong;
+	bool _actionMessageShown;
 	uint32 _screenBytesPerPage;
 	int _screenWidth;
 	int _screenHeight;
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 3350dd7..501ca08 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -133,9 +133,9 @@ void LabEngine::drawRoomMessage(uint16 curInv, CloseDataPtr closePtr) {
 				drawStaticMessage(kTextkLampOn);
 			else if (_inventory[curInv]._quantity > 1) {
 				Common::String roomMessage = _inventory[curInv]._name + "  (" + Common::String::format("%d", _inventory[curInv]._quantity) + ")";
-				_graphics->drawMessage(roomMessage.c_str());
+				_graphics->drawMessage(roomMessage.c_str(), false);
 			} else
-				_graphics->drawMessage(_inventory[curInv]._name.c_str());
+				_graphics->drawMessage(_inventory[curInv]._name.c_str(), false);
 		}
 	} else
 		drawDirection(closePtr);
@@ -305,7 +305,7 @@ bool LabEngine::doUse(uint16 curInv) {
 		_closeDataPtr = nullptr;
 		doMap(_roomNum);
 		_graphics->setPalette(initcolors, 8);
-		_graphics->drawMessage(nullptr);
+		_graphics->drawMessage(nullptr, false);
 		_graphics->drawPanel();
 		return true;
 	case kItemJournal:
@@ -316,7 +316,7 @@ bool LabEngine::doUse(uint16 curInv) {
 		_closeDataPtr = nullptr;
 		doJournal();
 		_graphics->drawPanel();
-		_graphics->drawMessage(nullptr);
+		_graphics->drawMessage(nullptr, false);
 		return true;
 	case kItemLamp:
 		interfaceOff();
@@ -718,7 +718,7 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &quali
 		}
 	} else if ((code == Common::KEYCODE_x) || (code == Common::KEYCODE_q)) {
 		// Quit?
-		_graphics->drawMessage("Do you want to quit? (Y/N)");
+		_graphics->drawMessage("Do you want to quit? (Y/N)", false);
 		eatMessages();
 		interfaceOff();
 
@@ -927,7 +927,7 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 		_graphics->drawPanel();
 
 		if (doit) {
-			_graphics->drawMessage("Disk operation failed.");
+			_graphics->drawMessage("Disk operation failed.", false);
 			_graphics->setPalette(initcolors, 8);
 			g_system->delayMillis(1000);
 		}
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index a60bd24..8e580f1 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -98,7 +98,7 @@ void Intro::doPictText(const Common::String filename, TextFont *msgFont, bool is
 				charDrawn = _vm->_graphics->flowText(msgFont, (!_vm->_isHiRes) * -1, 5, 7, false, false, true, true, _vm->_utils->vgaRectScale(14, 11, 306, 189), (char *)curText);
 				_vm->_graphics->fade(true, 0);
 			} else
-				charDrawn = _vm->_graphics->longDrawMessage(Common::String((char *)curText));
+				charDrawn = _vm->_graphics->longDrawMessage(Common::String((char *)curText), false);
 
 			curText += charDrawn;
 			doneFl = (*curText == 0);
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 52dd416..01300ae 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -222,7 +222,7 @@ Common::String LabEngine::generateSaveFileName(uint slot) {
 }
 
 void LabEngine::drawStaticMessage(byte index) {
-	_graphics->drawMessage(_resource->getStaticText((StaticText)index));
+	_graphics->drawMessage(_resource->getStaticText((StaticText)index), false);
 }
 
 void LabEngine::changeVolume(int delta) {
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 2e37847..fede42d 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -132,7 +132,7 @@ Common::String LabEngine::getPictName(CloseDataPtr *closePtrList) {
 
 void LabEngine::drawDirection(CloseDataPtr closePtr) {
 	if (closePtr && !closePtr->_message.empty()) {
-		_graphics->drawMessage(closePtr->_message);
+		_graphics->drawMessage(closePtr->_message, false);
 		return;
 	}
 
@@ -150,7 +150,7 @@ void LabEngine::drawDirection(CloseDataPtr closePtr) {
 	else if (_direction == WEST)
 		message += _resource->getStaticText(kTextFacingWest);
 
-	_graphics->drawMessage(message);
+	_graphics->drawMessage(message, false);
 }
 
 uint16 LabEngine::processArrow(uint16 curDirection, uint16 arrow) {
@@ -304,18 +304,18 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 
 		case kActionShowMessage:
 			if (_graphics->_longWinInFront)
-				_graphics->longDrawMessage(actionList->_messages[0]);
+				_graphics->longDrawMessage(actionList->_messages[0], true);
 			else
-				_graphics->drawMessage(actionList->_messages[0]);
+				_graphics->drawMessage(actionList->_messages[0], true);
 			break;
 
 		case kActionCShowMessage:
 			if (!*closePtrList)
-				_graphics->drawMessage(actionList->_messages[0]);
+				_graphics->drawMessage(actionList->_messages[0], true);
 			break;
 
 		case kActionShowMessages:
-			_graphics->drawMessage(actionList->_messages[_utils->getRandom(actionList->_param1)]);
+			_graphics->drawMessage(actionList->_messages[_utils->getRandom(actionList->_param1)], true);
 			break;
 
 		case kActionChangeRoom:
@@ -363,11 +363,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			break;
 
 		case kActionShowDir:
-			// Originally, this set _doNotDrawMessage to false, so that the
-			// message would be shown by drawMessage(). However, _doNotDrawMEssage
-			// ended up hiding subsequent game messages, so this call is actually
-			// a nasty hack, and has been removed in ScummVM without any notable
-			// side-effects.
+			_graphics->setActionMessage(false);
 			break;
 
 		case kActionWaitSecs: {


Commit: c855cd46df2b04cca08aeba68672e9828f8203fa
    https://github.com/scummvm/scummvm/commit/c855cd46df2b04cca08aeba68672e9828f8203fa
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:43:16+01:00

Commit Message:
LAB: Extend the scene_resources command and add the find_action command

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



diff --git a/engines/lab/console.cpp b/engines/lab/console.cpp
index b819e1d..00f8921 100644
--- a/engines/lab/console.cpp
+++ b/engines/lab/console.cpp
@@ -32,6 +32,7 @@ namespace Lab {
 Console::Console(LabEngine *vm) : GUI::Debugger(), _vm(vm) {
 	registerCmd("scene",			WRAP_METHOD(Console, Cmd_Scene));
 	registerCmd("scene_resources",  WRAP_METHOD(Console, Cmd_DumpSceneResources));
+	registerCmd("find_action",      WRAP_METHOD(Console, Cmd_FindAction));
 }
 
 Console::~Console() {
@@ -62,14 +63,59 @@ bool Console::Cmd_DumpSceneResources(int argc, const char **argv) {
 	RuleList *rules = roomData->_rules;
 	const char *transitions[] = { "None", "Wipe", "ScrollWipe", "ScrollBlack", "ScrollBounce", "Transporter", "ReadFirstFrame", "ReadNextFrame" };
 	const char *ruleTypes[] = { "None", "Action", "Operate", "Go forward", "Conditions", "Turn", "Go main view", "Turn from to" };
+	const char *directions[] = { "", "North", "South", "East", "West" };
+	const char *actionTypes[] = {
+		"", "PlaySound", "PlaySoundLooping", "ShowDiff", "ShowDiffLooping", "LoadDiff", "LoadBitmap", "ShowBitmap", "Transition", "NoUpdate", "ForceUpdate",
+		"ShowCurPict", "SetElement", "UnsetElement", "ShowMessage", "ShowMessages", "ChangeRoom", "SetCloseup", "MainView", "SubInv", "AddInv", "ShowDir",
+		"WaitSecs", "StopMusic", "StartMusic", "ChangeMusic", "ResetMusic", "FillMusic", "WaitSound", "ClearSound", "WinMusic", "WinGame", "LostGame",
+		"ResetBuffer", "SpecialCmd", "CShowMessage", "PlaySoundNoWait"
+	};
 
 	debugPrintf("Room mesage: %s\n", roomData->_roomMsg.c_str());
 	debugPrintf("Transition: %s (%d)\n", transitions[roomData->_transitionType], roomData->_transitionType);
 
 	debugPrintf("Script:\n");
+
 	for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) {
-		debugPrintf("Rule type: %s\n", ruleTypes[rule->_ruleType]);
+		debugPrintf("Rule type: %s", ruleTypes[rule->_ruleType]);
+		if (rule->_ruleType == kRuleTypeAction || rule->_ruleType == kRuleTypeOperate)
+			debugPrintf(" (item %d, closeup %d)", rule->_param1, rule->_param2);
+		else if (rule->_ruleType == kRuleTypeGoForward)
+			debugPrintf(" (%s)", directions[rule->_param1]);
+		else if (rule->_ruleType == kRuleTypeTurnFromTo)
+			debugPrintf(" (from %s to %s)", directions[rule->_param1], directions[rule->_param2]);
+		debugPrintf("\n");
+
+		while (rule->_actionList) {
+			Action *action = rule->_actionList;
+			debugPrintf("  - %s (%s, %d, %d, %d)\n", actionTypes[action->_actionType], action->_messages[0].c_str(), action->_param1, action->_param2, action->_param3);
+			rule->_actionList = rule->_actionList->_nextAction;
+		}
+	}
+
+	return true;
+}
+
+bool Console::Cmd_FindAction(int argc, const char **argv) {
+	if (argc < 2) {
+		debugPrintf("Usage: %s <action id> [param 1] [param 2]\n", argv[0]);
+		return true;
+	}
+
+	int actionId = atoi(argv[1]);
+	int param1 = (argc > 2) ? atoi(argv[2]) : -1;
+	int param2 = (argc > 3) ? atoi(argv[3]) : -1;
+
+	for (uint16 i = 1; i <= _vm->_manyRooms; i++) {
+		_vm->_resource->readViews(i);
 
+		for (RuleList::iterator rule = _vm->_rooms[i]._rules->begin(); rule != _vm->_rooms[i]._rules->end(); ++rule) {
+			if (rule->_ruleType == actionId &&
+				(rule->_param1 == param1 || param1 == -1) &&
+				(rule->_param2 == param2 || param2 == -1)) {
+				debugPrintf("Found at script %d\n", i);
+			}
+		}
 	}
 
 	return true;
diff --git a/engines/lab/console.h b/engines/lab/console.h
index a863e11..af41b60 100644
--- a/engines/lab/console.h
+++ b/engines/lab/console.h
@@ -39,6 +39,7 @@ private:
 
 	bool Cmd_Scene(int argc, const char **argv);
 	bool Cmd_DumpSceneResources(int argc, const char **argv);
+	bool Cmd_FindAction(int argc, const char **argv);
 };
 
 } // End of namespace Lab


Commit: 07da047fa1d519190478c1b26e5d65816edb17b3
    https://github.com/scummvm/scummvm/commit/07da047fa1d519190478c1b26e5d65816edb17b3
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:43:16+01:00

Commit Message:
LAB: Fix the find_action command

Changed paths:
    engines/lab/console.cpp



diff --git a/engines/lab/console.cpp b/engines/lab/console.cpp
index 00f8921..4aa9490 100644
--- a/engines/lab/console.cpp
+++ b/engines/lab/console.cpp
@@ -88,7 +88,7 @@ bool Console::Cmd_DumpSceneResources(int argc, const char **argv) {
 
 		while (rule->_actionList) {
 			Action *action = rule->_actionList;
-			debugPrintf("  - %s (%s, %d, %d, %d)\n", actionTypes[action->_actionType], action->_messages[0].c_str(), action->_param1, action->_param2, action->_param3);
+			debugPrintf("  - %s ('%s', %d, %d, %d)\n", actionTypes[action->_actionType], action->_messages[0].c_str(), action->_param1, action->_param2, action->_param3);
 			rule->_actionList = rule->_actionList->_nextAction;
 		}
 	}
@@ -105,15 +105,21 @@ bool Console::Cmd_FindAction(int argc, const char **argv) {
 	int actionId = atoi(argv[1]);
 	int param1 = (argc > 2) ? atoi(argv[2]) : -1;
 	int param2 = (argc > 3) ? atoi(argv[3]) : -1;
+	int param3 = (argc > 4) ? atoi(argv[4]) : -1;
 
 	for (uint16 i = 1; i <= _vm->_manyRooms; i++) {
 		_vm->_resource->readViews(i);
 
 		for (RuleList::iterator rule = _vm->_rooms[i]._rules->begin(); rule != _vm->_rooms[i]._rules->end(); ++rule) {
-			if (rule->_ruleType == actionId &&
-				(rule->_param1 == param1 || param1 == -1) &&
-				(rule->_param2 == param2 || param2 == -1)) {
-				debugPrintf("Found at script %d\n", i);
+			while (rule->_actionList) {
+				if (rule->_actionList->_actionType == actionId &&
+					(rule->_actionList->_param1 == param1 || param1 == -1) &&
+					(rule->_actionList->_param2 == param2 || param2 == -1) &&
+					(rule->_actionList->_param3 == param3 || param3 == -1)) {
+						debugPrintf("Found at script %d\n", i);
+				}
+
+				rule->_actionList = rule->_actionList->_nextAction;
 			}
 		}
 	}


Commit: 9d53245f731a4f4fe53b8e1ddb1f603055583674
    https://github.com/scummvm/scummvm/commit/9d53245f731a4f4fe53b8e1ddb1f603055583674
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:43:16+01:00

Commit Message:
LAB: Get rid of _waitTillFinished

There is no point waiting for looping sound effects to end

Changed paths:
    engines/lab/music.cpp
    engines/lab/music.h
    engines/lab/processroom.cpp



diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index a8dd281..4c09d92 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -60,7 +60,6 @@ Music::Music(LabEngine *vm) : _vm(vm) {
 	_queuingAudioStream = nullptr;
 	_lastMusicRoom = 1;
 	_doReset = true;
-	_waitTillFinished = false;
 }
 
 void Music::updateMusic() {
diff --git a/engines/lab/music.h b/engines/lab/music.h
index 857ea81..42fdf41 100644
--- a/engines/lab/music.h
+++ b/engines/lab/music.h
@@ -83,7 +83,6 @@ private:
 
 public:
 	bool _loopSoundEffect;
-	bool _waitTillFinished;
 
 public:
 	Music(LabEngine *vm);
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index fede42d..743f408 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -240,20 +240,17 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 		switch (actionList->_actionType) {
 		case kActionPlaySound:
 			_music->_loopSoundEffect = false;
-			_music->_waitTillFinished = true;
 			_music->readMusic(actionList->_messages[0], true);
-			_music->_waitTillFinished = false;
 			break;
 
 		case kActionPlaySoundNoWait:
 			_music->_loopSoundEffect = false;
-			_music->_waitTillFinished = false;
 			_music->readMusic(actionList->_messages[0], false);
 			break;
 
 		case kActionPlaySoundLooping:
 			_music->_loopSoundEffect = true;
-			_music->readMusic(actionList->_messages[0], _music->_waitTillFinished);
+			_music->readMusic(actionList->_messages[0], false);
 			break;
 
 		case kActionShowDiff:


Commit: 7a81e03b254a6615290b2761ca6ea1c0e30e64c8
    https://github.com/scummvm/scummvm/commit/7a81e03b254a6615290b2761ca6ea1c0e30e64c8
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:43:16+01:00

Commit Message:
LAB: Prevent the Image destructor from deleting external scroll buffers

Changed paths:
    engines/lab/dispman.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 2ae99a5..fda890d 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -996,6 +996,9 @@ void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint1
 		setPen(0);
 		rectFill(x2 + dx + 1, y1, x2, y2);
 	}
+
+	// Prevent the Image destructor from deleting the external buffer
+	im._imageData = nullptr;
 }
 
 void DisplayMan::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer) {
@@ -1027,6 +1030,9 @@ void DisplayMan::scrollDisplayY(int16 dy, uint16 x1, uint16 y1, uint16 x2, uint1
 		setPen(0);
 		rectFill(x1, y2 + dy + 1, x2, y2);
 	}
+
+	// Prevent the Image destructor from deleting the external buffer
+	im._imageData = nullptr;
 }
 
 uint16 DisplayMan::fadeNumIn(uint16 num, uint16 res, uint16 counter) {


Commit: 8de38a8d1094ed9cbf3f3377091981cbad6176a9
    https://github.com/scummvm/scummvm/commit/8de38a8d1094ed9cbf3f3377091981cbad6176a9
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:43:16+01:00

Commit Message:
LAB: Greatly simplify doScrollBlack() using scrollDisplayY()

This also fixes a crash when crossing the street

Changed paths:
    engines/lab/dispman.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index fda890d..f6705ff 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -648,68 +648,23 @@ void DisplayMan::drawText(TextFont *tf, uint16 x, uint16 y, uint16 color, const
 void DisplayMan::doScrollBlack() {
 	uint16 width = _vm->_utils->vgaScaleX(320);
 	uint16 height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
-	byte *mem = new byte[width * height];
 
 	_vm->_event->mouseHide();
 
-	Image img(_vm);
-	img._width = width;
-	img._height = height;
-	img._imageData = mem;
-	_vm->updateMusicAndEvents();
-	img.readScreenImage(0, 0);
-	_vm->updateMusicAndEvents();
+	byte *mem = new byte[width * height];
+	int16 by = _vm->_utils->vgaScaleX(4);
+	int16 verticalScroll = height;
 
-	byte *baseAddr = getCurrentDrawingBuffer();
-	uint16 by = _vm->_utils->vgaScaleX(4);
-	uint16 nheight = height;
+	while (verticalScroll > 0) {
+		scrollDisplayY(-by, 0, 0, width - 1, height - 1, mem);
+		verticalScroll -= by;
 
-	while (nheight) {
 		_vm->updateMusicAndEvents();
-
-		if (!_vm->_isHiRes)
-			_vm->waitTOF();
-
-		baseAddr = getCurrentDrawingBuffer();
-
-		if (by > nheight)
-			by = nheight;
-
-		mem += by * width;
-		nheight -= by;
-		uint32 copySize;
-		uint32 size = (int32)nheight * (int32)width;
-		byte *tempMem = mem;
-
-		while (size) {
-			if (size > _screenBytesPerPage)
-				copySize = _screenBytesPerPage;
-			else
-				copySize = size;
-
-			size -= copySize;
-
-			memcpy(baseAddr, tempMem, copySize);
-			tempMem += copySize;
-		}
-
-		setPen(0);
-		rectFill(0, nheight, width - 1, nheight + by - 1);
-
-		screenUpdate();
-
-		if (!_vm->_isHiRes) {
-			if (nheight <= (height / 8))
-				by = 1;
-			else if (nheight <= (height / 4))
-				by = 2;
-			else if (nheight <= (height / 2))
-				by = 3;
-		}
+		_vm->waitTOF();
 	}
 
 	delete[] mem;
-	freePict();
+
 	_vm->_event->mouseShow();
 }
 


Commit: e8edff85f395d8c812f154c230300fd70b127171
    https://github.com/scummvm/scummvm/commit/e8edff85f395d8c812f154c230300fd70b127171
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:43:16+01:00

Commit Message:
LAB: Synchronize function definition in Intro

Changed paths:
    engines/lab/intro.h



diff --git a/engines/lab/intro.h b/engines/lab/intro.h
index 7eb4c6d..fd72190 100644
--- a/engines/lab/intro.h
+++ b/engines/lab/intro.h
@@ -52,13 +52,13 @@ private:
 	/**
 	 * Reads in a picture.
 	 */
-	void doPictText(const Common::String Filename, TextFont *msgFont, bool isScreen);
+	void doPictText(const Common::String filename, TextFont *msgFont, bool isScreen);
 
 	/**
 	 * Does a one second delay, but checks the music while doing it.
 	 */
 	void musicDelay();
-	void nReadPict(const Common::String Filename, bool PlayOnce = true);
+	void nReadPict(const Common::String filename, bool playOnce = true);
 
 	LabEngine *_vm;
 	bool _quitIntro, _introDoBlack;


Commit: 34b59256fcddc116eb4ffd6069e1d034462168fc
    https://github.com/scummvm/scummvm/commit/34b59256fcddc116eb4ffd6069e1d034462168fc
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:43:16+01:00

Commit Message:
LAB: Replace g_system by _system

Changed paths:
    engines/lab/anim.cpp
    engines/lab/dispman.cpp
    engines/lab/engine.cpp
    engines/lab/eventman.cpp
    engines/lab/interface.cpp
    engines/lab/intro.cpp
    engines/lab/lab.cpp
    engines/lab/processroom.cpp
    engines/lab/savegame.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index b3a5a8f..b15e71a 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -95,9 +95,9 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 
 			if (!onlyDiffData) {
 				if (_headerdata._fps) {
-					uint32 targetMillis = g_system->getMillis() + _delayMicros;
-					while (g_system->getMillis() < targetMillis)
-						g_system->delayMillis(10);
+					uint32 targetMillis = _vm->_system->getMillis() + _delayMicros;
+					while (_vm->_system->getMillis() < targetMillis)
+						_vm->_system->delayMillis(10);
 				}
 
 				if (_isPal && !_noPalChange) {
@@ -302,7 +302,7 @@ void Anim::readDiff(Common::File *diffFile, bool playOnce, bool onlyDiffData) {
 	// as it was possible to see that something was displayed, without being able to tell
 	// what it was. A shorter delay (150ms) makes it acceptable during gameplay and
 	// readable. The big question is: do we need that message?
-	g_system->delayMillis(150);
+	_vm->_system->delayMillis(150);
 
 	if (_headerdata._fps == 1)
 		_headerdata._fps = 0;
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index f6705ff..2e13350 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -447,8 +447,8 @@ void DisplayMan::drawHLine(uint16 x1, uint16 y, uint16 x2) {
 }
 
 void DisplayMan::screenUpdate() {
-	g_system->copyRectToScreen(_displayBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight);
-	g_system->updateScreen();
+	_vm->_system->copyRectToScreen(_displayBuffer, _screenWidth, 0, 0, _screenWidth, _screenHeight);
+	_vm->_system->updateScreen();
 
 	_vm->_event->processInput();
 }
@@ -491,7 +491,7 @@ void DisplayMan::writeColorRegs(byte *buf, uint16 first, uint16 numReg) {
 	for (int i = 0; i < 256 * 3; i++)
 		tmp[i] = buf[i] * 4;
 
-	g_system->getPaletteManager()->setPalette(tmp, first, numReg);
+	_vm->_system->getPaletteManager()->setPalette(tmp, first, numReg);
 	memcpy(&(_curvgapal[first * 3]), buf, numReg * 3);
 }
 
@@ -905,7 +905,7 @@ void DisplayMan::blackScreen() {
 	memset(pal, 0, 248 * 3);
 	writeColorRegs(pal, 8, 248);
 
-	g_system->delayMillis(32);
+	_vm->_system->delayMillis(32);
 }
 
 void DisplayMan::whiteScreen() {
@@ -919,7 +919,7 @@ void DisplayMan::blackAllScreen() {
 	memset(pal, 0, 256 * 3);
 	writeColorRegs(pal, 0, 256);
 
-	g_system->delayMillis(32);
+	_vm->_system->delayMillis(32);
 }
 
 void DisplayMan::scrollDisplayX(int16 dx, uint16 x1, uint16 y1, uint16 x2, uint16 y2, byte *buffer) {
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 501ca08..f50a3b7 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -423,7 +423,7 @@ void LabEngine::mainGameLoop() {
 	// Set up initial picture.
 	while (1) {
 		_event->processInput();
-		g_system->delayMillis(10);
+		_system->delayMillis(10);
 
 		if (gotMessage) {
 			if (_quitLab || g_engine->shouldQuit()) {
@@ -693,7 +693,7 @@ bool LabEngine::processKey(IntuiMessage *curMsg, uint32 &msgClass, uint16 &quali
 				_followCrumbsFast = (code == Common::KEYCODE_r);
 				_isCrumbTurning = false;
 				_isCrumbWaiting = false;
-				_crumbTimestamp = g_system->getMillis();
+				_crumbTimestamp = _system->getMillis();
 
 				if (_alternate) {
 					eatMessages();
@@ -929,7 +929,7 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 		if (doit) {
 			_graphics->drawMessage("Disk operation failed.", false);
 			_graphics->setPalette(initcolors, 8);
-			g_system->delayMillis(1000);
+			_system->delayMillis(1000);
 		}
 		break;
 
@@ -988,7 +988,7 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 				_followCrumbsFast = false;
 				_isCrumbTurning = false;
 				_isCrumbWaiting = false;
-				_crumbTimestamp = g_system->getMillis();
+				_crumbTimestamp = _system->getMillis();
 
 				eatMessages();
 				_alternate = false;
@@ -1114,7 +1114,7 @@ int LabEngine::followCrumbs() {
 	};
 
 	if (_isCrumbWaiting) {
-		if (g_system->getMillis() <= _crumbTimestamp)
+		if (_system->getMillis() <= _crumbTimestamp)
 			return 0;
 
 		_isCrumbWaiting = false;
@@ -1155,7 +1155,7 @@ int LabEngine::followCrumbs() {
 		_isCrumbWaiting = true;
 
 		int theDelay = (_followCrumbsFast ? 1000 / 4 : 1000);
-		_crumbTimestamp = theDelay + g_system->getMillis();
+		_crumbTimestamp = theDelay + _system->getMillis();
 	}
 
 	return moveDir;
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 2e6561c..6e8b08e 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -148,8 +148,8 @@ void EventManager::updateMouse() {
 }
 
 void EventManager::initMouse() {
-	g_system->setMouseCursor(mouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0);
-	g_system->showMouse(false);
+	_vm->_system->setMouseCursor(mouseData, MOUSE_WIDTH, MOUSE_HEIGHT, 0, 0, 0);
+	_vm->_system->showMouse(false);
 
 	setMousePos(Common::Point(0, 0));
 }
@@ -160,14 +160,14 @@ void EventManager::mouseShow() {
 		_mouseHidden = false;
 	}
 
-	g_system->showMouse(true);
+	_vm->_system->showMouse(true);
 }
 
 void EventManager::mouseHide() {
 	if (!_mouseHidden) {
 		_mouseHidden = true;
 
-		g_system->showMouse(false);
+		_vm->_system->showMouse(false);
 	}
 }
 
@@ -180,9 +180,9 @@ Common::Point EventManager::getMousePos() {
 
 void EventManager::setMousePos(Common::Point pos) {
 	if (_vm->_isHiRes)
-		g_system->warpMouse(pos.x, pos.y);
+		_vm->_system->warpMouse(pos.x, pos.y);
 	else
-		g_system->warpMouse(pos.x * 2, pos.y);
+		_vm->_system->warpMouse(pos.x * 2, pos.y);
 
 	if (!_mouseHidden)
 		processInput();
@@ -206,7 +206,7 @@ void EventManager::processInput() {
 	Common::Event event;
 	Button *curButton = nullptr;
 
-	while (g_system->getEventManager()->pollEvent(event)) {
+	while (_vm->_system->getEventManager()->pollEvent(event)) {
 		switch (event.type) {
 		case Common::EVENT_LBUTTONDOWN:
 			if (_screenButtonList)
@@ -257,9 +257,9 @@ void EventManager::processInput() {
 		}
 	}
 
-	g_system->copyRectToScreen(_vm->_graphics->_displayBuffer, _vm->_graphics->_screenWidth, 0, 0, _vm->_graphics->_screenWidth, _vm->_graphics->_screenHeight);
+	_vm->_system->copyRectToScreen(_vm->_graphics->_displayBuffer, _vm->_graphics->_screenWidth, 0, 0, _vm->_graphics->_screenWidth, _vm->_graphics->_screenHeight);
 	_vm->_console->onFrame();
-	g_system->updateScreen();
+	_vm->_system->updateScreen();
 }
 
 Common::KeyCode EventManager::getNextChar() {
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index 7fb3ba2..bdf30c6 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -104,7 +104,7 @@ Button *EventManager::checkNumButtonHit(ButtonList *buttonList, uint16 key) {
 		 || ((button->_keyEquiv != 0) && (makeButtonKeyEquiv(key) == button->_keyEquiv)))
 			  && button->_isEnabled) {
 			button->_altImage->drawImage(button->_x, button->_y);
-			g_system->delayMillis(80);
+			_vm->_system->delayMillis(80);
 			button->_image->drawImage(button->_x, button->_y);
 			return button;
 		}
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index 8e580f1..de76c0c 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -114,7 +114,7 @@ void Intro::doPictText(const Common::String filename, TextFont *msgFont, bool is
 				return;
 			}
 
-			lastMillis = g_system->getMillis();
+			lastMillis = _vm->_system->getMillis();
 		}
 
 		IntuiMessage *msg = _vm->_event->getMsg();
@@ -127,7 +127,7 @@ void Intro::doPictText(const Common::String filename, TextFont *msgFont, bool is
 			_vm->updateMusicAndEvents();
 			_vm->_anim->diffNextFrame();
 
-			uint32 elapsedSeconds = (g_system->getMillis() - lastMillis) / 1000;
+			uint32 elapsedSeconds = (_vm->_system->getMillis() - lastMillis) / 1000;
 
 			if (elapsedSeconds > timeDelay) {
 				if (doneFl) {
@@ -239,7 +239,7 @@ void Intro::introSequence() {
 			introEatMessages();
 			if (_quitIntro)
 				break;
-			g_system->delayMillis(10);
+			_vm->_system->delayMillis(10);
 		}
 	}
 
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 01300ae..5d545d9 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -230,15 +230,15 @@ void LabEngine::changeVolume(int delta) {
 }
 
 void LabEngine::waitTOF() {
-	g_system->copyRectToScreen(_graphics->_displayBuffer, _graphics->_screenWidth, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight);
-	g_system->updateScreen();
+	_system->copyRectToScreen(_graphics->_displayBuffer, _graphics->_screenWidth, 0, 0, _graphics->_screenWidth, _graphics->_screenHeight);
+	_system->updateScreen();
 
 	_event->processInput();
 
 	uint32 now;
 
-	for (now = g_system->getMillis(); now - _lastWaitTOFTicks <= 0xF; now = g_system->getMillis() )
-		g_system->delayMillis(_lastWaitTOFTicks - now + 17);
+	for (now = _system->getMillis(); now - _lastWaitTOFTicks <= 0xF; now = _system->getMillis() )
+		_system->delayMillis(_lastWaitTOFTicks - now + 17);
 
 	_lastWaitTOFTicks = now;
 }
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 743f408..0d60724 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -364,11 +364,11 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 			break;
 
 		case kActionWaitSecs: {
-				uint32 targetMillis = g_system->getMillis() + actionList->_param1 * 1000;
+				uint32 targetMillis = _system->getMillis() + actionList->_param1 * 1000;
 
 				_graphics->screenUpdate();
 
-				while (g_system->getMillis() < targetMillis) {
+				while (_system->getMillis() < targetMillis) {
 					updateMusicAndEvents();
 					_anim->diffNextFrame();
 				}
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 70330a0..8ee8b1a 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -65,7 +65,7 @@ void LabEngine::writeSaveGameHeader(Common::OutSaveFile *out, const Common::Stri
 
 	// Creation date/time
 	TimeDate curTime;
-	g_system->getTimeAndDate(curTime);
+	_system->getTimeAndDate(curTime);
 
 	uint32 saveDate = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF);
 	uint16 saveTime = ((curTime.tm_hour & 0xFF) << 8) | ((curTime.tm_min) & 0xFF);
@@ -121,7 +121,7 @@ bool readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &header) {
 
 bool LabEngine::saveGame(int slot, const Common::String desc) {
 	Common::String fileName = generateSaveFileName(slot);
-	Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
+	Common::SaveFileManager *saveFileManager = _system->getSavefileManager();
 	Common::OutSaveFile *file = saveFileManager->openForSaving(fileName);
 
 	if (!file)
@@ -161,7 +161,7 @@ bool LabEngine::saveGame(int slot, const Common::String desc) {
 
 bool LabEngine::loadGame(int slot) {
 	Common::String fileName = generateSaveFileName(slot);
-	Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
+	Common::SaveFileManager *saveFileManager = _system->getSavefileManager();
 	Common::InSaveFile *file = saveFileManager->openForLoading(fileName);
 
 	if (!file)


Commit: 2f1506edecb0f7ad3ab9cf36831ac94f44dda4d7
    https://github.com/scummvm/scummvm/commit/2f1506edecb0f7ad3ab9cf36831ac94f44dda4d7
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:43:16+01:00

Commit Message:
LAB: Replace do..while by while statements in resource

Changed paths:
    engines/lab/resource.cpp



diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 6e2559d..3fcf7ac 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -257,22 +257,17 @@ int16 *Resource::readConditions(Common::File *file) {
 }
 
 RuleList *Resource::readRule(Common::File *file) {
-	char c;
 	RuleList *rules = new RuleList();
 
-	do {
-		c = file->readByte();
-
-		if (c == 1) {
-			Rule rule;
-			rule._ruleType = (RuleType)file->readSint16LE();
-			rule._param1 = file->readSint16LE();
-			rule._param2 = file->readSint16LE();
-			rule._condition = readConditions(file);
-			rule._actionList = readAction(file);
-			rules->push_back(rule);
-		}
-	} while (c == 1);
+	while (file->readByte() == 1) {
+		Rule rule;
+		rule._ruleType = (RuleType)file->readSint16LE();
+		rule._param1 = file->readSint16LE();
+		rule._param2 = file->readSint16LE();
+		rule._condition = readConditions(file);
+		rule._actionList = readAction(file);
+		rules->push_back(rule);
+	}
 
 	return rules;
 }
@@ -291,39 +286,34 @@ void Resource::freeRule(RuleList *ruleList) {
 }
 
 Action *Resource::readAction(Common::File *file) {
-	char c;
 	Action *action = nullptr;
 	Action *prev = nullptr;
 	Action *head = nullptr;
 
-	do {
-		c = file->readByte();
-
-		if (c == 1) {
-			action = new Action();
-			if (!head)
-				head = action;
-			if (prev)
-				prev->_nextAction = action;
-			action->_actionType = (ActionType)file->readSint16LE();
-			action->_param1 = file->readSint16LE();
-			action->_param2 = file->readSint16LE();
-			action->_param3 = file->readSint16LE();
-
-			if (action->_actionType == kActionShowMessages) {
-				action->_messages = new Common::String[action->_param1];
-
-				for (int i = 0; i < action->_param1; i++)
-					action->_messages[i] = readString(file);
-			} else {
-				action->_messages = new Common::String[1];
-				action->_messages[0] = readString(file);
-			}
-
-			action->_nextAction = nullptr;
-			prev = action;
+	while (file->readByte() == 1) {
+		action = new Action();
+		if (!head)
+			head = action;
+		if (prev)
+			prev->_nextAction = action;
+		action->_actionType = (ActionType)file->readSint16LE();
+		action->_param1 = file->readSint16LE();
+		action->_param2 = file->readSint16LE();
+		action->_param3 = file->readSint16LE();
+
+		if (action->_actionType == kActionShowMessages) {
+			action->_messages = new Common::String[action->_param1];
+
+			for (int i = 0; i < action->_param1; i++)
+				action->_messages[i] = readString(file);
+		} else {
+			action->_messages = new Common::String[1];
+			action->_messages[0] = readString(file);
 		}
-	} while (c == 1);
+
+		action->_nextAction = nullptr;
+		prev = action;
+	}
 
 	return head;
 }
@@ -338,33 +328,28 @@ void Resource::freeAction(Action *action) {
 }
 
 CloseData *Resource::readCloseUps(uint16 depth, Common::File *file) {
-	char c;
 	CloseData *closeup = nullptr;
 	CloseData *prev = nullptr;
 	CloseData *head = nullptr;
 
-	do {
-		c = file->readByte();
-
-		if (c != '\0') {
-			closeup = new CloseData();
-			if (!head)
-				head = closeup;
-			if (prev)
-				prev->_nextCloseUp = closeup;
-			closeup->_x1 = file->readUint16LE();
-			closeup->_y1 = file->readUint16LE();
-			closeup->_x2 = file->readUint16LE();
-			closeup->_y2 = file->readUint16LE();
-			closeup->_closeUpType = file->readSint16LE();
-			closeup->_depth = depth;
-			closeup->_graphicName = readString(file);
-			closeup->_message = readString(file);
-			closeup->_subCloseUps = readCloseUps(depth + 1, file);
-			closeup->_nextCloseUp = nullptr;
-			prev = closeup;
-		}
-	} while (c != '\0');
+	while (file->readByte() != '\0') {
+		closeup = new CloseData();
+		if (!head)
+			head = closeup;
+		if (prev)
+			prev->_nextCloseUp = closeup;
+		closeup->_x1 = file->readUint16LE();
+		closeup->_y1 = file->readUint16LE();
+		closeup->_x2 = file->readUint16LE();
+		closeup->_y2 = file->readUint16LE();
+		closeup->_closeUpType = file->readSint16LE();
+		closeup->_depth = depth;
+		closeup->_graphicName = readString(file);
+		closeup->_message = readString(file);
+		closeup->_subCloseUps = readCloseUps(depth + 1, file);
+		closeup->_nextCloseUp = nullptr;
+		prev = closeup;
+	}
 
 	return head;
 }
@@ -379,27 +364,22 @@ void Resource::freeCloseUps(CloseData *closeUps) {
 }
 
 ViewData *Resource::readView(Common::File *file) {
-	char c;
 	ViewData *view = nullptr;
 	ViewData *prev = nullptr;
 	ViewData *head = nullptr;
 
-	do {
-		c = file->readByte();
-
-		if (c == 1) {
-			view = new ViewData();
-			if (!head)
-				head = view;
-			if (prev)
-				prev->_nextCondition = view;
-			view->_condition = readConditions(file);
-			view->_graphicName = readString(file);
-			view->_closeUps = readCloseUps(0, file);
-			view->_nextCondition = nullptr;
-			prev = view;
-		}
-	} while (c == 1);
+	while (file->readByte() == 1) {
+		view = new ViewData();
+		if (!head)
+			head = view;
+		if (prev)
+			prev->_nextCondition = view;
+		view->_condition = readConditions(file);
+		view->_graphicName = readString(file);
+		view->_closeUps = readCloseUps(0, file);
+		view->_nextCondition = nullptr;
+		prev = view;
+	}
 
 	return head;
 }


Commit: c9049f232902e7856cb1e27cf6fa333374d46e6f
    https://github.com/scummvm/scummvm/commit/c9049f232902e7856cb1e27cf6fa333374d46e6f
Author: Strangerke (strangerke at scummvm.org)
Date: 2015-12-23T21:43:17+01:00

Commit Message:
LAB: Remove left-over long size specifiers

Changed paths:
    engines/lab/anim.cpp
    engines/lab/music.cpp
    engines/lab/processroom.h
    engines/lab/tilepuzzle.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index b15e71a..9444a8f 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -277,7 +277,7 @@ void Anim::readDiff(Common::File *diffFile, bool playOnce, bool onlyDiffData) {
 	uint32 signature1 = _diffFile->readUint32BE();
 	uint32 signature2 = _diffFile->readUint32LE();
 
-	if ((signature1 != MKTAG('D', 'I', 'F', 'F')) || (signature2 != 1219009121L)) {
+	if ((signature1 != MKTAG('D', 'I', 'F', 'F')) || (signature2 != 1219009121)) {
 		_isPlaying = false;
 		return;
 	}
diff --git a/engines/lab/music.cpp b/engines/lab/music.cpp
index 4c09d92..95581ae 100644
--- a/engines/lab/music.cpp
+++ b/engines/lab/music.cpp
@@ -39,8 +39,8 @@
 
 namespace Lab {
 
-#define MUSICBUFSIZE   (2 * 65536L)
-#define SAMPLESPEED    15000L
+#define MUSICBUFSIZE   (2 * 65536)
+#define SAMPLESPEED    15000
 
 #define CLOWNROOM           123
 #define DIMROOM              80
@@ -231,7 +231,7 @@ void Music::changeMusic(const Common::String filename) {
 	if (!_tFile) {
 		_tFile = _file;
 		_oldMusicOn = _musicOn;
-		_tLeftInFile = _leftInFile + 65536L;
+		_tLeftInFile = _leftInFile + 65536;
 
 		if (_tLeftInFile > (uint32)_tFile->size())
 			_tLeftInFile = _leftInFile;
@@ -291,7 +291,7 @@ bool Music::readMusic(const Common::String filename, bool waitTillFinished) {
 
 void Music::readSound(bool waitTillFinished, Common::File *file) {
 	uint32 magicBytes = file->readUint32LE();
-	if (magicBytes != 1219009121L) {
+	if (magicBytes != 1219009121) {
 		warning("readSound: Bad signature, skipping");
 		return;
 	}
@@ -321,7 +321,7 @@ void Music::readSound(bool waitTillFinished, Common::File *file) {
 			uint16 sampleRate = file->readUint16LE();
 			file->skip(2);
 			playSoundEffect(sampleRate, soundSize, file);
-		} else if (soundTag == 65535L) {
+		} else if (soundTag == 65535) {
 			if (waitTillFinished) {
 				while (isSoundEffectActive()) {
 					_vm->updateMusicAndEvents();
diff --git a/engines/lab/processroom.h b/engines/lab/processroom.h
index 9cdada2..3726435 100644
--- a/engines/lab/processroom.h
+++ b/engines/lab/processroom.h
@@ -146,21 +146,21 @@ struct InventoryData {
 // Map Flags
 
 // Where the doors are; in a corridor, assumed to be left doors
-#define     NORTHDOOR        1L
-#define     EASTDOOR         2L
-#define     SOUTHDOOR        4L
-#define     WESTDOOR         8L
+#define     NORTHDOOR        1
+#define     EASTDOOR         2
+#define     SOUTHDOOR        4
+#define     WESTDOOR         8
 
 // Where the doors are in corridors; M means middle, R means right, B means bottom
-#define     NORTHMDOOR      16L
-#define     NORTHRDOOR      32L
-#define     SOUTHMDOOR      64L
-#define     SOUTHRDOOR     128L
-
-#define     EASTMDOOR       16L
-#define     EASTBDOOR       32L
-#define     WESTMDOOR       64L
-#define     WESTBDOOR      128L
+#define     NORTHMDOOR      16
+#define     NORTHRDOOR      32
+#define     SOUTHMDOOR      64
+#define     SOUTHRDOOR     128
+
+#define     EASTMDOOR       16
+#define     EASTBDOOR       32
+#define     WESTMDOOR       64
+#define     WESTBDOOR      128
 
 // Special Map ID's
 #define     NORMAL           0
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index 54507fd..4b5fb09 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -285,7 +285,7 @@ void TilePuzzle::doTileScroll(uint16 col, uint16 row, uint16 scrolltype) {
 	uint16 x1 = _vm->_utils->vgaScaleX(100) + (col * _vm->_utils->vgaScaleX(30)) + dx;
 	uint16 y1 = _vm->_utils->vgaScaleY(25) + (row * _vm->_utils->vgaScaleY(25)) + dy;
 
-	byte *buffer = new byte[_tiles[1]->_width * _tiles[1]->_height * 2L];
+	byte *buffer = new byte[_tiles[1]->_width * _tiles[1]->_height * 2];
 
 	for (int i = 0; i < last; i++) {
 		_vm->waitTOF();
@@ -313,7 +313,7 @@ void TilePuzzle::changeCombination(uint16 number) {
 	display._width     = _vm->_graphics->_screenWidth;
 	display._height    = _vm->_graphics->_screenHeight;
 
-	byte *buffer = new byte[_tiles[1]->_width * _tiles[1]->_height * 2L];
+	byte *buffer = new byte[_tiles[1]->_width * _tiles[1]->_height * 2];
 
 	for (uint16 i = 1; i <= (_numberImages[combnum]->_height / 2); i++) {
 		if (_vm->_isHiRes) {


Commit: 9dae9eb811dfafaf109dd9d17cc12ffba128428a
    https://github.com/scummvm/scummvm/commit/9dae9eb811dfafaf109dd9d17cc12ffba128428a
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:43:17+01:00

Commit Message:
LAB: Implement the scroll buffer of doScrollWipe() and doScrollBounce()

This was left out from previous refactoring. Also, simplify
doScrollBounce()

Changed paths:
    engines/lab/anim.cpp
    engines/lab/anim.h
    engines/lab/dispman.cpp



diff --git a/engines/lab/anim.cpp b/engines/lab/anim.cpp
index 9444a8f..5f469d8 100644
--- a/engines/lab/anim.cpp
+++ b/engines/lab/anim.cpp
@@ -58,10 +58,7 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 	_diffFile = nullptr;
 	_diffFileStart = 0;
 	_size = 0;
-	_rawDiffBM._bytesPerRow = 0;
-	_rawDiffBM._drawOnScreen = false;
-	for (int i = 0; i < 16; i++)
-		_rawDiffBM._planes[i] = nullptr;
+	_scrollScreenBuffer = nullptr;
 	_waitForEffect = false;
 	_stopPlayingEnd = false;
 	_sampleSpeed = 0;
@@ -73,6 +70,11 @@ Anim::Anim(LabEngine *vm) : _vm(vm) {
 		_diffPalette[i] = 0;
 }
 
+Anim::~Anim() {
+	delete[] _vm->_anim->_scrollScreenBuffer;
+	_vm->_anim->_scrollScreenBuffer = nullptr;
+}
+
 void Anim::diffNextFrame(bool onlyDiffData) {
 	if (_lastBlockHeader == 65535)
 		// Already done.
@@ -143,9 +145,15 @@ void Anim::diffNextFrame(bool onlyDiffData) {
 			break;
 
 		case 10:
-			if (onlyDiffData)
-				warning("Boom");
-			_diffFile->read(disp->_planes[_curBit], _size);
+			if (onlyDiffData) {
+				if (_curBit > 0)
+					error("diffNextFrame: attempt to read screen to non-zero plane (%d)", _curBit);
+				delete[] _scrollScreenBuffer;
+				_scrollScreenBuffer = new byte[_headerdata._width * _headerdata._height];
+				_diffFile->read(_scrollScreenBuffer, _size);
+			} else {
+				_diffFile->read(disp->_planes[_curBit], _size);
+			}
 			_curBit++;
 			break;
 
@@ -325,8 +333,8 @@ void Anim::readDiff(Common::File *diffFile, bool playOnce, bool onlyDiffData) {
 
 	assert(_numChunks < 16);
 
-	for (int i = 0; i < 8; i++)
-		_rawDiffBM._planes[i] = nullptr;
+	delete[] _scrollScreenBuffer;
+	_scrollScreenBuffer = nullptr;
 
 	if (_headerdata._fps)
 		_delayMicros = 1000 / _headerdata._fps;
diff --git a/engines/lab/anim.h b/engines/lab/anim.h
index 563f281..db2e23e 100644
--- a/engines/lab/anim.h
+++ b/engines/lab/anim.h
@@ -74,13 +74,14 @@ private:
 
 public:
 	Anim(LabEngine *vm);
+	virtual ~Anim();
 
 	DIFFHeader _headerdata;
 	char _diffPalette[256 * 3];
 	bool _waitForEffect; // Wait for each sound effect to finish before continuing.
 	bool _doBlack;       // Black the screen before new picture
 	bool _noPalChange;   // Don't change the palette.
-	BitMap _rawDiffBM;
+	byte *_scrollScreenBuffer;
 
 	/**
 	 * Reads in a DIFF file.
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 2e13350..cbf7575 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -704,7 +704,7 @@ void DisplayMan::doScrollWipe(const Common::String filename) {
 
 	readPict(filename, true, true);
 	setPalette(_vm->_anim->_diffPalette, 256);
-	byte *mem = _vm->_anim->_rawDiffBM._planes[0];
+	byte *mem = _vm->_anim->_scrollScreenBuffer;
 
 	_vm->updateMusicAndEvents();
 	uint16 by = _vm->_utils->vgaScaleX(3);
@@ -744,42 +744,28 @@ void DisplayMan::doScrollWipe(const Common::String filename) {
 }
 
 void DisplayMan::doScrollBounce() {
-	const uint16 *newby, *newby1;
-
-	const uint16 newbyd[5] = {5, 4, 3, 2, 1}, newby1d[8] = {3, 3, 2, 2, 2, 1, 1, 1};
-	const uint16 newbyw[5] = {10, 8, 6, 4, 2}, newby1w[8] = {6, 6, 4, 4, 4, 2, 2, 2};
-
-	if (_vm->getPlatform() != Common::kPlatformWindows) {
-		newby = newbyd;
-		newby1 = newby1d;
-	} else {
-		newby = newbyw;
-		newby1 = newby1w;
-	}
+	const uint16 offsets[8] = { 3, 3, 2, 2, 2, 1, 1, 1 };
+	const int multiplier = (_vm->_isHiRes) ? 2 : 1;
 
 	_vm->_event->mouseHide();
 	int width = _vm->_utils->vgaScaleX(320);
 	int height = _vm->_utils->vgaScaleY(149) + _vm->_utils->svgaCord(2);
-	byte *mem = _vm->_anim->_rawDiffBM._planes[0];
+	byte *mem = _vm->_anim->_scrollScreenBuffer;
 
 	_vm->updateMusicAndEvents();
 	int startLine = _vm->_anim->_headerdata._height - height - 1;
 
 	for (int i = 0; i < 5; i++) {
 		_vm->updateMusicAndEvents();
-		startLine -= newby[i];
+		startLine -= (5 - i) * multiplier;
 		copyPage(width, height, 0, startLine, mem);
-
-		screenUpdate();
 		_vm->waitTOF();
 	}
 
 	for (int i = 8; i > 0; i--) {
 		_vm->updateMusicAndEvents();
-		startLine += newby1[i - 1];
+		startLine += offsets[i - 1] * multiplier;
 		copyPage(width, height, 0, startLine, mem);
-
-		screenUpdate();
 		_vm->waitTOF();
 	}
 


Commit: b3a19cf75ed30ddbb60fd05223efe6a26087834d
    https://github.com/scummvm/scummvm/commit/b3a19cf75ed30ddbb60fd05223efe6a26087834d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:43:17+01:00

Commit Message:
LAB: Show the correct number of parameters in find_action

Changed paths:
    engines/lab/console.cpp



diff --git a/engines/lab/console.cpp b/engines/lab/console.cpp
index 4aa9490..84f9365 100644
--- a/engines/lab/console.cpp
+++ b/engines/lab/console.cpp
@@ -98,7 +98,7 @@ bool Console::Cmd_DumpSceneResources(int argc, const char **argv) {
 
 bool Console::Cmd_FindAction(int argc, const char **argv) {
 	if (argc < 2) {
-		debugPrintf("Usage: %s <action id> [param 1] [param 2]\n", argv[0]);
+		debugPrintf("Usage: %s <action id> [param 1] [param 2] [param 3]\n", argv[0]);
 		return true;
 	}
 


Commit: 29d85c8d50967df907f2a12e87ad78abfa707be4
    https://github.com/scummvm/scummvm/commit/29d85c8d50967df907f2a12e87ad78abfa707be4
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:43:17+01:00

Commit Message:
LAB: Use int in for loops, instead of uint16

Changed paths:
    engines/lab/console.cpp
    engines/lab/dispman.cpp
    engines/lab/engine.cpp
    engines/lab/eventman.cpp
    engines/lab/intro.cpp
    engines/lab/lab.cpp
    engines/lab/map.cpp
    engines/lab/processroom.cpp
    engines/lab/resource.cpp
    engines/lab/savegame.cpp
    engines/lab/special.cpp
    engines/lab/tilepuzzle.cpp
    engines/lab/utils.cpp



diff --git a/engines/lab/console.cpp b/engines/lab/console.cpp
index 84f9365..0a61679 100644
--- a/engines/lab/console.cpp
+++ b/engines/lab/console.cpp
@@ -107,7 +107,7 @@ bool Console::Cmd_FindAction(int argc, const char **argv) {
 	int param2 = (argc > 3) ? atoi(argv[3]) : -1;
 	int param3 = (argc > 4) ? atoi(argv[4]) : -1;
 
-	for (uint16 i = 1; i <= _vm->_manyRooms; i++) {
+	for (int i = 1; i <= _vm->_manyRooms; i++) {
 		_vm->_resource->readViews(i);
 
 		for (RuleList::iterator rule = _vm->_rooms[i]._rules->begin(); rule != _vm->_rooms[i]._rules->end(); ++rule) {
diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index cbf7575..49818bf 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -79,7 +79,7 @@ void DisplayMan::loadBackPict(const Common::String fileName, uint16 *highPal) {
 	_vm->_anim->_noPalChange = true;
 	readPict(fileName);
 
-	for (uint16 i = 0; i < 16; i++) {
+	for (int i = 0; i < 16; i++) {
 		highPal[i] = ((_vm->_anim->_diffPalette[i * 3] >> 2) << 8) +
 			((_vm->_anim->_diffPalette[i * 3 + 1] >> 2) << 4) +
 			((_vm->_anim->_diffPalette[i * 3 + 2] >> 2));
@@ -354,7 +354,7 @@ void DisplayMan::setUpScreens() {
 
 	// TODO: The CONTROL file is not present in the Amiga version
 	Common::File *controlFile = _vm->_resource->openDataFile("P:Control");
-	for (uint16 i = 0; i < 20; i++)
+	for (int i = 0; i < 20; i++)
 		_vm->_moveImages[i] = new Image(controlFile, _vm);
 	delete controlFile;
 
@@ -377,10 +377,10 @@ void DisplayMan::setUpScreens() {
 	// TODO: The INV file is not present in the Amiga version
 	Common::File *invFile = _vm->_resource->openDataFile("P:Inv");
 	if (_vm->getPlatform() == Common::kPlatformWindows) {
-		for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++)
+		for (int imgIdx = 0; imgIdx < 10; imgIdx++)
 			_vm->_invImages[imgIdx] = new Image(invFile, _vm);
 	} else {
-		for (uint16 imgIdx = 0; imgIdx < 6; imgIdx++)
+		for (int imgIdx = 0; imgIdx < 6; imgIdx++)
 			_vm->_invImages[imgIdx] = new Image(invFile, _vm);
 	}
 	invButtonList->push_back(e->createButton( 24, y, 0,          'm', invImages[0],   invImages[1]));
@@ -475,7 +475,7 @@ void DisplayMan::setAmigaPal(uint16 *pal, uint16 numColors) {
 	if (numColors > 16)
 		numColors = 16;
 
-	for (uint16 i = 0; i < numColors; i++) {
+	for (int i = 0; i < numColors; i++) {
 		vgaPal[vgaIdx++] = (byte)(((pal[i] & 0xf00) >> 8) << 2);
 		vgaPal[vgaIdx++] = (byte)(((pal[i] & 0x0f0) >> 4) << 2);
 		vgaPal[vgaIdx++] = (byte)(((pal[i] & 0x00f)) << 2);
@@ -556,7 +556,7 @@ uint16 DisplayMan::textLength(TextFont *font, const Common::String text) {
 
 	if (font) {
 		int numChars = text.size();
-		for (uint16 i = 0; i < numChars; i++) {
+		for (int i = 0; i < numChars; i++) {
 			length += font->_widths[(byte)text[i]];
 		}
 	}
@@ -572,7 +572,7 @@ void DisplayMan::drawText(TextFont *tf, uint16 x, uint16 y, uint16 color, const
 	byte *vgaTop = getCurrentDrawingBuffer();
 	int numChars = text.size();
 
-	for (uint16 i = 0; i < numChars; i++) {
+	for (int i = 0; i < numChars; i++) {
 		uint32 realOffset = (_screenWidth * y) + x;
 		uint16 curPage    = realOffset / _screenBytesPerPage;
 		uint32 segmentOffset = realOffset - (curPage * _screenBytesPerPage);
@@ -585,12 +585,12 @@ void DisplayMan::drawText(TextFont *tf, uint16 x, uint16 y, uint16 color, const
 			byte *vgaTemp = vgaCur;
 			byte *vgaTempLine = vgaCur;
 
-			for (uint16 rows = 0; rows < tf->_height; rows++) {
+			for (int rows = 0; rows < tf->_height; rows++) {
 				int32 templeft = leftInSegment;
 
 				vgaTemp = vgaTempLine;
 
-				for (uint16 cols = 0; cols < bwidth; cols++) {
+				for (int cols = 0; cols < bwidth; cols++) {
 					uint16 data = *cdata++;
 
 					if (data && (templeft >= 8)) {
@@ -605,7 +605,7 @@ void DisplayMan::drawText(TextFont *tf, uint16 x, uint16 y, uint16 color, const
 						uint16 mask = 0x80;
 						templeft = leftInSegment;
 
-						for (uint16 counterb = 0; counterb < 8; counterb++) {
+						for (int counterb = 0; counterb < 8; counterb++) {
 							if (templeft <= 0) {
 								curPage++;
 								vgaTemp = (byte *)(vgaTop - templeft);
@@ -785,8 +785,8 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, const Common::String fi
 
 	uint16 linesDone = 0;
 
-	for (uint16 j = 0; j < 2; j++) {
-		for (uint16 i = 0; i < 2; i++) {
+	for (int j = 0; j < 2; j++) {
+		for (int i = 0; i < 2; i++) {
 			uint16 curY = i * 2;
 
 			while (curY < lastY) {
@@ -830,8 +830,8 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, const Common::String fi
 	imDest._height = _screenHeight;
 	imDest._imageData = getCurrentDrawingBuffer();
 
-	for (uint16 j = 0; j < 2; j++) {
-		for (uint16 i = 0; i < 2; i++) {
+	for (int j = 0; j < 2; j++) {
+		for (int i = 0; i < 2; i++) {
 			uint16 curY = i * 2;
 
 			while (curY < lastY) {
@@ -987,8 +987,8 @@ uint16 DisplayMan::fadeNumOut(uint16 num, uint16 res, uint16 counter) {
 void DisplayMan::fade(bool fadeIn, uint16 res) {
 	uint16 newPal[16];
 
-	for (uint16 i = 0; i < 16; i++) {
-		for (uint16 palIdx = 0; palIdx < 16; palIdx++) {
+	for (int i = 0; i < 16; i++) {
+		for (int palIdx = 0; palIdx < 16; palIdx++) {
 			if (fadeIn)
 				newPal[palIdx] = (0x00F & fadeNumIn(0x00F & _fadePalette[palIdx], 0x00F & res, i)) +
 				(0x0F0 & fadeNumIn(0x0F0 & _fadePalette[palIdx], 0x0F0 & res, i)) +
diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index f50a3b7..87380c3 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -144,12 +144,12 @@ void LabEngine::drawRoomMessage(uint16 curInv, CloseDataPtr closePtr) {
 }
 
 void LabEngine::freeScreens() {
-	for (uint16 i = 0; i < 20; i++) {
+	for (int i = 0; i < 20; i++) {
 		delete _moveImages[i];
 		_moveImages[i] = nullptr;
 	}
 
-	for (uint16 imgIdx = 0; imgIdx < 10; imgIdx++) {
+	for (int imgIdx = 0; imgIdx < 10; imgIdx++) {
 		delete _invImages[imgIdx];
 		_invImages[imgIdx] = nullptr;
 	}
@@ -550,7 +550,7 @@ void LabEngine::showLab2Teaser() {
 	_graphics->blackAllScreen();
 	_graphics->readPict("P:End/L2In.1");
 
-	for (uint16 i = 0; i < 120; i++) {
+	for (int i = 0; i < 120; i++) {
 		updateMusicAndEvents();
 		waitTOF();
 	}
diff --git a/engines/lab/eventman.cpp b/engines/lab/eventman.cpp
index 6e8b08e..4947991 100644
--- a/engines/lab/eventman.cpp
+++ b/engines/lab/eventman.cpp
@@ -72,7 +72,7 @@ Button *EventManager::checkButtonHit(ButtonList *buttonList, Common::Point pos)
 				button->_altImage->drawImage(button->_x, button->_y);
 				mouseShow();
 
-				for (uint16 i = 0; i < 3; i++)
+				for (int i = 0; i < 3; i++)
 					_vm->waitTOF();
 
 				mouseHide();
@@ -133,7 +133,7 @@ void EventManager::updateMouse() {
 		_hitButton->_altImage->drawImage(_hitButton->_x, _hitButton->_y);
 		mouseShow();
 
-		for (uint16 i = 0; i < 3; i++)
+		for (int i = 0; i < 3; i++)
 			_vm->waitTOF();
 
 		mouseHide();
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index de76c0c..e918987 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -195,7 +195,7 @@ void Intro::musicDelay() {
 	if (_quitIntro)
 		return;
 
-	for (uint16 i = 0; i < 20; i++) {
+	for (int i = 0; i < 20; i++) {
 		_vm->updateMusicAndEvents();
 		_vm->waitTOF();
 		_vm->waitTOF();
@@ -235,7 +235,7 @@ void Intro::introSequence() {
 	} else if (_vm->getPlatform() == Common::kPlatformWindows) {
 		nReadPict("WYRMKEEP");
 		// Wait 4 seconds
-		for (uint16 i = 0; i < 4 * 1000 / 10; i++) {
+		for (int i = 0; i < 4 * 1000 / 10; i++) {
 			introEatMessages();
 			if (_quitIntro)
 				break;
@@ -259,7 +259,7 @@ void Intro::introSequence() {
 
 	_vm->_graphics->_fadePalette = palette;
 
-	for (uint16 i = 0; i < 16; i++) {
+	for (int i = 0; i < 16; i++) {
 		if (_quitIntro)
 			break;
 
@@ -278,7 +278,7 @@ void Intro::introSequence() {
 		_vm->updateMusicAndEvents();
 		uint16 temp = palette[2];
 
-		for (uint16 i = 2; i < 15; i++)
+		for (int i = 2; i < 15; i++)
 			palette[i] = palette[i + 1];
 
 		palette[15] = temp;
@@ -321,7 +321,7 @@ void Intro::introSequence() {
 	nReadPict("Intro.1");
 	_vm->_anim->_noPalChange = false;
 
-	for (uint16 i = 0; i < 16; i++) {
+	for (int i = 0; i < 16; i++) {
 		palette[i] = ((_vm->_anim->_diffPalette[i * 3] >> 2) << 8) +
 					((_vm->_anim->_diffPalette[i * 3 + 1] >> 2) << 4) +
 					(_vm->_anim->_diffPalette[i * 3 + 2] >> 2);
@@ -365,8 +365,8 @@ void Intro::introSequence() {
 	doPictText("i.11", msgFont, false);
 
 	if (!_quitIntro)
-		for (uint16 i = 0; i < 50; i++) {
-			for (uint16 idx = (8 * 3); idx < (255 * 3); idx++)
+		for (int i = 0; i < 50; i++) {
+			for (int idx = (8 * 3); idx < (255 * 3); idx++)
 				_vm->_anim->_diffPalette[idx] = 255 - _vm->_anim->_diffPalette[idx];
 
 			_vm->updateMusicAndEvents();
diff --git a/engines/lab/lab.cpp b/engines/lab/lab.cpp
index 5d545d9..a1fd4f5 100644
--- a/engines/lab/lab.cpp
+++ b/engines/lab/lab.cpp
@@ -139,7 +139,7 @@ LabEngine::~LabEngine() {
 	DebugMan.clearAllDebugChannels();
 
 	freeMapData();
-	for (uint16 i = 1; i <= _manyRooms; i++)
+	for (int i = 1; i <= _manyRooms; i++)
 		_resource->freeViews(i);
 	delete[] _rooms;
 	delete[] _inventory;
diff --git a/engines/lab/map.cpp b/engines/lab/map.cpp
index b9f5703..e06fefd 100644
--- a/engines/lab/map.cpp
+++ b/engines/lab/map.cpp
@@ -299,7 +299,7 @@ void LabEngine::drawRoomMap(uint16 curRoom, bool drawMarkFl) {
 }
 
 bool LabEngine::floorVisited(uint16 floorNum) {
-	for (uint16 i = 0; i < _maxRooms; i++) {
+	for (int i = 0; i < _maxRooms; i++) {
 		if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x)
 			return true;
 	}
@@ -311,7 +311,7 @@ uint16 LabEngine::getUpperFloor(uint16 floorNum) {
 	if ((floorNum == kFloorCarnival) || (floorNum == kFloorNone))
 		return kFloorNone;
 
-	for (uint16 i = floorNum; i < kFloorCarnival; i++)
+	for (int i = floorNum; i < kFloorCarnival; i++)
 		if (floorVisited(i + 1))
 			return i + 1;
 
@@ -322,7 +322,7 @@ uint16 LabEngine::getLowerFloor(uint16 floorNum) {
 	if ((floorNum == kFloorLower) || (floorNum == kFloorNone))
 		return kFloorNone;
 
-	for (uint16 i = floorNum; i > kFloorLower; i--)
+	for (int i = floorNum; i > kFloorLower; i--)
 		if (floorVisited(i - 1))
 			return i - 1;
 
@@ -341,7 +341,7 @@ void LabEngine::drawMap(uint16 curRoom, uint16 curMsg, uint16 floorNum, bool fad
 	_imgMap->drawImage(0, 0);
 	_event->drawButtonList(&_mapButtonList);
 
-	for (uint16 i = 1; i <= _maxRooms; i++) {
+	for (int i = 1; i <= _maxRooms; i++) {
 		if ((_maps[i]._pageNumber == floorNum) && _roomsFound->in(i) && _maps[i]._x) {
 			drawRoomMap(i, (bool)(i == curRoom));
 			updateMusicAndEvents();
@@ -499,7 +499,7 @@ void LabEngine::processMap(uint16 curRoom) {
 					uint16 oldMsg = curMsg;
 					Common::Rect curCoords;
 
-					for (uint16 i = 1; i <= _maxRooms; i++) {
+					for (int i = 1; i <= _maxRooms; i++) {
 						curCoords = roomCoords(i);
 
 						if ((_maps[i]._pageNumber == curFloor)
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index 0d60724..ad8db84 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -443,7 +443,7 @@ void LabEngine::doActions(Action *actionList, CloseDataPtr *closePtrList) {
 				_anim->_doBlack = (_closeDataPtr != nullptr);
 			else if (actionList->_param1 == 5) {
 				// inverse the palette
-				for (uint16 idx = (8 * 3); idx < (255 * 3); idx++)
+				for (int idx = (8 * 3); idx < (255 * 3); idx++)
 					_anim->_diffPalette[idx] = 255 - _anim->_diffPalette[idx];
 
 				waitTOF();
diff --git a/engines/lab/resource.cpp b/engines/lab/resource.cpp
index 3fcf7ac..b9239a2 100644
--- a/engines/lab/resource.cpp
+++ b/engines/lab/resource.cpp
@@ -102,7 +102,7 @@ void Resource::readRoomData(const Common::String fileName) {
 	_vm->_rooms = new RoomData[_vm->_manyRooms + 1];
 	memset(_vm->_rooms, 0, (_vm->_manyRooms + 1) * sizeof(RoomData));
 
-	for (uint16 i = 1; i <= _vm->_manyRooms; i++) {
+	for (int i = 1; i <= _vm->_manyRooms; i++) {
 		RoomData *curRoom = &_vm->_rooms[i];
 		curRoom->_doors[NORTH] = dataFile->readUint16LE();
 		curRoom->_doors[SOUTH] = dataFile->readUint16LE();
@@ -127,7 +127,7 @@ InventoryData *Resource::readInventory(const Common::String fileName) {
 	_vm->_numInv = dataFile->readUint16LE();
 	InventoryData *inventory = new InventoryData[_vm->_numInv + 1];
 
-	for (uint16 i = 1; i <= _vm->_numInv; i++) {
+	for (int i = 1; i <= _vm->_numInv; i++) {
 		inventory[i]._quantity = dataFile->readUint16LE();
 		inventory[i]._name = readString(dataFile);
 		inventory[i]._bitmapName = readString(dataFile);
@@ -159,7 +159,7 @@ void Resource::freeViews(uint16 roomNum) {
 	if (!_vm->_rooms)
 		return;
 
-	for (uint16 i = 0; i < 4; i++)
+	for (int i = 0; i < 4; i++)
 		freeView(_vm->_rooms[roomNum]._view[i]);
 
 	freeRule(_vm->_rooms[roomNum]._rules);
diff --git a/engines/lab/savegame.cpp b/engines/lab/savegame.cpp
index 8ee8b1a..f70d73b 100644
--- a/engines/lab/savegame.cpp
+++ b/engines/lab/savegame.cpp
@@ -174,17 +174,17 @@ bool LabEngine::loadGame(int slot) {
 	setQuarters(file->readUint16LE());
 
 	// Conditions
-	for (uint16 i = 0; i < _conditions->_lastElement / (8 * 2); i++)
+	for (int i = 0; i < _conditions->_lastElement / (8 * 2); i++)
 		_conditions->_array[i] = file->readUint16LE();
 
 	// Rooms found
-	for (uint16 i = 0; i < _roomsFound->_lastElement / (8 * 2); i++)
+	for (int i = 0; i < _roomsFound->_lastElement / (8 * 2); i++)
 		_roomsFound->_array[i] = file->readUint16LE();
 
 	_tilePuzzle->load(file);
 
 	// Breadcrumbs
-	for (uint16 i = 0; i < 128; i++) {
+	for (int i = 0; i < 128; i++) {
 		_breadCrumbs[i]._roomNum = file->readUint16LE();
 		_breadCrumbs[i]._direction = file->readUint16LE();
 	}
@@ -192,7 +192,7 @@ bool LabEngine::loadGame(int slot) {
 	_droppingCrumbs = (_breadCrumbs[0]._roomNum != 0);
 	_followingCrumbs = false;
 
-	for (uint16 i = 0; i < 128; i++) {
+	for (int i = 0; i < 128; i++) {
 		if (_breadCrumbs[i]._roomNum == 0)
 			break;
 		_numCrumbs = i;
diff --git a/engines/lab/special.cpp b/engines/lab/special.cpp
index 7615c2d..649c725 100644
--- a/engines/lab/special.cpp
+++ b/engines/lab/special.cpp
@@ -319,7 +319,7 @@ void LabEngine::drawMonText(char *text, TextFont *monitorFont, Common::Rect text
 		_graphics->setPen(0);
 		_graphics->rectFill(0, 0, _graphics->_screenWidth - 1, textRect.bottom);
 
-		for (uint16 i = 0; i < numlines; i++)
+		for (int i = 0; i < numlines; i++)
 			_monitorButton->drawImage(0, i * _monitorButtonHeight);
 	} else if (isinteractive) {
 		_graphics->setPen(0);
diff --git a/engines/lab/tilepuzzle.cpp b/engines/lab/tilepuzzle.cpp
index 4b5fb09..d39612d 100644
--- a/engines/lab/tilepuzzle.cpp
+++ b/engines/lab/tilepuzzle.cpp
@@ -315,7 +315,7 @@ void TilePuzzle::changeCombination(uint16 number) {
 
 	byte *buffer = new byte[_tiles[1]->_width * _tiles[1]->_height * 2];
 
-	for (uint16 i = 1; i <= (_numberImages[combnum]->_height / 2); i++) {
+	for (int i = 1; i <= (_numberImages[combnum]->_height / 2); i++) {
 		if (_vm->_isHiRes) {
 			if (i & 1)
 				_vm->waitTOF();
@@ -362,7 +362,7 @@ void TilePuzzle::showCombination(const Common::String filename) {
 
 	Common::File *numFile = _vm->_resource->openDataFile("P:Numbers");
 
-	for (uint16 CurBit = 0; CurBit < 10; CurBit++)
+	for (int CurBit = 0; CurBit < 10; CurBit++)
 		_numberImages[CurBit] = new Image(numFile, _vm);
 
 	delete numFile;
diff --git a/engines/lab/utils.cpp b/engines/lab/utils.cpp
index aeb76e6..a1409d2 100644
--- a/engines/lab/utils.cpp
+++ b/engines/lab/utils.cpp
@@ -206,7 +206,7 @@ void Utils::verticalRunLengthDecode(byte *dest, Common::File *sourceFile, uint16
 	int16 count;
 	byte *top = dest;
 
-	for (uint16 i = 0; i < _dataBytesPerRow; i++) {
+	for (int i = 0; i < _dataBytesPerRow; i++) {
 		dest = top;
 		dest += i;
 


Commit: 07aec19a06a07ee1ef66d500644a3d778d592b51
    https://github.com/scummvm/scummvm/commit/07aec19a06a07ee1ef66d500644a3d778d592b51
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:43:17+01:00

Commit Message:
LAB: Also mention Terra Nova Development in the engine copyright message

Changed paths:
    engines/lab/detection.cpp



diff --git a/engines/lab/detection.cpp b/engines/lab/detection.cpp
index 7bb9821..0810c4c 100644
--- a/engines/lab/detection.cpp
+++ b/engines/lab/detection.cpp
@@ -131,7 +131,7 @@ public:
 	}
 
 	virtual const char *getOriginalCopyright() const {
-		return "Labyrinth of Time (c) 2004 The Wyrmkeep Entertainment Co.";
+		return "Labyrinth of Time (c) 2004 The Wyrmkeep Entertainment Co. and Terra Nova Development";
 	}
 
 	virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {


Commit: c66d5eca3a9d8ed7254d07435b74acf7ebf7d2d1
    https://github.com/scummvm/scummvm/commit/c66d5eca3a9d8ed7254d07435b74acf7ebf7d2d1
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:43:17+01:00

Commit Message:
LAB: setAmigaPal() is always using 16 colors

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/intro.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 49818bf..e0661b7 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -468,14 +468,11 @@ void DisplayMan::createScreen(bool hiRes) {
 	_displayBuffer = new byte[_screenBytesPerPage];
 }
 
-void DisplayMan::setAmigaPal(uint16 *pal, uint16 numColors) {
+void DisplayMan::setAmigaPal(uint16 *pal) {
 	byte vgaPal[16 * 3];
 	uint16 vgaIdx = 0;
 
-	if (numColors > 16)
-		numColors = 16;
-
-	for (int i = 0; i < numColors; i++) {
+	for (int i = 0; i < 16; i++) {
 		vgaPal[vgaIdx++] = (byte)(((pal[i] & 0xf00) >> 8) << 2);
 		vgaPal[vgaIdx++] = (byte)(((pal[i] & 0x0f0) >> 4) << 2);
 		vgaPal[vgaIdx++] = (byte)(((pal[i] & 0x00f)) << 2);
@@ -999,7 +996,7 @@ void DisplayMan::fade(bool fadeIn, uint16 res) {
 				(0xF00 & fadeNumOut(0xF00 & _fadePalette[palIdx], 0xF00 & res, i));
 		}
 
-		setAmigaPal(newPal, 16);
+		setAmigaPal(newPal);
 		_vm->waitTOF();
 		_vm->updateMusicAndEvents();
 	}
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index 99a4f45b..cbb80ac 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -213,10 +213,10 @@ public:
 	void createScreen(bool hiRes);
 
 	/**
-	 * Converts an Amiga palette (up to 16 colors) to a VGA palette, then sets
+	 * Converts a 16-color Amiga palette to a VGA palette, then sets
 	 * the VGA palette.
 	 */
-	void setAmigaPal(uint16 *pal, uint16 numColors);
+	void setAmigaPal(uint16 *pal);
 
 	/**
 	 * Writes any number of the 256 color registers.
diff --git a/engines/lab/intro.cpp b/engines/lab/intro.cpp
index e918987..1b4310a 100644
--- a/engines/lab/intro.cpp
+++ b/engines/lab/intro.cpp
@@ -283,7 +283,7 @@ void Intro::introSequence() {
 
 		palette[15] = temp;
 
-		_vm->_graphics->setAmigaPal(palette, 16);
+		_vm->_graphics->setAmigaPal(palette);
 		_vm->waitTOF();
 	}
 


Commit: 60f7849c20c07fc9507d89354abb0df3ddfdb62e
    https://github.com/scummvm/scummvm/commit/60f7849c20c07fc9507d89354abb0df3ddfdb62e
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:43:17+01:00

Commit Message:
LAB: Improve the palette assignment in writeColorRegs()

Thanks to LordHoto

Changed paths:
    engines/lab/dispman.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index e0661b7..de2bcc4 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -486,7 +486,7 @@ void DisplayMan::writeColorRegs(byte *buf, uint16 first, uint16 numReg) {
 	byte tmp[256 * 3];
 
 	for (int i = 0; i < 256 * 3; i++)
-		tmp[i] = buf[i] * 4;
+		tmp[i] = (buf[i] << 2) | (buf[i] >> 4);	// better results than buf[i] * 4
 
 	_vm->_system->getPaletteManager()->setPalette(tmp, first, numReg);
 	memcpy(&(_curvgapal[first * 3]), buf, numReg * 3);


Commit: 5327b6f545de1031909f09cb459ccc24c5467886
    https://github.com/scummvm/scummvm/commit/5327b6f545de1031909f09cb459ccc24c5467886
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:43:17+01:00

Commit Message:
LAB: Use byte instead of char in overlayRect()

This matches the idea that colors are in range of 0 - 255. Thanks to
LordHoto

Changed paths:
    engines/lab/dispman.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index de2bcc4..4e284e5 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -515,10 +515,10 @@ void DisplayMan::overlayRect(uint16 penColor, uint16 x1, uint16 y1, uint16 x2, u
 		h = _screenHeight - y1;
 
 	if ((w > 0) && (h > 0)) {
-		char *d = (char *)getCurrentDrawingBuffer() + y1 * _screenWidth + x1;
+		byte *d = (byte *)getCurrentDrawingBuffer() + y1 * _screenWidth + x1;
 
 		while (h-- > 0) {
-			char *dd = d;
+			byte *dd = d;
 			int ww = w;
 
 			if (y1 & 1) {


Commit: 52c7fcbfe5e65d47f0aa0b6169f95b529d6d9dc2
    https://github.com/scummvm/scummvm/commit/52c7fcbfe5e65d47f0aa0b6169f95b529d6d9dc2
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:43:17+01:00

Commit Message:
LAB: Rename overlayRect() to checkerboardEffect()

Changed paths:
    engines/lab/dispman.cpp
    engines/lab/dispman.h
    engines/lab/interface.cpp



diff --git a/engines/lab/dispman.cpp b/engines/lab/dispman.cpp
index 4e284e5..8def025 100644
--- a/engines/lab/dispman.cpp
+++ b/engines/lab/dispman.cpp
@@ -504,7 +504,7 @@ byte *DisplayMan::getCurrentDrawingBuffer() {
 	return _displayBuffer;
 }
 
-void DisplayMan::overlayRect(uint16 penColor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
+void DisplayMan::checkerboardEffect(uint16 penColor, uint16 x1, uint16 y1, uint16 x2, uint16 y2) {
 	int w = x2 - x1 + 1;
 	int h = y2 - y1 + 1;
 
@@ -794,7 +794,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, const Common::String fi
 				}
 
 				if (j == 9)
-					overlayRect(0, 0, curY, _screenWidth - 1, curY + 1);
+					checkerboardEffect(0, 0, curY, _screenWidth - 1, curY + 1);
 				else
 					rectFill(0, curY, _screenWidth - 1, curY + 1);
 				curY += 4;
@@ -842,7 +842,7 @@ void DisplayMan::doTransWipe(CloseDataPtr *closePtrList, const Common::String fi
 
 				if (j == 0) {
 					imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, 2, false);
-					overlayRect(0, 0, curY, _screenWidth - 1, curY + 1);
+					checkerboardEffect(0, 0, curY, _screenWidth - 1, curY + 1);
 				} else {
 					uint16 bitmapHeight = (curY == lastY) ? 1 : 2;
 					imSource.blitBitmap(0, curY, &imDest, 0, curY, _screenWidth, bitmapHeight, false);
diff --git a/engines/lab/dispman.h b/engines/lab/dispman.h
index cbb80ac..b77a178 100644
--- a/engines/lab/dispman.h
+++ b/engines/lab/dispman.h
@@ -234,7 +234,7 @@ public:
 	/**
 	 * Overlays a region on the screen using the desired pen color.
 	 */
-	void overlayRect(uint16 penColor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
+	void checkerboardEffect(uint16 penColor, uint16 x1, uint16 y1, uint16 x2, uint16 y2);
 
 	/**
 	 * Returns the base address of the current VGA display.
diff --git a/engines/lab/interface.cpp b/engines/lab/interface.cpp
index bdf30c6..0d03d21 100644
--- a/engines/lab/interface.cpp
+++ b/engines/lab/interface.cpp
@@ -78,7 +78,7 @@ void EventManager::drawButtonList(ButtonList *buttonList) {
 
 void EventManager::toggleButton(Button *button, uint16 disabledPenColor, bool enable) {
 	if (!enable)
-		_vm->_graphics->overlayRect(disabledPenColor, button->_x, button->_y, button->_x + button->_image->_width - 1, button->_y + button->_image->_height - 1);
+		_vm->_graphics->checkerboardEffect(disabledPenColor, button->_x, button->_y, button->_x + button->_image->_width - 1, button->_y + button->_image->_height - 1);
 	else
 		button->_image->drawImage(button->_x, button->_y);
 


Commit: d30ee82cdbda9a92522be6c506ded7def89bf6ba
    https://github.com/scummvm/scummvm/commit/d30ee82cdbda9a92522be6c506ded7def89bf6ba
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:43:17+01:00

Commit Message:
LAB: Use camelCase for a variable name

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 87380c3..4c12664 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -105,7 +105,7 @@ enum AltButtons {
 	kButtonFollowCrumbs
 };
 
-static char initcolors[] = { '\x00', '\x00', '\x00', '\x30',
+static char initColors[] = { '\x00', '\x00', '\x00', '\x30',
 							 '\x30', '\x30', '\x10', '\x10',
 							 '\x10', '\x14', '\x14', '\x14',
 							 '\x20', '\x20', '\x20', '\x24',
@@ -304,7 +304,7 @@ bool LabEngine::doUse(uint16 curInv) {
 		_curFileName = " ";
 		_closeDataPtr = nullptr;
 		doMap(_roomNum);
-		_graphics->setPalette(initcolors, 8);
+		_graphics->setPalette(initColors, 8);
 		_graphics->drawMessage(nullptr, false);
 		_graphics->drawPanel();
 		return true;
@@ -397,7 +397,7 @@ void LabEngine::mainGameLoop() {
 	bool forceDraw = false;
 	bool gotMessage = true;
 
-	_graphics->setPalette(initcolors, 8);
+	_graphics->setPalette(initColors, 8);
 
 	_closeDataPtr = nullptr;
 	_roomNum = 1;
@@ -928,7 +928,7 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 
 		if (doit) {
 			_graphics->drawMessage("Disk operation failed.", false);
-			_graphics->setPalette(initcolors, 8);
+			_graphics->setPalette(initColors, 8);
 			_system->delayMillis(1000);
 		}
 		break;


Commit: f9641a6d669ba5e361dffb91e832863bc1758812
    https://github.com/scummvm/scummvm/commit/f9641a6d669ba5e361dffb91e832863bc1758812
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-12-23T21:43:17+01:00

Commit Message:
LAB: Show a more descriptive message when save/restore is aborted

Changed paths:
    engines/lab/engine.cpp



diff --git a/engines/lab/engine.cpp b/engines/lab/engine.cpp
index 4c12664..cbac66e 100644
--- a/engines/lab/engine.cpp
+++ b/engines/lab/engine.cpp
@@ -895,7 +895,7 @@ void LabEngine::processMainButton(uint16 &curInv, uint16 &lastInv, uint16 &oldDi
 }
 
 void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonId, uint16 &actionMode) {
-	bool doit;
+	bool saveRestoreSuccessful = true;
 
 	_anim->_doBlack = true;
 
@@ -917,7 +917,7 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 		_anim->stopDiff();
 		_curFileName = " ";
 
-		doit = !saveRestoreGame();
+		saveRestoreSuccessful = saveRestoreGame();
 		_closeDataPtr = nullptr;
 		_mainDisplay = true;
 
@@ -926,8 +926,8 @@ void LabEngine::processAltButton(uint16 &curInv, uint16 &lastInv, uint16 buttonI
 
 		_graphics->drawPanel();
 
-		if (doit) {
-			_graphics->drawMessage("Disk operation failed.", false);
+		if (!saveRestoreSuccessful) {
+			_graphics->drawMessage("Save/restore aborted", false);
 			_graphics->setPalette(initColors, 8);
 			_system->delayMillis(1000);
 		}


Commit: ff93e55afd6467d7a53c836db931de786f8f7d63
    https://github.com/scummvm/scummvm/commit/ff93e55afd6467d7a53c836db931de786f8f7d63
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2015-12-23T21:43:35+01:00

Commit Message:
Merge pull request #636 from sev-/lab

This is a pull request for the game The Labyrinth of Time. This game is
currently available on www.wyrmkeep.com and on GOG.com. The game should
be completable: it was completable a month ago and we did regularly
regression testing. All the work has been based on sources kindly
provided by Wyrmkeep.

The DOS and the Windows versions are supported by this engine.

This is a manual merge of the PR, with some history fixups.

Changed paths:
  A engines/lab/anim.cpp
  A engines/lab/anim.h
  A engines/lab/configure.engine
  A engines/lab/console.cpp
  A engines/lab/console.h
  A engines/lab/detection.cpp
  A engines/lab/dispman.cpp
  A engines/lab/dispman.h
  A engines/lab/engine.cpp
  A engines/lab/eventman.cpp
  A engines/lab/eventman.h
  A engines/lab/image.cpp
  A engines/lab/image.h
  A engines/lab/interface.cpp
  A engines/lab/intro.cpp
  A engines/lab/intro.h
  A engines/lab/lab.cpp
  A engines/lab/lab.h
  A engines/lab/labsets.cpp
  A engines/lab/labsets.h
  A engines/lab/map.cpp
  A engines/lab/module.mk
  A engines/lab/music.cpp
  A engines/lab/music.h
  A engines/lab/processroom.cpp
  A engines/lab/processroom.h
  A engines/lab/resource.cpp
  A engines/lab/resource.h
  A engines/lab/savegame.cpp
  A engines/lab/special.cpp
  A engines/lab/tilepuzzle.cpp
  A engines/lab/tilepuzzle.h
  A engines/lab/utils.cpp
  A engines/lab/utils.h









More information about the Scummvm-git-logs mailing list